Version 14.47

This commit is contained in:
Antonio Cañas Vargas 2014-12-29 00:54:56 +01:00
parent d4b023492c
commit dea61286ec
13 changed files with 366 additions and 86 deletions

View File

@ -510,13 +510,13 @@ static void Ctr_Configuration (bool PrintView)
/********* Put a link (form) to view centres of current institution **********/
/*****************************************************************************/
// Gbl.CurrentIns.Ins.InsCod must be > 0
/*
void Ctr_PutLinkToViewCentresOfCurrentIns (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Centres_of_INSTITUTION_X;
/***** Put form to view centres of current institution *****/
***** Put form to view centres of current institution *****
Act_FormStart (ActSeeCtr);
sprintf (Gbl.Title,Txt_Centres_of_INSTITUTION_X,
Gbl.CurrentIns.Ins.ShortName);
@ -524,7 +524,7 @@ void Ctr_PutLinkToViewCentresOfCurrentIns (void)
Lay_PutSendIcon ("ctr",Gbl.Title,Gbl.Title);
fprintf (Gbl.F.Out,"</form>");
}
*/
/*****************************************************************************/
/*************** Show the centres of the current institution *****************/
/*****************************************************************************/

View File

@ -90,7 +90,7 @@ void Ctr_SeeCtrWithPendingDegs (void);
void Ctr_ShowConfiguration (void);
void Ctr_PrintConfiguration (void);
void Ctr_PutLinkToViewCentresOfCurrentIns (void);
// void Ctr_PutLinkToViewCentresOfCurrentIns (void);
void Ctr_ShowCtrsOfCurrentIns (void);
void Ctr_EditCentres (void);
void Ctr_GetListCentres (long InsCod);

View File

@ -35,11 +35,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.46.2 (2014/12/28)"
#define Log_PLATFORM_VERSION "SWAD 14.47 (2014/12/29)"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
/*
Version 14.47 :Dic 29, 2014 Changes in listing of user's courses. (174659 lines)
Version 14.46.2 :Dic 28, 2014 Code refactoring in forums. (174400 lines)
Version 14.46.1 :Dic 28, 2014 Changes in listing of forums. (174342 lines)
Version 14.46 :Dic 28, 2014 Course syllabus are shown in one unique option. (174340 lines)

View File

@ -475,19 +475,19 @@ static void Cty_Configuration (bool PrintView)
/*****************************************************************************/
/******************** Put a link (form) to view countries ********************/
/*****************************************************************************/
/*
void Cty_PutLinkToViewCountries (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Countries;
/***** Put form to view institutions of current country *****/
***** Put form to view institutions of current country *****
Act_FormStart (ActSeeCty);
Act_LinkFormSubmit (Txt_Countries,The_ClassFormul[Gbl.Prefs.Theme]);
Lay_PutSendIcon ("earth",Txt_Countries,Txt_Countries);
fprintf (Gbl.F.Out,"</form>");
}
*/
/*****************************************************************************/
/*************************** List all the countries **************************/
/*****************************************************************************/

View File

@ -75,7 +75,7 @@ void Cty_SeeCtyWithPendingInss (void);
void Cty_ShowConfiguration (void);
void Cty_PrintConfiguration (void);
void Cty_PutLinkToViewCountries (void);
// void Cty_PutLinkToViewCountries (void);
void Cty_ListCountries (void);
void Cty_ListCountries1 (void);
void Cty_ListCountries2 (void);

View File

@ -75,7 +75,7 @@ static void Crs_PutFormToConfigLogIn (bool IsForm);
static void Crs_WriteListMyCoursesToSelectOne (void);
static void Crs_PutLinkToViewCoursesOfCurrentDeg (void);
// static void Crs_PutLinkToViewCoursesOfCurrentDeg (void);
static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses);
static void Crs_ListCourses (void);
static void Crs_EditCourses (void);
@ -538,74 +538,312 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_My_courses;
extern const char *Txt_TABS_FULL_TXT[Act_NUM_TABS];
extern const char *Txt_Go_to_X;
unsigned NumMyCrs;
struct Country Cty;
struct Institution Ins;
struct Centre Ctr;
struct Degree Deg;
struct Course Crs;
char CourseFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME+1]; // Full name of course
bool IsLastItemInLevel[1+5];
MYSQL_RES *mysql_resCty;
MYSQL_RES *mysql_resIns;
MYSQL_RES *mysql_resCtr;
MYSQL_RES *mysql_resDeg;
MYSQL_RES *mysql_resCrs;
MYSQL_ROW row;
unsigned NumCty,NumCtys;
unsigned NumIns,NumInss;
unsigned NumCtr,NumCtrs;
unsigned NumDeg,NumDegs;
unsigned NumCrs,NumCrss;
char PathRelRSSFile[PATH_MAX+1];
/***** Start form *****/
char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1];
char Icon[512];
/***** Table start *****/
Lay_StartRoundFrameTable10 (NULL,0,Txt_My_courses);
/***** Write link to country *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left;\">"
"<ul style=\"list-style-type:none;"
" padding:0; margin:0;\">");
"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormGoToStart (ActMnu);
Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys);
Act_LinkFormSubmit (Txt_TABS_FULL_TXT[TabSys],
The_ClassFormul[Gbl.Prefs.Theme]);
/* Country map */
fprintf (Gbl.F.Out,"<img src=\"%s/sys16x16.gif\" alt=\"%s\" title=\"%s\""
" style=\"width:16px; height:16px;\" />",
Gbl.Prefs.IconsURL,
Txt_TABS_FULL_TXT[TabSys],
Txt_TABS_FULL_TXT[TabSys]);
fprintf (Gbl.F.Out,"&nbsp;%s",Txt_TABS_FULL_TXT[TabSys]);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>");
/***** Write an option for each of my courses *****/
for (NumMyCrs = 0;
NumMyCrs < Gbl.Usrs.Me.MyCourses.Num;
NumMyCrs++)
/***** Get my countries *****/
NumCtys = Usr_GetCtysFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_resCty);
for (NumCty = 0;
NumCty < NumCtys;
NumCty++)
{
/* Get data of this course */
Crs.CrsCod = Gbl.Usrs.Me.MyCourses.Crss[NumMyCrs].CrsCod;
Crs_GetDataOfCourseByCod (&Crs);
Deg.DegCod = Crs.DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
/***** Get next institution *****/
row = mysql_fetch_row (mysql_resCty);
strcpy (CourseFullName,Crs.FullName);
Str_LimitLengthHTMLStr (CourseFullName,Crs_MAX_LENGTH_FULL_NAME_COURSE_ON_LIST_OF_MY_COURSES);
/***** Get data of this institution *****/
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]);
if (!Cty_GetDataOfCountryByCod (&Cty))
Lay_ShowErrorAndExit ("Country not found.");
/* Start list entry */
fprintf (Gbl.F.Out,"<li");
if (Gbl.Usrs.Me.MyCourses.Crss[NumMyCrs].CrsCod == Gbl.CurrentCrs.Crs.CrsCod)
fprintf (Gbl.F.Out," style=\"background-color:%s;\"",VERY_LIGHT_BLUE);
fprintf (Gbl.F.Out," class=\"%s\">",The_ClassFormul[Gbl.Prefs.Theme]);
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left; vertical-align:top;\">"
"<table>"
"<tr>");
/* Put form to go to one of my courses */
Act_FormGoToStart (ActSeeCrsInf);
Crs_PutParamCrsCod (Crs.CrsCod);
sprintf (Gbl.Title,Txt_Go_to_X,Crs.FullName);
Act_LinkFormSubmit (Gbl.Title,The_ClassFormul[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"<img src=\"%s/%s/%s16x16.gif\" alt=\"%s\""
" class=\"ICON16x16\""
" style=\"vertical-align:middle;\" />"
" %s &gt; %s</a>"
"</form>",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_DEGREES,Deg.Logo,Deg.ShortName,
Deg.ShortName,CourseFullName);
/***** Indent country *****/
IsLastItemInLevel[1] = (NumCty == NumCtys - 1);
Msg_IndentDependingOnLevel (1,IsLastItemInLevel);
/* Write link to RSS file */
sprintf (PathRelRSSFile,"%s/%s/%ld/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
if (!Fil_CheckIfPathExists (PathRelRSSFile))
RSS_UpdateRSSFileForACrs (&Crs);
fprintf (Gbl.F.Out," <a href=\"");
RSS_WriteRSSLink (Gbl.F.Out,Crs.CrsCod);
fprintf (Gbl.F.Out,"\" target=\"_blank\">"
"<img src=\"%s/rss16x16.gif\" alt=\"RSS\""
" class=\"ICON16x16\""
" style=\"vertical-align:middle;\" />"
"</a>",
Gbl.Prefs.IconsURL);
/***** Write link to country *****/
fprintf (Gbl.F.Out,"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormStart (ActSeeCtyInf);
Cty_PutParamCtyCod (Cty.CtyCod);
Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeCtyInf].ActCod,ActTxt),
The_ClassFormul[Gbl.Prefs.Theme]);
/* Country map */
fprintf (Gbl.F.Out,"<img src=\"%s/%s/%s/%s.png\" alt=\"%s\" title=\"%s\""
" style=\"width:16px; height:16px;\" />",
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_COUNTRIES,
Cty.Alpha2,
Cty.Alpha2,
Cty.Alpha2,
Cty.Name[Gbl.Prefs.Language]);
fprintf (Gbl.F.Out,"&nbsp;%s",Cty.Name[Gbl.Prefs.Language]);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>");
/* End list entry */
fprintf (Gbl.F.Out,"</li>");
/***** Get my institutions in this country *****/
NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Cty.CtyCod,&mysql_resIns);
for (NumIns = 0;
NumIns < NumInss;
NumIns++)
{
/***** Get next institution *****/
row = mysql_fetch_row (mysql_resIns);
/***** Get data of this institution *****/
Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]);
if (!Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_MINIMAL_DATA))
Lay_ShowErrorAndExit ("Institution not found.");
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left; vertical-align:top;\">"
"<table>"
"<tr>");
/***** Indent institution *****/
IsLastItemInLevel[2] = (NumIns == NumInss - 1);
Msg_IndentDependingOnLevel (2,IsLastItemInLevel);
/***** Write link to institution *****/
fprintf (Gbl.F.Out,"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormStart (ActSeeInsInf);
Ins_PutParamInsCod (Ins.InsCod);
Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeInsInf].ActCod,ActTxt),
The_ClassFormul[Gbl.Prefs.Theme]);
Ins_DrawInstitutionLogo (Ins.Logo,Ins.ShortName,16,"vertical-align:top;");
fprintf (Gbl.F.Out,"&nbsp;%s",Ins.FullName);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>");
/***** Get my centres in this institution *****/
NumCtrs = (unsigned) Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Ins.InsCod,&mysql_resCtr);
for (NumCtr = 0;
NumCtr < NumCtrs;
NumCtr++)
{
/***** Get next centre *****/
row = mysql_fetch_row (mysql_resCtr);
/***** Get data of this centre *****/
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]);
if (!Ctr_GetDataOfCentreByCod (&Ctr))
Lay_ShowErrorAndExit ("Centre not found.");
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left; vertical-align:top;\">"
"<table>"
"<tr>");
/***** Indent centre *****/
IsLastItemInLevel[3] = (NumCtr == NumCtrs - 1);
Msg_IndentDependingOnLevel (3,IsLastItemInLevel);
/***** Write link to centre *****/
fprintf (Gbl.F.Out,"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormStart (ActSeeCtrInf);
Ctr_PutParamCtrCod (Ctr.CtrCod);
Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeCtrInf].ActCod,ActTxt),
The_ClassFormul[Gbl.Prefs.Theme]);
Ctr_DrawCentreLogo (Ctr.Logo,Ctr.ShortName,16,"vertical-align:top;");
fprintf (Gbl.F.Out,"&nbsp;%s",Ctr.FullName);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>");
/***** Get my degrees in this centre *****/
NumDegs = (unsigned) Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Ctr.CtrCod,&mysql_resDeg);
for (NumDeg = 0;
NumDeg < NumDegs;
NumDeg++)
{
/***** Get next degree *****/
row = mysql_fetch_row (mysql_resDeg);
/***** Get data of this degree *****/
Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]);
if (!Deg_GetDataOfDegreeByCod (&Deg))
Lay_ShowErrorAndExit ("Degree not found.");
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left; vertical-align:top;\">"
"<table>"
"<tr>");
/***** Indent degree *****/
IsLastItemInLevel[4] = (NumDeg == NumDegs - 1);
Msg_IndentDependingOnLevel (4,IsLastItemInLevel);
/***** Write link to degree *****/
fprintf (Gbl.F.Out,"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormStart (ActSeeDegInf);
Deg_PutParamDegCod (Deg.DegCod);
Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeDegInf].ActCod,ActTxt),
The_ClassFormul[Gbl.Prefs.Theme]);
Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,16,"vertical-align:top;");
fprintf (Gbl.F.Out,"&nbsp;%s",Deg.FullName);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>");
/***** Get my courses in this degree *****/
NumCrss = (unsigned) Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Deg.DegCod,&mysql_resCrs);
for (NumCrs = 0;
NumCrs < NumCrss;
NumCrs++)
{
/***** Get next course *****/
row = mysql_fetch_row (mysql_resCrs);
/***** Get data of this course *****/
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
if (!Crs_GetDataOfCourseByCod (&Crs))
Lay_ShowErrorAndExit ("Course not found.");
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"
"<td style=\"text-align:left; vertical-align:top;\">"
"<table>"
"<tr>");
/***** Indent course *****/
IsLastItemInLevel[5] = (NumCrs == NumCrss - 1);
Msg_IndentDependingOnLevel (5,IsLastItemInLevel);
/***** Write link to course *****/
fprintf (Gbl.F.Out,"<td class=\"%s\""
" style=\"text-align:left; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
Act_FormStart (ActSeeCrsInf);
Crs_PutParamCrsCod (Crs.CrsCod);
sprintf (Gbl.Title,Txt_Go_to_X,Crs.ShortName);
Act_LinkFormSubmit (Gbl.Title,
The_ClassFormul[Gbl.Prefs.Theme]);
sprintf (Icon,"<img src=\"%s/dot16x16.gif\" alt=\"%s\""
" class=\"ICON16x16\" style=\"vertical-align:top;\" />",
Gbl.Prefs.IconsURL,
Crs.ShortName);
fprintf (Gbl.F.Out,"%s",Icon);
fprintf (Gbl.F.Out,"&nbsp;%s",Crs.FullName);
/***** Write link to RSS file *****/
sprintf (PathRelRSSFile,"%s/%s/%ld/%s/%s",
Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CRS,Crs.CrsCod,Cfg_RSS_FOLDER,Cfg_RSS_FILE);
if (!Fil_CheckIfPathExists (PathRelRSSFile))
RSS_UpdateRSSFileForACrs (&Crs);
fprintf (Gbl.F.Out," <a href=\"");
RSS_WriteRSSLink (Gbl.F.Out,Crs.CrsCod);
fprintf (Gbl.F.Out,"\" target=\"_blank\">"
"<img src=\"%s/rss16x16.gif\" alt=\"RSS\""
" class=\"ICON16x16\""
" style=\"vertical-align:middle;\" />"
"</a>",
Gbl.Prefs.IconsURL);
fprintf (Gbl.F.Out,"</a>"
"</form>"
"</td>"
"</tr>"
"</table>"
"</td>"
"</tr>");
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_resCrs);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_resDeg);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_resCtr);
}
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_resIns);
}
fprintf (Gbl.F.Out,"</ul>"
"</td>"
"</tr>");
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_resCty);
/***** End frame *****/
Lay_EndRoundFrameTable10 ();
}
@ -711,13 +949,13 @@ unsigned Crs_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery)
/************ Put a link (form) to view courses of current degree ************/
/*****************************************************************************/
// Gbl.CurrentDeg.Deg.DegCod must be > 0
/*
static void Crs_PutLinkToViewCoursesOfCurrentDeg (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Courses_of_DEGREE_X;
/***** Put form to view courses of current degree *****/
***** Put form to view courses of current degree *****
Act_FormStart (ActSeeCrs);
sprintf (Gbl.Title,Txt_Courses_of_DEGREE_X,
Gbl.CurrentDeg.Deg.ShortName);
@ -725,7 +963,7 @@ static void Crs_PutLinkToViewCoursesOfCurrentDeg (void)
Lay_PutSendIcon ("hierarchy",Gbl.Title,Gbl.Title);
fprintf (Gbl.F.Out,"</form>");
}
*/
/*****************************************************************************/
/************************** Show courses of a degree *************************/
/*****************************************************************************/
@ -2768,6 +3006,7 @@ void Crs_ReqSelectOneOfMyCourses (void)
/***** Search / select more courses *****/
fprintf (Gbl.F.Out,"<div style=\"text-align:center;\">");
Crs_PutLinkToSearchCourses ();
/*
if (Gbl.CurrentDeg.Deg.DegCod > 0)
Crs_PutLinkToViewCoursesOfCurrentDeg ();
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
@ -2778,6 +3017,7 @@ void Crs_ReqSelectOneOfMyCourses (void)
Ins_PutLinkToViewInstitutionsOfCurrentCty ();
else
Cty_PutLinkToViewCountries ();
*/
fprintf (Gbl.F.Out,"</div>");
/***** Select one of my courses *****/

View File

@ -630,7 +630,7 @@ void Deg_WriteCtyInsCtrDeg (void)
extern const char *Txt_TABS_FULL_TXT[Act_NUM_TABS];
char DegreeShortName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree
/***** Form to go to the country *****/
/***** Form to go to the system *****/
Act_FormGoToStart (ActMnu);
Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys);
Act_LinkFormSubmit (Txt_TABS_FULL_TXT[TabSys],
@ -970,13 +970,13 @@ void Deg_ReqEditDegreeTypes (void)
/*********** Put a link (form) to view degrees of current centre *************/
/*****************************************************************************/
// Gbl.CurrentCtr.Ctr.CtrCod must be > 0
/*
void Deg_PutLinkToViewDegreesOfCurrentCtr (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Degrees_of_CENTRE_X;
/***** Put form to view degrees of current centre *****/
***** Put form to view degrees of current centre *****
Act_FormStart (ActSeeDeg);
sprintf (Gbl.Title,Txt_Degrees_of_CENTRE_X,
Gbl.CurrentCtr.Ctr.ShortName);
@ -984,7 +984,7 @@ void Deg_PutLinkToViewDegreesOfCurrentCtr (void)
Lay_PutSendIcon ("deg",Gbl.Title,Gbl.Title);
fprintf (Gbl.F.Out,"</form>");
}
*/
/*****************************************************************************/
/************* Show the degrees belonging to the current centre **************/
/*****************************************************************************/

View File

@ -114,7 +114,7 @@ void Deg_InitCurrentCourse (void);
void Deg_WriteSelectorDegTypes (void);
void Deg_SeeDegTypes (void);
void Deg_ReqEditDegreeTypes (void);
void Deg_PutLinkToViewDegreesOfCurrentCtr (void);
// void Deg_PutLinkToViewDegreesOfCurrentCtr (void);
void Deg_ShowDegsOfCurrentCtr (void);
unsigned Deg_ConvStrToYear (const char *StrYear);

View File

@ -1648,7 +1648,7 @@ void For_ShowForumList (void)
For_WriteLinksToInsForums (Gbl.Usrs.Me.MyInstitutions.Inss[NumMyIns].InsCod,(NumMyIns == Gbl.Usrs.Me.MyInstitutions.Num-1),IsLastItemInLevel);
/* Get my centres in this institution from database */
if ((NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Forum.Ins.InsCod,&mysql_resCtr)) > 0) // Degrees found in this institution
if ((NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Forum.Ins.InsCod,&mysql_resCtr)) > 0) // Centres found in this institution
for (NumCtr = 0;
NumCtr < NumCtrs;
NumCtr++)
@ -1861,7 +1861,7 @@ static long For_WriteLinksToCtrForums (long CtrCod,bool IsLastCtr,bool IsLastIte
ICanSeeTeacherForum = (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER ||
Rol_GetMyMaxRoleInCtr (CtrCod) >= Rol_ROLE_TEACHER);
/***** Get data of this degree *****/
/***** Get data of this centre *****/
Gbl.Forum.Ctr.CtrCod = CtrCod;
if (!Ctr_GetDataOfCentreByCod (&Gbl.Forum.Ctr))
Lay_ShowErrorAndExit ("Centre not found.");

View File

@ -463,13 +463,13 @@ static void Ins_Configuration (bool PrintView)
/********* Put a link (form) to view institutions of current country *********/
/*****************************************************************************/
// Gbl.CurrentCty.Cty.CtyCod must be > 0
/*
void Ins_PutLinkToViewInstitutionsOfCurrentCty (void)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Institutions_of_COUNTRY_X;
/***** Put form to view institutions of current country *****/
***** Put form to view institutions of current country *****
Act_FormStart (ActSeeIns);
sprintf (Gbl.Title,Txt_Institutions_of_COUNTRY_X,
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
@ -477,7 +477,7 @@ void Ins_PutLinkToViewInstitutionsOfCurrentCty (void)
Lay_PutSendIcon ("ins",Gbl.Title,Gbl.Title);
fprintf (Gbl.F.Out,"</form>");
}
*/
/*****************************************************************************/
/**************** List the institutions of the current country ***************/
/*****************************************************************************/

View File

@ -97,7 +97,7 @@ void Ins_SeeInsWithPendingCtrs (void);
void Ins_ShowConfiguration (void);
void Ins_PrintConfiguration (void);
void Ins_PutLinkToViewInstitutionsOfCurrentCty (void);
// void Ins_PutLinkToViewInstitutionsOfCurrentCty (void);
void Ins_ShowInssOfCurrentCty (void);
void Ins_EditInstitutions (void);
void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData);

View File

@ -764,7 +764,7 @@ void Usr_GetMyInstitutions (void)
Gbl.Usrs.Me.MyInstitutions.Num = 0;
/***** Get my institutions from database *****/
if ((NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_res)) > 0) // Institutions found
if ((NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res)) > 0) // Institutions found
for (NumIns = 0;
NumIns < NumInss;
NumIns++)
@ -783,7 +783,7 @@ void Usr_GetMyInstitutions (void)
Gbl.Usrs.Me.MyInstitutions.Num++;
}
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@ -1070,25 +1070,63 @@ bool Usr_CheckIfIBelongToCrs (long CrsCod)
}
/*****************************************************************************/
/************** Get the institutions of a user from database *****************/
/**************** Get the countries of a user from database ******************/
/*****************************************************************************/
// Returns the number of rows of the result
unsigned long Usr_GetInssFromUsr (long UsrCod,MYSQL_RES **mysql_res)
unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res)
{
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
char Query[512];
/***** Get the institutions a user belongs to from database *****/
sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)"
" FROM crs_usr,courses,degrees,centres,institutions"
sprintf (Query,"SELECT countries.CtyCod,MAX(crs_usr.Role)"
" FROM crs_usr,courses,degrees,centres,institutions,countries"
" WHERE crs_usr.UsrCod='%ld'"
" AND crs_usr.CrsCod=courses.CrsCod"
" AND courses.DegCod=degrees.DegCod"
" AND degrees.CtrCod=centres.CtrCod"
" AND centres.InsCod=institutions.InsCod"
" GROUP BY institutions.InsCod"
" ORDER BY institutions.ShortName",
UsrCod);
" AND institutions.CtyCod=countries.CtyCod"
" GROUP BY countries.CtyCod"
" ORDER BY countries.Name_%s",
UsrCod,Txt_STR_LANG_ID[Gbl.Prefs.Language]);
return (unsigned) DB_QuerySELECT (Query,mysql_res,"can not get the countries a user belongs to");
}
/*****************************************************************************/
/************** Get the institutions of a user from database *****************/
/*****************************************************************************/
// Returns the number of rows of the result
unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res)
{
char Query[512];
/***** Get the institutions a user belongs to from database *****/
if (CtyCod > 0)
sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)"
" FROM crs_usr,courses,degrees,centres,institutions"
" WHERE crs_usr.UsrCod='%ld'"
" AND crs_usr.CrsCod=courses.CrsCod"
" AND courses.DegCod=degrees.DegCod"
" AND degrees.CtrCod=centres.CtrCod"
" AND centres.InsCod=institutions.InsCod"
" AND institutions.CtyCod='%ld'"
" GROUP BY institutions.InsCod"
" ORDER BY institutions.ShortName",
UsrCod,CtyCod);
else
sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)"
" FROM crs_usr,courses,degrees,centres,institutions"
" WHERE crs_usr.UsrCod='%ld'"
" AND crs_usr.CrsCod=courses.CrsCod"
" AND courses.DegCod=degrees.DegCod"
" AND degrees.CtrCod=centres.CtrCod"
" AND centres.InsCod=institutions.InsCod"
" GROUP BY institutions.InsCod"
" ORDER BY institutions.ShortName",
UsrCod);
return DB_QuerySELECT (Query,mysql_res,"can not get the institutions a user belongs to");
}

View File

@ -218,7 +218,8 @@ bool Usr_CheckIfIBelongToIns (long InsCod);
bool Usr_CheckIfIBelongToCtr (long CtrCod);
bool Usr_CheckIfIBelongToDeg (long DegCod);
bool Usr_CheckIfIBelongToCrs (long CrsCod);
unsigned long Usr_GetInssFromUsr (long UsrCod,MYSQL_RES **mysql_res);
unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res);
unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res);
unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);
unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res);
unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res);