mirror of https://github.com/acanas/swad-core.git
Version 20.63: Apr 16, 2021 Optimizations in database selects.
This commit is contained in:
parent
367b80943e
commit
d3bc257ce5
181
swad_API.c
181
swad_API.c
|
@ -1013,14 +1013,14 @@ int swad__loginBySessionKey (struct soap *soap,
|
||||||
|
|
||||||
// Now, we know that sessionID is a valid session identifier
|
// Now, we know that sessionID is a valid session identifier
|
||||||
/***** Query data of the session from database *****/
|
/***** Query data of the session from database *****/
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get session data",
|
DB_QuerySELECT (&mysql_res,"can not get session data",
|
||||||
"SELECT UsrCod," // row[0]
|
"SELECT UsrCod," // row[0]
|
||||||
"DegCod," // row[1]
|
"DegCod," // row[1]
|
||||||
"CrsCod" // row[2]
|
"CrsCod" // row[2]
|
||||||
" FROM ses_sessions"
|
" FROM ses_sessions"
|
||||||
" WHERE SessionId='%s'",
|
" WHERE SessionId='%s'",
|
||||||
sessionID);
|
sessionID);
|
||||||
if (NumRows == 1) // Session found in table of sessions
|
if (NumRows == 1) // Session found in table of sessions
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2625,13 +2625,12 @@ static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap,
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
/***** Get list of groups *****/
|
/***** Get list of groups *****/
|
||||||
NumGrps =
|
NumGrps = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get groups"
|
DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
||||||
" of an attendance event",
|
"SELECT GrpCod"
|
||||||
"SELECT GrpCod"
|
" FROM att_groups"
|
||||||
" FROM att_groups"
|
" WHERE AttCod=%ld",
|
||||||
" WHERE AttCod=%ld",
|
AttCod);
|
||||||
AttCod);
|
|
||||||
if (NumGrps == 0)
|
if (NumGrps == 0)
|
||||||
*ListGroups = NULL;
|
*ListGroups = NULL;
|
||||||
else // Events found
|
else // Events found
|
||||||
|
@ -3587,8 +3586,8 @@ int swad__sendMessage (struct soap *soap,
|
||||||
char *Query = NULL;
|
char *Query = NULL;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRow;
|
unsigned NumUsrs;
|
||||||
unsigned NumRows;
|
unsigned NumUsr;
|
||||||
bool FirstNickname = true;
|
bool FirstNickname = true;
|
||||||
bool ThereAreNicknames = false;
|
bool ThereAreNicknames = false;
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
|
@ -3715,22 +3714,23 @@ int swad__sendMessage (struct soap *soap,
|
||||||
if (ReplyUsrCod > 0 || ThereAreNicknames) // There are a recipient to reply or nicknames in "to"
|
if (ReplyUsrCod > 0 || ThereAreNicknames) // There are a recipient to reply or nicknames in "to"
|
||||||
{
|
{
|
||||||
/***** Get users *****/
|
/***** Get users *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get users",
|
NumUsrs = (unsigned)
|
||||||
"%s",
|
DB_QuerySELECT (&mysql_res,"can not get users",
|
||||||
Query);
|
"%s",
|
||||||
|
Query);
|
||||||
|
|
||||||
sendMessageOut->numUsers = (int) NumRows;
|
sendMessageOut->numUsers = (int) NumUsrs;
|
||||||
sendMessageOut->usersArray.__size = (int) NumRows;
|
sendMessageOut->usersArray.__size = (int) NumUsrs;
|
||||||
|
|
||||||
if (NumRows) // Users found
|
if (NumUsrs) // Users found
|
||||||
{
|
{
|
||||||
sendMessageOut->usersArray.__ptr = soap_malloc (soap,
|
sendMessageOut->usersArray.__ptr = soap_malloc (soap,
|
||||||
(sendMessageOut->usersArray.__size) *
|
(sendMessageOut->usersArray.__size) *
|
||||||
sizeof (*(sendMessageOut->usersArray.__ptr)));
|
sizeof (*(sendMessageOut->usersArray.__ptr)));
|
||||||
|
|
||||||
for (NumRow = 0;
|
for (NumUsr = 0;
|
||||||
NumRow < NumRows;
|
NumUsr < NumUsrs;
|
||||||
NumRow++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3754,7 +3754,7 @@ int swad__sendMessage (struct soap *soap,
|
||||||
|
|
||||||
/* Copy user's data into output structure */
|
/* Copy user's data into output structure */
|
||||||
API_CopyUsrData (soap,
|
API_CopyUsrData (soap,
|
||||||
&(sendMessageOut->usersArray.__ptr[NumRow]),
|
&(sendMessageOut->usersArray.__ptr[NumUsr]),
|
||||||
&Gbl.Usrs.Other.UsrDat,
|
&Gbl.Usrs.Other.UsrDat,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -4180,22 +4180,23 @@ static int API_GetTstTags (struct soap *soap,
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRow;
|
unsigned NumTags;
|
||||||
unsigned NumRows;
|
unsigned NumTag;
|
||||||
|
|
||||||
/***** Get available tags from database *****/
|
/***** Get available tags from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get test tags",
|
NumTags = (unsigned)
|
||||||
"SELECT TagCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get test tags",
|
||||||
"TagTxt" // row[1]
|
"SELECT TagCod," // row[0]
|
||||||
" FROM tst_tags"
|
"TagTxt" // row[1]
|
||||||
" WHERE CrsCod=%ld"
|
" FROM tst_tags"
|
||||||
" AND TagHidden='N'"
|
" WHERE CrsCod=%ld"
|
||||||
" ORDER BY TagTxt",
|
" AND TagHidden='N'"
|
||||||
CrsCod);
|
" ORDER BY TagTxt",
|
||||||
|
CrsCod);
|
||||||
|
|
||||||
getTestsOut->tagsArray.__size = (int) NumRows;
|
getTestsOut->tagsArray.__size = (int) NumTags;
|
||||||
|
|
||||||
if (NumRows == 0)
|
if (NumTags == 0)
|
||||||
getTestsOut->tagsArray.__ptr = NULL;
|
getTestsOut->tagsArray.__ptr = NULL;
|
||||||
else // Tags found
|
else // Tags found
|
||||||
{
|
{
|
||||||
|
@ -4203,20 +4204,20 @@ static int API_GetTstTags (struct soap *soap,
|
||||||
(getTestsOut->tagsArray.__size) *
|
(getTestsOut->tagsArray.__size) *
|
||||||
sizeof (*(getTestsOut->tagsArray.__ptr)));
|
sizeof (*(getTestsOut->tagsArray.__ptr)));
|
||||||
|
|
||||||
for (NumRow = 0;
|
for (NumTag = 0;
|
||||||
NumRow < NumRows;
|
NumTag < NumTags;
|
||||||
NumRow++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
/* Get next tag */
|
/* Get next tag */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get tag code (row[0]) */
|
/* Get tag code (row[0]) */
|
||||||
getTestsOut->tagsArray.__ptr[NumRow].tagCode = (int) Str_ConvertStrCodToLongCod (row[0]);
|
getTestsOut->tagsArray.__ptr[NumTag].tagCode = (int) Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get tag text (row[1]) */
|
/* Get tag text (row[1]) */
|
||||||
getTestsOut->tagsArray.__ptr[NumRow].tagText =
|
getTestsOut->tagsArray.__ptr[NumTag].tagText =
|
||||||
soap_malloc (soap,Tag_MAX_BYTES_TAG + 1);
|
soap_malloc (soap,Tag_MAX_BYTES_TAG + 1);
|
||||||
Str_Copy (getTestsOut->tagsArray.__ptr[NumRow].tagText,row[1],
|
Str_Copy (getTestsOut->tagsArray.__ptr[NumTag].tagText,row[1],
|
||||||
Tag_MAX_BYTES_TAG);
|
Tag_MAX_BYTES_TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4766,7 +4767,7 @@ int swad__getGames (struct soap *soap,
|
||||||
int ReturnCode;
|
int ReturnCode;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumGames;
|
||||||
int NumGame;
|
int NumGame;
|
||||||
long GamCod;
|
long GamCod;
|
||||||
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
||||||
|
@ -4808,27 +4809,28 @@ int swad__getGames (struct soap *soap,
|
||||||
"Requester must be a student in the course");
|
"Requester must be a student in the course");
|
||||||
|
|
||||||
/***** Query list of games *****/
|
/***** Query list of games *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get games",
|
NumGames = (unsigned)
|
||||||
"SELECT gam_games.GamCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get games",
|
||||||
"gam_games.UsrCod," // row[1]
|
"SELECT gam_games.GamCod," // row[0]
|
||||||
"UNIX_TIMESTAMP(MIN(mch_matches.StartTime)) AS StartTime," // row[2]
|
"gam_games.UsrCod," // row[1]
|
||||||
"UNIX_TIMESTAMP(MAX(mch_matches.EndTime)) AS EndTime," // row[3]
|
"UNIX_TIMESTAMP(MIN(mch_matches.StartTime)) AS StartTime," // row[2]
|
||||||
"gam_games.MaxGrade," // row[4]
|
"UNIX_TIMESTAMP(MAX(mch_matches.EndTime)) AS EndTime," // row[3]
|
||||||
"gam_games.Visibility," // row[5]
|
"gam_games.MaxGrade," // row[4]
|
||||||
"gam_games.Title," // row[6]
|
"gam_games.Visibility," // row[5]
|
||||||
"gam_games.Txt" // row[7]
|
"gam_games.Title," // row[6]
|
||||||
" FROM gam_games"
|
"gam_games.Txt" // row[7]
|
||||||
" LEFT JOIN mch_matches"
|
" FROM gam_games"
|
||||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
" LEFT JOIN mch_matches"
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||||
" AND Hidden='N'"
|
" WHERE gam_games.CrsCod=%ld"
|
||||||
" GROUP BY gam_games.GamCod"
|
" AND Hidden='N'"
|
||||||
" ORDER BY StartTime DESC,"
|
" GROUP BY gam_games.GamCod"
|
||||||
"EndTime DESC,"
|
" ORDER BY StartTime DESC,"
|
||||||
"gam_games.Title DESC",
|
"EndTime DESC,"
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
"gam_games.Title DESC",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
getGamesOut->gamesArray.__size =
|
getGamesOut->gamesArray.__size =
|
||||||
getGamesOut->numGames = (int) NumRows;
|
getGamesOut->numGames = (int) NumGames;
|
||||||
|
|
||||||
if (getGamesOut->numGames == 0)
|
if (getGamesOut->numGames == 0)
|
||||||
getGamesOut->gamesArray.__ptr = NULL;
|
getGamesOut->gamesArray.__ptr = NULL;
|
||||||
|
@ -4938,7 +4940,7 @@ int swad__getMatches (struct soap *soap,
|
||||||
struct Gam_Game Game;
|
struct Gam_Game Game;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumMatches;
|
||||||
int NumMatch;
|
int NumMatch;
|
||||||
long MchCod;
|
long MchCod;
|
||||||
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
char PhotoURL[Cns_MAX_BYTES_WWW + 1];
|
||||||
|
@ -4991,29 +4993,30 @@ int swad__getMatches (struct soap *soap,
|
||||||
"Requester must be a student in the course");
|
"Requester must be a student in the course");
|
||||||
|
|
||||||
/***** Query list of matches *****/
|
/***** Query list of matches *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get matches",
|
NumMatches = (unsigned)
|
||||||
"SELECT MchCod," // row[ 0]
|
DB_QuerySELECT (&mysql_res,"can not get matches",
|
||||||
"UsrCod," // row[ 1]
|
"SELECT MchCod," // row[ 0]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[ 2]
|
"UsrCod," // row[ 1]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[ 3]
|
"UNIX_TIMESTAMP(StartTime)," // row[ 2]
|
||||||
"Title," // row[ 4]
|
"UNIX_TIMESTAMP(EndTime)," // row[ 3]
|
||||||
"QstInd" // row[ 5]
|
"Title," // row[ 4]
|
||||||
" FROM mch_matches"
|
"QstInd" // row[ 5]
|
||||||
" WHERE GamCod=%ld"
|
" FROM mch_matches"
|
||||||
" AND (MchCod NOT IN"
|
" WHERE GamCod=%ld"
|
||||||
" (SELECT MchCod FROM mch_groups)"
|
" AND (MchCod NOT IN"
|
||||||
" OR"
|
" (SELECT MchCod FROM mch_groups)"
|
||||||
" MchCod IN"
|
" OR"
|
||||||
" (SELECT mch_groups.MchCod"
|
" MchCod IN"
|
||||||
" FROM mch_groups,"
|
" (SELECT mch_groups.MchCod"
|
||||||
"grp_users"
|
" FROM mch_groups,"
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
"grp_users"
|
||||||
" AND mch_groups.GrpCod=grp_users.GrpCod))"
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
" ORDER BY MchCod",
|
" AND mch_groups.GrpCod=grp_users.GrpCod))"
|
||||||
Game.GamCod,
|
" ORDER BY MchCod",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Game.GamCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
getMatchesOut->matchesArray.__size =
|
getMatchesOut->matchesArray.__size =
|
||||||
getMatchesOut->numMatches = (int) NumRows;
|
getMatchesOut->numMatches = (int) NumMatches;
|
||||||
|
|
||||||
if (getMatchesOut->numMatches == 0)
|
if (getMatchesOut->numMatches == 0)
|
||||||
getMatchesOut->matchesArray.__ptr = NULL;
|
getMatchesOut->matchesArray.__ptr = NULL;
|
||||||
|
|
25
swad_MFU.c
25
swad_MFU.c
|
@ -102,24 +102,25 @@ void MFU_GetMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned MaxAc
|
||||||
{
|
{
|
||||||
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumActions;
|
||||||
unsigned long NumRow;
|
unsigned NumAction;
|
||||||
long ActCod;
|
long ActCod;
|
||||||
Act_Action_t Action;
|
Act_Action_t Action;
|
||||||
|
|
||||||
/***** Get most frequently used actions *****/
|
/***** Get most frequently used actions *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get most frequently used actions",
|
NumActions = (unsigned)
|
||||||
"SELECT ActCod"
|
DB_QuerySELECT (&mysql_res,"can not get most frequently used actions",
|
||||||
" FROM act_frequent"
|
"SELECT ActCod"
|
||||||
" WHERE UsrCod=%ld"
|
" FROM act_frequent"
|
||||||
" ORDER BY Score DESC,"
|
" WHERE UsrCod=%ld"
|
||||||
"LastClick DESC",
|
" ORDER BY Score DESC,"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
"LastClick DESC",
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
|
||||||
/***** Write list of frequently used actions *****/
|
/***** Write list of frequently used actions *****/
|
||||||
for (NumRow = 0, ListMFUActions->NumActions = 0;
|
for (NumAction = 0, ListMFUActions->NumActions = 0;
|
||||||
NumRow < NumRows && ListMFUActions->NumActions < MaxActionsShown;
|
NumAction < NumActions && ListMFUActions->NumActions < MaxActionsShown;
|
||||||
NumRow++)
|
NumAction++)
|
||||||
{
|
{
|
||||||
/* Get action code */
|
/* Get action code */
|
||||||
ActCod = DB_GetNextCode (mysql_res);
|
ActCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
|
@ -89,7 +89,7 @@ static void Asg_PutParams (void *Assignments);
|
||||||
static void Asg_GetListAssignments (struct Asg_Assignments *Assignments);
|
static void Asg_GetListAssignments (struct Asg_Assignments *Assignments);
|
||||||
static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
||||||
MYSQL_RES **mysql_res,
|
MYSQL_RES **mysql_res,
|
||||||
unsigned long NumRows);
|
unsigned NumAsgs);
|
||||||
static void Asg_ResetAssignment (struct Asg_Assignment *Asg);
|
static void Asg_ResetAssignment (struct Asg_Assignment *Asg);
|
||||||
static void Asg_FreeListAssignments (struct Asg_Assignments *Assignments);
|
static void Asg_FreeListAssignments (struct Asg_Assignments *Assignments);
|
||||||
static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
||||||
|
@ -684,7 +684,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
||||||
[Dat_END_TIME ] = "EndTime DESC,StartTime DESC,Title DESC",
|
[Dat_END_TIME ] = "EndTime DESC,StartTime DESC,Title DESC",
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumAsgs;
|
||||||
unsigned NumAsg;
|
unsigned NumAsg;
|
||||||
|
|
||||||
if (Assignments->LstIsRead)
|
if (Assignments->LstIsRead)
|
||||||
|
@ -692,45 +692,47 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
||||||
|
|
||||||
/***** Get list of assignments from database *****/
|
/***** Get list of assignments from database *****/
|
||||||
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
NumAsgs = (unsigned)
|
||||||
"SELECT AsgCod"
|
DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||||
" FROM asg_assignments"
|
"SELECT AsgCod"
|
||||||
" WHERE CrsCod=%ld%s"
|
" FROM asg_assignments"
|
||||||
" AND ("
|
" WHERE CrsCod=%ld%s"
|
||||||
// Assignment is for the whole course
|
" AND ("
|
||||||
"AsgCod NOT IN"
|
// Assignment is for the whole course
|
||||||
" (SELECT AsgCod"
|
"AsgCod NOT IN"
|
||||||
" FROM asg_groups)" // Not associated to any group
|
" (SELECT AsgCod"
|
||||||
" OR"
|
" FROM asg_groups)" // Not associated to any group
|
||||||
// Assignment is for some of my groups
|
" OR"
|
||||||
" AsgCod IN"
|
// Assignment is for some of my groups
|
||||||
" (SELECT asg_groups.AsgCod"
|
" AsgCod IN"
|
||||||
" FROM asg_groups,"
|
" (SELECT asg_groups.AsgCod"
|
||||||
"grp_users"
|
" FROM asg_groups,"
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
"grp_users"
|
||||||
" AND asg_groups.GrpCod=grp_users.GrpCod)"
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
")"
|
" AND asg_groups.GrpCod=grp_users.GrpCod)"
|
||||||
" ORDER BY %s",
|
")"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||||
OrderBySubQuery[Assignments->SelectedOrder]);
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
OrderBySubQuery[Assignments->SelectedOrder]);
|
||||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
NumAsgs = (unsigned)
|
||||||
"SELECT AsgCod"
|
DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||||
" FROM asg_assignments"
|
"SELECT AsgCod"
|
||||||
" WHERE CrsCod=%ld%s"
|
" FROM asg_assignments"
|
||||||
" ORDER BY %s",
|
" WHERE CrsCod=%ld%s"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
OrderBySubQuery[Assignments->SelectedOrder]);
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||||
|
OrderBySubQuery[Assignments->SelectedOrder]);
|
||||||
|
|
||||||
if (NumRows) // Assignments found...
|
if (NumAsgs) // Assignments found...
|
||||||
{
|
{
|
||||||
Assignments->Num = (unsigned) NumRows;
|
Assignments->Num = (unsigned) NumAsgs;
|
||||||
|
|
||||||
/***** Create list of assignments *****/
|
/***** Create list of assignments *****/
|
||||||
if ((Assignments->LstAsgCods = calloc (NumRows,
|
if ((Assignments->LstAsgCods = calloc (NumAsgs,
|
||||||
sizeof (*Assignments->LstAsgCods))) == NULL)
|
sizeof (*Assignments->LstAsgCods))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -760,28 +762,29 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
||||||
void Asg_GetDataOfAssignmentByCod (struct Asg_Assignment *Asg)
|
void Asg_GetDataOfAssignmentByCod (struct Asg_Assignment *Asg)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumAsgs;
|
||||||
|
|
||||||
if (Asg->AsgCod > 0)
|
if (Asg->AsgCod > 0)
|
||||||
{
|
{
|
||||||
/***** Build query *****/
|
/***** Build query *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
NumAsgs = (unsigned)
|
||||||
"SELECT AsgCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
||||||
"Hidden," // row[1]
|
"SELECT AsgCod," // row[0]
|
||||||
"UsrCod," // row[2]
|
"Hidden," // row[1]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
"UsrCod," // row[2]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
||||||
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
||||||
"Title," // row[6]
|
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
||||||
"Folder" // row[7]
|
"Title," // row[6]
|
||||||
" FROM asg_assignments"
|
"Folder" // row[7]
|
||||||
" WHERE AsgCod=%ld"
|
" FROM asg_assignments"
|
||||||
" AND CrsCod=%ld",
|
" WHERE AsgCod=%ld"
|
||||||
Asg->AsgCod,
|
" AND CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Asg->AsgCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** Get data of assignment *****/
|
/***** Get data of assignment *****/
|
||||||
Asg_GetDataOfAssignment (Asg,&mysql_res,NumRows);
|
Asg_GetDataOfAssignment (Asg,&mysql_res,NumAsgs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -798,28 +801,29 @@ void Asg_GetDataOfAssignmentByCod (struct Asg_Assignment *Asg)
|
||||||
void Asg_GetDataOfAssignmentByFolder (struct Asg_Assignment *Asg)
|
void Asg_GetDataOfAssignmentByFolder (struct Asg_Assignment *Asg)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumAsgs;
|
||||||
|
|
||||||
if (Asg->Folder[0])
|
if (Asg->Folder[0])
|
||||||
{
|
{
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
NumAsgs = (unsigned)
|
||||||
"SELECT AsgCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get assignment data",
|
||||||
"Hidden," // row[1]
|
"SELECT AsgCod," // row[0]
|
||||||
"UsrCod," // row[2]
|
"Hidden," // row[1]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
"UsrCod," // row[2]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
||||||
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
||||||
"Title," // row[6]
|
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
||||||
"Folder" // row[7]
|
"Title," // row[6]
|
||||||
" FROM asg_assignments"
|
"Folder" // row[7]
|
||||||
" WHERE CrsCod=%ld"
|
" FROM asg_assignments"
|
||||||
" AND Folder='%s'",
|
" WHERE CrsCod=%ld"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" AND Folder='%s'",
|
||||||
Asg->Folder);
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
Asg->Folder);
|
||||||
|
|
||||||
/***** Get data of assignment *****/
|
/***** Get data of assignment *****/
|
||||||
Asg_GetDataOfAssignment (Asg,&mysql_res,NumRows);
|
Asg_GetDataOfAssignment (Asg,&mysql_res,NumAsgs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -835,7 +839,7 @@ void Asg_GetDataOfAssignmentByFolder (struct Asg_Assignment *Asg)
|
||||||
|
|
||||||
static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
||||||
MYSQL_RES **mysql_res,
|
MYSQL_RES **mysql_res,
|
||||||
unsigned long NumRows)
|
unsigned NumAsgs)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
@ -843,7 +847,7 @@ static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
|
||||||
Asg_ResetAssignment (Asg);
|
Asg_ResetAssignment (Asg);
|
||||||
|
|
||||||
/***** Get data of assignment from database *****/
|
/***** Get data of assignment from database *****/
|
||||||
if (NumRows) // Assignment found...
|
if (NumAsgs) // Assignment found...
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (*mysql_res);
|
row = mysql_fetch_row (*mysql_res);
|
||||||
|
@ -953,21 +957,22 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumAsgs;
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
SummaryStr[0] = '\0'; // Return nothing on error
|
SummaryStr[0] = '\0'; // Return nothing on error
|
||||||
|
|
||||||
/***** Build query *****/
|
/***** Build query *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment title and text",
|
NumAsgs = (unsigned)
|
||||||
"SELECT Title," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get assignment title and text",
|
||||||
"Txt" // row[1]
|
"SELECT Title," // row[0]
|
||||||
" FROM asg_assignments"
|
"Txt" // row[1]
|
||||||
" WHERE AsgCod=%ld",
|
" FROM asg_assignments"
|
||||||
AsgCod);
|
" WHERE AsgCod=%ld",
|
||||||
|
AsgCod);
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (NumRows == 1)
|
if (NumAsgs == 1)
|
||||||
{
|
{
|
||||||
/***** Get row *****/
|
/***** Get row *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1727,36 +1732,37 @@ static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *As
|
||||||
extern const char *Txt_The_whole_course;
|
extern const char *Txt_The_whole_course;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumGrps;
|
||||||
unsigned long NumRows;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups associated to an assignment from database *****/
|
/***** Get groups associated to an assignment from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get groups of an assignment",
|
NumGrps = (unsigned)
|
||||||
"SELECT grp_types.GrpTypName," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get groups of an assignment",
|
||||||
"grp_groups.GrpName" // row[1]
|
"SELECT grp_types.GrpTypName," // row[0]
|
||||||
" FROM asg_groups,"
|
"grp_groups.GrpName" // row[1]
|
||||||
"grp_groups,"
|
" FROM asg_groups,"
|
||||||
"grp_types"
|
"grp_groups,"
|
||||||
" WHERE asg_groups.AsgCod=%ld"
|
"grp_types"
|
||||||
" AND asg_groups.GrpCod=grp_groups.GrpCod"
|
" WHERE asg_groups.AsgCod=%ld"
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
" AND asg_groups.GrpCod=grp_groups.GrpCod"
|
||||||
" ORDER BY grp_types.GrpTypName,"
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
"grp_groups.GrpName",
|
" ORDER BY grp_types.GrpTypName,"
|
||||||
Asg->AsgCod);
|
"grp_groups.GrpName",
|
||||||
|
Asg->AsgCod);
|
||||||
|
|
||||||
/***** Write heading *****/
|
/***** Write heading *****/
|
||||||
HTM_DIV_Begin ("class=\"%s\"",Asg->Hidden ? "ASG_GRP_LIGHT" :
|
HTM_DIV_Begin ("class=\"%s\"",Asg->Hidden ? "ASG_GRP_LIGHT" :
|
||||||
"ASG_GRP");
|
"ASG_GRP");
|
||||||
HTM_TxtColonNBSP (NumRows == 1 ? Txt_Group :
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
||||||
Txt_Groups);
|
Txt_Groups);
|
||||||
|
|
||||||
/***** Write groups *****/
|
/***** Write groups *****/
|
||||||
if (NumRows) // Groups found...
|
if (NumGrps) // Groups found...
|
||||||
{
|
{
|
||||||
/* Get and write the group types and names */
|
/* Get and write the group types and names */
|
||||||
for (NumRow = 0;
|
for (NumGrp = 0;
|
||||||
NumRow < NumRows;
|
NumGrp < NumGrps;
|
||||||
NumRow++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1764,12 +1770,12 @@ static void Asg_GetAndWriteNamesOfGrpsAssociatedToAsg (struct Asg_Assignment *As
|
||||||
/* Write group type name and group name */
|
/* Write group type name and group name */
|
||||||
HTM_TxtF ("%s %s",row[0],row[1]);
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
||||||
|
|
||||||
if (NumRows >= 2)
|
if (NumGrps >= 2)
|
||||||
{
|
{
|
||||||
if (NumRow == NumRows-2)
|
if (NumGrp == NumGrps - 2)
|
||||||
HTM_TxtF (" %s ",Txt_and);
|
HTM_TxtF (" %s ",Txt_and);
|
||||||
if (NumRows >= 3)
|
if (NumGrps >= 3)
|
||||||
if (NumRow < NumRows-2)
|
if (NumGrp < NumGrps - 2)
|
||||||
HTM_Txt (", ");
|
HTM_Txt (", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -668,7 +668,6 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
[Dat_END_TIME ][Att_OLDEST_FIRST] = "EndTime,StartTime,Title",
|
[Dat_END_TIME ][Att_OLDEST_FIRST] = "EndTime,StartTime,Title",
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumAttEvent;
|
unsigned NumAttEvent;
|
||||||
|
|
||||||
if (Events->LstIsRead)
|
if (Events->LstIsRead)
|
||||||
|
@ -676,42 +675,42 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
|
|
||||||
/***** Get list of attendance events from database *****/
|
/***** Get list of attendance events from database *****/
|
||||||
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
Events->Num = (unsigned)
|
||||||
"SELECT AttCod"
|
DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||||
" FROM att_events"
|
"SELECT AttCod"
|
||||||
" WHERE CrsCod=%ld"
|
" FROM att_events"
|
||||||
"%s"
|
" WHERE CrsCod=%ld"
|
||||||
" AND (AttCod NOT IN"
|
"%s"
|
||||||
" (SELECT AttCod"
|
" AND (AttCod NOT IN"
|
||||||
" FROM att_groups)"
|
" (SELECT AttCod"
|
||||||
" OR"
|
" FROM att_groups)"
|
||||||
" AttCod IN"
|
" OR"
|
||||||
" (SELECT att_groups.AttCod"
|
" AttCod IN"
|
||||||
" FROM grp_users,"
|
" (SELECT att_groups.AttCod"
|
||||||
"att_groups"
|
" FROM grp_users,"
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
"att_groups"
|
||||||
" AND att_groups.GrpCod=grp_users.GrpCod))"
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
" ORDER BY %s",
|
" AND att_groups.GrpCod=grp_users.GrpCod))"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||||
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
||||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
Events->Num = (unsigned)
|
||||||
"SELECT AttCod"
|
DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||||
" FROM att_events"
|
"SELECT AttCod"
|
||||||
" WHERE CrsCod=%ld%s"
|
" FROM att_events"
|
||||||
" ORDER BY %s",
|
" WHERE CrsCod=%ld%s"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||||
|
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
||||||
|
|
||||||
if (NumRows) // Attendance events found...
|
if (Events->Num) // Attendance events found...
|
||||||
{
|
{
|
||||||
Events->Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list of attendance events *****/
|
/***** Create list of attendance events *****/
|
||||||
if ((Events->Lst = calloc (NumRows,sizeof (*Events->Lst))) == NULL)
|
if ((Events->Lst = calloc (Events->Num,sizeof (*Events->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the attendance events codes *****/
|
/***** Get the attendance events codes *****/
|
||||||
|
@ -724,8 +723,6 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
Lay_ShowErrorAndExit ("Error: wrong attendance event code.");
|
Lay_ShowErrorAndExit ("Error: wrong attendance event code.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Events->Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -758,7 +755,7 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumAttEvents;
|
||||||
bool Found = false;
|
bool Found = false;
|
||||||
|
|
||||||
/***** Reset attendance event data *****/
|
/***** Reset attendance event data *****/
|
||||||
|
@ -767,22 +764,23 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
||||||
if (Event->AttCod > 0)
|
if (Event->AttCod > 0)
|
||||||
{
|
{
|
||||||
/***** Build query *****/
|
/***** Build query *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance event data",
|
NumAttEvents = (unsigned)
|
||||||
"SELECT AttCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get attendance event data",
|
||||||
"CrsCod," // row[1]
|
"SELECT AttCod," // row[0]
|
||||||
"Hidden," // row[2]
|
"CrsCod," // row[1]
|
||||||
"UsrCod," // row[3]
|
"Hidden," // row[2]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[4]
|
"UsrCod," // row[3]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[5]
|
"UNIX_TIMESTAMP(StartTime)," // row[4]
|
||||||
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
"UNIX_TIMESTAMP(EndTime)," // row[5]
|
||||||
"CommentTchVisible," // row[7]
|
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||||
"Title" // row[8]
|
"CommentTchVisible," // row[7]
|
||||||
" FROM att_events"
|
"Title" // row[8]
|
||||||
" WHERE AttCod=%ld",
|
" FROM att_events"
|
||||||
Event->AttCod);
|
" WHERE AttCod=%ld",
|
||||||
|
Event->AttCod);
|
||||||
|
|
||||||
/***** Get data of attendance event from database *****/
|
/***** Get data of attendance event from database *****/
|
||||||
if ((Found = (NumRows != 0))) // Attendance event found...
|
if ((Found = (NumAttEvents != 0))) // Attendance event found...
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2236,11 +2234,12 @@ static void Att_PutParamsCodGrps (long AttCod)
|
||||||
|
|
||||||
/***** Get groups associated to an attendance event from database *****/
|
/***** Get groups associated to an attendance event from database *****/
|
||||||
if (Gbl.Crs.Grps.NumGrps)
|
if (Gbl.Crs.Grps.NumGrps)
|
||||||
NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
NumGrps = (unsigned)
|
||||||
"SELECT GrpCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
||||||
" FROM att_groups"
|
"SELECT GrpCod" // row[0]
|
||||||
" WHERE att_groups.AttCod=%ld",
|
" FROM att_groups"
|
||||||
AttCod);
|
" WHERE att_groups.AttCod=%ld",
|
||||||
|
AttCod);
|
||||||
else
|
else
|
||||||
NumGrps = 0;
|
NumGrps = 0;
|
||||||
|
|
||||||
|
@ -2572,21 +2571,19 @@ static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long Us
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
bool Present;
|
bool Present;
|
||||||
|
|
||||||
/***** Check if a students is registered in an event in database *****/
|
/***** Check if a students is registered in an event in database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student"
|
if (DB_QuerySELECT (&mysql_res,"can not get if a student"
|
||||||
" is already registered in an event",
|
" is already registered in an event",
|
||||||
"SELECT Present," // row[0]
|
"SELECT Present," // row[0]
|
||||||
"CommentStd," // row[1]
|
"CommentStd," // row[1]
|
||||||
"CommentTch" // row[2]
|
"CommentTch" // row[2]
|
||||||
" FROM att_users"
|
" FROM att_users"
|
||||||
" WHERE AttCod=%ld"
|
" WHERE AttCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
AttCod,
|
AttCod,
|
||||||
UsrCod);
|
UsrCod))
|
||||||
if (NumRows)
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
113
swad_banner.c
113
swad_banner.c
|
@ -83,7 +83,7 @@ static void Ban_PutIconToEditBanners (void);
|
||||||
static void Ban_EditBannersInternal (struct Ban_Banners *Banners,
|
static void Ban_EditBannersInternal (struct Ban_Banners *Banners,
|
||||||
const struct Ban_Banner *Ban);
|
const struct Ban_Banner *Ban);
|
||||||
static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
||||||
MYSQL_RES **mysql_res,unsigned long NumRows);
|
MYSQL_RES **mysql_res,unsigned NumBanners);
|
||||||
static void Ban_FreeListBanners (struct Ban_Banners *Banners);
|
static void Ban_FreeListBanners (struct Ban_Banners *Banners);
|
||||||
|
|
||||||
static void Ban_PutIconsEditingBanners (__attribute__((unused)) void *Args);
|
static void Ban_PutIconsEditingBanners (__attribute__((unused)) void *Args);
|
||||||
|
@ -134,23 +134,24 @@ void Ban_SeeBanners (void)
|
||||||
extern const char *Txt_New_banner;
|
extern const char *Txt_New_banner;
|
||||||
struct Ban_Banners Banners;
|
struct Ban_Banners Banners;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumBanners;
|
||||||
|
|
||||||
/***** Reset banners *****/
|
/***** Reset banners *****/
|
||||||
Ban_ResetBanners (&Banners);
|
Ban_ResetBanners (&Banners);
|
||||||
|
|
||||||
/***** Get list of banners *****/
|
/***** Get list of banners *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get banners",
|
NumBanners = (unsigned)
|
||||||
"SELECT BanCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get banners",
|
||||||
"Hidden," // row[1]
|
"SELECT BanCod," // row[0]
|
||||||
"ShortName," // row[2]
|
"Hidden," // row[1]
|
||||||
"FullName," // row[3]
|
"ShortName," // row[2]
|
||||||
"Img," // row[4]
|
"FullName," // row[3]
|
||||||
"WWW" // row[5]
|
"Img," // row[4]
|
||||||
" FROM ban_banners"
|
"WWW" // row[5]
|
||||||
" WHERE Hidden='N'"
|
" FROM ban_banners"
|
||||||
" ORDER BY ShortName");
|
" WHERE Hidden='N'"
|
||||||
Ban_GetListBanners (&Banners,&mysql_res,NumRows);
|
" ORDER BY ShortName");
|
||||||
|
Ban_GetListBanners (&Banners,&mysql_res,NumBanners);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (NULL,Txt_Banners,
|
Box_BoxBegin (NULL,Txt_Banners,
|
||||||
|
@ -258,19 +259,20 @@ static void Ban_EditBannersInternal (struct Ban_Banners *Banners,
|
||||||
extern const char *Hlp_SYSTEM_Banners_edit;
|
extern const char *Hlp_SYSTEM_Banners_edit;
|
||||||
extern const char *Txt_Banners;
|
extern const char *Txt_Banners;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumBanners;
|
||||||
|
|
||||||
/***** Get list of banners *****/
|
/***** Get list of banners *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get banners",
|
NumBanners = (unsigned)
|
||||||
"SELECT BanCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get banners",
|
||||||
"Hidden," // row[1]
|
"SELECT BanCod," // row[0]
|
||||||
"ShortName," // row[2]
|
"Hidden," // row[1]
|
||||||
"FullName," // row[3]
|
"ShortName," // row[2]
|
||||||
"Img," // row[4]
|
"FullName," // row[3]
|
||||||
"WWW" // row[5]
|
"Img," // row[4]
|
||||||
" FROM ban_banners"
|
"WWW" // row[5]
|
||||||
" ORDER BY ShortName");
|
" FROM ban_banners"
|
||||||
Ban_GetListBanners (Banners,&mysql_res,NumRows);
|
" ORDER BY ShortName");
|
||||||
|
Ban_GetListBanners (Banners,&mysql_res,NumBanners);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (NULL,Txt_Banners,
|
Box_BoxBegin (NULL,Txt_Banners,
|
||||||
|
@ -296,19 +298,19 @@ static void Ban_EditBannersInternal (struct Ban_Banners *Banners,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
||||||
MYSQL_RES **mysql_res,unsigned long NumRows)
|
MYSQL_RES **mysql_res,unsigned NumBanners)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumBan;
|
unsigned NumBan;
|
||||||
struct Ban_Banner *Ban;
|
struct Ban_Banner *Ban;
|
||||||
|
|
||||||
/***** Get banners from database *****/
|
/***** Get banners from database *****/
|
||||||
if (NumRows) // Banners found...
|
Banners->Num = NumBanners;
|
||||||
|
if (Banners->Num) // Banners found...
|
||||||
{
|
{
|
||||||
Banners->Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with banners *****/
|
/***** Create list with banners *****/
|
||||||
if ((Banners->Lst = calloc (NumRows,sizeof (*Banners->Lst))) == NULL)
|
if ((Banners->Lst = calloc ((size_t) Banners->Num,sizeof (*Banners->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the banners *****/
|
/***** Get the banners *****/
|
||||||
|
@ -336,8 +338,6 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
||||||
Str_Copy (Ban->WWW ,row[5],sizeof (Ban->WWW ) - 1);
|
Str_Copy (Ban->WWW ,row[5],sizeof (Ban->WWW ) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Banners->Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (mysql_res);
|
DB_FreeMySQLResult (mysql_res);
|
||||||
|
@ -351,7 +351,6 @@ void Ban_GetDataOfBannerByCod (struct Ban_Banner *Ban)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
Ban->Hidden = false;
|
Ban->Hidden = false;
|
||||||
|
@ -361,16 +360,15 @@ void Ban_GetDataOfBannerByCod (struct Ban_Banner *Ban)
|
||||||
if (Ban->BanCod > 0)
|
if (Ban->BanCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a banner from database *****/
|
/***** Get data of a banner from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a banner",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a banner",
|
||||||
"SELECT Hidden," // row[0]
|
"SELECT Hidden," // row[0]
|
||||||
"ShortName," // row[1]
|
"ShortName," // row[1]
|
||||||
"FullName," // row[2]
|
"FullName," // row[2]
|
||||||
"Img," // row[3]
|
"Img," // row[3]
|
||||||
"WWW" // row[4]
|
"WWW" // row[4]
|
||||||
" FROM ban_banners"
|
" FROM ban_banners"
|
||||||
" WHERE BanCod=%ld",
|
" WHERE BanCod=%ld",
|
||||||
Ban->BanCod);
|
Ban->BanCod)) // Banner found...
|
||||||
if (NumRows) // Banner found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1103,7 +1101,7 @@ void Ban_WriteMenuWithBanners (void)
|
||||||
{
|
{
|
||||||
struct Ban_Banners Banners;
|
struct Ban_Banners Banners;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumBanners;
|
||||||
unsigned NumBan;
|
unsigned NumBan;
|
||||||
|
|
||||||
/***** Reset banners *****/
|
/***** Reset banners *****/
|
||||||
|
@ -1111,21 +1109,22 @@ void Ban_WriteMenuWithBanners (void)
|
||||||
|
|
||||||
/***** Get random banner *****/
|
/***** Get random banner *****/
|
||||||
// The banner(s) will change once in a while
|
// The banner(s) will change once in a while
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get banners",
|
NumBanners = (unsigned)
|
||||||
"SELECT BanCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get banners",
|
||||||
"Hidden," // row[1]
|
"SELECT BanCod," // row[0]
|
||||||
"ShortName," // row[2]
|
"Hidden," // row[1]
|
||||||
"FullName," // row[3]
|
"ShortName," // row[2]
|
||||||
"Img," // row[4]
|
"FullName," // row[3]
|
||||||
"WWW" // row[5]
|
"Img," // row[4]
|
||||||
" FROM ban_banners"
|
"WWW" // row[5]
|
||||||
" WHERE Hidden='N'"
|
" FROM ban_banners"
|
||||||
" ORDER BY RAND(%lu)"
|
" WHERE Hidden='N'"
|
||||||
" LIMIT %u",
|
" ORDER BY RAND(%lu)"
|
||||||
(unsigned long) (Gbl.StartExecutionTimeUTC /
|
" LIMIT %u",
|
||||||
Cfg_TIME_TO_CHANGE_BANNER),
|
(unsigned long) (Gbl.StartExecutionTimeUTC /
|
||||||
Cfg_NUMBER_OF_BANNERS);
|
Cfg_TIME_TO_CHANGE_BANNER),
|
||||||
Ban_GetListBanners (&Banners,&mysql_res,NumRows);
|
Cfg_NUMBER_OF_BANNERS);
|
||||||
|
Ban_GetListBanners (&Banners,&mysql_res,NumBanners);
|
||||||
|
|
||||||
/***** Write all the banners *****/
|
/***** Write all the banners *****/
|
||||||
for (NumBan = 0;
|
for (NumBan = 0;
|
||||||
|
|
|
@ -318,7 +318,6 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumBuilding;
|
unsigned NumBuilding;
|
||||||
struct Bld_Building *Building;
|
struct Bld_Building *Building;
|
||||||
|
|
||||||
|
@ -326,36 +325,36 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
||||||
switch (WhichData)
|
switch (WhichData)
|
||||||
{
|
{
|
||||||
case Bld_ALL_DATA:
|
case Bld_ALL_DATA:
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings",
|
Buildings->Num = (unsigned)
|
||||||
"SELECT BldCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get buildings",
|
||||||
"ShortName," // row[1]
|
"SELECT BldCod," // row[0]
|
||||||
"FullName," // row[2]
|
"ShortName," // row[1]
|
||||||
"Location" // row[3]
|
"FullName," // row[2]
|
||||||
" FROM bld_buildings"
|
"Location" // row[3]
|
||||||
" WHERE CtrCod=%ld"
|
" FROM bld_buildings"
|
||||||
" ORDER BY %s",
|
" WHERE CtrCod=%ld"
|
||||||
Gbl.Hierarchy.Ctr.CtrCod,
|
" ORDER BY %s",
|
||||||
OrderBySubQuery[Buildings->SelectedOrder]);
|
Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
|
OrderBySubQuery[Buildings->SelectedOrder]);
|
||||||
break;
|
break;
|
||||||
case Bld_ONLY_SHRT_NAME:
|
case Bld_ONLY_SHRT_NAME:
|
||||||
default:
|
default:
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings",
|
Buildings->Num = (unsigned)
|
||||||
"SELECT BldCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get buildings",
|
||||||
"ShortName" // row[1]
|
"SELECT BldCod," // row[0]
|
||||||
" FROM bld_buildings"
|
"ShortName" // row[1]
|
||||||
" WHERE CtrCod=%ld"
|
" FROM bld_buildings"
|
||||||
" ORDER BY ShortName",
|
" WHERE CtrCod=%ld"
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
" ORDER BY ShortName",
|
||||||
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Buildings found...
|
if (Buildings->Num) // Buildings found...
|
||||||
{
|
{
|
||||||
Buildings->Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with courses in center *****/
|
/***** Create list with courses in center *****/
|
||||||
if ((Buildings->Lst = calloc (NumRows,sizeof (*Buildings->Lst))) == NULL)
|
if ((Buildings->Lst = calloc ((size_t) Buildings->Num,sizeof (*Buildings->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the buildings *****/
|
/***** Get the buildings *****/
|
||||||
|
@ -383,8 +382,6 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Buildings->Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -398,7 +395,6 @@ void Bld_GetDataOfBuildingByCod (struct Bld_Building *Building)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
Building->ShrtName[0] = '\0';
|
Building->ShrtName[0] = '\0';
|
||||||
|
@ -409,16 +405,13 @@ void Bld_GetDataOfBuildingByCod (struct Bld_Building *Building)
|
||||||
if (Building->BldCod > 0)
|
if (Building->BldCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a building from database *****/
|
/***** Get data of a building from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a building",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a building",
|
||||||
"SELECT ShortName," // row[0]
|
"SELECT ShortName," // row[0]
|
||||||
"FullName," // row[1]
|
"FullName," // row[1]
|
||||||
"Location" // row[2]
|
"Location" // row[2]
|
||||||
" FROM bld_buildings"
|
" FROM bld_buildings"
|
||||||
" WHERE BldCod=%ld",
|
" WHERE BldCod=%ld",
|
||||||
Building->BldCod);
|
Building->BldCod)) // Building found...
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
|
||||||
if (NumRows) // Building found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -683,8 +683,8 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
|
||||||
extern const char *Txt_No_calls_for_exams_of_X;
|
extern const char *Txt_No_calls_for_exams_of_X;
|
||||||
char SubQueryStatus[64];
|
char SubQueryStatus[64];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumExaAnn;
|
unsigned NumExaAnns;
|
||||||
unsigned long NumExaAnns;
|
unsigned NumExaAnn;
|
||||||
long ExaCod;
|
long ExaCod;
|
||||||
bool HighLight;
|
bool HighLight;
|
||||||
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
||||||
|
@ -700,14 +700,16 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
|
||||||
|
|
||||||
/***** Get calls for exams (the most recent first)
|
/***** Get calls for exams (the most recent first)
|
||||||
in current course from database *****/
|
in current course from database *****/
|
||||||
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get calls for exams"
|
NumExaAnns = (unsigned)
|
||||||
" in this course for listing",
|
DB_QuerySELECT (&mysql_res,"can not get calls for exams"
|
||||||
"SELECT ExaCod" // row[0]
|
" in this course for listing",
|
||||||
" FROM cfe_exams"
|
"SELECT ExaCod" // row[0]
|
||||||
" WHERE CrsCod=%ld"
|
" FROM cfe_exams"
|
||||||
" AND %s"
|
" WHERE CrsCod=%ld"
|
||||||
" ORDER BY ExamDate DESC",
|
" AND %s"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,SubQueryStatus);
|
" ORDER BY ExamDate DESC",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
SubQueryStatus);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
if (ICanEdit)
|
if (ICanEdit)
|
||||||
|
@ -887,24 +889,24 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumExaAnn;
|
unsigned NumExaAnns;
|
||||||
unsigned long NumExaAnns;
|
unsigned NumExaAnn;
|
||||||
|
|
||||||
if (Gbl.DB.DatabaseIsOpen)
|
if (Gbl.DB.DatabaseIsOpen)
|
||||||
{
|
{
|
||||||
/***** Get exam dates (ordered from more recent to older)
|
/***** Get exam dates (ordered from more recent to older)
|
||||||
of visible calls for exams
|
of visible calls for exams
|
||||||
in current course from database *****/
|
in current course from database *****/
|
||||||
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get calls for exams"
|
NumExaAnns = (unsigned)
|
||||||
" in this course",
|
DB_QuerySELECT (&mysql_res,"can not get calls for exams in this course",
|
||||||
"SELECT ExaCod," // row[0]
|
"SELECT ExaCod," // row[0]
|
||||||
"DATE(ExamDate)" // row[1]
|
"DATE(ExamDate)" // row[1]
|
||||||
" FROM cfe_exams"
|
" FROM cfe_exams"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND Status=%u"
|
" AND Status=%u"
|
||||||
" ORDER BY ExamDate DESC",
|
" ORDER BY ExamDate DESC",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
||||||
|
|
||||||
/***** The result of the query may be empty *****/
|
/***** The result of the query may be empty *****/
|
||||||
CallsForExams->Lst = NULL;
|
CallsForExams->Lst = NULL;
|
||||||
|
@ -966,36 +968,31 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumExaAnns;
|
|
||||||
unsigned UnsignedNum;
|
unsigned UnsignedNum;
|
||||||
unsigned Hour;
|
unsigned Hour;
|
||||||
unsigned Minute;
|
unsigned Minute;
|
||||||
unsigned Second;
|
unsigned Second;
|
||||||
|
|
||||||
/***** Get data of a call for exam from database *****/
|
/***** Get data of a call for exam from database *****/
|
||||||
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get data"
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a call for exam",
|
||||||
" of a call for exam",
|
"SELECT CrsCod," // row[ 0]
|
||||||
"SELECT CrsCod," // row[ 0]
|
"Status," // row[ 1]
|
||||||
"Status," // row[ 1]
|
"CrsFullName," // row[ 2]
|
||||||
"CrsFullName," // row[ 2]
|
"Year," // row[ 3]
|
||||||
"Year," // row[ 3]
|
"ExamSession," // row[ 4]
|
||||||
"ExamSession," // row[ 4]
|
"CallDate," // row[ 5]
|
||||||
"CallDate," // row[ 5]
|
"ExamDate," // row[ 6]
|
||||||
"ExamDate," // row[ 6]
|
"Duration," // row[ 7]
|
||||||
"Duration," // row[ 7]
|
"Place," // row[ 8]
|
||||||
"Place," // row[ 8]
|
"ExamMode," // row[ 9]
|
||||||
"ExamMode," // row[ 9]
|
"Structure," // row[10]
|
||||||
"Structure," // row[10]
|
"DocRequired," // row[11]
|
||||||
"DocRequired," // row[11]
|
"MatRequired," // row[12]
|
||||||
"MatRequired," // row[12]
|
"MatAllowed," // row[13]
|
||||||
"MatAllowed," // row[13]
|
"OtherInfo" // row[14]
|
||||||
"OtherInfo" // row[14]
|
" FROM cfe_exams"
|
||||||
" FROM cfe_exams"
|
" WHERE ExaCod=%ld",
|
||||||
" WHERE ExaCod=%ld",
|
ExaCod) != 1)
|
||||||
ExaCod);
|
|
||||||
|
|
||||||
/***** The result of the query must have one row *****/
|
|
||||||
if (NumExaAnns != 1)
|
|
||||||
Lay_WrongCallForExamExit ();
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Get the data of the call for exam *****/
|
/***** Get the data of the call for exam *****/
|
||||||
|
|
164
swad_center.c
164
swad_center.c
|
@ -550,35 +550,32 @@ void Ctr_GetBasicListOfCenters (long InsCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumCtr;
|
unsigned NumCtr;
|
||||||
struct Ctr_Center *Ctr;
|
struct Ctr_Center *Ctr;
|
||||||
|
|
||||||
/***** Get centers from database *****/
|
/***** Get centers from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get centers",
|
Gbl.Hierarchy.Ctrs.Num = (unsigned)
|
||||||
"SELECT CtrCod," // row[ 0]
|
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||||
"InsCod," // row[ 1]
|
"SELECT CtrCod," // row[ 0]
|
||||||
"PlcCod," // row[ 2]
|
"InsCod," // row[ 1]
|
||||||
"Status," // row[ 3]
|
"PlcCod," // row[ 2]
|
||||||
"RequesterUsrCod," // row[ 4]
|
"Status," // row[ 3]
|
||||||
"Latitude," // row[ 5]
|
"RequesterUsrCod," // row[ 4]
|
||||||
"Longitude," // row[ 6]
|
"Latitude," // row[ 5]
|
||||||
"Altitude," // row[ 7]
|
"Longitude," // row[ 6]
|
||||||
"ShortName," // row[ 8]
|
"Altitude," // row[ 7]
|
||||||
"FullName," // row[ 9]
|
"ShortName," // row[ 8]
|
||||||
"WWW" // row[10]
|
"FullName," // row[ 9]
|
||||||
" FROM ctr_centers"
|
"WWW" // row[10]
|
||||||
" WHERE InsCod=%ld"
|
" FROM ctr_centers"
|
||||||
" ORDER BY FullName",
|
" WHERE InsCod=%ld"
|
||||||
InsCod);
|
" ORDER BY FullName",
|
||||||
|
InsCod);
|
||||||
|
|
||||||
if (NumRows) // Centers found...
|
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to Deg->NumCourses
|
|
||||||
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -597,8 +594,6 @@ void Ctr_GetBasicListOfCenters (long InsCod)
|
||||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Hierarchy.Ctrs.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -618,58 +613,55 @@ void Ctr_GetFullListOfCenters (long InsCod)
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumCtr;
|
unsigned NumCtr;
|
||||||
struct Ctr_Center *Ctr;
|
struct Ctr_Center *Ctr;
|
||||||
|
|
||||||
/***** Get centers from database *****/
|
/***** Get centers from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get centers",
|
Gbl.Hierarchy.Ctrs.Num = (unsigned)
|
||||||
"(SELECT ctr_centers.CtrCod," // row[ 0]
|
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||||
"ctr_centers.InsCod," // row[ 1]
|
"(SELECT ctr_centers.CtrCod," // row[ 0]
|
||||||
"ctr_centers.PlcCod," // row[ 2]
|
"ctr_centers.InsCod," // row[ 1]
|
||||||
"ctr_centers.Status," // row[ 3]
|
"ctr_centers.PlcCod," // row[ 2]
|
||||||
"ctr_centers.RequesterUsrCod," // row[ 4]
|
"ctr_centers.Status," // row[ 3]
|
||||||
"ctr_centers.Latitude," // row[ 5]
|
"ctr_centers.RequesterUsrCod," // row[ 4]
|
||||||
"ctr_centers.Longitude," // row[ 6]
|
"ctr_centers.Latitude," // row[ 5]
|
||||||
"ctr_centers.Altitude," // row[ 7]
|
"ctr_centers.Longitude," // row[ 6]
|
||||||
"ctr_centers.ShortName," // row[ 8]
|
"ctr_centers.Altitude," // row[ 7]
|
||||||
"ctr_centers.FullName," // row[ 9]
|
"ctr_centers.ShortName," // row[ 8]
|
||||||
"ctr_centers.WWW," // row[10]
|
"ctr_centers.FullName," // row[ 9]
|
||||||
"COUNT(*) AS NumUsrs" // row[11]
|
"ctr_centers.WWW," // row[10]
|
||||||
" FROM ctr_centers,usr_data"
|
"COUNT(*) AS NumUsrs" // row[11]
|
||||||
" WHERE ctr_centers.InsCod=%ld"
|
" FROM ctr_centers,usr_data"
|
||||||
" AND ctr_centers.CtrCod=usr_data.CtrCod"
|
" WHERE ctr_centers.InsCod=%ld"
|
||||||
" GROUP BY ctr_centers.CtrCod)"
|
" AND ctr_centers.CtrCod=usr_data.CtrCod"
|
||||||
" UNION "
|
" GROUP BY ctr_centers.CtrCod)"
|
||||||
"(SELECT CtrCod," // row[ 0]
|
" UNION "
|
||||||
"InsCod," // row[ 1]
|
"(SELECT CtrCod," // row[ 0]
|
||||||
"PlcCod," // row[ 2]
|
"InsCod," // row[ 1]
|
||||||
"Status," // row[ 3]
|
"PlcCod," // row[ 2]
|
||||||
"RequesterUsrCod," // row[ 4]
|
"Status," // row[ 3]
|
||||||
"Latitude," // row[ 5]
|
"RequesterUsrCod," // row[ 4]
|
||||||
"Longitude," // row[ 6]
|
"Latitude," // row[ 5]
|
||||||
"Altitude," // row[ 7]
|
"Longitude," // row[ 6]
|
||||||
"ShortName," // row[ 8]
|
"Altitude," // row[ 7]
|
||||||
"FullName," // row[ 9]
|
"ShortName," // row[ 8]
|
||||||
"WWW," // row[10]
|
"FullName," // row[ 9]
|
||||||
"0 AS NumUsrs" // row[11]
|
"WWW," // row[10]
|
||||||
" FROM ctr_centers"
|
"0 AS NumUsrs" // row[11]
|
||||||
" WHERE InsCod=%ld"
|
" FROM ctr_centers"
|
||||||
" AND CtrCod NOT IN"
|
" WHERE InsCod=%ld"
|
||||||
" (SELECT DISTINCT CtrCod"
|
" AND CtrCod NOT IN"
|
||||||
" FROM usr_data))"
|
" (SELECT DISTINCT CtrCod"
|
||||||
" ORDER BY %s",
|
" FROM usr_data))"
|
||||||
InsCod,
|
" ORDER BY %s",
|
||||||
InsCod,
|
InsCod,
|
||||||
OrderBySubQuery[Gbl.Hierarchy.Ctrs.SelectedOrder]);
|
InsCod,
|
||||||
|
OrderBySubQuery[Gbl.Hierarchy.Ctrs.SelectedOrder]);
|
||||||
|
|
||||||
if (NumRows) // Centers found...
|
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to Deg->NumCourses
|
|
||||||
Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.Hierarchy.Ctrs.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -690,8 +682,6 @@ void Ctr_GetFullListOfCenters (long InsCod)
|
||||||
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = true;
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Hierarchy.Ctrs.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -705,7 +695,6 @@ bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
bool CtrFound = false;
|
bool CtrFound = false;
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
|
@ -722,22 +711,21 @@ bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr)
|
||||||
if (Ctr->CtrCod > 0)
|
if (Ctr->CtrCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a center from database *****/
|
/***** Get data of a center from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a center",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a center",
|
||||||
"SELECT CtrCod," // row[ 0]
|
"SELECT CtrCod," // row[ 0]
|
||||||
"InsCod," // row[ 1]
|
"InsCod," // row[ 1]
|
||||||
"PlcCod," // row[ 2]
|
"PlcCod," // row[ 2]
|
||||||
"Status," // row[ 3]
|
"Status," // row[ 3]
|
||||||
"RequesterUsrCod," // row[ 4]
|
"RequesterUsrCod," // row[ 4]
|
||||||
"Latitude," // row[ 5]
|
"Latitude," // row[ 5]
|
||||||
"Longitude," // row[ 6]
|
"Longitude," // row[ 6]
|
||||||
"Altitude," // row[ 7]
|
"Altitude," // row[ 7]
|
||||||
"ShortName," // row[ 8]
|
"ShortName," // row[ 8]
|
||||||
"FullName," // row[ 9]
|
"FullName," // row[ 9]
|
||||||
"WWW" // row[10]
|
"WWW" // row[10]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE CtrCod=%ld",
|
" WHERE CtrCod=%ld",
|
||||||
Ctr->CtrCod);
|
Ctr->CtrCod)) // Center found...
|
||||||
if (NumRows) // Center found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -600,13 +600,14 @@ TODO: Salvador Romero Cort
|
||||||
|
|
||||||
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.62 (2021-04-15)"
|
#define Log_PLATFORM_VERSION "SWAD 20.63 (2021-04-16)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 20.63: Apr 16, 2021 Optimizations in database selects. (308487 lines)
|
||||||
Version 20.62: Apr 15, 2021 Optimizations in database selects related to roles. (308574 lines)
|
Version 20.62: Apr 15, 2021 Optimizations in database selects related to roles. (308574 lines)
|
||||||
Version 20.61: Apr 13, 2021 Optimizations in database selects. (308567 lines)
|
Version 20.61: Apr 13, 2021 Optimizations in database selects. (308567 lines)
|
||||||
Version 20.60: Apr 07, 2021 Optimizations in database selects. (308790 lines)
|
Version 20.60: Apr 07, 2021 Optimizations in database selects. (308790 lines)
|
||||||
|
|
80
swad_chat.c
80
swad_chat.c
|
@ -114,8 +114,8 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
struct Crs_Course Crs;
|
struct Crs_Course Crs;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumCrss;
|
||||||
unsigned long NumRows;
|
unsigned NumCrs;
|
||||||
char ThisRoomCode [Cht_MAX_BYTES_ROOM_CODE + 1];
|
char ThisRoomCode [Cht_MAX_BYTES_ROOM_CODE + 1];
|
||||||
char ThisRoomShrtName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
|
char ThisRoomShrtName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
|
||||||
char ThisRoomFullName[Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
|
char ThisRoomFullName[Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
|
||||||
|
@ -190,33 +190,33 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
||||||
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
||||||
|
|
||||||
/* Get my courses in this degree from database */
|
/* Get my courses in this degree from database */
|
||||||
if ((NumRows = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Deg.DegCod,&mysql_res)) > 0) // Courses found in this degree
|
NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Deg.DegCod,&mysql_res);
|
||||||
for (NumRow = 0;
|
for (NumCrs = 0;
|
||||||
NumRow < NumRows;
|
NumCrs < NumCrss;
|
||||||
NumRow++)
|
NumCrs++)
|
||||||
|
{
|
||||||
|
/* Get next course */
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
/* Get course code */
|
||||||
|
if ((Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
||||||
{
|
{
|
||||||
/* Get next course */
|
/* Get data of this course */
|
||||||
row = mysql_fetch_row (mysql_res);
|
Crs_GetDataOfCourseByCod (&Crs);
|
||||||
|
|
||||||
/* Get course code */
|
/* Link to the room of this course */
|
||||||
if ((Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
IsLastItemInLevel[2] = (NumCrs == NumCrss - 1);
|
||||||
{
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
||||||
/* Get data of this course */
|
Crs.CrsCod);
|
||||||
Crs_GetDataOfCourseByCod (&Crs);
|
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
||||||
|
Crs.ShrtName);
|
||||||
/* Link to the room of this course */
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
||||||
IsLastItemInLevel[2] = (NumRow == NumRows - 1);
|
Txt_Course,Crs.ShrtName);
|
||||||
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,2,IsLastItemInLevel);
|
||||||
Crs.CrsCod);
|
Ico_PutIcon ("chalkboard-teacher.svg",ThisRoomFullName,"ICO16x16");
|
||||||
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
||||||
Crs.ShrtName);
|
|
||||||
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
|
||||||
Txt_Course,Crs.ShrtName);
|
|
||||||
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,2,IsLastItemInLevel);
|
|
||||||
Ico_PutIcon ("chalkboard-teacher.svg",ThisRoomFullName,"ICO16x16");
|
|
||||||
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -238,19 +238,19 @@ void Cht_ShowListOfChatRoomsWithUsrs (void)
|
||||||
extern const char *Txt_Number_of_users;
|
extern const char *Txt_Number_of_users;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRooms;
|
||||||
unsigned long NumRow;
|
unsigned NumRoom;
|
||||||
|
|
||||||
/***** Get chat rooms with connected users from database *****/
|
/***** Get chat rooms with connected users from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get chat rooms"
|
NumRooms = (unsigned)
|
||||||
" with connected users",
|
DB_QuerySELECT (&mysql_res,"can not get chat rooms with connected users",
|
||||||
"SELECT RoomCode," // row[0]
|
"SELECT RoomCode," // row[0]
|
||||||
"NumUsrs" // row[1]
|
"NumUsrs" // row[1]
|
||||||
" FROM cht_rooms"
|
" FROM cht_rooms"
|
||||||
" WHERE NumUsrs>0"
|
" WHERE NumUsrs>0"
|
||||||
" ORDER BY NumUsrs DESC,"
|
" ORDER BY NumUsrs DESC,"
|
||||||
"RoomCode");
|
"RoomCode");
|
||||||
if (NumRows > 0) // If not empty chat rooms found
|
if (NumRooms) // If not empty chat rooms found
|
||||||
{
|
{
|
||||||
/***** Begin box and table *****/
|
/***** Begin box and table *****/
|
||||||
Box_BoxTableBegin (NULL,Txt_Rooms_with_users,
|
Box_BoxTableBegin (NULL,Txt_Rooms_with_users,
|
||||||
|
@ -266,9 +266,9 @@ void Cht_ShowListOfChatRoomsWithUsrs (void)
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
||||||
/***** Loop over chat rooms *****/
|
/***** Loop over chat rooms *****/
|
||||||
for (NumRow = 0;
|
for (NumRoom = 0;
|
||||||
NumRow < NumRows;
|
NumRoom < NumRooms;
|
||||||
NumRow++)
|
NumRoom++)
|
||||||
{
|
{
|
||||||
/* Get next chat room */
|
/* Get next chat room */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -784,25 +784,26 @@ static void Con_ComputeConnectedUsrsWithARoleCurrentCrsOneByOne (Rol_Role_t Role
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr = Gbl.Usrs.Connected.NumUsrs; // Save current number of users
|
unsigned NumUsr = Gbl.Usrs.Connected.NumUsrs; // Save current number of users
|
||||||
|
|
||||||
/***** Get connected users who belong to current course from database *****/
|
/***** Get connected users who belong to current course from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get list of connected users"
|
NumUsrs = (unsigned)
|
||||||
" who belong to this course",
|
DB_QuerySELECT (&mysql_res,"can not get list of connected users"
|
||||||
"SELECT usr_connected.UsrCod," // row[0]
|
" who belong to this course",
|
||||||
"usr_connected.LastCrsCod," // row[1]
|
"SELECT usr_connected.UsrCod," // row[0]
|
||||||
"UNIX_TIMESTAMP()-UNIX_TIMESTAMP(usr_connected.LastTime) AS Dif" // row[2]
|
"usr_connected.LastCrsCod," // row[1]
|
||||||
" FROM crs_users,"
|
"UNIX_TIMESTAMP()-UNIX_TIMESTAMP(usr_connected.LastTime) AS Dif" // row[2]
|
||||||
"usr_connected"
|
" FROM crs_users,"
|
||||||
" WHERE crs_users.CrsCod=%ld"
|
"usr_connected"
|
||||||
" AND crs_users.Role=%u"
|
" WHERE crs_users.CrsCod=%ld"
|
||||||
" AND crs_users.UsrCod=usr_connected.UsrCod"
|
" AND crs_users.Role=%u"
|
||||||
" ORDER BY Dif",
|
" AND crs_users.UsrCod=usr_connected.UsrCod"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY Dif",
|
||||||
(unsigned) Role);
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Gbl.Usrs.Connected.NumUsrs += (unsigned) NumRows;
|
(unsigned) Role);
|
||||||
Gbl.Usrs.Connected.NumUsrsToList += (unsigned) NumRows;
|
Gbl.Usrs.Connected.NumUsrs += NumUsrs;
|
||||||
|
Gbl.Usrs.Connected.NumUsrsToList += NumUsrs;
|
||||||
if (Gbl.Usrs.Connected.NumUsrsToList > Cfg_MAX_CONNECTED_SHOWN)
|
if (Gbl.Usrs.Connected.NumUsrsToList > Cfg_MAX_CONNECTED_SHOWN)
|
||||||
Gbl.Usrs.Connected.NumUsrsToList = Cfg_MAX_CONNECTED_SHOWN;
|
Gbl.Usrs.Connected.NumUsrsToList = Cfg_MAX_CONNECTED_SHOWN;
|
||||||
|
|
||||||
|
|
|
@ -753,26 +753,24 @@ void Cty_GetBasicListOfCountries (void)
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0;
|
|
||||||
unsigned NumCty;
|
unsigned NumCty;
|
||||||
struct Cty_Countr *Cty;
|
struct Cty_Countr *Cty;
|
||||||
Lan_Language_t Lan;
|
Lan_Language_t Lan;
|
||||||
|
|
||||||
/***** Get countries from database *****/
|
/***** Get countries from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get countries",
|
Gbl.Hierarchy.Ctys.Num = (unsigned)
|
||||||
"SELECT CtyCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||||
"Alpha2," // row[1]
|
"SELECT CtyCod," // row[0]
|
||||||
"Name_%s" // row[2]
|
"Alpha2," // row[1]
|
||||||
" FROM cty_countrs"
|
"Name_%s" // row[2]
|
||||||
" ORDER BY Name_%s",
|
" FROM cty_countrs"
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
" ORDER BY Name_%s",
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||||
if (NumRows) // Countries found...
|
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||||
|
if (Gbl.Hierarchy.Ctys.Num) // Countries found...
|
||||||
{
|
{
|
||||||
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with countries *****/
|
/***** Create list with countries *****/
|
||||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -809,8 +807,6 @@ void Cty_GetBasicListOfCountries (void)
|
||||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
Cty->NumUsrsWhoClaimToBelongToCty.Valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Hierarchy.Ctys.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -839,7 +835,6 @@ void Cty_GetFullListOfCountries (void)
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0;
|
|
||||||
unsigned NumCty;
|
unsigned NumCty;
|
||||||
struct Cty_Countr *Cty;
|
struct Cty_Countr *Cty;
|
||||||
Lan_Language_t Lan;
|
Lan_Language_t Lan;
|
||||||
|
@ -870,39 +865,38 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/* Query database */
|
/* Query database */
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get countries",
|
Gbl.Hierarchy.Ctys.Num = (unsigned)
|
||||||
"(SELECT cty_countrs.CtyCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||||
"cty_countrs.Alpha2," // row[1]
|
"(SELECT cty_countrs.CtyCod," // row[0]
|
||||||
"%s" // row[...]
|
"cty_countrs.Alpha2," // row[1]
|
||||||
"%s" // row[...]
|
"%s" // row[...]
|
||||||
"COUNT(*) AS NumUsrs" // row[...]
|
"%s" // row[...]
|
||||||
" FROM cty_countrs,"
|
"COUNT(*) AS NumUsrs" // row[...]
|
||||||
"usr_data"
|
" FROM cty_countrs,"
|
||||||
" WHERE cty_countrs.CtyCod=usr_data.CtyCod"
|
"usr_data"
|
||||||
" GROUP BY cty_countrs.CtyCod)"
|
" WHERE cty_countrs.CtyCod=usr_data.CtyCod"
|
||||||
" UNION "
|
" GROUP BY cty_countrs.CtyCod)"
|
||||||
"(SELECT CtyCod," // row[0]
|
" UNION "
|
||||||
"Alpha2," // row[1]
|
"(SELECT CtyCod," // row[0]
|
||||||
"%s" // row[...]
|
"Alpha2," // row[1]
|
||||||
"%s" // row[...]
|
"%s" // row[...]
|
||||||
"0 AS NumUsrs" // row[...]
|
"%s" // row[...]
|
||||||
" FROM cty_countrs"
|
"0 AS NumUsrs" // row[...]
|
||||||
" WHERE CtyCod NOT IN"
|
" FROM cty_countrs"
|
||||||
" (SELECT DISTINCT CtyCod"
|
" WHERE CtyCod NOT IN"
|
||||||
" FROM usr_data))"
|
" (SELECT DISTINCT CtyCod"
|
||||||
" ORDER BY %s",
|
" FROM usr_data))"
|
||||||
SubQueryNam1,SubQueryWWW1,
|
" ORDER BY %s",
|
||||||
SubQueryNam2,SubQueryWWW2,OrderBySubQuery);
|
SubQueryNam1,SubQueryWWW1,
|
||||||
|
SubQueryNam2,SubQueryWWW2,OrderBySubQuery);
|
||||||
|
|
||||||
/* Free memory for subquery */
|
/* Free memory for subquery */
|
||||||
free (OrderBySubQuery);
|
free (OrderBySubQuery);
|
||||||
|
|
||||||
if (NumRows) // Countries found...
|
if (Gbl.Hierarchy.Ctys.Num) // Countries found...
|
||||||
{
|
{
|
||||||
Gbl.Hierarchy.Ctys.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with countries *****/
|
/***** Create list with countries *****/
|
||||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -941,8 +935,6 @@ void Cty_GetFullListOfCountries (void)
|
||||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
|
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Hierarchy.Ctys.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1045,7 +1037,6 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0;
|
|
||||||
Lan_Language_t Lan;
|
Lan_Language_t Lan;
|
||||||
bool CtyFound;
|
bool CtyFound;
|
||||||
|
|
||||||
|
@ -1079,7 +1070,7 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
||||||
// Here Cty->CtyCod > 0
|
// Here Cty->CtyCod > 0
|
||||||
|
|
||||||
/***** Get data of a country from database *****/
|
/***** Get data of a country from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a country",
|
if(DB_QuerySELECT (&mysql_res,"can not get data of a country",
|
||||||
"SELECT Alpha2," // row[0]
|
"SELECT Alpha2," // row[0]
|
||||||
"Name_%s," // row[1]
|
"Name_%s," // row[1]
|
||||||
"WWW_%s" // row[2]
|
"WWW_%s" // row[2]
|
||||||
|
@ -1087,10 +1078,7 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
||||||
" WHERE CtyCod='%03ld'",
|
" WHERE CtyCod='%03ld'",
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||||
Cty->CtyCod);
|
Cty->CtyCod)) // Country found...
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
|
||||||
if (NumRows) // Country found...
|
|
||||||
{
|
{
|
||||||
CtyFound = true;
|
CtyFound = true;
|
||||||
|
|
||||||
|
|
|
@ -237,8 +237,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
HTM_LI_End ();
|
HTM_LI_End ();
|
||||||
|
|
||||||
/***** Get my institutions in this country *****/
|
/***** Get my institutions in this country *****/
|
||||||
NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
NumInss = Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie.Cty.CtyCod,&mysql_resIns);
|
Hie.Cty.CtyCod,&mysql_resIns);
|
||||||
for (NumIns = 0;
|
for (NumIns = 0;
|
||||||
NumIns < NumInss;
|
NumIns < NumInss;
|
||||||
NumIns++)
|
NumIns++)
|
||||||
|
@ -271,8 +271,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
HTM_LI_End ();
|
HTM_LI_End ();
|
||||||
|
|
||||||
/***** Get my centers in this institution *****/
|
/***** Get my centers in this institution *****/
|
||||||
NumCtrs = (unsigned) Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie.Ins.InsCod,&mysql_resCtr);
|
Hie.Ins.InsCod,&mysql_resCtr);
|
||||||
for (NumCtr = 0;
|
for (NumCtr = 0;
|
||||||
NumCtr < NumCtrs;
|
NumCtr < NumCtrs;
|
||||||
NumCtr++)
|
NumCtr++)
|
||||||
|
@ -305,8 +305,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
HTM_LI_End ();
|
HTM_LI_End ();
|
||||||
|
|
||||||
/***** Get my degrees in this center *****/
|
/***** Get my degrees in this center *****/
|
||||||
NumDegs = (unsigned) Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie.Ctr.CtrCod,&mysql_resDeg);
|
Hie.Ctr.CtrCod,&mysql_resDeg);
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
NumDeg < NumDegs;
|
NumDeg < NumDegs;
|
||||||
NumDeg++)
|
NumDeg++)
|
||||||
|
@ -339,8 +339,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
HTM_LI_End ();
|
HTM_LI_End ();
|
||||||
|
|
||||||
/***** Get my courses in this degree *****/
|
/***** Get my courses in this degree *****/
|
||||||
NumCrss = (unsigned) Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Hie.Deg.DegCod,&mysql_resCrs);
|
Hie.Deg.DegCod,&mysql_resCrs);
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < NumCrss;
|
NumCrs < NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
|
@ -2992,8 +2992,8 @@ void Crs_RemoveOldCrss (void)
|
||||||
unsigned MonthsWithoutAccess;
|
unsigned MonthsWithoutAccess;
|
||||||
unsigned long SecondsWithoutAccess;
|
unsigned long SecondsWithoutAccess;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumCrs;
|
unsigned NumCrss;
|
||||||
unsigned long NumCrss;
|
unsigned NumCrs;
|
||||||
unsigned NumCrssRemoved = 0;
|
unsigned NumCrssRemoved = 0;
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
|
|
||||||
|
@ -3008,14 +3008,15 @@ void Crs_RemoveOldCrss (void)
|
||||||
SecondsWithoutAccess = (unsigned long) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
SecondsWithoutAccess = (unsigned long) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
||||||
|
|
||||||
/***** Get old courses from database *****/
|
/***** Get old courses from database *****/
|
||||||
NumCrss = DB_QuerySELECT (&mysql_res,"can not get old courses",
|
NumCrss = (unsigned)
|
||||||
"SELECT CrsCod"
|
DB_QuerySELECT (&mysql_res,"can not get old courses",
|
||||||
" FROM crs_last"
|
"SELECT CrsCod"
|
||||||
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
" FROM crs_last"
|
||||||
" AND CrsCod NOT IN"
|
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
||||||
" (SELECT DISTINCT CrsCod"
|
" AND CrsCod NOT IN"
|
||||||
" FROM crs_users)",
|
" (SELECT DISTINCT CrsCod"
|
||||||
SecondsWithoutAccess);
|
" FROM crs_users)",
|
||||||
|
SecondsWithoutAccess);
|
||||||
if (NumCrss)
|
if (NumCrss)
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_INFO,Txt_Eliminating_X_courses_whithout_users_and_with_more_than_Y_months_without_access,
|
Ale_ShowAlert (Ale_INFO,Txt_Eliminating_X_courses_whithout_users_and_with_more_than_Y_months_without_access,
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <stddef.h> // For NULL
|
#include <stddef.h> // For NULL
|
||||||
#include <stdio.h> // For FILE, vasprintf
|
#include <stdio.h> // For FILE, vasprintf
|
||||||
#include <stdlib.h> // For free
|
#include <stdlib.h> // For free
|
||||||
|
#include <string.h> // For strlen
|
||||||
|
|
||||||
#include "swad_config.h"
|
#include "swad_config.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
@ -3954,6 +3955,8 @@ void DB_QuerySELECTString (char *Str,size_t StrSize,const char *MsgError,
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int NumBytesPrinted;
|
int NumBytesPrinted;
|
||||||
char *Query;
|
char *Query;
|
||||||
|
bool TooBig = false;
|
||||||
|
char ErrorTxt[256];
|
||||||
|
|
||||||
/***** Create query string *****/
|
/***** Create query string *****/
|
||||||
va_start (ap,fmt);
|
va_start (ap,fmt);
|
||||||
|
@ -3963,16 +3966,27 @@ void DB_QuerySELECTString (char *Str,size_t StrSize,const char *MsgError,
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Do SELECT query *****/
|
/***** Do SELECT query *****/
|
||||||
|
Str[0] = '\0';
|
||||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError) == 1) // Row found
|
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError) == 1) // Row found
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Str,row[0],StrSize);
|
|
||||||
|
TooBig = (strlen (row[0]) > StrSize);
|
||||||
|
if (!TooBig)
|
||||||
|
Str_Copy (Str,row[0],StrSize);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Str[0] = '\0';
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
if (TooBig)
|
||||||
|
{
|
||||||
|
snprintf (ErrorTxt,sizeof (ErrorTxt),
|
||||||
|
"Too large string from database,"
|
||||||
|
" it exceed the maximum allowed size (%zu bytes).",
|
||||||
|
StrSize);
|
||||||
|
Lay_ShowErrorAndExit (ErrorTxt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1125,32 +1125,30 @@ void Deg_GetListDegsInCurrentCtr (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumDeg;
|
unsigned NumDeg;
|
||||||
struct Deg_Degree *Deg;
|
struct Deg_Degree *Deg;
|
||||||
|
|
||||||
/***** Get degrees of the current center from database *****/
|
/***** Get degrees of the current center from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a center",
|
Gbl.Hierarchy.Degs.Num = (unsigned)
|
||||||
"SELECT DegCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get degrees of a center",
|
||||||
"CtrCod," // row[1]
|
"SELECT DegCod," // row[0]
|
||||||
"DegTypCod," // row[2]
|
"CtrCod," // row[1]
|
||||||
"Status," // row[3]
|
"DegTypCod," // row[2]
|
||||||
"RequesterUsrCod," // row[4]
|
"Status," // row[3]
|
||||||
"ShortName," // row[5]
|
"RequesterUsrCod," // row[4]
|
||||||
"FullName," // row[6]
|
"ShortName," // row[5]
|
||||||
"WWW" // row[7]
|
"FullName," // row[6]
|
||||||
" FROM deg_degrees"
|
"WWW" // row[7]
|
||||||
" WHERE CtrCod=%ld"
|
" FROM deg_degrees"
|
||||||
" ORDER BY FullName",
|
" WHERE CtrCod=%ld"
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
" ORDER BY FullName",
|
||||||
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (NumRows) // Degrees found...
|
if (Gbl.Hierarchy.Degs.Num) // Degrees found...
|
||||||
{
|
{
|
||||||
Gbl.Hierarchy.Degs.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with degrees of this center *****/
|
/***** Create list with degrees of this center *****/
|
||||||
if ((Gbl.Hierarchy.Degs.Lst = calloc (Gbl.Hierarchy.Degs.Num,
|
if ((Gbl.Hierarchy.Degs.Lst = calloc ((size_t) Gbl.Hierarchy.Degs.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Degs.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Degs.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -1166,8 +1164,6 @@ void Deg_GetListDegsInCurrentCtr (void)
|
||||||
Deg_GetDataOfDegreeFromRow (Deg,row);
|
Deg_GetDataOfDegreeFromRow (Deg,row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Hierarchy.Degs.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1491,22 +1487,23 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
||||||
void Deg_RemoveDegreeCompletely (long DegCod)
|
void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumCrss;
|
||||||
unsigned long NumRow;
|
unsigned NumCrs;
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
char PathDeg[PATH_MAX + 1];
|
char PathDeg[PATH_MAX + 1];
|
||||||
|
|
||||||
/***** Get courses of a degree from database *****/
|
/***** Get courses of a degree from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
NumCrss = (unsigned)
|
||||||
"SELECT CrsCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||||
" FROM crs_courses"
|
"SELECT CrsCod"
|
||||||
" WHERE DegCod=%ld",
|
" FROM crs_courses"
|
||||||
DegCod);
|
" WHERE DegCod=%ld",
|
||||||
|
DegCod);
|
||||||
|
|
||||||
/* Get courses in this degree */
|
/* Get courses in this degree */
|
||||||
for (NumRow = 0;
|
for (NumCrs = 0;
|
||||||
NumRow < NumRows;
|
NumCrs < NumCrss;
|
||||||
NumRow++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
/* Get next course */
|
/* Get next course */
|
||||||
if ((CrsCod = DB_GetNextCode (mysql_res)) < 0)
|
if ((CrsCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
|
|
|
@ -901,21 +901,22 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
|
||||||
static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumDegs;
|
||||||
unsigned long NumRow;
|
unsigned NumDeg;
|
||||||
long DegCod;
|
long DegCod;
|
||||||
|
|
||||||
/***** Get degrees of a type from database *****/
|
/***** Get degrees of a type from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a type",
|
NumDegs = (unsigned)
|
||||||
"SELECT DegCod"
|
DB_QuerySELECT (&mysql_res,"can not get degrees of a type",
|
||||||
" FROM deg_degrees"
|
"SELECT DegCod"
|
||||||
" WHERE DegTypCod=%ld",
|
" FROM deg_degrees"
|
||||||
DegTypCod);
|
" WHERE DegTypCod=%ld",
|
||||||
|
DegTypCod);
|
||||||
|
|
||||||
/* Get degrees of this type */
|
/* Get degrees of this type */
|
||||||
for (NumRow = 0;
|
for (NumDeg = 0;
|
||||||
NumRow < NumRows;
|
NumDeg < NumDegs;
|
||||||
NumRow++)
|
NumDeg++)
|
||||||
{
|
{
|
||||||
/* Get next degree */
|
/* Get next degree */
|
||||||
if ((DegCod = DB_GetNextCode (mysql_res)) < 0)
|
if ((DegCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
|
|
|
@ -423,7 +423,6 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
|
||||||
extern const char *Txt_Another_department;
|
extern const char *Txt_Another_department;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
Dpt->InsCod = -1L;
|
Dpt->InsCod = -1L;
|
||||||
|
@ -439,38 +438,36 @@ void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt)
|
||||||
else if (Dpt->DptCod > 0)
|
else if (Dpt->DptCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a department from database *****/
|
/***** Get data of a department from database *****/
|
||||||
NumRows =
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a department",
|
||||||
DB_QuerySELECT (&mysql_res,"can not get data of a department",
|
"(SELECT dpt_departments.InsCod," // row[0]
|
||||||
"(SELECT dpt_departments.InsCod," // row[0]
|
"dpt_departments.ShortName," // row[1]
|
||||||
"dpt_departments.ShortName," // row[1]
|
"dpt_departments.FullName," // row[2]
|
||||||
"dpt_departments.FullName," // row[2]
|
"dpt_departments.WWW," // row[3]
|
||||||
"dpt_departments.WWW," // row[3]
|
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" // row[4]
|
||||||
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" // row[4]
|
" FROM dpt_departments,"
|
||||||
" FROM dpt_departments,"
|
"usr_data,"
|
||||||
"usr_data,"
|
"crs_users"
|
||||||
"crs_users"
|
" WHERE dpt_departments.DptCod=%ld"
|
||||||
" WHERE dpt_departments.DptCod=%ld"
|
" AND dpt_departments.DptCod=usr_data.DptCod"
|
||||||
" AND dpt_departments.DptCod=usr_data.DptCod"
|
" AND usr_data.UsrCod=crs_users.UsrCod"
|
||||||
" AND usr_data.UsrCod=crs_users.UsrCod"
|
" AND crs_users.Role=%u"
|
||||||
" AND crs_users.Role=%u"
|
" GROUP BY dpt_departments.DptCod)"
|
||||||
" GROUP BY dpt_departments.DptCod)"
|
" UNION "
|
||||||
" UNION "
|
"(SELECT InsCod," // row[0]
|
||||||
"(SELECT InsCod," // row[0]
|
"ShortName," // row[1]
|
||||||
"ShortName," // row[1]
|
"FullName," // row[2]
|
||||||
"FullName," // row[2]
|
"WWW," // row[3]
|
||||||
"WWW," // row[3]
|
"0" // row[4]
|
||||||
"0" // row[4]
|
" FROM dpt_departments"
|
||||||
" FROM dpt_departments"
|
" WHERE DptCod=%ld"
|
||||||
" WHERE DptCod=%ld"
|
" AND DptCod NOT IN"
|
||||||
" AND DptCod NOT IN"
|
" (SELECT DISTINCT usr_data.DptCod"
|
||||||
" (SELECT DISTINCT usr_data.DptCod"
|
" FROM usr_data,"
|
||||||
" FROM usr_data,"
|
"crs_users"
|
||||||
"crs_users"
|
" WHERE crs_users.Role=%u"
|
||||||
" WHERE crs_users.Role=%u"
|
" AND crs_users.UsrCod=usr_data.UsrCod))",
|
||||||
" AND crs_users.UsrCod=usr_data.UsrCod))",
|
Dpt->DptCod,(unsigned) Rol_TCH,
|
||||||
Dpt->DptCod,(unsigned) Rol_TCH,
|
Dpt->DptCod,(unsigned) Rol_TCH)) // Department found...
|
||||||
Dpt->DptCod,(unsigned) Rol_TCH);
|
|
||||||
if (NumRows) // Department found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -274,34 +274,36 @@ static void Dup_ListSimilarUsrs (void)
|
||||||
/***** Make query *****/
|
/***** Make query *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
|
if (Gbl.Usrs.Other.UsrDat.Surname1[0] &&
|
||||||
Gbl.Usrs.Other.UsrDat.FrstName[0]) // Name and surname 1 not empty
|
Gbl.Usrs.Other.UsrDat.FrstName[0]) // Name and surname 1 not empty
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
NumUsrs = (unsigned)
|
||||||
"SELECT DISTINCT UsrCod"
|
DB_QuerySELECT (&mysql_res,"can not get similar users",
|
||||||
" FROM (SELECT DISTINCT UsrCod"
|
"SELECT DISTINCT UsrCod"
|
||||||
" FROM usr_ids"
|
" FROM (SELECT DISTINCT UsrCod"
|
||||||
" WHERE UsrID IN"
|
" FROM usr_ids"
|
||||||
" (SELECT UsrID"
|
" WHERE UsrID IN"
|
||||||
" FROM usr_ids"
|
" (SELECT UsrID"
|
||||||
" WHERE UsrCod=%ld)"
|
" FROM usr_ids"
|
||||||
" UNION"
|
" WHERE UsrCod=%ld)"
|
||||||
" SELECT UsrCod"
|
" UNION"
|
||||||
" FROM usr_data"
|
" SELECT UsrCod"
|
||||||
" WHERE Surname1='%s'"
|
" FROM usr_data"
|
||||||
" AND Surname2='%s'"
|
" WHERE Surname1='%s'"
|
||||||
" AND FirstName='%s')"
|
" AND Surname2='%s'"
|
||||||
" AS U",
|
" AND FirstName='%s')"
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod,
|
" AS U",
|
||||||
Gbl.Usrs.Other.UsrDat.Surname1,
|
Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Other.UsrDat.Surname2,
|
Gbl.Usrs.Other.UsrDat.Surname1,
|
||||||
Gbl.Usrs.Other.UsrDat.FrstName);
|
Gbl.Usrs.Other.UsrDat.Surname2,
|
||||||
|
Gbl.Usrs.Other.UsrDat.FrstName);
|
||||||
else
|
else
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
NumUsrs = (unsigned)
|
||||||
"SELECT DISTINCT UsrCod"
|
DB_QuerySELECT (&mysql_res,"can not get similar users",
|
||||||
" FROM usr_ids"
|
"SELECT DISTINCT UsrCod"
|
||||||
" WHERE UsrID IN"
|
" FROM usr_ids"
|
||||||
" (SELECT UsrID"
|
" WHERE UsrID IN"
|
||||||
" FROM usr_ids"
|
" (SELECT UsrID"
|
||||||
" WHERE UsrCod=%ld)",
|
" FROM usr_ids"
|
||||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
" WHERE UsrCod=%ld)",
|
||||||
|
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||||
|
|
||||||
/***** List possible similar users *****/
|
/***** List possible similar users *****/
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
|
|
|
@ -865,8 +865,8 @@ void Enr_RemoveOldUsrs (void)
|
||||||
unsigned MonthsWithoutAccess;
|
unsigned MonthsWithoutAccess;
|
||||||
time_t SecondsWithoutAccess;
|
time_t SecondsWithoutAccess;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsrsEliminated = 0;
|
unsigned NumUsrsEliminated = 0;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
|
|
||||||
|
@ -881,22 +881,23 @@ void Enr_RemoveOldUsrs (void)
|
||||||
SecondsWithoutAccess = (time_t) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
SecondsWithoutAccess = (time_t) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
||||||
|
|
||||||
/***** Get old users from database *****/
|
/***** Get old users from database *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get old users",
|
NumUsrs = (unsigned)
|
||||||
"SELECT UsrCod"
|
DB_QuerySELECT (&mysql_res,"can not get old users",
|
||||||
" FROM (SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM usr_last"
|
" FROM (SELECT UsrCod"
|
||||||
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
" FROM usr_last"
|
||||||
" UNION "
|
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
||||||
"SELECT UsrCod"
|
" UNION "
|
||||||
" FROM usr_data"
|
"SELECT UsrCod"
|
||||||
" WHERE UsrCod NOT IN"
|
" FROM usr_data"
|
||||||
" (SELECT UsrCod"
|
" WHERE UsrCod NOT IN"
|
||||||
" FROM usr_last)"
|
" (SELECT UsrCod"
|
||||||
") AS candidate_usrs"
|
" FROM usr_last)"
|
||||||
" WHERE UsrCod NOT IN"
|
") AS candidate_usrs"
|
||||||
" (SELECT DISTINCT UsrCod"
|
" WHERE UsrCod NOT IN"
|
||||||
" FROM crs_users)",
|
" (SELECT DISTINCT UsrCod"
|
||||||
(unsigned long) SecondsWithoutAccess);
|
" FROM crs_users)",
|
||||||
|
(unsigned long) SecondsWithoutAccess);
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_INFO,Txt_Eliminating_X_users_who_were_not_enroled_in_any_course_and_with_more_than_Y_months_without_access_to_Z,
|
Ale_ShowAlert (Ale_INFO,Txt_Eliminating_X_users_who_were_not_enroled_in_any_course_and_with_more_than_Y_months_without_access_to_Z,
|
||||||
|
@ -2260,8 +2261,8 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
extern const char *Txt_No_enrolment_requests;
|
extern const char *Txt_No_enrolment_requests;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumReqs = 0; // Initialized to avoid warning
|
unsigned NumReqs = 0; // Initialized to avoid warning
|
||||||
unsigned long NumReq;
|
unsigned NumReq;
|
||||||
long ReqCod;
|
long ReqCod;
|
||||||
struct Deg_Degree Deg;
|
struct Deg_Degree Deg;
|
||||||
struct Crs_Course Crs;
|
struct Crs_Course Crs;
|
||||||
|
@ -2334,7 +2335,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
// Requests in all courses in which I am teacher
|
// Requests in all courses in which I am teacher
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2354,7 +2355,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
// Requests in all degrees administrated by me
|
// Requests in all degrees administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2375,7 +2376,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
// Requests in all centers administrated by me
|
// Requests in all centers administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2398,7 +2399,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
// Requests in all institutions administrated by me
|
// Requests in all institutions administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2423,7 +2424,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// All requests
|
// All requests
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT ReqCod," // row[0]
|
"SELECT ReqCod," // row[0]
|
||||||
"CrsCod," // row[1]
|
"CrsCod," // row[1]
|
||||||
|
@ -2445,7 +2446,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
// Requests in courses of this country in which I am teacher
|
// Requests in courses of this country in which I am teacher
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2475,7 +2476,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
// Requests in degrees of this country administrated by me
|
// Requests in degrees of this country administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2505,7 +2506,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
// Requests in centers of this country administrated by me
|
// Requests in centers of this country administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2535,7 +2536,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_INS_ADM:
|
case Rol_INS_ADM:
|
||||||
// Requests in institutions of this country administrated by me
|
// Requests in institutions of this country administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2565,7 +2566,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// Requests in any course of this country
|
// Requests in any course of this country
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2597,7 +2598,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
// Requests in courses of this institution in which I am teacher
|
// Requests in courses of this institution in which I am teacher
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2625,7 +2626,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
// Requests in degrees of this institution administrated by me
|
// Requests in degrees of this institution administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2653,7 +2654,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_CTR_ADM:
|
case Rol_CTR_ADM:
|
||||||
// Requests in centers of this institution administrated by me
|
// Requests in centers of this institution administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2681,7 +2682,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this institution
|
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this institution
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// Requests in any course of this institution
|
// Requests in any course of this institution
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2711,7 +2712,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
// Requests in courses of this center in which I am teacher
|
// Requests in courses of this center in which I am teacher
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2737,7 +2738,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
break;
|
break;
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
// Requests in degrees of this center administrated by me
|
// Requests in degrees of this center administrated by me
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2765,7 +2766,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this center
|
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this center
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// Request in any course of this center
|
// Request in any course of this center
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2793,7 +2794,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
// Requests in courses of this degree in which I am teacher
|
// Requests in courses of this degree in which I am teacher
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2820,7 +2821,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this degree
|
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this degree
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// Requests in any course of this degree
|
// Requests in any course of this degree
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT crs_requests.ReqCod," // row[0]
|
"SELECT crs_requests.ReqCod," // row[0]
|
||||||
"crs_requests.CrsCod," // row[1]
|
"crs_requests.CrsCod," // row[1]
|
||||||
|
@ -2850,7 +2851,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this course
|
case Rol_INS_ADM: // If I am logged as admin of this institution, I can view all the requesters from this course
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
// Requests in this course
|
// Requests in this course
|
||||||
NumReqs =
|
NumReqs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
DB_QuerySELECT (&mysql_res,"can not get requests for enrolment",
|
||||||
"SELECT ReqCod," // row[0]
|
"SELECT ReqCod," // row[0]
|
||||||
"CrsCod," // row[1]
|
"CrsCod," // row[1]
|
||||||
|
@ -2932,7 +2933,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
/***** Number *****/
|
/***** Number *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
HTM_TD_Begin ("class=\"DAT RT\"");
|
HTM_TD_Begin ("class=\"DAT RT\"");
|
||||||
HTM_UnsignedLong (NumReqs - NumReq);
|
HTM_Unsigned (NumReqs - NumReq);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Link to course *****/
|
/***** Link to course *****/
|
||||||
|
|
96
swad_exam.c
96
swad_exam.c
|
@ -800,7 +800,6 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char *HiddenSubQuery;
|
char *HiddenSubQuery;
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
|
||||||
unsigned NumExam;
|
unsigned NumExam;
|
||||||
|
|
||||||
/***** Free list of exams *****/
|
/***** Free list of exams *****/
|
||||||
|
@ -829,30 +828,30 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get list of exams from database *****/
|
/***** Get list of exams from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get exams",
|
Exams->Num = (unsigned)
|
||||||
"SELECT exa_exams.ExaCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get exams",
|
||||||
"MIN(exa_sessions.StartTime) AS StartTime," // row[1]
|
"SELECT exa_exams.ExaCod," // row[0]
|
||||||
"MAX(exa_sessions.EndTime) AS EndTime" // row[2]
|
"MIN(exa_sessions.StartTime) AS StartTime," // row[1]
|
||||||
" FROM exa_exams"
|
"MAX(exa_sessions.EndTime) AS EndTime" // row[2]
|
||||||
" LEFT JOIN exa_sessions"
|
" FROM exa_exams"
|
||||||
" ON exa_exams.ExaCod=exa_sessions.ExaCod"
|
" LEFT JOIN exa_sessions"
|
||||||
" WHERE exa_exams.CrsCod=%ld"
|
" ON exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||||
"%s"
|
" WHERE exa_exams.CrsCod=%ld"
|
||||||
" GROUP BY exa_exams.ExaCod"
|
"%s"
|
||||||
" ORDER BY %s",
|
" GROUP BY exa_exams.ExaCod"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
OrderBySubQuery[SelectedOrder]);
|
HiddenSubQuery,
|
||||||
|
OrderBySubQuery[SelectedOrder]);
|
||||||
|
|
||||||
/***** Free allocated memory for subquery *****/
|
/***** Free allocated memory for subquery *****/
|
||||||
free (HiddenSubQuery);
|
free (HiddenSubQuery);
|
||||||
|
|
||||||
if (NumRows) // Exams found...
|
if (Exams->Num) // Exams found...
|
||||||
{
|
{
|
||||||
Exams->Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list of exams *****/
|
/***** Create list of exams *****/
|
||||||
if ((Exams->Lst = malloc (NumRows * sizeof (*Exams->Lst))) == NULL)
|
if ((Exams->Lst = malloc ((size_t) Exams->Num *
|
||||||
|
sizeof (*Exams->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the exams codes *****/
|
/***** Get the exams codes *****/
|
||||||
|
@ -866,8 +865,6 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong exam code.");
|
Lay_ShowErrorAndExit ("Error: wrong exam code.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Exams->Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -945,7 +942,6 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Trivial check *****/
|
/***** Trivial check *****/
|
||||||
if (Exam->ExaCod <= 0)
|
if (Exam->ExaCod <= 0)
|
||||||
|
@ -956,18 +952,17 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
/***** Get exam data from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get exam data",
|
if (DB_QuerySELECT (&mysql_res,"can not get exam data",
|
||||||
"SELECT ExaCod," // row[0]
|
"SELECT ExaCod," // row[0]
|
||||||
"CrsCod," // row[1]
|
"CrsCod," // row[1]
|
||||||
"Hidden," // row[2]
|
"Hidden," // row[2]
|
||||||
"UsrCod," // row[3]
|
"UsrCod," // row[3]
|
||||||
"MaxGrade," // row[4]
|
"MaxGrade," // row[4]
|
||||||
"Visibility," // row[5]
|
"Visibility," // row[5]
|
||||||
"Title" // row[6]
|
"Title" // row[6]
|
||||||
" FROM exa_exams"
|
" FROM exa_exams"
|
||||||
" WHERE ExaCod=%ld",
|
" WHERE ExaCod=%ld",
|
||||||
Exam->ExaCod);
|
Exam->ExaCod)) // Exam found...
|
||||||
if (NumRows) // Exam found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1017,13 +1012,12 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
||||||
if (Exam->ExaCod > 0)
|
if (Exam->ExaCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get start and end times from database *****/
|
/***** Get start and end times from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get exam data",
|
if (DB_QuerySELECT (&mysql_res,"can not get exam data",
|
||||||
"SELECT UNIX_TIMESTAMP(MIN(StartTime))," // row[0]
|
"SELECT UNIX_TIMESTAMP(MIN(StartTime))," // row[0]
|
||||||
"UNIX_TIMESTAMP(MAX(EndTime))" // row[1]
|
"UNIX_TIMESTAMP(MAX(EndTime))" // row[1]
|
||||||
" FROM exa_sessions"
|
" FROM exa_sessions"
|
||||||
" WHERE ExaCod=%ld",
|
" WHERE ExaCod=%ld",
|
||||||
Exam->ExaCod);
|
Exam->ExaCod))
|
||||||
if (NumRows)
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1242,16 +1236,16 @@ static void Exa_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod)
|
||||||
unsigned NumMedia;
|
unsigned NumMedia;
|
||||||
|
|
||||||
/***** Get media codes associated to stems of exam questions from database *****/
|
/***** Get media codes associated to stems of exam questions from database *****/
|
||||||
NumMedia =
|
NumMedia = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
DB_QuerySELECT (&mysql_res,"can not get media",
|
||||||
"SELECT exa_set_questions.MedCod"
|
"SELECT exa_set_questions.MedCod"
|
||||||
" FROM exa_exams,"
|
" FROM exa_exams,"
|
||||||
"exa_sets,"
|
"exa_sets,"
|
||||||
"exa_set_questions"
|
"exa_set_questions"
|
||||||
" WHERE exa_exams.CrsCod=%ld"
|
" WHERE exa_exams.CrsCod=%ld"
|
||||||
" AND exa_exams.ExaCod=exa_sets.ExaCod"
|
" AND exa_exams.ExaCod=exa_sets.ExaCod"
|
||||||
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
||||||
CrsCod);
|
CrsCod);
|
||||||
|
|
||||||
/***** Go over result removing media files *****/
|
/***** Go over result removing media files *****/
|
||||||
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
||||||
|
|
|
@ -69,7 +69,7 @@ extern struct Globals Gbl;
|
||||||
|
|
||||||
static void ExaPrn_GetDataOfPrint (struct ExaPrn_Print *Print,
|
static void ExaPrn_GetDataOfPrint (struct ExaPrn_Print *Print,
|
||||||
MYSQL_RES **mysql_res,
|
MYSQL_RES **mysql_res,
|
||||||
unsigned long NumRows);
|
unsigned NumPrints);
|
||||||
|
|
||||||
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,long ExaCod);
|
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,long ExaCod);
|
||||||
static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
||||||
|
@ -252,25 +252,26 @@ void ExaPrn_ShowExamPrint (void)
|
||||||
void ExaPrn_GetDataOfPrintByPrnCod (struct ExaPrn_Print *Print)
|
void ExaPrn_GetDataOfPrintByPrnCod (struct ExaPrn_Print *Print)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumPrints;
|
||||||
|
|
||||||
/***** Make database query *****/
|
/***** Make database query *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
NumPrints = (unsigned)
|
||||||
"SELECT PrnCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
||||||
"SesCod," // row[1]
|
"SELECT PrnCod," // row[0]
|
||||||
"UsrCod," // row[2]
|
"SesCod," // row[1]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
"UsrCod," // row[2]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
||||||
"NumQsts," // row[5]
|
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
||||||
"NumQstsNotBlank," // row[6]
|
"NumQsts," // row[5]
|
||||||
"Sent," // row[7]
|
"NumQstsNotBlank," // row[6]
|
||||||
"Score" // row[8]
|
"Sent," // row[7]
|
||||||
" FROM exa_prints"
|
"Score" // row[8]
|
||||||
" WHERE PrnCod=%ld",
|
" FROM exa_prints"
|
||||||
Print->PrnCod);
|
" WHERE PrnCod=%ld",
|
||||||
|
Print->PrnCod);
|
||||||
|
|
||||||
/***** Get data of print *****/
|
/***** Get data of print *****/
|
||||||
ExaPrn_GetDataOfPrint (Print,&mysql_res,NumRows);
|
ExaPrn_GetDataOfPrint (Print,&mysql_res,NumPrints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -280,27 +281,28 @@ void ExaPrn_GetDataOfPrintByPrnCod (struct ExaPrn_Print *Print)
|
||||||
void ExaPrn_GetDataOfPrintBySesCodAndUsrCod (struct ExaPrn_Print *Print)
|
void ExaPrn_GetDataOfPrintBySesCodAndUsrCod (struct ExaPrn_Print *Print)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumPrints;
|
||||||
|
|
||||||
/***** Make database query *****/
|
/***** Make database query *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
NumPrints = (unsigned)
|
||||||
"SELECT PrnCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
||||||
"SesCod," // row[1]
|
"SELECT PrnCod," // row[0]
|
||||||
"UsrCod," // row[2]
|
"SesCod," // row[1]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
"UsrCod," // row[2]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
"UNIX_TIMESTAMP(StartTime)," // row[3]
|
||||||
"NumQsts," // row[5]
|
"UNIX_TIMESTAMP(EndTime)," // row[4]
|
||||||
"NumQstsNotBlank," // row[6]
|
"NumQsts," // row[5]
|
||||||
"Sent," // row[7]
|
"NumQstsNotBlank," // row[6]
|
||||||
"Score" // row[8]
|
"Sent," // row[7]
|
||||||
" FROM exa_prints"
|
"Score" // row[8]
|
||||||
" WHERE SesCod=%ld"
|
" FROM exa_prints"
|
||||||
" AND UsrCod=%ld",
|
" WHERE SesCod=%ld"
|
||||||
Print->SesCod,
|
" AND UsrCod=%ld",
|
||||||
Print->UsrCod);
|
Print->SesCod,
|
||||||
|
Print->UsrCod);
|
||||||
|
|
||||||
/***** Get data of print *****/
|
/***** Get data of print *****/
|
||||||
ExaPrn_GetDataOfPrint (Print,&mysql_res,NumRows);
|
ExaPrn_GetDataOfPrint (Print,&mysql_res,NumPrints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -309,11 +311,11 @@ void ExaPrn_GetDataOfPrintBySesCodAndUsrCod (struct ExaPrn_Print *Print)
|
||||||
|
|
||||||
static void ExaPrn_GetDataOfPrint (struct ExaPrn_Print *Print,
|
static void ExaPrn_GetDataOfPrint (struct ExaPrn_Print *Print,
|
||||||
MYSQL_RES **mysql_res,
|
MYSQL_RES **mysql_res,
|
||||||
unsigned long NumRows)
|
unsigned NumPrints)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
if (NumRows)
|
if (NumPrints)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (*mysql_res);
|
row = mysql_fetch_row (*mysql_res);
|
||||||
|
|
||||||
|
|
|
@ -427,28 +427,29 @@ void ExaRes_ShowAllResultsInExa (void)
|
||||||
static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
|
|
||||||
/***** Table head *****/
|
/***** Table head *****/
|
||||||
ExaRes_ShowHeaderResults (Usr_OTHER);
|
ExaRes_ShowHeaderResults (Usr_OTHER);
|
||||||
|
|
||||||
/***** Get all users who have answered any session question in this exam *****/
|
/***** Get all users who have answered any session question in this exam *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in exam",
|
NumUsrs = (unsigned)
|
||||||
"SELECT users.UsrCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get users in exam",
|
||||||
" FROM (SELECT DISTINCT exa_prints.UsrCod AS UsrCod"
|
"SELECT users.UsrCod" // row[0]
|
||||||
" FROM exa_prints,exa_sessions,exa_exams"
|
" FROM (SELECT DISTINCT exa_prints.UsrCod AS UsrCod"
|
||||||
" WHERE exa_sessions.ExaCod=%ld"
|
" FROM exa_prints,exa_sessions,exa_exams"
|
||||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
" WHERE exa_sessions.ExaCod=%ld"
|
||||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||||
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||||
"usr_data"
|
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
||||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
"usr_data"
|
||||||
" ORDER BY usr_data.Surname1,"
|
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||||
"usr_data.Surname2,"
|
" ORDER BY usr_data.Surname1,"
|
||||||
"usr_data.FirstName",
|
"usr_data.Surname2,"
|
||||||
ExaCod,
|
"usr_data.FirstName",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
ExaCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** List sessions results for each user *****/
|
/***** List sessions results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
|
@ -516,28 +517,29 @@ void ExaRes_ShowAllResultsInSes (void)
|
||||||
static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
|
|
||||||
/***** Table head *****/
|
/***** Table head *****/
|
||||||
ExaRes_ShowHeaderResults (Usr_OTHER);
|
ExaRes_ShowHeaderResults (Usr_OTHER);
|
||||||
|
|
||||||
/***** Get all users who have answered any session question in this exam *****/
|
/***** Get all users who have answered any session question in this exam *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in session",
|
NumUsrs = (unsigned)
|
||||||
"SELECT users.UsrCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get users in session",
|
||||||
" FROM (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
"SELECT users.UsrCod" // row[0]
|
||||||
" FROM exa_prints,exa_sessions,exa_exams"
|
" FROM (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
||||||
" WHERE exa_prints.SesCod=%ld"
|
" FROM exa_prints,exa_sessions,exa_exams"
|
||||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
" WHERE exa_prints.SesCod=%ld"
|
||||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||||
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||||
"usr_data"
|
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
||||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
"usr_data"
|
||||||
" ORDER BY usr_data.Surname1,"
|
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||||
"usr_data.Surname2,"
|
" ORDER BY usr_data.Surname1,"
|
||||||
"usr_data.FirstName",
|
"usr_data.Surname2,"
|
||||||
SesCod,
|
"usr_data.FirstName",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
SesCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** List sessions results for each user *****/
|
/***** List sessions results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
|
@ -905,25 +907,25 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
||||||
/***** Make database query *****/
|
/***** Make database query *****/
|
||||||
// Do not filter by groups, because a student who has changed groups
|
// Do not filter by groups, because a student who has changed groups
|
||||||
// must be able to access exams taken in other groups
|
// must be able to access exams taken in other groups
|
||||||
NumResults =
|
NumResults = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get sessions results",
|
DB_QuerySELECT (&mysql_res,"can not get sessions results",
|
||||||
"SELECT exa_prints.PrnCod" // row[0]
|
"SELECT exa_prints.PrnCod" // row[0]
|
||||||
" FROM exa_prints,exa_sessions,exa_exams"
|
" FROM exa_prints,exa_sessions,exa_exams"
|
||||||
" WHERE exa_prints.UsrCod=%ld"
|
" WHERE exa_prints.UsrCod=%ld"
|
||||||
"%s" // Session subquery
|
"%s" // Session subquery
|
||||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||||
"%s" // Hidden sessions subquery
|
"%s" // Hidden sessions subquery
|
||||||
"%s" // Exams subquery
|
"%s" // Exams subquery
|
||||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||||
"%s" // Hidden exams subquery
|
"%s" // Hidden exams subquery
|
||||||
" AND exa_exams.CrsCod=%ld" // Extra check
|
" AND exa_exams.CrsCod=%ld" // Extra check
|
||||||
" ORDER BY exa_sessions.Title",
|
" ORDER BY exa_sessions.Title",
|
||||||
UsrDat->UsrCod,
|
UsrDat->UsrCod,
|
||||||
SesSubQuery,
|
SesSubQuery,
|
||||||
HidSesSubQuery,
|
HidSesSubQuery,
|
||||||
ExaSubQuery,
|
ExaSubQuery,
|
||||||
HidExaSubQuery,
|
HidExaSubQuery,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
free (HidExaSubQuery);
|
free (HidExaSubQuery);
|
||||||
free (ExaSubQuery);
|
free (ExaSubQuery);
|
||||||
free (HidSesSubQuery);
|
free (HidSesSubQuery);
|
||||||
|
|
|
@ -291,7 +291,6 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
||||||
void ExaSes_GetDataOfSessionByCod (struct ExaSes_Session *Session)
|
void ExaSes_GetDataOfSessionByCod (struct ExaSes_Session *Session)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Trivial check *****/
|
/***** Trivial check *****/
|
||||||
if (Session->SesCod <= 0)
|
if (Session->SesCod <= 0)
|
||||||
|
@ -302,26 +301,24 @@ void ExaSes_GetDataOfSessionByCod (struct ExaSes_Session *Session)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get exam data session from database *****/
|
/***** Get exam data session from database *****/
|
||||||
NumRows = (unsigned)
|
if (DB_QuerySELECT (&mysql_res,"can not get sessions",
|
||||||
DB_QuerySELECT (&mysql_res,"can not get sessions",
|
"SELECT SesCod," // row[0]
|
||||||
"SELECT SesCod," // row[0]
|
"ExaCod," // row[1]
|
||||||
"ExaCod," // row[1]
|
"Hidden," // row[2]
|
||||||
"Hidden," // row[2]
|
"UsrCod," // row[3]
|
||||||
"UsrCod," // row[3]
|
"UNIX_TIMESTAMP(StartTime)," // row[4]
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[4]
|
"UNIX_TIMESTAMP(EndTime)," // row[5]
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[5]
|
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||||
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
"Title," // row[7]
|
||||||
"Title," // row[7]
|
"ShowUsrResults" // row[8]
|
||||||
"ShowUsrResults" // row[8]
|
" FROM exa_sessions"
|
||||||
" FROM exa_sessions"
|
" WHERE SesCod=%ld"
|
||||||
" WHERE SesCod=%ld"
|
" AND ExaCod IN" // Extra check
|
||||||
" AND ExaCod IN" // Extra check
|
" (SELECT ExaCod"
|
||||||
" (SELECT ExaCod"
|
" FROM exa_exams"
|
||||||
" FROM exa_exams"
|
" WHERE CrsCod='%ld')",
|
||||||
" WHERE CrsCod='%ld')",
|
Session->SesCod,
|
||||||
Session->SesCod,
|
Gbl.Hierarchy.Crs.CrsCod)) // Session found...
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
if (NumRows) // Session found...
|
|
||||||
/* Get exam session data from row */
|
/* Get exam session data from row */
|
||||||
ExaSes_GetSessionDataFromRow (mysql_res,Session);
|
ExaSes_GetSessionDataFromRow (mysql_res,Session);
|
||||||
else
|
else
|
||||||
|
@ -662,36 +659,37 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe
|
||||||
extern const char *Txt_The_whole_course;
|
extern const char *Txt_The_whole_course;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumGrps;
|
||||||
unsigned long NumRows;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups associated to an exam session from database *****/
|
/***** Get groups associated to an exam session from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get groups of an exam session",
|
NumGrps = (unsigned)
|
||||||
"SELECT grp_types.GrpTypName," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get groups of an exam session",
|
||||||
"grp_groups.GrpName" // row[1]
|
"SELECT grp_types.GrpTypName," // row[0]
|
||||||
" FROM exa_groups,"
|
"grp_groups.GrpName" // row[1]
|
||||||
"grp_groups,"
|
" FROM exa_groups,"
|
||||||
"grp_types"
|
"grp_groups,"
|
||||||
" WHERE exa_groups.SesCod=%ld"
|
"grp_types"
|
||||||
" AND exa_groups.GrpCod=grp_groups.GrpCod"
|
" WHERE exa_groups.SesCod=%ld"
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
" AND exa_groups.GrpCod=grp_groups.GrpCod"
|
||||||
" ORDER BY grp_types.GrpTypName,"
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
"grp_groups.GrpName",
|
" ORDER BY grp_types.GrpTypName,"
|
||||||
Session->SesCod);
|
"grp_groups.GrpName",
|
||||||
|
Session->SesCod);
|
||||||
|
|
||||||
/***** Write heading *****/
|
/***** Write heading *****/
|
||||||
HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT":
|
HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT":
|
||||||
"ASG_GRP");
|
"ASG_GRP");
|
||||||
HTM_TxtColonNBSP (NumRows == 1 ? Txt_Group :
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
||||||
Txt_Groups);
|
Txt_Groups);
|
||||||
|
|
||||||
/***** Write groups *****/
|
/***** Write groups *****/
|
||||||
if (NumRows) // Groups found...
|
if (NumGrps) // Groups found...
|
||||||
{
|
{
|
||||||
/* Get and write the group types and names */
|
/* Get and write the group types and names */
|
||||||
for (NumRow = 0;
|
for (NumGrp = 0;
|
||||||
NumRow < NumRows;
|
NumGrp < NumGrps;
|
||||||
NumRow++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -699,12 +697,12 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe
|
||||||
/* Write group type name and group name */
|
/* Write group type name and group name */
|
||||||
HTM_TxtF ("%s %s",row[0],row[1]);
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
||||||
|
|
||||||
if (NumRows >= 2)
|
if (NumGrps >= 2)
|
||||||
{
|
{
|
||||||
if (NumRow == NumRows-2)
|
if (NumGrp == NumGrps - 2)
|
||||||
HTM_TxtF (" %s ",Txt_and);
|
HTM_TxtF (" %s ",Txt_and);
|
||||||
if (NumRows >= 3)
|
if (NumGrps >= 3)
|
||||||
if (NumRow < NumRows-2)
|
if (NumGrp < NumGrps - 2)
|
||||||
HTM_Txt (", ");
|
HTM_Txt (", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1394,40 +1394,40 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss =
|
NumInss = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod," // row[0]
|
"SELECT InsCod," // row[0]
|
||||||
"COUNT(*) AS N" // row[1]
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE InsCod>0"
|
" WHERE InsCod>0"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
" ORDER BY N DESC");
|
" ORDER BY N DESC");
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss =
|
NumInss = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT usr_data.InsCod," // row[0]
|
"SELECT usr_data.InsCod," // row[0]
|
||||||
"COUNT(*) AS N" // row[1]
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ins_instits,usr_data"
|
" FROM ins_instits,usr_data"
|
||||||
" WHERE ins_instits.CtyCod=%ld"
|
" WHERE ins_instits.CtyCod=%ld"
|
||||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||||
" GROUP BY usr_data.InsCod"
|
" GROUP BY usr_data.InsCod"
|
||||||
" ORDER BY N DESC",
|
" ORDER BY N DESC",
|
||||||
Gbl.Hierarchy.Cty.CtyCod);
|
Gbl.Hierarchy.Cty.CtyCod);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss =
|
NumInss = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod," // row[0]
|
"SELECT InsCod," // row[0]
|
||||||
"COUNT(*) AS N" // row[1]
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
" ORDER BY N DESC",
|
" ORDER BY N DESC",
|
||||||
Gbl.Hierarchy.Ins.InsCod);
|
Gbl.Hierarchy.Ins.InsCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
|
@ -3552,8 +3552,8 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
Tml_Not_NoteType_t NoteType;
|
Tml_Not_NoteType_t NoteType;
|
||||||
unsigned long NumNotes;
|
unsigned NumNotes;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsrsTotal;
|
unsigned NumUsrsTotal;
|
||||||
|
|
||||||
|
@ -3584,7 +3584,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(*)," // row[0]
|
"SELECT COUNT(*)," // row[0]
|
||||||
"COUNT(DISTINCT UsrCod)" // row[1]
|
"COUNT(DISTINCT UsrCod)" // row[1]
|
||||||
|
@ -3592,7 +3592,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
NoteType);
|
NoteType);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3613,7 +3613,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
(unsigned) NoteType);
|
(unsigned) NoteType);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3632,7 +3632,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
(unsigned) NoteType);
|
(unsigned) NoteType);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3649,7 +3649,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
(unsigned) NoteType);
|
(unsigned) NoteType);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3664,7 +3664,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
(unsigned) NoteType);
|
(unsigned) NoteType);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3691,7 +3691,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
|
|
||||||
/* Get number of social notes */
|
/* Get number of social notes */
|
||||||
if (row[0])
|
if (row[0])
|
||||||
if (sscanf (row[0],"%lu",&NumNotes) != 1)
|
if (sscanf (row[0],"%u",&NumNotes) != 1)
|
||||||
NumNotes = 0;
|
NumNotes = 0;
|
||||||
|
|
||||||
/* Get number of users */
|
/* Get number of users */
|
||||||
|
@ -3711,7 +3711,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"DAT RM\"");
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
||||||
HTM_UnsignedLong (NumNotes);
|
HTM_Unsigned (NumNotes);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"DAT RM\"");
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
||||||
|
@ -3736,14 +3736,14 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
switch (Gbl.Scope.Current)
|
switch (Gbl.Scope.Current)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(*)," // row[0]
|
"SELECT COUNT(*)," // row[0]
|
||||||
"COUNT(DISTINCT UsrCod)" // row[1]
|
"COUNT(DISTINCT UsrCod)" // row[1]
|
||||||
" FROM tml_notes");
|
" FROM tml_notes");
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3762,7 +3762,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
Gbl.Hierarchy.Cty.CtyCod);
|
Gbl.Hierarchy.Cty.CtyCod);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3779,7 +3779,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
Gbl.Hierarchy.Ins.InsCod);
|
Gbl.Hierarchy.Ins.InsCod);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3794,7 +3794,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3807,7 +3807,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
Gbl.Hierarchy.Deg.DegCod);
|
Gbl.Hierarchy.Deg.DegCod);
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
"SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0]
|
||||||
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
"COUNT(DISTINCT tml_notes.UsrCod)" // row[1]
|
||||||
|
@ -3832,7 +3832,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
|
|
||||||
/* Get number of social notes */
|
/* Get number of social notes */
|
||||||
if (row[0])
|
if (row[0])
|
||||||
if (sscanf (row[0],"%lu",&NumNotes) != 1)
|
if (sscanf (row[0],"%u",&NumNotes) != 1)
|
||||||
NumNotes = 0;
|
NumNotes = 0;
|
||||||
|
|
||||||
/* Get number of users */
|
/* Get number of users */
|
||||||
|
@ -3852,7 +3852,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\"");
|
HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\"");
|
||||||
HTM_UnsignedLong (NumNotes);
|
HTM_Unsigned (NumNotes);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\"");
|
HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\"");
|
||||||
|
|
|
@ -2678,12 +2678,12 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
||||||
bool FolderExists = false;
|
bool FolderExists = false;
|
||||||
|
|
||||||
/***** Get all the users belonging to current course from database *****/
|
/***** Get all the users belonging to current course from database *****/
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get users"
|
NumUsrs = (unsigned)
|
||||||
" from current course",
|
DB_QuerySELECT (&mysql_res,"can not get users from current course",
|
||||||
"SELECT UsrCod" // row[0]
|
"SELECT UsrCod"
|
||||||
" FROM crs_users"
|
" FROM crs_users"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** Check folders *****/
|
/***** Check folders *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
|
@ -2722,35 +2722,37 @@ static void Brw_CreateFoldersAssignmentsIfNotExist (long ZoneUsrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumFolders;
|
||||||
unsigned long NumRow;
|
unsigned NumFolder;
|
||||||
char PathFolderAsg[PATH_MAX + 1 + PATH_MAX + 1];
|
char PathFolderAsg[PATH_MAX + 1 + PATH_MAX + 1];
|
||||||
|
|
||||||
/***** Get assignment folders from database *****/
|
/***** Get assignment folders from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get folders of assignments",
|
NumFolders = (unsigned)
|
||||||
"SELECT Folder" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get folders of assignments",
|
||||||
" FROM asg_assignments"
|
"SELECT Folder" // row[0]
|
||||||
" WHERE CrsCod=%ld"
|
" FROM asg_assignments"
|
||||||
" AND Hidden='N'"
|
" WHERE CrsCod=%ld"
|
||||||
" AND Folder<>''"
|
" AND Hidden='N'"
|
||||||
" AND ("
|
" AND Folder<>''"
|
||||||
"AsgCod NOT IN"
|
" AND ("
|
||||||
" (SELECT AsgCod"
|
"AsgCod NOT IN"
|
||||||
" FROM asg_groups)"
|
" (SELECT AsgCod"
|
||||||
" OR "
|
" FROM asg_groups)"
|
||||||
"AsgCod IN"
|
" OR "
|
||||||
" (SELECT asg_groups.AsgCod"
|
"AsgCod IN"
|
||||||
" FROM grp_users,"
|
" (SELECT asg_groups.AsgCod"
|
||||||
"asg_groups"
|
" FROM grp_users,"
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
"asg_groups"
|
||||||
" AND asg_groups.GrpCod=grp_users.GrpCod)"
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
")",
|
" AND asg_groups.GrpCod=grp_users.GrpCod)"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,ZoneUsrCod);
|
")",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
ZoneUsrCod);
|
||||||
|
|
||||||
/***** Create one folder for each assignment *****/
|
/***** Create one folder for each assignment *****/
|
||||||
for (NumRow = 0;
|
for (NumFolder = 0;
|
||||||
NumRow < NumRows;
|
NumFolder < NumFolders;
|
||||||
NumRow++)
|
NumFolder++)
|
||||||
{
|
{
|
||||||
/* Get next assignment with folder */
|
/* Get next assignment with folder */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -5159,7 +5161,7 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
|
||||||
long Cod;
|
long Cod;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Get date of last accesss to a file browser from database *****/
|
/***** Get date of last accesss to a file browser from database *****/
|
||||||
switch (Gbl.FileBrowser.Type)
|
switch (Gbl.FileBrowser.Type)
|
||||||
|
@ -5209,16 +5211,17 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get date-time"
|
NumRows = (unsigned)
|
||||||
" of last access to a file browser",
|
DB_QuerySELECT (&mysql_res,"can not get date-time"
|
||||||
"SELECT UNIX_TIMESTAMP(LastClick)" // row[0]
|
" of last access to a file browser",
|
||||||
" FROM brw_last"
|
"SELECT UNIX_TIMESTAMP(LastClick)" // row[0]
|
||||||
" WHERE UsrCod=%ld"
|
" FROM brw_last"
|
||||||
" AND FileBrowser=%u"
|
" WHERE UsrCod=%ld"
|
||||||
" AND Cod=%ld",
|
" AND FileBrowser=%u"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
" AND Cod=%ld",
|
||||||
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Cod);
|
(unsigned) Brw_FileBrowserForDB_file_browser_last[Gbl.FileBrowser.Type],
|
||||||
|
Cod);
|
||||||
|
|
||||||
if (NumRows == 0) // May be an administrator not belonging to this course
|
if (NumRows == 0) // May be an administrator not belonging to this course
|
||||||
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialize to a big value in order to show files as old
|
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = LONG_MAX; // Initialize to a big value in order to show files as old
|
||||||
|
@ -5256,24 +5259,24 @@ static long Brw_GetGrpLastAccZone (const char *FieldNameDB)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumGrps;
|
||||||
long GrpCod = -1L;
|
long GrpCod = -1L;
|
||||||
|
|
||||||
/***** Get the group of my last access to a common zone from database *****/
|
/***** Get the group of my last access to a common zone from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the group"
|
NumGrps = (unsigned)
|
||||||
" of your last access"
|
DB_QuerySELECT (&mysql_res,"can not get the group of your last access"
|
||||||
" to a file browser",
|
" to a file browser",
|
||||||
"SELECT %s" // row[0]
|
"SELECT %s" // row[0]
|
||||||
" FROM crs_user_settings"
|
" FROM crs_user_settings"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" AND CrsCod=%ld",
|
" AND CrsCod=%ld",
|
||||||
FieldNameDB,
|
FieldNameDB,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
if (NumRows == 0) // May be an administrator not belonging to this course
|
if (NumGrps == 0) // May be an administrator not belonging to this course
|
||||||
GrpCod = -1L;
|
GrpCod = -1L;
|
||||||
else if (NumRows == 1)
|
else if (NumGrps == 1)
|
||||||
{
|
{
|
||||||
/* Get the group code (row[0]) */
|
/* Get the group code (row[0]) */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -11710,27 +11713,22 @@ static long Brw_GetPublisherOfSubtree (void)
|
||||||
void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod)
|
void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
unsigned NumGrps;
|
||||||
unsigned long NumRow;
|
unsigned NumGrp;
|
||||||
unsigned long NumRows;
|
|
||||||
long GrpCod;
|
long GrpCod;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
if ((NumRows = Grp_GetGrpsOfType (GrpTypCod,&mysql_res))) // If there exists groups...
|
NumGrps = Grp_GetGrpsOfType (GrpTypCod,&mysql_res);
|
||||||
for (NumRow = 0;
|
for (NumGrp = 0;
|
||||||
NumRow < NumRows;
|
NumGrp < NumGrps;
|
||||||
NumRow++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
GrpCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
||||||
/* Group code is in row[0] */
|
/* Remove file zones of this group */
|
||||||
if (sscanf (row[0],"%ld",&GrpCod) != 1)
|
Brw_RemoveGrpZones (Gbl.Hierarchy.Crs.CrsCod,GrpCod);
|
||||||
Lay_ShowErrorAndExit ("Wrong group code.");
|
}
|
||||||
|
|
||||||
/* Remove file zones of this group */
|
|
||||||
Brw_RemoveGrpZones (Gbl.Hierarchy.Crs.CrsCod,GrpCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -11783,27 +11781,27 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned long NumCrss;
|
||||||
unsigned long NumRow;
|
unsigned long NumCrs;
|
||||||
unsigned NumCrssWorksRemoved = 0;
|
unsigned NumCrssWorksRemoved = 0;
|
||||||
struct Crs_Course Crs;
|
struct Crs_Course Crs;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
if ((NumRows = Usr_GetCrssFromUsr (UsrDat->UsrCod,-1L,&mysql_res)) > 0) // If courses found
|
NumCrss = Usr_GetCrssFromUsr (UsrDat->UsrCod,-1L,&mysql_res);
|
||||||
|
|
||||||
|
/***** Remove the zone of works of the user in the courses he/she belongs to *****/
|
||||||
|
for (NumCrs = 0;
|
||||||
|
NumCrs < NumCrss;
|
||||||
|
NumCrs++)
|
||||||
{
|
{
|
||||||
/***** Remove the zone of works of the user in the courses he/she belongs to *****/
|
/* Get the next course */
|
||||||
for (NumRow = 0;
|
row = mysql_fetch_row (mysql_res);
|
||||||
NumRow < NumRows;
|
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
NumRow++)
|
|
||||||
{
|
/* Get data of course */
|
||||||
/* Get the next course */
|
Crs_GetDataOfCourseByCod (&Crs);
|
||||||
row = mysql_fetch_row (mysql_res);
|
Brw_RemoveUsrWorksInCrs (UsrDat,&Crs);
|
||||||
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
NumCrssWorksRemoved++;
|
||||||
/* Get data of course */
|
|
||||||
Crs_GetDataOfCourseByCod (&Crs);
|
|
||||||
Brw_RemoveUsrWorksInCrs (UsrDat,&Crs);
|
|
||||||
NumCrssWorksRemoved++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
263
swad_follow.c
263
swad_follow.c
|
@ -77,9 +77,9 @@ extern struct Globals Gbl;
|
||||||
/***************************** Private prototypes ****************************/
|
/***************************** Private prototypes ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned long Fol_GetUsrsToFollow (unsigned long MaxUsrsToShow,
|
static unsigned Fol_GetUsrsToFollow (unsigned MaxUsrsToShow,
|
||||||
Fol_WhichUsersSuggestToFollowThem_t WhichUsersSuggestToFollowThem,
|
Fol_WhichUsersSuggestToFollowThem_t WhichUsersSuggestToFollowThem,
|
||||||
MYSQL_RES **mysql_res);
|
MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
static void Fol_PutIconsWhoToFollow (__attribute__((unused)) void *Args);
|
static void Fol_PutIconsWhoToFollow (__attribute__((unused)) void *Args);
|
||||||
static void Fol_PutIconToUpdateWhoToFollow (void);
|
static void Fol_PutIconToUpdateWhoToFollow (void);
|
||||||
|
@ -134,8 +134,8 @@ void Fol_SuggestUsrsToFollowMainZone (void)
|
||||||
extern const char *Txt_No_user_to_whom_you_can_follow_Try_again_later;
|
extern const char *Txt_No_user_to_whom_you_can_follow_Try_again_later;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
|
|
||||||
/***** Contextual menu *****/
|
/***** Contextual menu *****/
|
||||||
|
@ -262,9 +262,9 @@ void Fol_SuggestUsrsToFollowMainZoneOnRightColumn (void)
|
||||||
/*************************** Get users to follow *****************************/
|
/*************************** Get users to follow *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned long Fol_GetUsrsToFollow (unsigned long MaxUsrsToShow,
|
static unsigned Fol_GetUsrsToFollow (unsigned MaxUsrsToShow,
|
||||||
Fol_WhichUsersSuggestToFollowThem_t WhichUsersSuggestToFollowThem,
|
Fol_WhichUsersSuggestToFollowThem_t WhichUsersSuggestToFollowThem,
|
||||||
MYSQL_RES **mysql_res)
|
MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
extern const char *Pri_VisibilityDB[Pri_NUM_OPTIONS_PRIVACY];
|
||||||
char SubQuery1[256];
|
char SubQuery1[256];
|
||||||
|
@ -311,115 +311,116 @@ static unsigned long Fol_GetUsrsToFollow (unsigned long MaxUsrsToShow,
|
||||||
|
|
||||||
/***** Build query to get users to follow *****/
|
/***** Build query to get users to follow *****/
|
||||||
// Get only users with surname 1 and first name
|
// Get only users with surname 1 and first name
|
||||||
return DB_QuerySELECT (mysql_res,"can not get users to follow",
|
return (unsigned)
|
||||||
"SELECT DISTINCT UsrCod FROM"
|
DB_QuerySELECT (mysql_res,"can not get users to follow",
|
||||||
" ("
|
"SELECT DISTINCT UsrCod FROM"
|
||||||
/***** Likely known users *****/
|
" ("
|
||||||
"(SELECT DISTINCT UsrCod FROM"
|
/***** Likely known users *****/
|
||||||
" ("
|
"(SELECT DISTINCT UsrCod FROM"
|
||||||
// 1. Users followed by my followed
|
" ("
|
||||||
"("
|
// 1. Users followed by my followed
|
||||||
"SELECT DISTINCT usr_follow.FollowedCod AS UsrCod"
|
"("
|
||||||
" FROM usr_follow,"
|
"SELECT DISTINCT usr_follow.FollowedCod AS UsrCod"
|
||||||
"(SELECT FollowedCod"
|
" FROM usr_follow,"
|
||||||
" FROM usr_follow"
|
"(SELECT FollowedCod"
|
||||||
" WHERE FollowerCod=%ld) AS my_followed,"
|
" FROM usr_follow"
|
||||||
" usr_data"
|
" WHERE FollowerCod=%ld) AS my_followed,"
|
||||||
" WHERE usr_follow.FollowerCod=my_followed.FollowedCod"
|
" usr_data"
|
||||||
" AND usr_follow.FollowedCod<>%ld"
|
" WHERE usr_follow.FollowerCod=my_followed.FollowedCod"
|
||||||
" AND usr_follow.FollowedCod=usr_data.UsrCod"
|
" AND usr_follow.FollowedCod<>%ld"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND usr_follow.FollowedCod=usr_data.UsrCod"
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
"%s" // SubQuery1
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
")"
|
"%s" // SubQuery1
|
||||||
" UNION "
|
")"
|
||||||
// 2. Users who share any course with me
|
" UNION "
|
||||||
"("
|
// 2. Users who share any course with me
|
||||||
"SELECT DISTINCT crs_users.UsrCod"
|
"("
|
||||||
" FROM crs_users,"
|
"SELECT DISTINCT crs_users.UsrCod"
|
||||||
"(SELECT CrsCod"
|
" FROM crs_users,"
|
||||||
" FROM crs_users"
|
"(SELECT CrsCod"
|
||||||
" WHERE UsrCod=%ld) AS my_crs,"
|
" FROM crs_users"
|
||||||
" usr_data"
|
" WHERE UsrCod=%ld) AS my_crs,"
|
||||||
" WHERE crs_users.CrsCod=my_crs.CrsCod"
|
" usr_data"
|
||||||
" AND crs_users.UsrCod<>%ld"
|
" WHERE crs_users.CrsCod=my_crs.CrsCod"
|
||||||
" AND crs_users.UsrCod=usr_data.UsrCod"
|
" AND crs_users.UsrCod<>%ld"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND crs_users.UsrCod=usr_data.UsrCod"
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
"%s" // SubQuery2
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
")"
|
"%s" // SubQuery2
|
||||||
" UNION "
|
")"
|
||||||
// 3. Users who share any course with me with another role
|
" UNION "
|
||||||
"("
|
// 3. Users who share any course with me with another role
|
||||||
"SELECT DISTINCT crs_users.UsrCod"
|
"("
|
||||||
" FROM crs_users,"
|
"SELECT DISTINCT crs_users.UsrCod"
|
||||||
"(SELECT CrsCod,Role"
|
" FROM crs_users,"
|
||||||
" FROM crs_users"
|
"(SELECT CrsCod,Role"
|
||||||
" WHERE UsrCod=%ld) AS my_crs_role,"
|
" FROM crs_users"
|
||||||
" usr_data"
|
" WHERE UsrCod=%ld) AS my_crs_role,"
|
||||||
" WHERE crs_users.CrsCod=my_crs_role.CrsCod"
|
" usr_data"
|
||||||
" AND crs_users.Role<>my_crs_role.Role"
|
" WHERE crs_users.CrsCod=my_crs_role.CrsCod"
|
||||||
" AND crs_users.UsrCod=usr_data.UsrCod"
|
" AND crs_users.Role<>my_crs_role.Role"
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" AND crs_users.UsrCod=usr_data.UsrCod"
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
"%s" // SubQuery3
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
")"
|
"%s" // SubQuery3
|
||||||
") AS LikelyKnownUsrsToFollow"
|
")"
|
||||||
// Do not select my followed
|
") AS LikelyKnownUsrsToFollow"
|
||||||
" WHERE UsrCod NOT IN"
|
// Do not select my followed
|
||||||
" (SELECT FollowedCod FROM usr_follow"
|
" WHERE UsrCod NOT IN"
|
||||||
" WHERE FollowerCod=%ld)"
|
" (SELECT FollowedCod FROM usr_follow"
|
||||||
// Get only MaxUsrsToShow * 3 users
|
" WHERE FollowerCod=%ld)"
|
||||||
" ORDER BY RAND() LIMIT %lu"
|
// Get only MaxUsrsToShow * 3 users
|
||||||
")"
|
" ORDER BY RAND() LIMIT %u"
|
||||||
" UNION "
|
")"
|
||||||
"("
|
" UNION "
|
||||||
/***** Likely unknown userd *****/
|
"("
|
||||||
// 4. Add some likely unknown random user
|
/***** Likely unknown userd *****/
|
||||||
// Be careful with the method to get some random users
|
// 4. Add some likely unknown random user
|
||||||
// from the big table of users.
|
// Be careful with the method to get some random users
|
||||||
// It's much faster getting a random code and then get the first users
|
// from the big table of users.
|
||||||
// with codes >= that random code
|
// It's much faster getting a random code and then get the first users
|
||||||
// that getting all users and then ordering by rand.
|
// with codes >= that random code
|
||||||
"SELECT usr_data.UsrCod"
|
// that getting all users and then ordering by rand.
|
||||||
" FROM usr_data,"
|
"SELECT usr_data.UsrCod"
|
||||||
"(SELECT ROUND(RAND()*(SELECT MAX(UsrCod)"
|
" FROM usr_data,"
|
||||||
" FROM usr_data)) AS RandomUsrCod) AS random_usr" // a random user code
|
"(SELECT ROUND(RAND()*(SELECT MAX(UsrCod)"
|
||||||
" WHERE usr_data.UsrCod<>%ld"
|
" FROM usr_data)) AS RandomUsrCod) AS random_usr" // a random user code
|
||||||
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
" WHERE usr_data.UsrCod<>%ld"
|
||||||
" AND usr_data.FirstName<>''" // First name not empty
|
" AND usr_data.Surname1<>''" // Surname 1 not empty
|
||||||
"%s" // SubQuery4
|
" AND usr_data.FirstName<>''" // First name not empty
|
||||||
// Do not select my followed
|
"%s" // SubQuery4
|
||||||
" AND usr_data.UsrCod NOT IN"
|
// Do not select my followed
|
||||||
" (SELECT FollowedCod"
|
" AND usr_data.UsrCod NOT IN"
|
||||||
" FROM usr_follow"
|
" (SELECT FollowedCod"
|
||||||
" WHERE FollowerCod=%ld)"
|
" FROM usr_follow"
|
||||||
" AND usr_data.UsrCod>=random_usr.RandomUsrCod" // random user code could not exists in table of users
|
" WHERE FollowerCod=%ld)"
|
||||||
// Get only MaxUsrsToShow users
|
" AND usr_data.UsrCod>=random_usr.RandomUsrCod" // random user code could not exists in table of users
|
||||||
" LIMIT %lu"
|
// Get only MaxUsrsToShow users
|
||||||
")"
|
" LIMIT %u"
|
||||||
") AS UsrsToFollow"
|
")"
|
||||||
// Get only MaxUsrsToShow users
|
") AS UsrsToFollow"
|
||||||
" ORDER BY RAND()"
|
// Get only MaxUsrsToShow users
|
||||||
" LIMIT %lu",
|
" ORDER BY RAND()"
|
||||||
|
" LIMIT %u",
|
||||||
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
SubQuery1,
|
SubQuery1,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
SubQuery2,
|
SubQuery2,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
SubQuery3,
|
SubQuery3,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
MaxUsrsToShow * 2, // 2/3 likely known users
|
MaxUsrsToShow * 2, // 2/3 likely known users
|
||||||
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
SubQuery4,
|
SubQuery4,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
MaxUsrsToShow, // 1/3 likely unknown users
|
MaxUsrsToShow, // 1/3 likely unknown users
|
||||||
|
|
||||||
MaxUsrsToShow);
|
MaxUsrsToShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -675,20 +676,21 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Following;
|
extern const char *Txt_Following;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
struct UsrData FollowingUsrDat;
|
struct UsrData FollowingUsrDat;
|
||||||
|
|
||||||
/***** Show user's profile *****/
|
/***** Show user's profile *****/
|
||||||
if (Prf_ShowUserProfile (UsrDat))
|
if (Prf_ShowUserProfile (UsrDat))
|
||||||
{
|
{
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followed users",
|
NumUsrs = (unsigned)
|
||||||
"SELECT FollowedCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get followed users",
|
||||||
" FROM usr_follow"
|
"SELECT FollowedCod" // row[0]
|
||||||
" WHERE FollowerCod=%ld"
|
" FROM usr_follow"
|
||||||
" ORDER BY FollowTime DESC",
|
" WHERE FollowerCod=%ld"
|
||||||
UsrDat->UsrCod);
|
" ORDER BY FollowTime DESC",
|
||||||
|
UsrDat->UsrCod);
|
||||||
|
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
|
@ -755,8 +757,8 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Followers;
|
extern const char *Txt_Followers;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
struct UsrData FollowerUsrDat;
|
struct UsrData FollowerUsrDat;
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
|
|
||||||
|
@ -764,12 +766,13 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
if (Prf_ShowUserProfile (UsrDat))
|
if (Prf_ShowUserProfile (UsrDat))
|
||||||
{
|
{
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followers",
|
NumUsrs = (unsigned)
|
||||||
"SELECT FollowerCod"
|
DB_QuerySELECT (&mysql_res,"can not get followers",
|
||||||
" FROM usr_follow"
|
"SELECT FollowerCod"
|
||||||
" WHERE FollowedCod=%ld"
|
" FROM usr_follow"
|
||||||
" ORDER BY FollowTime DESC",
|
" WHERE FollowedCod=%ld"
|
||||||
UsrDat->UsrCod);
|
" ORDER BY FollowTime DESC",
|
||||||
|
UsrDat->UsrCod);
|
||||||
|
|
||||||
if (NumUsrs)
|
if (NumUsrs)
|
||||||
{
|
{
|
||||||
|
|
259
swad_forum.c
259
swad_forum.c
|
@ -1018,8 +1018,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
char FrameTitle[128 + Cns_MAX_BYTES_SUBJECT];
|
char FrameTitle[128 + Cns_MAX_BYTES_SUBJECT];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumRow;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumPst = 0; // Initialized to avoid warning
|
unsigned NumPst = 0; // Initialized to avoid warning
|
||||||
unsigned NumPsts;
|
unsigned NumPsts;
|
||||||
time_t ReadTimeUTC; // Read time of thread for the current user
|
time_t ReadTimeUTC; // Read time of thread for the current user
|
||||||
|
@ -1056,15 +1055,15 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
Hlp_COMMUNICATION_Forums_posts,Box_NOT_CLOSABLE);
|
Hlp_COMMUNICATION_Forums_posts,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/***** Get posts of a thread from database *****/
|
/***** Get posts of a thread from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get posts of a thread",
|
NumPsts = (unsigned)
|
||||||
"SELECT PstCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get posts of a thread",
|
||||||
"UNIX_TIMESTAMP(CreatTime)" // row[1]
|
"SELECT PstCod," // row[0]
|
||||||
" FROM for_posts"
|
"UNIX_TIMESTAMP(CreatTime)" // row[1]
|
||||||
" WHERE ThrCod=%ld"
|
" FROM for_posts"
|
||||||
" ORDER BY PstCod",
|
" WHERE ThrCod=%ld"
|
||||||
Thread.ThrCod);
|
" ORDER BY PstCod",
|
||||||
|
Thread.ThrCod);
|
||||||
|
|
||||||
NumPsts = (unsigned) NumRows;
|
|
||||||
LastSubject[0] = '\0';
|
LastSubject[0] = '\0';
|
||||||
if (NumPsts) // If there are posts...
|
if (NumPsts) // If there are posts...
|
||||||
{
|
{
|
||||||
|
@ -1125,7 +1124,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
|
|
||||||
CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
||||||
|
|
||||||
NumPst = (unsigned) NumRow;
|
NumPst = NumRow;
|
||||||
NewPst = (CreatTimeUTC > ReadTimeUTC);
|
NewPst = (CreatTimeUTC > ReadTimeUTC);
|
||||||
|
|
||||||
if (NewPst && NumRow == PaginationPsts.LastItemVisible)
|
if (NewPst && NumRow == PaginationPsts.LastItemVisible)
|
||||||
|
@ -1140,7 +1139,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
||||||
|
|
||||||
/* Show post */
|
/* Show post */
|
||||||
For_ShowAForumPost (Forums,NumPst,
|
For_ShowAForumPost (Forums,NumPst,
|
||||||
(NumRow == NumRows),LastSubject,
|
(NumRow == NumPsts),LastSubject,
|
||||||
NewPst,ICanModerateForum);
|
NewPst,ICanModerateForum);
|
||||||
|
|
||||||
/* Mark possible notification as seen */
|
/* Mark possible notification as seen */
|
||||||
|
@ -1367,10 +1366,9 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
|
||||||
|
|
||||||
/***** Get data of a post from database *****/
|
/***** Get data of a post from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a post",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a post",
|
||||||
"SELECT UsrCod," // row[0]
|
"SELECT UsrCod," // row[0]
|
||||||
"UNIX_TIMESTAMP(CreatTime)," // row[1]
|
"UNIX_TIMESTAMP(CreatTime)," // row[1]
|
||||||
"Subject," // row[2]
|
"Subject," // row[2]
|
||||||
|
@ -1378,10 +1376,7 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
"MedCod" // row[4]
|
"MedCod" // row[4]
|
||||||
" FROM for_posts"
|
" FROM for_posts"
|
||||||
" WHERE PstCod=%ld",
|
" WHERE PstCod=%ld",
|
||||||
PstCod);
|
PstCod) != 1)
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Internal error in database when getting data of a post.");
|
Lay_ShowErrorAndExit ("Internal error in database when getting data of a post.");
|
||||||
|
|
||||||
/***** Get number of rows *****/
|
/***** Get number of rows *****/
|
||||||
|
@ -1690,69 +1685,68 @@ static void For_ShowForumList (struct For_Forums *Forums)
|
||||||
IsLastItemInLevel);
|
IsLastItemInLevel);
|
||||||
|
|
||||||
/* Get my centers in this institution from database */
|
/* Get my centers in this institution from database */
|
||||||
if ((NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
InsCod,
|
InsCod,&mysql_resCtr);
|
||||||
&mysql_resCtr)) > 0) // Centers found in this institution
|
for (NumCtr = 0;
|
||||||
for (NumCtr = 0;
|
NumCtr < NumCtrs;
|
||||||
NumCtr < NumCtrs;
|
NumCtr++)
|
||||||
NumCtr++)
|
{
|
||||||
{
|
/* Get next center */
|
||||||
/* Get next center */
|
row = mysql_fetch_row (mysql_resCtr);
|
||||||
row = mysql_fetch_row (mysql_resCtr);
|
CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Links to forums of this center */
|
/* Links to forums of this center */
|
||||||
if (For_WriteLinksToCtrForums (Forums,
|
if (For_WriteLinksToCtrForums (Forums,
|
||||||
CtrCod,
|
CtrCod,
|
||||||
(NumCtr == NumCtrs - 1),
|
(NumCtr == NumCtrs - 1),
|
||||||
IsLastItemInLevel) > 0)
|
IsLastItemInLevel) > 0)
|
||||||
{
|
{
|
||||||
/* Get my degrees in this institution from database */
|
/* Get my degrees in this institution from database */
|
||||||
if ((NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
if ((NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
CtrCod,
|
CtrCod,
|
||||||
&mysql_resDeg)) > 0) // Degrees found in this center
|
&mysql_resDeg)) > 0) // Degrees found in this center
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
NumDeg < NumDegs;
|
NumDeg < NumDegs;
|
||||||
NumDeg++)
|
NumDeg++)
|
||||||
|
{
|
||||||
|
/* Get next degree */
|
||||||
|
row = mysql_fetch_row (mysql_resDeg);
|
||||||
|
DegCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
|
/* Links to forums of this degree */
|
||||||
|
if (For_WriteLinksToDegForums (Forums,
|
||||||
|
DegCod,
|
||||||
|
(NumDeg == NumDegs - 1),
|
||||||
|
IsLastItemInLevel) > 0)
|
||||||
{
|
{
|
||||||
/* Get next degree */
|
/* Get my courses in this degree from database */
|
||||||
row = mysql_fetch_row (mysql_resDeg);
|
NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
DegCod = Str_ConvertStrCodToLongCod (row[0]);
|
DegCod,
|
||||||
|
&mysql_resCrs);
|
||||||
/* Links to forums of this degree */
|
for (NumCrs = 0;
|
||||||
if (For_WriteLinksToDegForums (Forums,
|
NumCrs < NumCrss;
|
||||||
DegCod,
|
NumCrs++)
|
||||||
(NumDeg == NumDegs - 1),
|
|
||||||
IsLastItemInLevel) > 0)
|
|
||||||
{
|
{
|
||||||
/* Get my courses in this degree from database */
|
/* Get next course */
|
||||||
if ((NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,
|
row = mysql_fetch_row (mysql_resCrs);
|
||||||
DegCod,
|
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
&mysql_resCrs)) > 0) // Courses found in this degree
|
|
||||||
for (NumCrs = 0;
|
|
||||||
NumCrs < NumCrss;
|
|
||||||
NumCrs++)
|
|
||||||
{
|
|
||||||
/* Get next course */
|
|
||||||
row = mysql_fetch_row (mysql_resCrs);
|
|
||||||
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Links to forums of this course */
|
/* Links to forums of this course */
|
||||||
For_WriteLinksToCrsForums (Forums,
|
For_WriteLinksToCrsForums (Forums,
|
||||||
CrsCod,
|
CrsCod,
|
||||||
(NumCrs == NumCrss - 1),
|
(NumCrs == NumCrss - 1),
|
||||||
IsLastItemInLevel);
|
IsLastItemInLevel);
|
||||||
}
|
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
|
||||||
DB_FreeMySQLResult (&mysql_resCrs);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_resDeg);
|
DB_FreeMySQLResult (&mysql_resCrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free structure that stores the query result */
|
||||||
|
DB_FreeMySQLResult (&mysql_resDeg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_resCtr);
|
DB_FreeMySQLResult (&mysql_resCtr);
|
||||||
|
@ -2286,7 +2280,6 @@ static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum,
|
||||||
char SubQuery[256];
|
char SubQuery[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumThrsWithNewPosts = NumThreads; // By default, all the threads are new to me
|
unsigned NumThrsWithNewPosts = NumThreads; // By default, all the threads are new to me
|
||||||
|
|
||||||
/***** Get last time I read this forum from database *****/
|
/***** Get last time I read this forum from database *****/
|
||||||
|
@ -2294,17 +2287,18 @@ static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum,
|
||||||
sprintf (SubQuery," AND for_threads.Location=%ld",Forum->Location);
|
sprintf (SubQuery," AND for_threads.Location=%ld",Forum->Location);
|
||||||
else
|
else
|
||||||
SubQuery[0] = '\0';
|
SubQuery[0] = '\0';
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the date of reading of a forum",
|
if (DB_QuerySELECT (&mysql_res,"can not get the date of reading of a forum",
|
||||||
"SELECT IFNULL(MAX(for_read.ReadTime)," // row[0]
|
"SELECT IFNULL(MAX(for_read.ReadTime)," // row[0]
|
||||||
"FROM_UNIXTIME(0))" // row[1]
|
"FROM_UNIXTIME(0))" // row[1]
|
||||||
" FROM for_read,"
|
" FROM for_read,"
|
||||||
"for_threads"
|
"for_threads"
|
||||||
" WHERE for_read.UsrCod=%ld"
|
" WHERE for_read.UsrCod=%ld"
|
||||||
" AND for_read.ThrCod=for_threads.ThrCod"
|
" AND for_read.ThrCod=for_threads.ThrCod"
|
||||||
" AND for_threads.ForumType=%u%s",
|
" AND for_threads.ForumType=%u"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
"%s",
|
||||||
(unsigned) Forum->Type,SubQuery);
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
if (NumRows)
|
(unsigned) Forum->Type,
|
||||||
|
SubQuery))
|
||||||
{
|
{
|
||||||
/***** Get number of threads with a last message modify time > newest read time (row[0]) *****/
|
/***** Get number of threads with a last message modify time > newest read time (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2354,20 +2348,16 @@ static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumUnreadPosts = NumPostsInThr; // By default, all the posts are unread by me
|
unsigned NumUnreadPosts = NumPostsInThr; // By default, all the posts are unread by me
|
||||||
|
|
||||||
/***** Get last time I read this thread from database *****/
|
/***** Get last time I read this thread from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the date of reading"
|
if (DB_QuerySELECT (&mysql_res,"can not get the date of reading of a thread",
|
||||||
" of a thread",
|
"SELECT ReadTime" // row[0]
|
||||||
"SELECT ReadTime" // row[0]
|
" FROM for_read"
|
||||||
" FROM for_read"
|
" WHERE ThrCod=%ld"
|
||||||
" WHERE ThrCod=%ld"
|
" AND UsrCod=%ld",
|
||||||
" AND UsrCod=%ld",
|
ThrCod,
|
||||||
ThrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
|
|
||||||
/***** Get if last time I read this thread exists in database *****/
|
|
||||||
if (NumRows)
|
|
||||||
{
|
{
|
||||||
/***** Get the number of posts in thread with a modify time > newest read time for me (row[0]) *****/
|
/***** Get the number of posts in thread with a modify time > newest read time for me (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2472,24 +2462,30 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
|
||||||
switch (Forums->ThreadsOrder)
|
switch (Forums->ThreadsOrder)
|
||||||
{
|
{
|
||||||
case Dat_START_TIME: // First post time
|
case Dat_START_TIME: // First post time
|
||||||
NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
|
NumThrs = (unsigned)
|
||||||
"SELECT for_threads.ThrCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
|
||||||
" FROM for_threads,"
|
"SELECT for_threads.ThrCod" // row[0]
|
||||||
"for_posts"
|
" FROM for_threads,"
|
||||||
" WHERE for_threads.ForumType=%u%s"
|
"for_posts"
|
||||||
" AND for_threads.FirstPstCod=for_posts.PstCod"
|
" WHERE for_threads.ForumType=%u"
|
||||||
" ORDER BY for_posts.CreatTime DESC",
|
"%s"
|
||||||
(unsigned) Forums->Forum.Type,SubQuery);
|
" AND for_threads.FirstPstCod=for_posts.PstCod"
|
||||||
|
" ORDER BY for_posts.CreatTime DESC",
|
||||||
|
(unsigned) Forums->Forum.Type,
|
||||||
|
SubQuery);
|
||||||
break;
|
break;
|
||||||
case Dat_END_TIME: // Last post time
|
case Dat_END_TIME: // Last post time
|
||||||
NumThrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
|
NumThrs = (unsigned)
|
||||||
"SELECT for_threads.ThrCod" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get thread of a forum",
|
||||||
" FROM for_threads,"
|
"SELECT for_threads.ThrCod" // row[0]
|
||||||
"for_posts"
|
" FROM for_threads,"
|
||||||
" WHERE for_threads.ForumType=%u%s"
|
"for_posts"
|
||||||
" AND for_threads.LastPstCod=for_posts.PstCod"
|
" WHERE for_threads.ForumType=%u"
|
||||||
" ORDER BY for_posts.CreatTime DESC",
|
"%s"
|
||||||
(unsigned) Forums->Forum.Type,SubQuery);
|
" AND for_threads.LastPstCod=for_posts.PstCod"
|
||||||
|
" ORDER BY for_posts.CreatTime DESC",
|
||||||
|
(unsigned) Forums->Forum.Type,
|
||||||
|
SubQuery);
|
||||||
break;
|
break;
|
||||||
default: // Impossible
|
default: // Impossible
|
||||||
return;
|
return;
|
||||||
|
@ -3654,29 +3650,24 @@ static void For_GetThreadData (struct For_Thread *Thr)
|
||||||
extern const char *Txt_no_subject;
|
extern const char *Txt_no_subject;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
Dat_StartEndTime_t Order;
|
Dat_StartEndTime_t Order;
|
||||||
|
|
||||||
/***** Get data of a thread from database *****/
|
/***** Get data of a thread from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a thread of a forum",
|
||||||
" of a thread of a forum",
|
"SELECT m0.PstCod," // row[0]
|
||||||
"SELECT m0.PstCod," // row[0]
|
"m1.PstCod," // row[1]
|
||||||
"m1.PstCod," // row[1]
|
"m0.UsrCod," // row[2]
|
||||||
"m0.UsrCod," // row[2]
|
"m1.UsrCod," // row[3]
|
||||||
"m1.UsrCod," // row[3]
|
"UNIX_TIMESTAMP(m0.CreatTime)," // row[4]
|
||||||
"UNIX_TIMESTAMP(m0.CreatTime)," // row[4]
|
"UNIX_TIMESTAMP(m1.CreatTime)," // row[5]
|
||||||
"UNIX_TIMESTAMP(m1.CreatTime)," // row[5]
|
"m0.Subject"
|
||||||
"m0.Subject"
|
" FROM for_threads,"
|
||||||
" FROM for_threads,"
|
"for_posts AS m0,"
|
||||||
"for_posts AS m0,"
|
"for_posts AS m1"
|
||||||
"for_posts AS m1"
|
" WHERE for_threads.ThrCod=%ld"
|
||||||
" WHERE for_threads.ThrCod=%ld"
|
" AND for_threads.FirstPstCod=m0.PstCod"
|
||||||
" AND for_threads.FirstPstCod=m0.PstCod"
|
" AND for_threads.LastPstCod=m1.PstCod",
|
||||||
" AND for_threads.LastPstCod=m1.PstCod",
|
Thr->ThrCod) != 1)
|
||||||
Thr->ThrCod);
|
|
||||||
|
|
||||||
/***** The result of the query should have one row *****/
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting data of a thread of a forum.");
|
Lay_ShowErrorAndExit ("Error when getting data of a thread of a forum.");
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
|
98
swad_game.c
98
swad_game.c
|
@ -866,7 +866,6 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
char *HiddenSubQuery;
|
char *HiddenSubQuery;
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
|
||||||
unsigned NumGame;
|
unsigned NumGame;
|
||||||
|
|
||||||
/***** Free list of games *****/
|
/***** Free list of games *****/
|
||||||
|
@ -895,30 +894,30 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get list of games from database *****/
|
/***** Get list of games from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get games",
|
Games->Num = (unsigned)
|
||||||
"SELECT gam_games.GamCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get games",
|
||||||
"MIN(mch_matches.StartTime) AS StartTime," // row[1]
|
"SELECT gam_games.GamCod," // row[0]
|
||||||
"MAX(mch_matches.EndTime) AS EndTime" // row[2]
|
"MIN(mch_matches.StartTime) AS StartTime," // row[1]
|
||||||
" FROM gam_games"
|
"MAX(mch_matches.EndTime) AS EndTime" // row[2]
|
||||||
" LEFT JOIN mch_matches"
|
" FROM gam_games"
|
||||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
" LEFT JOIN mch_matches"
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||||
"%s"
|
" WHERE gam_games.CrsCod=%ld"
|
||||||
" GROUP BY gam_games.GamCod"
|
"%s"
|
||||||
" ORDER BY %s",
|
" GROUP BY gam_games.GamCod"
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
" ORDER BY %s",
|
||||||
HiddenSubQuery,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
OrderBySubQuery[SelectedOrder]);
|
HiddenSubQuery,
|
||||||
|
OrderBySubQuery[SelectedOrder]);
|
||||||
|
|
||||||
/***** Free allocated memory for subquery *****/
|
/***** Free allocated memory for subquery *****/
|
||||||
free (HiddenSubQuery);
|
free (HiddenSubQuery);
|
||||||
|
|
||||||
if (NumRows) // Games found...
|
if (Games->Num) // Games found...
|
||||||
{
|
{
|
||||||
Games->Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list of games *****/
|
/***** Create list of games *****/
|
||||||
if ((Games->Lst = malloc (NumRows * sizeof (*Games->Lst))) == NULL)
|
if ((Games->Lst = malloc ((size_t) Games->Num *
|
||||||
|
sizeof (*Games->Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the games codes *****/
|
/***** Get the games codes *****/
|
||||||
|
@ -932,8 +931,6 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong game code.");
|
Lay_ShowErrorAndExit ("Error: wrong game code.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Games->Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1017,25 +1014,23 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get data of game from database *****/
|
/***** Get data of game from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get game data",
|
if (DB_QuerySELECT (&mysql_res,"can not get game data",
|
||||||
"SELECT gam_games.GamCod," // row[0]
|
"SELECT gam_games.GamCod," // row[0]
|
||||||
"gam_games.CrsCod," // row[1]
|
"gam_games.CrsCod," // row[1]
|
||||||
"gam_games.Hidden," // row[2]
|
"gam_games.Hidden," // row[2]
|
||||||
"gam_games.UsrCod," // row[3]
|
"gam_games.UsrCod," // row[3]
|
||||||
"gam_games.MaxGrade," // row[4]
|
"gam_games.MaxGrade," // row[4]
|
||||||
"gam_games.Visibility," // row[5]
|
"gam_games.Visibility," // row[5]
|
||||||
"gam_games.Title" // row[6]
|
"gam_games.Title" // row[6]
|
||||||
" FROM gam_games"
|
" FROM gam_games"
|
||||||
" LEFT JOIN mch_matches"
|
" LEFT JOIN mch_matches"
|
||||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||||
" WHERE gam_games.GamCod=%ld"
|
" WHERE gam_games.GamCod=%ld"
|
||||||
" AND gam_games.CrsCod='%ld'", // Extra check
|
" AND gam_games.CrsCod='%ld'", // Extra check
|
||||||
Game->GamCod,
|
Game->GamCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod)) // Game found...
|
||||||
if (NumRows) // Game found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1082,13 +1077,12 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
|
||||||
if (Game->GamCod > 0)
|
if (Game->GamCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get start and end times from database *****/
|
/***** Get start and end times from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get game data",
|
if (DB_QuerySELECT (&mysql_res,"can not get game data",
|
||||||
"SELECT UNIX_TIMESTAMP(MIN(StartTime))," // row[0]
|
"SELECT UNIX_TIMESTAMP(MIN(StartTime))," // row[0]
|
||||||
"UNIX_TIMESTAMP(MAX(EndTime))" // row[1]
|
"UNIX_TIMESTAMP(MAX(EndTime))" // row[1]
|
||||||
" FROM mch_matches"
|
" FROM mch_matches"
|
||||||
" WHERE GamCod=%ld",
|
" WHERE GamCod=%ld",
|
||||||
Game->GamCod);
|
Game->GamCod))
|
||||||
if (NumRows)
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1935,13 +1929,13 @@ static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game
|
||||||
|
|
||||||
/***** Get data of questions from database *****/
|
/***** Get data of questions from database *****/
|
||||||
NumQsts = (unsigned)
|
NumQsts = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get game questions",
|
DB_QuerySELECT (&mysql_res,"can not get game questions",
|
||||||
"SELECT QstInd," // row[0]
|
"SELECT QstInd," // row[0]
|
||||||
"QstCod" // row[1]
|
"QstCod" // row[1]
|
||||||
" FROM gam_questions"
|
" FROM gam_questions"
|
||||||
" WHERE GamCod=%ld"
|
" WHERE GamCod=%ld"
|
||||||
" ORDER BY QstInd",
|
" ORDER BY QstInd",
|
||||||
Game->GamCod);
|
Game->GamCod);
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Games->GamCod = Game->GamCod;
|
Games->GamCod = Game->GamCod;
|
||||||
|
|
117
swad_group.c
117
swad_group.c
|
@ -2935,7 +2935,6 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
unsigned NumGrp;
|
unsigned NumGrp;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
struct GroupType *GrpTyp;
|
struct GroupType *GrpTyp;
|
||||||
struct Group *Grp;
|
struct Group *Grp;
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
|
@ -2952,13 +2951,11 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
if (GrpTyp->NumGrps) // If there are groups of this type...
|
if (GrpTyp->NumGrps) // If there are groups of this type...
|
||||||
{
|
{
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
if ((NumRows = Grp_GetGrpsOfType (GrpTyp->GrpTypCod,&mysql_res)) > 0) // Groups found...
|
GrpTyp->NumGrps = Grp_GetGrpsOfType (GrpTyp->GrpTypCod,&mysql_res);
|
||||||
|
if (GrpTyp->NumGrps > 0) // Groups found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to GrpTyp->NumGrps
|
|
||||||
GrpTyp->NumGrps = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with groups of this type *****/
|
/***** Create list with groups of this type *****/
|
||||||
if ((GrpTyp->LstGrps = calloc (GrpTyp->NumGrps,
|
if ((GrpTyp->LstGrps = calloc ((size_t) GrpTyp->NumGrps,
|
||||||
sizeof (*GrpTyp->LstGrps))) == NULL)
|
sizeof (*GrpTyp->LstGrps))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -3005,9 +3002,6 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
||||||
Grp->FileZones = (row[6][0] == 'Y');
|
Grp->FileZones = (row[6][0] == 'Y');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Error: groups should be found, but really they haven't be found.
|
|
||||||
// This never should happen.
|
|
||||||
GrpTyp->NumGrps = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -3085,24 +3079,25 @@ static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod)
|
||||||
/******************** Get groups of a type in this course ********************/
|
/******************** Get groups of a type in this course ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
unsigned Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get groups of a type from database *****/
|
/***** Get groups of a type from database *****/
|
||||||
// Don't use INNER JOIN because there are groups without assigned room
|
// Don't use INNER JOIN because there are groups without assigned room
|
||||||
return DB_QuerySELECT (mysql_res,"can not get groups of a type",
|
return (unsigned)
|
||||||
"SELECT grp_groups.GrpCod," // row[0]
|
DB_QuerySELECT (mysql_res,"can not get groups of a type",
|
||||||
"grp_groups.GrpName," // row[1]
|
"SELECT grp_groups.GrpCod," // row[0]
|
||||||
"grp_groups.RooCod," // row[2]
|
"grp_groups.GrpName," // row[1]
|
||||||
"roo_rooms.ShortName," // row[3]
|
"grp_groups.RooCod," // row[2]
|
||||||
"grp_groups.MaxStudents," // row[4]
|
"roo_rooms.ShortName," // row[3]
|
||||||
"grp_groups.Open," // row[5]
|
"grp_groups.MaxStudents," // row[4]
|
||||||
"grp_groups.FileZones" // row[6]
|
"grp_groups.Open," // row[5]
|
||||||
" FROM grp_groups"
|
"grp_groups.FileZones" // row[6]
|
||||||
" LEFT JOIN roo_rooms"
|
" FROM grp_groups"
|
||||||
" ON grp_groups.RooCod=roo_rooms.RooCod"
|
" LEFT JOIN roo_rooms"
|
||||||
" WHERE grp_groups.GrpTypCod=%ld"
|
" ON grp_groups.RooCod=roo_rooms.RooCod"
|
||||||
" ORDER BY grp_groups.GrpName",
|
" WHERE grp_groups.GrpTypCod=%ld"
|
||||||
GrpTypCod);
|
" ORDER BY grp_groups.GrpName",
|
||||||
|
GrpTypCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3177,7 +3172,6 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Reset values *****/
|
/***** Reset values *****/
|
||||||
GrpDat->GrpTypCod = -1L;
|
GrpDat->GrpTypCod = -1L;
|
||||||
|
@ -3195,26 +3189,24 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
||||||
if (GrpDat->GrpCod > 0)
|
if (GrpDat->GrpCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a group from database *****/
|
/***** Get data of a group from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a group",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a group",
|
||||||
"SELECT grp_groups.GrpTypCod," // row[0]
|
"SELECT grp_groups.GrpTypCod," // row[0]
|
||||||
"grp_types.CrsCod," // row[1]
|
"grp_types.CrsCod," // row[1]
|
||||||
"grp_types.GrpTypName," // row[2]
|
"grp_types.GrpTypName," // row[2]
|
||||||
"grp_types.Multiple," // row[3]
|
"grp_types.Multiple," // row[3]
|
||||||
"grp_groups.GrpName," // row[4]
|
"grp_groups.GrpName," // row[4]
|
||||||
"grp_groups.RooCod," // row[5]
|
"grp_groups.RooCod," // row[5]
|
||||||
"roo_rooms.ShortName," // row[6]
|
"roo_rooms.ShortName," // row[6]
|
||||||
"grp_groups.MaxStudents," // row[7]
|
"grp_groups.MaxStudents," // row[7]
|
||||||
"grp_groups.Open," // row[8]
|
"grp_groups.Open," // row[8]
|
||||||
"grp_groups.FileZones" // row[9]
|
"grp_groups.FileZones" // row[9]
|
||||||
" FROM (grp_groups,"
|
" FROM (grp_groups,"
|
||||||
"grp_types)"
|
"grp_types)"
|
||||||
" LEFT JOIN roo_rooms"
|
" LEFT JOIN roo_rooms"
|
||||||
" ON grp_groups.RooCod=roo_rooms.RooCod"
|
" ON grp_groups.RooCod=roo_rooms.RooCod"
|
||||||
" WHERE grp_groups.GrpCod=%ld"
|
" WHERE grp_groups.GrpCod=%ld"
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod",
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod",
|
||||||
GrpDat->GrpCod);
|
GrpDat->GrpCod) == 1)
|
||||||
|
|
||||||
if (NumRows == 1)
|
|
||||||
{
|
{
|
||||||
/***** Get data of group *****/
|
/***** Get data of group *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3735,34 +3727,35 @@ void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GroupNames)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumGrps;
|
||||||
unsigned long NumRows;
|
unsigned NumGrp;
|
||||||
size_t MaxLength = (Grp_MAX_BYTES_GROUP_NAME + 2) *
|
size_t MaxLength = (Grp_MAX_BYTES_GROUP_NAME + 2) *
|
||||||
Gbl.Crs.Grps.GrpTypes.NumGrpsTotal;
|
Gbl.Crs.Grps.GrpTypes.NumGrpsTotal;
|
||||||
|
|
||||||
/***** Get the names of groups which a user belongs to, from database *****/
|
/***** Get the names of groups which a user belongs to, from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the names of groups"
|
NumGrps = (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (&mysql_res,"can not get names of groups a user belongs to",
|
||||||
"SELECT grp_groups.GrpName" // row[0]
|
"SELECT grp_groups.GrpName" // row[0]
|
||||||
" FROM grp_groups,"
|
" FROM grp_groups,"
|
||||||
"grp_users"
|
"grp_users"
|
||||||
" WHERE grp_groups.GrpTypCod=%ld"
|
" WHERE grp_groups.GrpTypCod=%ld"
|
||||||
" AND grp_groups.GrpCod=grp_users.GrpCod"
|
" AND grp_groups.GrpCod=grp_users.GrpCod"
|
||||||
" AND grp_users.UsrCod=%ld"
|
" AND grp_users.UsrCod=%ld"
|
||||||
" ORDER BY grp_groups.GrpName",
|
" ORDER BY grp_groups.GrpName",
|
||||||
GrpTypCod,UsrCod);
|
GrpTypCod,
|
||||||
|
UsrCod);
|
||||||
|
|
||||||
/***** Get the groups *****/
|
/***** Get the groups *****/
|
||||||
GroupNames[0] = '\0';
|
GroupNames[0] = '\0';
|
||||||
for (NumRow = 0;
|
for (NumGrp = 0;
|
||||||
NumRow < NumRows;
|
NumGrp < NumGrps;
|
||||||
NumRow++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* El group name in row[0] */
|
/* Group name is in row[0] */
|
||||||
if (NumRow)
|
if (NumGrp)
|
||||||
Str_Concat (GroupNames,", ",MaxLength);
|
Str_Concat (GroupNames,", ",MaxLength);
|
||||||
Str_Concat (GroupNames,row[0],MaxLength);
|
Str_Concat (GroupNames,row[0],MaxLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ void Grp_FreeListGrpTypesAndGrps (void);
|
||||||
void Grp_OpenGroupsAutomatically (void);
|
void Grp_OpenGroupsAutomatically (void);
|
||||||
void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes);
|
void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes);
|
||||||
unsigned Grp_CountNumGrpsInCurrentCrs (void);
|
unsigned Grp_CountNumGrpsInCurrentCrs (void);
|
||||||
unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res);
|
unsigned Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res);
|
||||||
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat);
|
void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat);
|
||||||
bool Grp_CheckIfGroupExists (long GrpCod);
|
bool Grp_CheckIfGroupExists (long GrpCod);
|
||||||
bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod);
|
bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod);
|
||||||
|
|
78
swad_info.c
78
swad_info.c
|
@ -524,8 +524,8 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumInfos;
|
||||||
unsigned long NumRows;
|
unsigned NumInfo;
|
||||||
Inf_InfoType_t InfoType;
|
Inf_InfoType_t InfoType;
|
||||||
|
|
||||||
/***** Reset must-be-read to false for all info types *****/
|
/***** Reset must-be-read to false for all info types *****/
|
||||||
|
@ -535,25 +535,25 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
||||||
Gbl.Crs.Info.MustBeRead[InfoType] = false;
|
Gbl.Crs.Info.MustBeRead[InfoType] = false;
|
||||||
|
|
||||||
/***** Get info types where students must read info *****/
|
/***** Get info types where students must read info *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get if you must read"
|
NumInfos = (unsigned)
|
||||||
" any course info",
|
DB_QuerySELECT (&mysql_res,"can not get if you must read any course info",
|
||||||
"SELECT InfoType" // row[0]
|
"SELECT InfoType" // row[0]
|
||||||
" FROM crs_info_src"
|
" FROM crs_info_src"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND MustBeRead='Y'"
|
" AND MustBeRead='Y'"
|
||||||
" AND InfoType NOT IN"
|
" AND InfoType NOT IN"
|
||||||
" (SELECT InfoType"
|
" (SELECT InfoType"
|
||||||
" FROM crs_info_read"
|
" FROM crs_info_read"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" AND CrsCod=%ld)",
|
" AND CrsCod=%ld)",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** Set must-be-read to true for each rown in result *****/
|
/***** Set must-be-read to true for each rown in result *****/
|
||||||
for (NumRow = 0;
|
for (NumInfo = 0;
|
||||||
NumRow < NumRows;
|
NumInfo < NumInfos;
|
||||||
NumRow++)
|
NumInfo++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
return (NumRows != 0);
|
return (NumInfos != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1500,24 +1500,20 @@ void Inf_GetAndCheckInfoSrcFromDB (struct Syl_Syllabus *Syllabus,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Set default values *****/
|
/***** Set default values *****/
|
||||||
*InfoSrc = Inf_INFO_SRC_NONE;
|
*InfoSrc = Inf_INFO_SRC_NONE;
|
||||||
*MustBeRead = false;
|
*MustBeRead = false;
|
||||||
|
|
||||||
/***** Get info source for a specific type of info from database *****/
|
/***** Get info source for a specific type of info from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get info source",
|
if (DB_QuerySELECT (&mysql_res,"can not get info source",
|
||||||
"SELECT InfoSrc," // row[0]
|
"SELECT InfoSrc," // row[0]
|
||||||
"MustBeRead" // row[1]
|
"MustBeRead" // row[1]
|
||||||
" FROM crs_info_src"
|
" FROM crs_info_src"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND InfoType='%s'",
|
" AND InfoType='%s'",
|
||||||
CrsCod,
|
CrsCod,
|
||||||
Inf_NamesInDBForInfoType[InfoType]);
|
Inf_NamesInDBForInfoType[InfoType]) == 1)
|
||||||
|
|
||||||
/***** The result of the query must have one row or none *****/
|
|
||||||
if (NumRows == 1)
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1528,13 +1524,12 @@ void Inf_GetAndCheckInfoSrcFromDB (struct Syl_Syllabus *Syllabus,
|
||||||
/* Get if students must read info (row[1]) */
|
/* Get if students must read info (row[1]) */
|
||||||
*MustBeRead = (row[1][0] == 'Y');
|
*MustBeRead = (row[1][0] == 'Y');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error when getting info source.");
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
if (NumRows > 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting info source.");
|
|
||||||
|
|
||||||
/***** If info is empty, return Inf_INFO_SRC_NONE *****/
|
/***** If info is empty, return Inf_INFO_SRC_NONE *****/
|
||||||
switch (*InfoSrc)
|
switch (*InfoSrc)
|
||||||
{
|
{
|
||||||
|
@ -1663,21 +1658,17 @@ void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get info source for a specific type of course information
|
/***** Get info source for a specific type of course information
|
||||||
(bibliography, FAQ, links or evaluation) from database *****/
|
(bibliography, FAQ, links or evaluation) from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get info text",
|
if (DB_QuerySELECT (&mysql_res,"can not get info text",
|
||||||
"SELECT InfoTxtHTML," // row[0]
|
"SELECT InfoTxtHTML," // row[0]
|
||||||
"InfoTxtMD" // row[1]
|
"InfoTxtMD" // row[1]
|
||||||
" FROM crs_info_txt"
|
" FROM crs_info_txt"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND InfoType='%s'",
|
" AND InfoType='%s'",
|
||||||
CrsCod,
|
CrsCod,
|
||||||
Inf_NamesInDBForInfoType[InfoType]);
|
Inf_NamesInDBForInfoType[InfoType]) == 1)
|
||||||
|
|
||||||
/***** The result of the query must have one row or none *****/
|
|
||||||
if (NumRows == 1)
|
|
||||||
{
|
{
|
||||||
/* Get info text */
|
/* Get info text */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1695,14 +1686,11 @@ void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
|
||||||
if (InfoTxtHTML)
|
if (InfoTxtHTML)
|
||||||
InfoTxtHTML[0] = '\0';
|
InfoTxtHTML[0] = '\0';
|
||||||
if (InfoTxtMD)
|
if (InfoTxtMD)
|
||||||
InfoTxtMD [0] = '\0';
|
InfoTxtMD [0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
if (NumRows > 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting info text.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -628,31 +628,28 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
|
||||||
unsigned NumIns;
|
unsigned NumIns;
|
||||||
struct Ins_Instit *Ins;
|
struct Ins_Instit *Ins;
|
||||||
|
|
||||||
/***** Get institutions from database *****/
|
/***** Get institutions from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
Gbl.Hierarchy.Inss.Num = (unsigned)
|
||||||
"SELECT InsCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"CtyCod," // row[1]
|
"SELECT InsCod," // row[0]
|
||||||
"Status," // row[2]
|
"CtyCod," // row[1]
|
||||||
"RequesterUsrCod," // row[3]
|
"Status," // row[2]
|
||||||
"ShortName," // row[4]
|
"RequesterUsrCod," // row[3]
|
||||||
"FullName," // row[5]
|
"ShortName," // row[4]
|
||||||
"WWW" // row[6]
|
"FullName," // row[5]
|
||||||
" FROM ins_instits"
|
"WWW" // row[6]
|
||||||
" WHERE CtyCod=%ld"
|
" FROM ins_instits"
|
||||||
" ORDER BY FullName",
|
" WHERE CtyCod=%ld"
|
||||||
CtyCod);
|
" ORDER BY FullName",
|
||||||
|
CtyCod);
|
||||||
|
|
||||||
if (NumRows) // Institutions found...
|
if (Gbl.Hierarchy.Inss.Num) // Institutions found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to Deg->NumCourses
|
|
||||||
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with institutions *****/
|
/***** Create list with institutions *****/
|
||||||
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Inss.Lst = calloc ((size_t) Gbl.Hierarchy.Inss.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -672,10 +669,7 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Gbl.Hierarchy.Inss.Num = 0;
|
|
||||||
Gbl.Hierarchy.Inss.Lst = NULL;
|
Gbl.Hierarchy.Inss.Lst = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -695,52 +689,49 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
|
||||||
unsigned NumIns;
|
unsigned NumIns;
|
||||||
struct Ins_Instit *Ins;
|
struct Ins_Instit *Ins;
|
||||||
|
|
||||||
/***** Get institutions from database *****/
|
/***** Get institutions from database *****/
|
||||||
/* Query database */
|
/* Query database */
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
Gbl.Hierarchy.Inss.Num = (unsigned)
|
||||||
"(SELECT ins_instits.InsCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"ins_instits.CtyCod," // row[1]
|
"(SELECT ins_instits.InsCod," // row[0]
|
||||||
"ins_instits.Status," // row[2]
|
"ins_instits.CtyCod," // row[1]
|
||||||
"ins_instits.RequesterUsrCod," // row[3]
|
"ins_instits.Status," // row[2]
|
||||||
"ins_instits.ShortName," // row[4]
|
"ins_instits.RequesterUsrCod," // row[3]
|
||||||
"ins_instits.FullName," // row[5]
|
"ins_instits.ShortName," // row[4]
|
||||||
"ins_instits.WWW," // row[6]
|
"ins_instits.FullName," // row[5]
|
||||||
"COUNT(*) AS NumUsrs" // row[7]
|
"ins_instits.WWW," // row[6]
|
||||||
" FROM ins_instits,"
|
"COUNT(*) AS NumUsrs" // row[7]
|
||||||
"usr_data"
|
" FROM ins_instits,"
|
||||||
" WHERE ins_instits.CtyCod=%ld"
|
"usr_data"
|
||||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
" WHERE ins_instits.CtyCod=%ld"
|
||||||
" GROUP BY ins_instits.InsCod)"
|
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||||
" UNION "
|
" GROUP BY ins_instits.InsCod)"
|
||||||
"(SELECT InsCod," // row[0]
|
" UNION "
|
||||||
"CtyCod," // row[1]
|
"(SELECT InsCod," // row[0]
|
||||||
"Status," // row[2]
|
"CtyCod," // row[1]
|
||||||
"RequesterUsrCod," // row[3]
|
"Status," // row[2]
|
||||||
"ShortName," // row[4]
|
"RequesterUsrCod," // row[3]
|
||||||
"FullName," // row[5]
|
"ShortName," // row[4]
|
||||||
"WWW," // row[6]
|
"FullName," // row[5]
|
||||||
"0 AS NumUsrs" // row[7]
|
"WWW," // row[6]
|
||||||
" FROM ins_instits"
|
"0 AS NumUsrs" // row[7]
|
||||||
" WHERE CtyCod=%ld"
|
" FROM ins_instits"
|
||||||
" AND InsCod NOT IN"
|
" WHERE CtyCod=%ld"
|
||||||
" (SELECT DISTINCT InsCod"
|
" AND InsCod NOT IN"
|
||||||
" FROM usr_data))"
|
" (SELECT DISTINCT InsCod"
|
||||||
" ORDER BY %s",
|
" FROM usr_data))"
|
||||||
CtyCod,
|
" ORDER BY %s",
|
||||||
CtyCod,
|
CtyCod,
|
||||||
OrderBySubQuery[Gbl.Hierarchy.Inss.SelectedOrder]);
|
CtyCod,
|
||||||
|
OrderBySubQuery[Gbl.Hierarchy.Inss.SelectedOrder]);
|
||||||
|
|
||||||
if (NumRows) // Institutions found...
|
if (Gbl.Hierarchy.Inss.Num) // Institutions found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to Deg->NumCourses
|
|
||||||
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with institutions *****/
|
/***** Create list with institutions *****/
|
||||||
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
if ((Gbl.Hierarchy.Inss.Lst = calloc ((size_t) Gbl.Hierarchy.Inss.Num,
|
||||||
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -762,10 +753,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
Gbl.Hierarchy.Inss.Num = 0;
|
|
||||||
Gbl.Hierarchy.Inss.Lst = NULL;
|
Gbl.Hierarchy.Inss.Lst = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
43
swad_link.c
43
swad_link.c
|
@ -287,27 +287,26 @@ void Lnk_GetListLinks (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumLnk;
|
unsigned NumLnk;
|
||||||
struct Link *Lnk;
|
struct Link *Lnk;
|
||||||
|
|
||||||
if (Gbl.DB.DatabaseIsOpen)
|
if (Gbl.DB.DatabaseIsOpen)
|
||||||
{
|
{
|
||||||
/***** Get institutional links from database *****/
|
/***** Get institutional links from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutional links",
|
Gbl.Links.Num = (unsigned)
|
||||||
"SELECT LnkCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get institutional links",
|
||||||
"ShortName," // row[1]
|
"SELECT LnkCod," // row[0]
|
||||||
"FullName," // row[2]
|
"ShortName," // row[1]
|
||||||
"WWW" // row[3]
|
"FullName," // row[2]
|
||||||
" FROM lnk_links"
|
"WWW" // row[3]
|
||||||
" ORDER BY ShortName");
|
" FROM lnk_links"
|
||||||
|
" ORDER BY ShortName");
|
||||||
|
|
||||||
if (NumRows) // Places found...
|
if (Gbl.Links.Num) // Places found...
|
||||||
{
|
{
|
||||||
Gbl.Links.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with places *****/
|
/***** Create list with places *****/
|
||||||
if ((Gbl.Links.Lst = calloc (NumRows,sizeof (*Gbl.Links.Lst))) == NULL)
|
if ((Gbl.Links.Lst = calloc ((size_t) Gbl.Links.Num,
|
||||||
|
sizeof (*Gbl.Links.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the links *****/
|
/***** Get the links *****/
|
||||||
|
@ -331,8 +330,6 @@ void Lnk_GetListLinks (void)
|
||||||
Str_Copy (Lnk->WWW ,row[3],sizeof (Lnk->WWW ) - 1);
|
Str_Copy (Lnk->WWW ,row[3],sizeof (Lnk->WWW ) - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Links.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -347,7 +344,6 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
Lnk->ShrtName[0] = Lnk->FullName[0] = Lnk->WWW[0] = '\0';
|
Lnk->ShrtName[0] = Lnk->FullName[0] = Lnk->WWW[0] = '\0';
|
||||||
|
@ -356,16 +352,13 @@ void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
||||||
if (Lnk->LnkCod > 0)
|
if (Lnk->LnkCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of an institutional link from database *****/
|
/***** Get data of an institutional link from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
if (DB_QuerySELECT (&mysql_res,"can not get data of an institutional link",
|
||||||
" of an institutional link",
|
"SELECT ShortName," // row[0]
|
||||||
"SELECT ShortName," // row[0]
|
"FullName," // row[1]
|
||||||
"FullName," // row[1]
|
"WWW" // row[2]
|
||||||
"WWW" // row[2]
|
" FROM lnk_links"
|
||||||
" FROM lnk_links"
|
" WHERE LnkCod=%ld",
|
||||||
" WHERE LnkCod=%ld",
|
Lnk->LnkCod)) // Link found...
|
||||||
Lnk->LnkCod);
|
|
||||||
|
|
||||||
if (NumRows) // Link found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
37
swad_log.c
37
swad_log.c
|
@ -256,8 +256,8 @@ void Log_GetAndShowLastClicks (void)
|
||||||
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumClicks;
|
||||||
unsigned long NumRows;
|
unsigned NumClick;
|
||||||
long ActCod;
|
long ActCod;
|
||||||
Act_Action_t Action;
|
Act_Action_t Action;
|
||||||
const char *ClassRow;
|
const char *ClassRow;
|
||||||
|
@ -265,19 +265,20 @@ void Log_GetAndShowLastClicks (void)
|
||||||
struct Hie_Hierarchy Hie;
|
struct Hie_Hierarchy Hie;
|
||||||
|
|
||||||
/***** Get last clicks from database *****/
|
/***** Get last clicks from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get last clicks",
|
NumClicks = (unsigned)
|
||||||
"SELECT LogCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get last clicks",
|
||||||
"ActCod," // row[1]
|
"SELECT LogCod," // row[0]
|
||||||
"UNIX_TIMESTAMP()-"
|
"ActCod," // row[1]
|
||||||
"UNIX_TIMESTAMP(ClickTime)," // row[2]
|
"UNIX_TIMESTAMP()-"
|
||||||
"Role," // row[3]
|
"UNIX_TIMESTAMP(ClickTime)," // row[2]
|
||||||
"CtyCod," // row[4]
|
"Role," // row[3]
|
||||||
"InsCod," // row[5]
|
"CtyCod," // row[4]
|
||||||
"CtrCod," // row[6]
|
"InsCod," // row[5]
|
||||||
"DegCod" // row[7]
|
"CtrCod," // row[6]
|
||||||
" FROM log_recent"
|
"DegCod" // row[7]
|
||||||
" ORDER BY LogCod DESC"
|
" FROM log_recent"
|
||||||
" LIMIT 20");
|
" ORDER BY LogCod DESC"
|
||||||
|
" LIMIT 20");
|
||||||
|
|
||||||
/***** Write list of connected users *****/
|
/***** Write list of connected users *****/
|
||||||
HTM_TABLE_BeginCenterPadding (1);
|
HTM_TABLE_BeginCenterPadding (1);
|
||||||
|
@ -294,9 +295,9 @@ void Log_GetAndShowLastClicks (void)
|
||||||
|
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
|
|
||||||
for (NumRow = 0;
|
for (NumClick = 0;
|
||||||
NumRow < NumRows;
|
NumClick < NumClicks;
|
||||||
NumRow++)
|
NumClick++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
|
97
swad_mail.c
97
swad_mail.c
|
@ -252,13 +252,18 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
{
|
{
|
||||||
static const char *OrderBySubQuery[Mai_NUM_ORDERS] =
|
static const char *OrderBySubQuery[Mai_NUM_ORDERS] =
|
||||||
{
|
{
|
||||||
[Mai_ORDER_BY_DOMAIN] = "Domain,Info,N DESC",
|
[Mai_ORDER_BY_DOMAIN] = "Domain,"
|
||||||
[Mai_ORDER_BY_INFO ] = "Info,Domain,N DESC",
|
"Info,"
|
||||||
[Mai_ORDER_BY_USERS ] = "N DESC,Info,Domain",
|
"N DESC",
|
||||||
|
[Mai_ORDER_BY_INFO ] = "Info,"
|
||||||
|
"Domain,"
|
||||||
|
"N DESC",
|
||||||
|
[Mai_ORDER_BY_USERS ] = "N DESC,"
|
||||||
|
"Info,"
|
||||||
|
"Domain",
|
||||||
};
|
};
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
unsigned NumMai;
|
unsigned NumMai;
|
||||||
struct Mail *Mai;
|
struct Mail *Mai;
|
||||||
|
|
||||||
|
@ -282,31 +287,31 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
" FROM T1");
|
" FROM T1");
|
||||||
|
|
||||||
/***** Get mail domains from database *****/
|
/***** Get mail domains from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get mail domains",
|
Gbl.Mails.Num = (unsigned)
|
||||||
"(SELECT ntf_mail_domains.MaiCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get mail domains",
|
||||||
"ntf_mail_domains.Domain AS Domain," // row[1]
|
"(SELECT ntf_mail_domains.MaiCod," // row[0]
|
||||||
"ntf_mail_domains.Info AS Info," // row[2]
|
"ntf_mail_domains.Domain AS Domain," // row[1]
|
||||||
"T1.N AS N" // row[3]
|
"ntf_mail_domains.Info AS Info," // row[2]
|
||||||
" FROM ntf_mail_domains,T1"
|
"T1.N AS N" // row[3]
|
||||||
" WHERE ntf_mail_domains.Domain=T1.Domain COLLATE 'latin1_bin')"
|
" FROM ntf_mail_domains,T1"
|
||||||
" UNION "
|
" WHERE ntf_mail_domains.Domain=T1.Domain COLLATE 'latin1_bin')"
|
||||||
"(SELECT MaiCod," // row[0]
|
" UNION "
|
||||||
"Domain," // row[1]
|
"(SELECT MaiCod," // row[0]
|
||||||
"Info," // row[2]
|
"Domain," // row[1]
|
||||||
"0 AS N" // row[3]
|
"Info," // row[2]
|
||||||
" FROM ntf_mail_domains"
|
"0 AS N" // row[3]
|
||||||
" WHERE Domain NOT IN"
|
" FROM ntf_mail_domains"
|
||||||
" (SELECT Domain COLLATE 'latin1_bin'"
|
" WHERE Domain NOT IN"
|
||||||
" FROM T2))"
|
" (SELECT Domain COLLATE 'latin1_bin'"
|
||||||
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
" FROM T2))"
|
||||||
OrderBySubQuery[Gbl.Mails.SelectedOrder]);
|
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
||||||
|
OrderBySubQuery[Gbl.Mails.SelectedOrder]);
|
||||||
|
|
||||||
if (NumRows) // Mail domains found...
|
if (Gbl.Mails.Num) // Mail domains found...
|
||||||
{
|
{
|
||||||
Gbl.Mails.Num = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with places *****/
|
/***** Create list with places *****/
|
||||||
if ((Gbl.Mails.Lst = calloc (NumRows,sizeof (*Gbl.Mails.Lst))) == NULL)
|
if ((Gbl.Mails.Lst = calloc ((size_t) Gbl.Mails.Num,
|
||||||
|
sizeof (*Gbl.Mails.Lst))) == NULL)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
/***** Get the mail domains *****/
|
/***** Get the mail domains *****/
|
||||||
|
@ -332,15 +337,14 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||||
Mai->NumUsrs = 0;
|
Mai->NumUsrs = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.Mails.Num = 0;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Drop temporary table *****/
|
/***** Drop temporary table *****/
|
||||||
DB_Query ("can not remove temporary tables",
|
DB_Query ("can not remove temporary tables",
|
||||||
"DROP TEMPORARY TABLE IF EXISTS T1,T2");
|
"DROP TEMPORARY TABLE IF EXISTS T1,"
|
||||||
|
"T2");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -424,7 +428,6 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Clear data *****/
|
/***** Clear data *****/
|
||||||
Mai->Domain[0] = Mai->Info[0] = '\0';
|
Mai->Domain[0] = Mai->Info[0] = '\0';
|
||||||
|
@ -433,15 +436,12 @@ void Mai_GetDataOfMailDomainByCod (struct Mail *Mai)
|
||||||
if (Mai->MaiCod > 0)
|
if (Mai->MaiCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a mail domain from database *****/
|
/***** Get data of a mail domain from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
if (DB_QuerySELECT (&mysql_res,"can not get data of a mail domain",
|
||||||
" of a mail domain",
|
"SELECT Domain," // row[0]
|
||||||
"SELECT Domain," // row[0]
|
"Info" // row[1]
|
||||||
"Info" // row[1]
|
" FROM ntf_mail_domains"
|
||||||
" FROM ntf_mail_domains"
|
" WHERE MaiCod=%ld",
|
||||||
" WHERE MaiCod=%ld",
|
Mai->MaiCod)) // Mail found...
|
||||||
Mai->MaiCod);
|
|
||||||
|
|
||||||
if (NumRows) // Mail found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1082,20 +1082,17 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
bool Found;
|
bool Found;
|
||||||
|
|
||||||
/***** Get current (last updated) user's nickname from database *****/
|
/***** Get current (last updated) user's nickname from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get email address",
|
if (DB_QuerySELECT (&mysql_res,"can not get email address",
|
||||||
"SELECT E_mail," // row[0]
|
"SELECT E_mail," // row[0]
|
||||||
"Confirmed" // row[1]
|
"Confirmed" // row[1]
|
||||||
" FROM usr_emails"
|
" FROM usr_emails"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" ORDER BY CreatTime DESC"
|
" ORDER BY CreatTime DESC"
|
||||||
" LIMIT 1",
|
" LIMIT 1",
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod) == 0)
|
||||||
|
|
||||||
if (NumRows == 0)
|
|
||||||
{
|
{
|
||||||
UsrDat->Email[0] = '\0';
|
UsrDat->Email[0] = '\0';
|
||||||
UsrDat->EmailConfirmed = false;
|
UsrDat->EmailConfirmed = false;
|
||||||
|
|
38
swad_mark.c
38
swad_mark.c
|
@ -169,32 +169,28 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
||||||
long Cod = Brw_GetCodForFiles ();
|
long Cod = Brw_GetCodForFiles ();
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get number of rows of header and footer from database *****/
|
/***** Get number of rows of header and footer from database *****/
|
||||||
/* There should be a single file in database.
|
/* There should be a single file in database.
|
||||||
If, due to an error, there is more than one file,
|
If, due to an error, there is more than one file,
|
||||||
get the number of rows of the more recent file. */
|
get the number of rows of the more recent file. */
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the number of rows"
|
if (DB_QuerySELECT (&mysql_res,"can not get the number of rows"
|
||||||
" in header and footer",
|
" in header and footer",
|
||||||
"SELECT mrk_marks.%s," // row[0]
|
"SELECT mrk_marks.%s," // row[0]
|
||||||
"mrk_marks.%s" // row[1]
|
"mrk_marks.%s" // row[1]
|
||||||
" FROM brw_files,"
|
" FROM brw_files,"
|
||||||
"mrk_marks"
|
"mrk_marks"
|
||||||
" WHERE brw_files.FileBrowser=%u"
|
" WHERE brw_files.FileBrowser=%u"
|
||||||
" AND brw_files.Cod=%ld"
|
" AND brw_files.Cod=%ld"
|
||||||
" AND brw_files.Path='%s'"
|
" AND brw_files.Path='%s'"
|
||||||
" AND brw_files.FilCod=mrk_marks.FilCod"
|
" AND brw_files.FilCod=mrk_marks.FilCod"
|
||||||
" ORDER BY brw_files.FilCod DESC"
|
" ORDER BY brw_files.FilCod DESC"
|
||||||
" LIMIT 1", // On duplicate entries, get the more recent
|
" LIMIT 1", // On duplicate entries, get the more recent
|
||||||
Mrk_HeadOrFootStr[Brw_HEADER],
|
Mrk_HeadOrFootStr[Brw_HEADER],
|
||||||
Mrk_HeadOrFootStr[Brw_FOOTER],
|
Mrk_HeadOrFootStr[Brw_FOOTER],
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||||
Cod,
|
Cod,
|
||||||
Gbl.FileBrowser.FilFolLnk.Full);
|
Gbl.FileBrowser.FilFolLnk.Full) == 1)
|
||||||
|
|
||||||
/***** The result of the query must have only one row *****/
|
|
||||||
if (NumRows == 1)
|
|
||||||
{
|
{
|
||||||
/***** Get number of header and footer rows *****/
|
/***** Get number of header and footer rows *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
85
swad_match.c
85
swad_match.c
|
@ -404,7 +404,7 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
||||||
void Mch_GetDataOfMatchByCod (struct Mch_Match *Match)
|
void Mch_GetDataOfMatchByCod (struct Mch_Match *Match)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Get data of match from database *****/
|
/***** Get data of match from database *****/
|
||||||
NumRows = (unsigned)
|
NumRows = (unsigned)
|
||||||
|
@ -765,35 +765,36 @@ static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (const struct Mch_Match
|
||||||
extern const char *Txt_The_whole_course;
|
extern const char *Txt_The_whole_course;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumGrps;
|
||||||
unsigned long NumRows;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups associated to a match from database *****/
|
/***** Get groups associated to a match from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get groups of a match",
|
NumGrps = (unsigned)
|
||||||
"SELECT grp_types.GrpTypName," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get groups of a match",
|
||||||
"grp_groups.GrpName" // row[1]
|
"SELECT grp_types.GrpTypName," // row[0]
|
||||||
" FROM mch_groups,"
|
"grp_groups.GrpName" // row[1]
|
||||||
"grp_groups,"
|
" FROM mch_groups,"
|
||||||
"grp_types"
|
"grp_groups,"
|
||||||
" WHERE mch_groups.MchCod=%ld"
|
"grp_types"
|
||||||
" AND mch_groups.GrpCod=grp_groups.GrpCod"
|
" WHERE mch_groups.MchCod=%ld"
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
" AND mch_groups.GrpCod=grp_groups.GrpCod"
|
||||||
" ORDER BY grp_types.GrpTypName,"
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
"grp_groups.GrpName",
|
" ORDER BY grp_types.GrpTypName,"
|
||||||
Match->MchCod);
|
"grp_groups.GrpName",
|
||||||
|
Match->MchCod);
|
||||||
|
|
||||||
/***** Write heading *****/
|
/***** Write heading *****/
|
||||||
HTM_DIV_Begin ("class=\"ASG_GRP\"");
|
HTM_DIV_Begin ("class=\"ASG_GRP\"");
|
||||||
HTM_TxtColonNBSP (NumRows == 1 ? Txt_Group :
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
||||||
Txt_Groups);
|
Txt_Groups);
|
||||||
|
|
||||||
/***** Write groups *****/
|
/***** Write groups *****/
|
||||||
if (NumRows) // Groups found...
|
if (NumGrps) // Groups found...
|
||||||
{
|
{
|
||||||
/* Get and write the group types and names */
|
/* Get and write the group types and names */
|
||||||
for (NumRow = 0;
|
for (NumGrp = 0;
|
||||||
NumRow < NumRows;
|
NumGrp < NumGrps;
|
||||||
NumRow++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -801,12 +802,12 @@ static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (const struct Mch_Match
|
||||||
/* Write group type name and group name */
|
/* Write group type name and group name */
|
||||||
HTM_TxtF ("%s %s",row[0],row[1]);
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
||||||
|
|
||||||
if (NumRows >= 2)
|
if (NumGrps >= 2)
|
||||||
{
|
{
|
||||||
if (NumRow == NumRows-2)
|
if (NumGrp == NumGrps - 2)
|
||||||
HTM_TxtF (" %s ",Txt_and);
|
HTM_TxtF (" %s ",Txt_and);
|
||||||
if (NumRows >= 3)
|
if (NumGrps >= 3)
|
||||||
if (NumRow < NumRows-2)
|
if (NumGrp < NumGrps - 2)
|
||||||
HTM_Txt (", ");
|
HTM_Txt (", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1787,16 +1788,16 @@ static void Mch_CreateIndexes (long GamCod,long MchCod)
|
||||||
|
|
||||||
/***** Get questions of the game *****/
|
/***** Get questions of the game *****/
|
||||||
NumQsts = (unsigned)
|
NumQsts = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get questions of a game",
|
DB_QuerySELECT (&mysql_res,"can not get questions of a game",
|
||||||
"SELECT gam_questions.QstCod," // row[0]
|
"SELECT gam_questions.QstCod," // row[0]
|
||||||
"gam_questions.QstInd," // row[1]
|
"gam_questions.QstInd," // row[1]
|
||||||
"tst_questions.AnsType," // row[2]
|
"tst_questions.AnsType," // row[2]
|
||||||
"tst_questions.Shuffle" // row[3]
|
"tst_questions.Shuffle" // row[3]
|
||||||
" FROM gam_questions,tst_questions"
|
" FROM gam_questions,tst_questions"
|
||||||
" WHERE gam_questions.GamCod=%ld"
|
" WHERE gam_questions.GamCod=%ld"
|
||||||
" AND gam_questions.QstCod=tst_questions.QstCod"
|
" AND gam_questions.QstCod=tst_questions.QstCod"
|
||||||
" ORDER BY gam_questions.QstInd",
|
" ORDER BY gam_questions.QstInd",
|
||||||
GamCod);
|
GamCod);
|
||||||
|
|
||||||
/***** For each question in game... *****/
|
/***** For each question in game... *****/
|
||||||
for (NumQst = 0;
|
for (NumQst = 0;
|
||||||
|
@ -3511,14 +3512,14 @@ static void Mch_ShowMatchScore (const struct Mch_Match *Match)
|
||||||
|
|
||||||
/***** Get scores from database *****/
|
/***** Get scores from database *****/
|
||||||
NumScores = (unsigned)
|
NumScores = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get scores",
|
DB_QuerySELECT (&mysql_res,"can not get scores",
|
||||||
"SELECT Score," // row[0]
|
"SELECT Score," // row[0]
|
||||||
"COUNT(*) AS NumUsrs" // row[1]
|
"COUNT(*) AS NumUsrs" // row[1]
|
||||||
" FROM mch_results"
|
" FROM mch_results"
|
||||||
" WHERE MchCod=%ld"
|
" WHERE MchCod=%ld"
|
||||||
" GROUP BY Score"
|
" GROUP BY Score"
|
||||||
" ORDER BY Score DESC",
|
" ORDER BY Score DESC",
|
||||||
Match->MchCod);
|
Match->MchCod);
|
||||||
|
|
||||||
/***** Begin table ****/
|
/***** Begin table ****/
|
||||||
HTM_TABLE_BeginWide ();
|
HTM_TABLE_BeginWide ();
|
||||||
|
|
|
@ -393,30 +393,31 @@ void MchRes_ShowAllMchResultsInGam (void)
|
||||||
static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod)
|
static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
|
|
||||||
/***** Table head *****/
|
/***** Table head *****/
|
||||||
MchRes_ShowHeaderMchResults (Usr_OTHER);
|
MchRes_ShowHeaderMchResults (Usr_OTHER);
|
||||||
|
|
||||||
/***** Get all users who have answered any match question in this game *****/
|
/***** Get all users who have answered any match question in this game *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in game",
|
NumUsrs = (unsigned)
|
||||||
"SELECT users.UsrCod"
|
DB_QuerySELECT (&mysql_res,"can not get users in game",
|
||||||
" FROM (SELECT DISTINCT mch_results.UsrCod AS UsrCod"
|
"SELECT users.UsrCod"
|
||||||
" FROM mch_results,"
|
" FROM (SELECT DISTINCT mch_results.UsrCod AS UsrCod"
|
||||||
"mch_matches,"
|
" FROM mch_results,"
|
||||||
"gam_games"
|
"mch_matches,"
|
||||||
" WHERE mch_matches.GamCod=%ld"
|
"gam_games"
|
||||||
" AND mch_matches.MchCod=mch_results.MchCod"
|
" WHERE mch_matches.GamCod=%ld"
|
||||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
" AND mch_matches.MchCod=mch_results.MchCod"
|
||||||
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||||
"usr_data"
|
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
||||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
"usr_data"
|
||||||
" ORDER BY usr_data.Surname1,"
|
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||||
"usr_data.Surname2,"
|
" ORDER BY usr_data.Surname1,"
|
||||||
"usr_data.FirstName",
|
"usr_data.Surname2,"
|
||||||
GamCod,
|
"usr_data.FirstName",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
GamCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** List matches results for each user *****/
|
/***** List matches results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
|
@ -482,30 +483,31 @@ void MchRes_ShowAllMchResultsInMch (void)
|
||||||
static void MchRes_ListAllMchResultsInMch (struct Gam_Games *Games,long MchCod)
|
static void MchRes_ListAllMchResultsInMch (struct Gam_Games *Games,long MchCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned long NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned NumUsr;
|
||||||
|
|
||||||
/***** Table head *****/
|
/***** Table head *****/
|
||||||
MchRes_ShowHeaderMchResults (Usr_OTHER);
|
MchRes_ShowHeaderMchResults (Usr_OTHER);
|
||||||
|
|
||||||
/***** Get all users who have answered any match question in this game *****/
|
/***** Get all users who have answered any match question in this game *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in match",
|
NumUsrs = (unsigned)
|
||||||
"SELECT users.UsrCod"
|
DB_QuerySELECT (&mysql_res,"can not get users in match",
|
||||||
" FROM (SELECT mch_results.UsrCod AS UsrCod"
|
"SELECT users.UsrCod"
|
||||||
" FROM mch_results,"
|
" FROM (SELECT mch_results.UsrCod AS UsrCod"
|
||||||
"mch_matches,"
|
" FROM mch_results,"
|
||||||
"gam_games"
|
"mch_matches,"
|
||||||
" WHERE mch_results.MchCod=%ld"
|
"gam_games"
|
||||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
" WHERE mch_results.MchCod=%ld"
|
||||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||||
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||||
"usr_data"
|
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
||||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
"usr_data"
|
||||||
" ORDER BY usr_data.Surname1,"
|
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||||
"usr_data.Surname2,"
|
" ORDER BY usr_data.Surname1,"
|
||||||
"usr_data.FirstName",
|
"usr_data.Surname2,"
|
||||||
MchCod,
|
"usr_data.FirstName",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
MchCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
/***** List matches results for each user *****/
|
/***** List matches results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
|
|
17
swad_media.c
17
swad_media.c
|
@ -267,14 +267,15 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
||||||
size_t Length;
|
size_t Length;
|
||||||
|
|
||||||
/***** Get data of a media from database *****/
|
/***** Get data of a media from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get media",
|
NumRows = (unsigned)
|
||||||
"SELECT Type," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get media",
|
||||||
"Name," // row[1]
|
"SELECT Type," // row[0]
|
||||||
"URL," // row[2]
|
"Name," // row[1]
|
||||||
"Title" // row[3]
|
"URL," // row[2]
|
||||||
" FROM med_media"
|
"Title" // row[3]
|
||||||
" WHERE MedCod=%ld",
|
" FROM med_media"
|
||||||
Media->MedCod);
|
" WHERE MedCod=%ld",
|
||||||
|
Media->MedCod);
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
/***** Result should have a unique row *****/
|
||||||
if (NumRows == 0) // Media not found
|
if (NumRows == 0) // Media not found
|
||||||
|
|
250
swad_message.c
250
swad_message.c
|
@ -116,7 +116,7 @@ static void Msg_ShowFormToShowOnlyUnreadMessages (const struct Msg_Messages *Mes
|
||||||
static bool Msg_GetParamOnlyUnreadMsgs (void);
|
static bool Msg_GetParamOnlyUnreadMsgs (void);
|
||||||
static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
||||||
long MsgNum,long MsgCod);
|
long MsgNum,long MsgCod);
|
||||||
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded);
|
static bool Msg_GetStatusOfSentMsg (long MsgCod);
|
||||||
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded);
|
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded);
|
||||||
static long Msg_GetParamMsgCod (void);
|
static long Msg_GetParamMsgCod (void);
|
||||||
static void Msg_PutLinkToShowMorePotentialRecipients (const struct Msg_Messages *Messages);
|
static void Msg_PutLinkToShowMorePotentialRecipients (const struct Msg_Messages *Messages);
|
||||||
|
@ -590,7 +590,6 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
|
||||||
extern const char *Txt_Original_message;
|
extern const char *Txt_Original_message;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
long MsgCod;
|
long MsgCod;
|
||||||
bool SubjectAndContentComeFromForm = (Messages->Subject[0] || Content[0]);
|
bool SubjectAndContentComeFromForm = (Messages->Subject[0] || Content[0]);
|
||||||
|
|
||||||
|
@ -614,15 +613,12 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
|
||||||
if (!SubjectAndContentComeFromForm)
|
if (!SubjectAndContentComeFromForm)
|
||||||
{
|
{
|
||||||
/* Get subject and content of message from database */
|
/* Get subject and content of message from database */
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get message content",
|
if (DB_QuerySELECT (&mysql_res,"can not get message content",
|
||||||
"SELECT Subject," // row[0]
|
"SELECT Subject," // row[0]
|
||||||
"Content" // row[1]
|
"Content" // row[1]
|
||||||
" FROM msg_content"
|
" FROM msg_content"
|
||||||
" WHERE MsgCod=%ld",
|
" WHERE MsgCod=%ld",
|
||||||
MsgCod);
|
MsgCod) != 1)
|
||||||
|
|
||||||
/* Result should have a unique row */
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting message.");
|
Lay_ShowErrorAndExit ("Error when getting message.");
|
||||||
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2072,7 +2068,7 @@ static unsigned long Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messa
|
||||||
{
|
{
|
||||||
char *SubQuery;
|
char *SubQuery;
|
||||||
const char *StrUnreadMsg;
|
const char *StrUnreadMsg;
|
||||||
unsigned long NumMsgs;
|
unsigned NumMsgs;
|
||||||
|
|
||||||
if (Messages->FilterCrsCod > 0) // If origin course selected
|
if (Messages->FilterCrsCod > 0) // If origin course selected
|
||||||
switch (Messages->TypeOfMessages)
|
switch (Messages->TypeOfMessages)
|
||||||
|
@ -2244,21 +2240,23 @@ static unsigned long Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messa
|
||||||
|
|
||||||
if (Messages->FilterContent[0])
|
if (Messages->FilterContent[0])
|
||||||
/* Match against the content written in filter form */
|
/* Match against the content written in filter form */
|
||||||
NumMsgs = DB_QuerySELECT (mysql_res,"can not get messages",
|
NumMsgs = (unsigned)
|
||||||
"SELECT MsgCod"
|
DB_QuerySELECT (mysql_res,"can not get messages",
|
||||||
" FROM msg_content"
|
"SELECT MsgCod"
|
||||||
" WHERE MsgCod IN"
|
" FROM msg_content"
|
||||||
" (SELECT MsgCod"
|
" WHERE MsgCod IN"
|
||||||
" FROM (%s) AS M)"
|
" (SELECT MsgCod"
|
||||||
" AND MATCH (Subject,Content) AGAINST ('%s')"
|
" FROM (%s) AS M)"
|
||||||
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
" AND MATCH (Subject,Content) AGAINST ('%s')"
|
||||||
SubQuery,
|
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
||||||
Messages->FilterContent);
|
SubQuery,
|
||||||
|
Messages->FilterContent);
|
||||||
else
|
else
|
||||||
NumMsgs = DB_QuerySELECT (mysql_res,"can not get messages",
|
NumMsgs = (unsigned)
|
||||||
"%s"
|
DB_QuerySELECT (mysql_res,"can not get messages",
|
||||||
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
"%s"
|
||||||
SubQuery);
|
" ORDER BY MsgCod DESC", // End the query ordering the result from most recent message to oldest
|
||||||
|
SubQuery);
|
||||||
|
|
||||||
/***** Free memory used for subquery *****/
|
/***** Free memory used for subquery *****/
|
||||||
free (SubQuery);
|
free (SubQuery);
|
||||||
|
@ -2854,15 +2852,15 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRow;
|
unsigned NumCrss = 0; // Initialized to avoid warning
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
unsigned NumCrs;
|
||||||
struct Crs_Course Crs;
|
struct Crs_Course Crs;
|
||||||
|
|
||||||
/***** Get distinct courses in my messages from database *****/
|
/***** Get distinct courses in my messages from database *****/
|
||||||
switch (Messages->TypeOfMessages)
|
switch (Messages->TypeOfMessages)
|
||||||
{
|
{
|
||||||
case Msg_RECEIVED:
|
case Msg_RECEIVED:
|
||||||
NumRows =
|
NumCrss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get distinct courses in your messages",
|
DB_QuerySELECT (&mysql_res,"can not get distinct courses in your messages",
|
||||||
"SELECT DISTINCT crs_courses.CrsCod," // row[0]
|
"SELECT DISTINCT crs_courses.CrsCod," // row[0]
|
||||||
"crs_courses.ShortName" // row[1]
|
"crs_courses.ShortName" // row[1]
|
||||||
|
@ -2876,7 +2874,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
break;
|
break;
|
||||||
case Msg_SENT:
|
case Msg_SENT:
|
||||||
NumRows =
|
NumCrss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get distinct courses in your messages",
|
DB_QuerySELECT (&mysql_res,"can not get distinct courses in your messages",
|
||||||
"SELECT DISTINCT crs_courses.CrsCod," // row[0]
|
"SELECT DISTINCT crs_courses.CrsCod," // row[0]
|
||||||
"crs_courses.ShortName" // row[1]
|
"crs_courses.ShortName" // row[1]
|
||||||
|
@ -2893,9 +2891,9 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
|
||||||
|
|
||||||
/***** Get distinct courses in messages from database *****/
|
/***** Get distinct courses in messages from database *****/
|
||||||
Messages->NumCourses = 0;
|
Messages->NumCourses = 0;
|
||||||
for (NumRow = 0;
|
for (NumCrs = 0;
|
||||||
NumRow < NumRows;
|
NumCrs < NumCrss;
|
||||||
NumRow++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
/* Get next course */
|
/* Get next course */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -3040,28 +3038,30 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Get data of message from table msg_snt *****/
|
/***** Get data of message from table msg_snt *****/
|
||||||
*Deleted = false;
|
*Deleted = false;
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
NumRows = (unsigned)
|
||||||
"SELECT CrsCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
||||||
"UsrCod," // row[1]
|
"SELECT CrsCod," // row[0]
|
||||||
"UNIX_TIMESTAMP(CreatTime)" // row[2]
|
"UsrCod," // row[1]
|
||||||
" FROM msg_snt"
|
"UNIX_TIMESTAMP(CreatTime)" // row[2]
|
||||||
" WHERE MsgCod=%ld",
|
" FROM msg_snt"
|
||||||
MsgCod);
|
" WHERE MsgCod=%ld",
|
||||||
|
MsgCod);
|
||||||
|
|
||||||
if (NumRows == 0) // If not result ==> sent message is deleted
|
if (NumRows == 0) // If not result ==> sent message is deleted
|
||||||
{
|
{
|
||||||
/***** Get data of message from table msg_snt_deleted *****/
|
/***** Get data of message from table msg_snt_deleted *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
NumRows = (unsigned)
|
||||||
"SELECT CrsCod," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get data of a message",
|
||||||
"UsrCod," // row[1]
|
"SELECT CrsCod," // row[0]
|
||||||
"UNIX_TIMESTAMP(CreatTime)" // row[2]
|
"UsrCod," // row[1]
|
||||||
" FROM msg_snt_deleted"
|
"UNIX_TIMESTAMP(CreatTime)" // row[2]
|
||||||
" WHERE MsgCod=%ld",
|
" FROM msg_snt_deleted"
|
||||||
MsgCod);
|
" WHERE MsgCod=%ld",
|
||||||
|
MsgCod);
|
||||||
|
|
||||||
*Deleted = true;
|
*Deleted = true;
|
||||||
}
|
}
|
||||||
|
@ -3095,25 +3095,13 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
||||||
|
|
||||||
static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1])
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get subject of message from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the subject of a message",
|
DB_QuerySELECTString (Subject,Cns_MAX_BYTES_SUBJECT,
|
||||||
"SELECT Subject" // row[0]
|
"can not get the subject of a message",
|
||||||
" FROM msg_content"
|
"SELECT Subject" // row[0]
|
||||||
" WHERE MsgCod=%ld",
|
" FROM msg_content"
|
||||||
MsgCod) == 1) // Result should have a unique row
|
" WHERE MsgCod=%ld",
|
||||||
{
|
MsgCod);
|
||||||
/***** Get subject *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
Str_Copy (Subject,row[0],Cns_MAX_BYTES_SUBJECT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Subject[0] = '\0';
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3125,18 +3113,14 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get content of message from database *****/
|
/***** Get content of message from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the content of a message",
|
if (DB_QuerySELECT (&mysql_res,"can not get the content of a message",
|
||||||
"SELECT Content," // row[0]
|
"SELECT Content," // row[0]
|
||||||
"MedCod" // row[1]
|
"MedCod" // row[1]
|
||||||
" FROM msg_content"
|
" FROM msg_content"
|
||||||
" WHERE MsgCod=%ld",
|
" WHERE MsgCod=%ld",
|
||||||
MsgCod);
|
MsgCod) != 1)
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting content of a message.");
|
Lay_ShowErrorAndExit ("Error when getting content of a message.");
|
||||||
|
|
||||||
/***** Get number of rows *****/
|
/***** Get number of rows *****/
|
||||||
|
@ -3157,60 +3141,44 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
|
||||||
/********************** Get if a sent message is expanded ********************/
|
/********************** Get if a sent message is expanded ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded)
|
static bool Msg_GetStatusOfSentMsg (long MsgCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
char StrExpanded[1 + 1];
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get if sent message has been replied/expanded from database *****/
|
/***** Get if sent message has been expanded from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a sent message"
|
DB_QuerySELECTString (StrExpanded,1,
|
||||||
" has been replied/expanded",
|
"can not get if a sent message has been expanded",
|
||||||
"SELECT Expanded" // row[0]
|
"SELECT Expanded" // row[0]
|
||||||
" FROM msg_snt"
|
" FROM msg_snt"
|
||||||
" WHERE MsgCod=%ld"
|
" WHERE MsgCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
MsgCod,
|
MsgCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting if a sent message has been replied/expanded.");
|
|
||||||
|
|
||||||
/***** Get number of rows *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/***** Get if message is expanded *****/
|
/***** Get if message is expanded *****/
|
||||||
*Expanded = (row[0][0] == 'Y');
|
return (StrExpanded[0] == 'Y');
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Get if a received message has been replied ****************/
|
/********* Get if a received message has been open/replied/expanded **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded)
|
static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get if received message has been replied/expanded from database *****/
|
/***** Get if received message has been open/replied/expanded from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a received message"
|
if (DB_QuerySELECT (&mysql_res,"can not get if a received message"
|
||||||
" has been replied/expanded",
|
" has been replied/expanded",
|
||||||
"SELECT Open," // row[0]
|
"SELECT Open," // row[0]
|
||||||
"Replied," // row[1]
|
"Replied," // row[1]
|
||||||
"Expanded" // row[2]
|
"Expanded" // row[2]
|
||||||
" FROM msg_rcv"
|
" FROM msg_rcv"
|
||||||
" WHERE MsgCod=%ld"
|
" WHERE MsgCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
MsgCod,
|
MsgCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod) != 1)
|
||||||
|
|
||||||
/***** Result should have a unique row *****/
|
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting if a received message has been replied/expanded.");
|
Lay_ShowErrorAndExit ("Error when getting if a received message has been replied/expanded.");
|
||||||
|
|
||||||
/***** Get number of rows *****/
|
/***** Get number of rows *****/
|
||||||
|
@ -3273,7 +3241,7 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages,
|
||||||
Msg_GetStatusOfReceivedMsg (MsgCod,&Open,&Replied,&Expanded);
|
Msg_GetStatusOfReceivedMsg (MsgCod,&Open,&Replied,&Expanded);
|
||||||
break;
|
break;
|
||||||
case Msg_SENT:
|
case Msg_SENT:
|
||||||
Msg_GetStatusOfSentMsg (MsgCod,&Expanded);
|
Expanded = Msg_GetStatusOfSentMsg (MsgCod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -3781,34 +3749,34 @@ static void Msg_WriteMsgTo (struct Msg_Messages *Messages,long MsgCod)
|
||||||
MsgCod);
|
MsgCod);
|
||||||
|
|
||||||
/***** Get recipients of a message from database *****/
|
/***** Get recipients of a message from database *****/
|
||||||
NumRecipientsKnown =
|
NumRecipientsKnown = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get recipients of a message",
|
DB_QuerySELECT (&mysql_res,"can not get recipients of a message",
|
||||||
"(SELECT msg_rcv.UsrCod," // row[0]
|
"(SELECT msg_rcv.UsrCod," // row[0]
|
||||||
"'N'," // row[1]
|
"'N'," // row[1]
|
||||||
"msg_rcv.Open," // row[2]
|
"msg_rcv.Open," // row[2]
|
||||||
"usr_data.Surname1 AS S1," // row[3]
|
"usr_data.Surname1 AS S1," // row[3]
|
||||||
"usr_data.Surname2 AS S2," // row[4]
|
"usr_data.Surname2 AS S2," // row[4]
|
||||||
"usr_data.FirstName AS FN" // row[5]
|
"usr_data.FirstName AS FN" // row[5]
|
||||||
" FROM msg_rcv,"
|
" FROM msg_rcv,"
|
||||||
"usr_data"
|
"usr_data"
|
||||||
" WHERE msg_rcv.MsgCod=%ld"
|
" WHERE msg_rcv.MsgCod=%ld"
|
||||||
" AND msg_rcv.UsrCod=usr_data.UsrCod)"
|
" AND msg_rcv.UsrCod=usr_data.UsrCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT msg_rcv_deleted.UsrCod," // row[0]
|
"(SELECT msg_rcv_deleted.UsrCod," // row[0]
|
||||||
"'Y'," // row[1]
|
"'Y'," // row[1]
|
||||||
"msg_rcv_deleted.Open," // row[2]
|
"msg_rcv_deleted.Open," // row[2]
|
||||||
"usr_data.Surname1 AS S1," // row[3]
|
"usr_data.Surname1 AS S1," // row[3]
|
||||||
"usr_data.Surname2 AS S2," // row[4]
|
"usr_data.Surname2 AS S2," // row[4]
|
||||||
"usr_data.FirstName AS FN" // row[5]
|
"usr_data.FirstName AS FN" // row[5]
|
||||||
" FROM msg_rcv_deleted,"
|
" FROM msg_rcv_deleted,"
|
||||||
"usr_data"
|
"usr_data"
|
||||||
" WHERE msg_rcv_deleted.MsgCod=%ld"
|
" WHERE msg_rcv_deleted.MsgCod=%ld"
|
||||||
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod)"
|
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod)"
|
||||||
" ORDER BY S1,"
|
" ORDER BY S1,"
|
||||||
"S2,"
|
"S2,"
|
||||||
"FN",
|
"FN",
|
||||||
MsgCod,
|
MsgCod,
|
||||||
MsgCod);
|
MsgCod);
|
||||||
|
|
||||||
/***** Check number of recipients *****/
|
/***** Check number of recipients *****/
|
||||||
if (NumRecipientsTotal)
|
if (NumRecipientsTotal)
|
||||||
|
|
66
swad_role.c
66
swad_role.c
|
@ -435,28 +435,27 @@ void Rol_GetRolesInAllCrssIfNotYetGot (struct UsrData *UsrDat)
|
||||||
unsigned NumRole;
|
unsigned NumRole;
|
||||||
unsigned NumRoles;
|
unsigned NumRoles;
|
||||||
|
|
||||||
/***** If roles is already filled ==> nothing to do *****/
|
/***** Trivial check: if already filled, nothing to do *****/
|
||||||
if (UsrDat->Roles.InCrss < 0) // Not yet filled
|
if (UsrDat->Roles.InCrss >= 0)
|
||||||
{
|
return;
|
||||||
/***** Get distinct roles in all courses of the user from database *****/
|
|
||||||
NumRoles =
|
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get the roles of a user"
|
|
||||||
" in all his/her courses",
|
|
||||||
"SELECT DISTINCT(Role)" // row[0]
|
|
||||||
" FROM crs_users"
|
|
||||||
" WHERE UsrCod=%ld",
|
|
||||||
UsrDat->UsrCod);
|
|
||||||
for (NumRole = 0, UsrDat->Roles.InCrss = 0;
|
|
||||||
NumRole < NumRoles;
|
|
||||||
NumRole++)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
UsrDat->Roles.InCrss |= (int) (1 << Rol_ConvertUnsignedStrToRole (row[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Get distinct roles in all courses of the user from database *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
NumRoles = (unsigned)
|
||||||
|
DB_QuerySELECT (&mysql_res,"can not get user's roles in all courses",
|
||||||
|
"SELECT DISTINCT(Role)" // row[0]
|
||||||
|
" FROM crs_users"
|
||||||
|
" WHERE UsrCod=%ld",
|
||||||
|
UsrDat->UsrCod);
|
||||||
|
for (NumRole = 0, UsrDat->Roles.InCrss = 0;
|
||||||
|
NumRole < NumRoles;
|
||||||
|
NumRole++)
|
||||||
|
{
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
UsrDat->Roles.InCrss |= (int) (1 << Rol_ConvertUnsignedStrToRole (row[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -637,27 +636,14 @@ unsigned Rol_GetSelectedRoles (void)
|
||||||
|
|
||||||
Rol_Role_t Rol_GetRequestedRole (long UsrCod)
|
Rol_Role_t Rol_GetRequestedRole (long UsrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
Rol_Role_t Role = Rol_UNK;
|
|
||||||
|
|
||||||
/***** Get requested role from database *****/
|
/***** Get requested role from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get requested role",
|
return DB_QuerySELECTRole ("can not get requested role",
|
||||||
"SELECT Role" // row[0]
|
"SELECT Role"
|
||||||
" FROM crs_requests"
|
" FROM crs_requests"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,UsrCod))
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
{
|
UsrCod);
|
||||||
/***** Get role *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
Role = Rol_ConvertUnsignedStrToRole (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return Role;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -358,7 +358,7 @@ static unsigned Roo_GetMACAddresses (long RooCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get MAC addresses from database *****/
|
/***** Get MAC addresses from database *****/
|
||||||
return (unsigned) DB_QuerySELECT (mysql_res,"can not get MAC addresses",
|
return (unsigned) DB_QuerySELECT (mysql_res,"can not get MAC addresses",
|
||||||
"SELECT MAC" // row[0]
|
"SELECT MAC" // row[0]
|
||||||
" FROM roo_macs"
|
" FROM roo_macs"
|
||||||
" WHERE RooCod=%ld"
|
" WHERE RooCod=%ld"
|
||||||
" ORDER BY MAC",
|
" ORDER BY MAC",
|
||||||
|
|
673
swad_search.c
673
swad_search.c
|
@ -704,106 +704,115 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
NumDocs =
|
NumDocs =
|
||||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||||
"SELECT * FROM "
|
"SELECT *"
|
||||||
"("
|
" FROM "
|
||||||
"SELECT brw_files.FilCod," // Institution
|
// Institution
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"(SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ins_instits.InsCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"-1 AS CtrCod,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"'' AS CtrShortName,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"-1 AS DegCod,"
|
"-1 AS CtrCod," // row[ 4]
|
||||||
"'' AS DegShortName,"
|
"'' AS CtrShortName," // row[ 5]
|
||||||
"-1 AS CrsCod,"
|
"-1 AS DegCod," // row[ 6]
|
||||||
"'' AS CrsShortName,"
|
"'' AS DegShortName," // row[ 7]
|
||||||
"-1 AS GrpCod"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
" FROM brw_files,"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
"crs_courses,"
|
"-1 AS GrpCod" // row[10]
|
||||||
"deg_degrees,"
|
" FROM brw_files,"
|
||||||
"ctr_centers,"
|
"crs_courses,"
|
||||||
"ins_instits,"
|
"deg_degrees,"
|
||||||
"cty_countrs"
|
"ctr_centers,"
|
||||||
" WHERE brw_files.Public='Y'"
|
"ins_instits,"
|
||||||
" AND %s"
|
"cty_countrs"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
" WHERE brw_files.Public='Y'"
|
||||||
" AND brw_files.Cod=ins_instits.InsCod"
|
" AND %s"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
"%s"
|
" AND brw_files.Cod=ins_instits.InsCod"
|
||||||
" UNION "
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"SELECT brw_files.FilCod," // Center
|
"%s"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
" UNION "
|
||||||
"ins_instits.InsCod,"
|
// Center -------------------------------------
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ctr_centers.CtrCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"-1 AS DegCod,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"'' AS DegShortName,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"-1 AS CrsCod,"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
"'' AS CrsShortName,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"-1 AS GrpCod"
|
"-1 AS DegCod," // row[ 6]
|
||||||
" FROM brw_files,"
|
"'' AS DegShortName," // row[ 7]
|
||||||
"crs_courses,"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
"deg_degrees,"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
"ctr_centers,"
|
"-1 AS GrpCod" // row[10]
|
||||||
"ins_instits,"
|
" FROM brw_files,"
|
||||||
"cty_countrs"
|
"crs_courses,"
|
||||||
" WHERE brw_files.Public='Y' AND %s"
|
"deg_degrees,"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
"ctr_centers,"
|
||||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
"ins_instits,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"cty_countrs"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
" WHERE brw_files.Public='Y' AND %s"
|
||||||
"%s"
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
" UNION "
|
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||||
"SELECT brw_files.FilCod," // Degree
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"ins_instits.InsCod,"
|
"%s"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
" UNION "
|
||||||
"ctr_centers.CtrCod,"
|
// Degree -------------------------------------
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"deg_degrees.DegCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"-1,'' AS CrsShortName,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"-1"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
" FROM brw_files,"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
"crs_courses,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"deg_degrees,"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
"ctr_centers,"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
"ins_instits,"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
"cty_countrs"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
" WHERE brw_files.Public='Y' AND %s"
|
"-1 AS GrpCod" // row[10]
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
" FROM brw_files,"
|
||||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
"crs_courses,"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
"deg_degrees,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"ctr_centers,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"ins_instits,"
|
||||||
"%s"
|
"cty_countrs"
|
||||||
" UNION "
|
" WHERE brw_files.Public='Y' AND %s"
|
||||||
"SELECT brw_files.FilCod," // Course
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||||
"ins_instits.InsCod,"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"ctr_centers.CtrCod,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"%s"
|
||||||
"deg_degrees.DegCod,"
|
" UNION "
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
// Course -------------------------------------
|
||||||
"crs_courses.CrsCod,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"crs_courses.ShortName AS CrsShortName,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"-1"
|
"LOCATE('/',brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
" FROM brw_files,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"crs_courses,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"deg_degrees,"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
"ctr_centers,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"ins_instits,"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
"cty_countrs"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
" WHERE brw_files.Public='Y' AND %s"
|
"crs_courses.CrsCod," // row[ 8]
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
"-1 AS GrpCod" // row[10]
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" FROM brw_files,"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
"crs_courses,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"deg_degrees,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"ctr_centers,"
|
||||||
"%s"
|
"ins_instits,"
|
||||||
") AS selected_files"
|
"cty_countrs"
|
||||||
|
" WHERE brw_files.Public='Y' AND %s"
|
||||||
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
|
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||||
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
|
"%s"
|
||||||
|
") AS selected_files"
|
||||||
" WHERE PathFromRoot<>''"
|
" WHERE PathFromRoot<>''"
|
||||||
" ORDER BY InsShortName,"
|
" ORDER BY InsShortName,"
|
||||||
"CtrShortName,"
|
"CtrShortName,"
|
||||||
|
@ -859,11 +868,13 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
|
||||||
It is necessary to speed up the second query *****/
|
It is necessary to speed up the second query *****/
|
||||||
DB_Query ("can not remove temporary table",
|
DB_Query ("can not remove temporary table",
|
||||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
|
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||||
|
"my_files_grp");
|
||||||
|
|
||||||
DB_Query ("can not create temporary table",
|
DB_Query ("can not create temporary table",
|
||||||
"CREATE TEMPORARY TABLE my_files_crs"
|
"CREATE TEMPORARY TABLE my_files_crs"
|
||||||
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
" (FilCod INT NOT NULL,"
|
||||||
|
"UNIQUE INDEX(FilCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
" SELECT brw_files.FilCod"
|
" SELECT brw_files.FilCod"
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
|
@ -879,7 +890,8 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
|
|
||||||
DB_Query ("can not create temporary table",
|
DB_Query ("can not create temporary table",
|
||||||
"CREATE TEMPORARY TABLE my_files_grp"
|
"CREATE TEMPORARY TABLE my_files_grp"
|
||||||
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
|
" (FilCod INT NOT NULL,"
|
||||||
|
"UNIQUE INDEX(FilCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
" SELECT brw_files.FilCod"
|
" SELECT brw_files.FilCod"
|
||||||
" FROM grp_users,"
|
" FROM grp_users,"
|
||||||
|
@ -896,70 +908,76 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
/***** Build the query *****/
|
/***** Build the query *****/
|
||||||
NumDocs =
|
NumDocs =
|
||||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||||
"SELECT * FROM "
|
"SELECT *"
|
||||||
"("
|
" FROM ("
|
||||||
"SELECT brw_files.FilCod,"
|
// Files in course zones ----------------------
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ins_instits.InsCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
"LOCATE('/',"
|
||||||
"ctr_centers.CtrCod,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"deg_degrees.DegCod,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
"crs_courses.CrsCod,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"crs_courses.ShortName AS CrsShortName,"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
"-1 AS GrpCod"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
" FROM brw_files,"
|
"crs_courses.CrsCod," // row[ 8]
|
||||||
"crs_courses,"
|
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||||
"deg_degrees,"
|
"-1 AS GrpCod" // row[10]
|
||||||
"ctr_centers,"
|
" FROM brw_files,"
|
||||||
"ins_instits,"
|
"crs_courses,"
|
||||||
"cty_countrs"
|
"deg_degrees,"
|
||||||
" WHERE brw_files.FilCod IN"
|
"ctr_centers,"
|
||||||
" (SELECT FilCod"
|
"ins_instits,"
|
||||||
" FROM my_files_crs)"
|
"cty_countrs"
|
||||||
" AND %s"
|
" WHERE brw_files.FilCod IN"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
" (SELECT FilCod"
|
||||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
" FROM my_files_crs)"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND %s"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
"%s"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" UNION "
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"SELECT brw_files.FilCod,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"%s"
|
||||||
"ins_instits.InsCod,"
|
" UNION "
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
// Files in group zones -----------------------
|
||||||
"ctr_centers.CtrCod,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"deg_degrees.DegCod,"
|
"LOCATE('/',"
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"crs_courses.CrsCod,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"crs_courses.ShortName AS CrsShortName,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"grp_groups.GrpCod"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
" FROM brw_files,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"grp_groups,"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
"grp_types,"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
"crs_courses,"
|
"crs_courses.CrsCod," // row[ 8]
|
||||||
"deg_degrees,"
|
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||||
"ctr_centers,"
|
"grp_groups.GrpCod" // row[10]
|
||||||
"ins_instits,"
|
" FROM brw_files,"
|
||||||
"cty_countrs"
|
"grp_groups,"
|
||||||
" WHERE brw_files.FilCod IN"
|
"grp_types,"
|
||||||
" (SELECT FilCod"
|
"crs_courses,"
|
||||||
" FROM my_files_grp)"
|
"deg_degrees,"
|
||||||
" AND %s"
|
"ctr_centers,"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
"ins_instits,"
|
||||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
"cty_countrs"
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
" WHERE brw_files.FilCod IN"
|
||||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
" (SELECT FilCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" FROM my_files_grp)"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND %s"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||||
"%s"
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
") AS selected_files"
|
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||||
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
|
"%s"
|
||||||
|
") AS selected_files"
|
||||||
" WHERE PathFromRoot<>''"
|
" WHERE PathFromRoot<>''"
|
||||||
" ORDER BY InsShortName,"
|
" ORDER BY InsShortName,"
|
||||||
"CtrShortName,"
|
"CtrShortName,"
|
||||||
|
@ -986,7 +1004,8 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
||||||
|
|
||||||
/***** Drop temporary table *****/
|
/***** Drop temporary table *****/
|
||||||
DB_Query ("can not remove temporary table",
|
DB_Query ("can not remove temporary table",
|
||||||
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
|
"DROP TEMPORARY TABLE IF EXISTS my_files_crs,"
|
||||||
|
"my_files_grp");
|
||||||
|
|
||||||
return (unsigned) NumDocs;
|
return (unsigned) NumDocs;
|
||||||
}
|
}
|
||||||
|
@ -1015,156 +1034,174 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
|
||||||
/***** Build the query *****/
|
/***** Build the query *****/
|
||||||
NumDocs =
|
NumDocs =
|
||||||
DB_QuerySELECT (&mysql_res,"can not get files",
|
DB_QuerySELECT (&mysql_res,"can not get files",
|
||||||
"SELECT * FROM "
|
"SELECT *"
|
||||||
"("
|
" FROM ("
|
||||||
"SELECT brw_files.FilCod," // Institution
|
// Institution --------------------------------
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ins_instits.InsCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
"LOCATE('/',"
|
||||||
"-1 AS CtrCod,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"'' AS CtrShortName,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"-1 AS DegCod,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"'' AS DegShortName,"
|
"-1 AS CtrCod," // row[ 4]
|
||||||
"-1 AS CrsCod,"
|
"'' AS CtrShortName," // row[ 5]
|
||||||
"'' AS CrsShortName,"
|
"-1 AS DegCod," // row[ 6]
|
||||||
"-1 AS GrpCod"
|
"'' AS DegShortName," // row[ 7]
|
||||||
" FROM brw_files,"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
"crs_courses,"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
"deg_degrees,"
|
"-1 AS GrpCod" // row[10]
|
||||||
"ctr_centers,"
|
" FROM brw_files,"
|
||||||
"ins_instits,"
|
"crs_courses,"
|
||||||
"cty_countrs"
|
"deg_degrees,"
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
"ctr_centers,"
|
||||||
" AND %s"
|
"ins_instits,"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
"cty_countrs"
|
||||||
" AND brw_files.Cod=ins_instits.InsCod"
|
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
" AND %s"
|
||||||
"%s"
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
" UNION "
|
" AND brw_files.Cod=ins_instits.InsCod"
|
||||||
"SELECT brw_files.FilCod," // Center
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"%s"
|
||||||
"ins_instits.InsCod,"
|
" UNION "
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
// Center -------------------------------------
|
||||||
"ctr_centers.CtrCod,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"-1 AS DegCod,"
|
"LOCATE('/',"
|
||||||
"'' AS DegShortName,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"-1 AS CrsCod,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"'' AS CrsShortName,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"-1 AS GrpCod"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
" FROM brw_files,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"crs_courses,"
|
"-1 AS DegCod," // row[ 6]
|
||||||
"deg_degrees,"
|
"'' AS DegShortName," // row[ 7]
|
||||||
"ctr_centers,"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
"ins_instits,"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
"cty_countrs"
|
"-1 AS GrpCod" // row[10]
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld AND %s"
|
" FROM brw_files,"
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
"crs_courses,"
|
||||||
" AND brw_files.Cod=ctr_centers.CtrCod"
|
"deg_degrees,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"ctr_centers,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"ins_instits,"
|
||||||
"%s"
|
"cty_countrs"
|
||||||
" UNION "
|
" WHERE brw_files.PublisherUsrCod=%ld AND %s"
|
||||||
"SELECT brw_files.FilCod," // Degree
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
" AND brw_files.Cod=ctr_centers.CtrCod"
|
||||||
"ins_instits.InsCod,"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"ctr_centers.CtrCod,"
|
"%s"
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
" UNION "
|
||||||
"deg_degrees.DegCod,"
|
// Degree -------------------------------------
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"-1 AS CrsCod,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"'' AS CrsShortName,"
|
"LOCATE('/',"
|
||||||
"-1 AS GrpCod"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
" FROM brw_files,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"crs_courses,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"deg_degrees,"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
"ctr_centers,"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
"ins_instits,"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
"cty_countrs"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
"-1 AS CrsCod," // row[ 8]
|
||||||
" AND %s"
|
"'' AS CrsShortName," // row[ 9]
|
||||||
" AND brw_files.FileBrowser IN (%u,%u)"
|
"-1 AS GrpCod" // row[10]
|
||||||
" AND brw_files.Cod=deg_degrees.DegCod"
|
" FROM brw_files,"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
"crs_courses,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"deg_degrees,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"ctr_centers,"
|
||||||
"%s"
|
"ins_instits,"
|
||||||
" UNION "
|
"cty_countrs"
|
||||||
"SELECT brw_files.FilCod," // Course
|
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
" AND %s"
|
||||||
"ins_instits.InsCod,"
|
" AND brw_files.FileBrowser IN (%u,%u)"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
" AND brw_files.Cod=deg_degrees.DegCod"
|
||||||
"ctr_centers.CtrCod,"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"deg_degrees.DegCod,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
"%s"
|
||||||
"crs_courses.CrsCod,"
|
" UNION "
|
||||||
"crs_courses.ShortName AS CrsShortName,"
|
// Course -------------------------------------
|
||||||
"-1 AS GrpCod"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
" FROM brw_files,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"crs_courses,"
|
"LOCATE('/',"
|
||||||
"deg_degrees,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"ctr_centers,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"ins_instits,"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
"cty_countrs"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
" AND %s"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
"crs_courses.CrsCod," // row[ 8]
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
"-1 AS GrpCod" // row[10]
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
" FROM brw_files,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"crs_courses,"
|
||||||
"%s"
|
"deg_degrees,"
|
||||||
" UNION "
|
"ctr_centers,"
|
||||||
"SELECT brw_files.FilCod," // Group
|
"ins_instits,"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"cty_countrs"
|
||||||
"ins_instits.InsCod,"
|
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||||
"ins_instits.ShortName AS InsShortName,"
|
" AND %s"
|
||||||
"ctr_centers.CtrCod,"
|
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||||
"ctr_centers.ShortName AS CtrShortName,"
|
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||||
"deg_degrees.DegCod,"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
"deg_degrees.ShortName AS DegShortName,"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
"crs_courses.CrsCod,"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
"crs_courses.ShortName AS CrsShortName,"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
"grp_groups.GrpCod"
|
"%s"
|
||||||
" FROM brw_files,"
|
" UNION "
|
||||||
"grp_groups,"
|
// Group --------------------------------------
|
||||||
"grp_types,"
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
"crs_courses,"
|
"SUBSTRING(brw_files.Path,"
|
||||||
"deg_degrees,"
|
"LOCATE('/',"
|
||||||
"ctr_centers,"
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
"ins_instits,"
|
"ins_instits.InsCod," // row[ 2]
|
||||||
"cty_countrs"
|
"ins_instits.ShortName AS InsShortName," // row[ 3]
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
"ctr_centers.CtrCod," // row[ 4]
|
||||||
" AND %s"
|
"ctr_centers.ShortName AS CtrShortName," // row[ 5]
|
||||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
"deg_degrees.DegCod," // row[ 6]
|
||||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
"deg_degrees.ShortName AS DegShortName," // row[ 7]
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
"crs_courses.CrsCod," // row[ 8]
|
||||||
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
"crs_courses.ShortName AS CrsShortName," // row[ 9]
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
"grp_groups.GrpCod" // row[10]
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" FROM brw_files,"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
"grp_groups,"
|
||||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
"grp_types,"
|
||||||
"%s"
|
"crs_courses,"
|
||||||
" UNION "
|
"deg_degrees,"
|
||||||
"SELECT brw_files.FilCod," // Briefcase
|
"ctr_centers,"
|
||||||
"SUBSTRING(brw_files.Path,LOCATE('/',brw_files.Path)) AS PathFromRoot,"
|
"ins_instits,"
|
||||||
"-1 AS InsCod,"
|
"cty_countrs"
|
||||||
"'' AS InsShortName,"
|
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||||
"-1 AS CtrCod,"
|
" AND %s"
|
||||||
"'' AS CtrShortName,"
|
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||||
"-1 AS DegCod,"
|
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||||
"'' AS DegShortName,"
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
"-1 AS CrsCod,"
|
" AND grp_types.CrsCod=crs_courses.CrsCod"
|
||||||
"'' AS CrsShortName,"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
"-1 AS GrpCod"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" FROM brw_files"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
" WHERE brw_files.PublisherUsrCod=%ld"
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||||
" AND %s"
|
"%s"
|
||||||
" AND brw_files.FileBrowser=%u"
|
" UNION "
|
||||||
") AS selected_files"
|
// Briefcase ----------------------------------
|
||||||
|
"SELECT brw_files.FilCod," // row[ 0]
|
||||||
|
"SUBSTRING(brw_files.Path,"
|
||||||
|
"LOCATE('/',"
|
||||||
|
"brw_files.Path)) AS PathFromRoot," // row[ 1]
|
||||||
|
"-1 AS InsCod," // row[ 2]
|
||||||
|
"'' AS InsShortName," // row[ 3]
|
||||||
|
"-1 AS CtrCod," // row[ 4]
|
||||||
|
"'' AS CtrShortName," // row[ 5]
|
||||||
|
"-1 AS DegCod," // row[ 6]
|
||||||
|
"'' AS DegShortName," // row[ 7]
|
||||||
|
"-1 AS CrsCod," // row[ 8]
|
||||||
|
"'' AS CrsShortName," // row[ 9]
|
||||||
|
"-1 AS GrpCod" // row[10]
|
||||||
|
" FROM brw_files"
|
||||||
|
" WHERE brw_files.PublisherUsrCod=%ld"
|
||||||
|
" AND %s"
|
||||||
|
" AND brw_files.FileBrowser=%u"
|
||||||
|
") AS selected_files"
|
||||||
" WHERE PathFromRoot<>''"
|
" WHERE PathFromRoot<>''"
|
||||||
" ORDER BY InsShortName,"
|
" ORDER BY InsShortName,"
|
||||||
"CtrShortName,"
|
"CtrShortName,"
|
||||||
|
|
|
@ -423,50 +423,20 @@ static bool Ses_CheckIfParamIsAlreadyInDB (const char *ParamName)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Get session parameter from the database *******************/
|
/***************** Get session parameter from the database *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
// StrSize is the size of the parameter value, not including the ending '\0'
|
||||||
|
|
||||||
void Ses_GetParamFromDB (const char *ParamName,char *ParamValue,size_t MaxBytes)
|
void Ses_GetParamFromDB (const char *ParamName,char *ParamValue,size_t StrSize)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
|
||||||
bool ParameterIsTooBig = false;
|
|
||||||
char ErrorTxt[256];
|
|
||||||
|
|
||||||
ParamValue[0] = '\0';
|
ParamValue[0] = '\0';
|
||||||
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
|
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
|
||||||
{
|
|
||||||
/***** Get a session parameter from database *****/
|
/***** Get a session parameter from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get a session parameter",
|
DB_QuerySELECTString (ParamValue,StrSize,"can not get a session parameter",
|
||||||
"SELECT ParamValue" // row[0]
|
"SELECT ParamValue" // row[0]
|
||||||
" FROM ses_params"
|
" FROM ses_params"
|
||||||
" WHERE SessionId='%s'"
|
" WHERE SessionId='%s'"
|
||||||
" AND ParamName='%s'",
|
" AND ParamName='%s'",
|
||||||
Gbl.Session.Id,
|
Gbl.Session.Id,
|
||||||
ParamName);
|
ParamName);
|
||||||
|
|
||||||
/***** Check if the parameter is found in database *****/
|
|
||||||
if (NumRows)
|
|
||||||
{
|
|
||||||
/***** Get the value del parameter *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
ParameterIsTooBig = (strlen (row[0]) > MaxBytes);
|
|
||||||
if (!ParameterIsTooBig)
|
|
||||||
Str_Copy (ParamValue,row[0],MaxBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ParameterIsTooBig)
|
|
||||||
{
|
|
||||||
snprintf (ErrorTxt,sizeof (ErrorTxt),
|
|
||||||
"Session parameter <strong>%s</strong> too large,"
|
|
||||||
" it exceed the maximum allowed size (%lu bytes).",
|
|
||||||
ParamName,(unsigned long) MaxBytes);
|
|
||||||
Lay_ShowErrorAndExit (ErrorTxt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -50,7 +50,7 @@ bool Ses_GetSessionData (void);
|
||||||
void Ses_InsertParamInDB (const char *ParamName,const char *ParamValue);
|
void Ses_InsertParamInDB (const char *ParamName,const char *ParamValue);
|
||||||
void Ses_RemoveParamFromThisSession (void);
|
void Ses_RemoveParamFromThisSession (void);
|
||||||
void Ses_RemoveParamsFromExpiredSessions (void);
|
void Ses_RemoveParamsFromExpiredSessions (void);
|
||||||
void Ses_GetParamFromDB (const char *ParamName,char *ParamValue,size_t MaxBytes);
|
void Ses_GetParamFromDB (const char *ParamName,char *ParamValue,size_t StrSize);
|
||||||
|
|
||||||
bool Ses_GetPublicDirFromCache (const char *FullPathMediaPriv,
|
bool Ses_GetPublicDirFromCache (const char *FullPathMediaPriv,
|
||||||
char TmpPubDir[PATH_MAX + 1]);
|
char TmpPubDir[PATH_MAX + 1]);
|
||||||
|
|
|
@ -1784,23 +1784,19 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats,
|
||||||
|
|
||||||
static void Sta_WriteLogComments (long LogCod)
|
static void Sta_WriteLogComments (long LogCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
char Comments[Cns_MAX_BYTES_TEXT + 1];
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
/***** Get log comments from database *****/
|
/***** Get log comments from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get log comments",
|
DB_QuerySELECTString (Comments,sizeof (Comments) - 1,
|
||||||
"SELECT Comments" // row[0]
|
"can not get log comments",
|
||||||
" FROM log_comments"
|
"SELECT Comments"
|
||||||
" WHERE LogCod=%ld",
|
" FROM log_comments"
|
||||||
LogCod))
|
" WHERE LogCod=%ld",
|
||||||
{
|
LogCod);
|
||||||
/***** Get and write comments *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
HTM_Txt (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Write comments *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
if (Comments[0])
|
||||||
|
HTM_Txt (Comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -3187,37 +3187,17 @@ void Svy_ReceiveQst (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Get next question index in a survey *********************/
|
/************ Get question index from question code in a survey **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned Svy_GetQstIndFromQstCod (long QstCod)
|
static unsigned Svy_GetQstIndFromQstCod (long QstCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
/***** Get question index from database *****/
|
||||||
MYSQL_ROW row;
|
return DB_QuerySELECTUnsigned ("can not get question index",
|
||||||
unsigned long NumRows;
|
"SELECT QstInd"
|
||||||
unsigned QstInd = 0;
|
" FROM svy_questions"
|
||||||
|
" WHERE QstCod=%ld",
|
||||||
/***** Get number of surveys with a field value from database *****/
|
QstCod);
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get question index",
|
|
||||||
"SELECT QstInd" // row[0]
|
|
||||||
" FROM svy_questions"
|
|
||||||
" WHERE QstCod=%ld",
|
|
||||||
QstCod);
|
|
||||||
|
|
||||||
/***** Get number of users *****/
|
|
||||||
if (NumRows)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if (sscanf (row[0],"%u",&QstInd) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting question index.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting question index.");
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return QstInd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -254,7 +254,7 @@ static void SysCfg_Map (void)
|
||||||
/* Get centers with coordinates */
|
/* Get centers with coordinates */
|
||||||
NumCtrs = (unsigned)
|
NumCtrs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get centers with coordinates",
|
DB_QuerySELECT (&mysql_res,"can not get centers with coordinates",
|
||||||
"SELECT CtrCod" // row[0]
|
"SELECT CtrCod"
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE ctr_centers.Latitude<>0"
|
" WHERE ctr_centers.Latitude<>0"
|
||||||
" AND ctr_centers.Longitude<>0");
|
" AND ctr_centers.Longitude<>0");
|
||||||
|
|
144
swad_test.c
144
swad_test.c
|
@ -1355,15 +1355,16 @@ bool Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown (void)
|
||||||
extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
TstCfg_Pluggable_t Pluggable;
|
TstCfg_Pluggable_t Pluggable;
|
||||||
|
|
||||||
/***** Get pluggability of tests for current course from database *****/
|
/***** Get pluggability of tests for current course from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
NumRows = (unsigned)
|
||||||
"SELECT Pluggable" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
||||||
" FROM tst_config"
|
"SELECT Pluggable" // row[0]
|
||||||
" WHERE CrsCod=%ld",
|
" FROM tst_config"
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
" WHERE CrsCod=%ld",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
||||||
|
@ -2908,18 +2909,20 @@ void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question)
|
||||||
/************************* Get tags of a test question ***********************/
|
/************************* Get tags of a test question ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned long Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res)
|
unsigned Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get the tags of a question from database *****/
|
/***** Get the tags of a question from database *****/
|
||||||
return DB_QuerySELECT (mysql_res,"can not get the tags of a question",
|
return (unsigned)
|
||||||
"SELECT tst_tags.TagTxt" // row[0]
|
DB_QuerySELECT (mysql_res,"can not get the tags of a question",
|
||||||
" FROM tst_question_tags,"
|
"SELECT tst_tags.TagTxt" // row[0]
|
||||||
"tst_tags"
|
" FROM tst_question_tags,"
|
||||||
" WHERE tst_question_tags.QstCod=%ld"
|
"tst_tags"
|
||||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
" WHERE tst_question_tags.QstCod=%ld"
|
||||||
" AND tst_tags.CrsCod=%ld"
|
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||||
" ORDER BY tst_question_tags.TagInd",
|
" AND tst_tags.CrsCod=%ld"
|
||||||
QstCod,Gbl.Hierarchy.Crs.CrsCod);
|
" ORDER BY tst_question_tags.TagInd",
|
||||||
|
QstCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2929,18 +2932,18 @@ unsigned long Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res)
|
||||||
void Tst_GetAndWriteTagsQst (long QstCod)
|
void Tst_GetAndWriteTagsQst (long QstCod)
|
||||||
{
|
{
|
||||||
extern const char *Txt_no_tags;
|
extern const char *Txt_no_tags;
|
||||||
unsigned long NumRow;
|
unsigned NumTags;
|
||||||
unsigned long NumRows;
|
unsigned NumTag;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
if ((NumRows = Tst_GetTagsQst (QstCod,&mysql_res)))
|
if ((NumTags = Tst_GetTagsQst (QstCod,&mysql_res)))
|
||||||
{
|
{
|
||||||
/***** Write the tags *****/
|
/***** Write the tags *****/
|
||||||
HTM_UL_Begin ("class=\"TEST_TAG_LIST DAT_SMALL\"");
|
HTM_UL_Begin ("class=\"TEST_TAG_LIST DAT_SMALL\"");
|
||||||
for (NumRow = 0;
|
for (NumTag = 0;
|
||||||
NumRow < NumRows;
|
NumTag < NumTags;
|
||||||
NumRow++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
HTM_LI_Begin (NULL);
|
HTM_LI_Begin (NULL);
|
||||||
|
@ -3813,26 +3816,16 @@ static void Tst_FreeMediaOfQuestion (struct Tst_Question *Question)
|
||||||
|
|
||||||
Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod)
|
Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
char StrAnsTypeDB[256];
|
||||||
MYSQL_ROW row;
|
|
||||||
Tst_AnswerType_t AnswerType;
|
|
||||||
|
|
||||||
/***** Get type of answer from database *****/
|
/***** Get type of answer from database *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get the type of a question",
|
DB_QuerySELECTString (StrAnsTypeDB,sizeof (StrAnsTypeDB) - 1,
|
||||||
"SELECT AnsType" // row[0]
|
"can not get the type of a question",
|
||||||
" FROM tst_questions"
|
"SELECT AnsType"
|
||||||
" WHERE QstCod=%ld",
|
" FROM tst_questions"
|
||||||
QstCod))
|
" WHERE QstCod=%ld",
|
||||||
Lay_ShowErrorAndExit ("Question does not exist.");
|
QstCod);
|
||||||
|
return Tst_ConvertFromStrAnsTypDBToAnsTyp (StrAnsTypeDB);
|
||||||
/* Get type of answer */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
|
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return AnswerType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3844,8 +3837,8 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
bool QuestionExists;
|
bool QuestionExists;
|
||||||
unsigned long NumRows;
|
unsigned NumTags;
|
||||||
unsigned long NumRow;
|
unsigned NumTag;
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Get question data from database *****/
|
/***** Get question data from database *****/
|
||||||
|
@ -3914,14 +3907,14 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Get the tags from the database *****/
|
/***** Get the tags from the database *****/
|
||||||
NumRows = Tst_GetTagsQst (Question->QstCod,&mysql_res);
|
NumTags = Tst_GetTagsQst (Question->QstCod,&mysql_res);
|
||||||
for (NumRow = 0;
|
for (NumTag = 0;
|
||||||
NumRow < NumRows;
|
NumTag < NumTags;
|
||||||
NumRow++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Str_Copy (Question->Tags.Txt[NumRow],row[0],
|
Str_Copy (Question->Tags.Txt[NumTag],row[0],
|
||||||
sizeof (Question->Tags.Txt[NumRow]) - 1);
|
sizeof (Question->Tags.Txt[NumTag]) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
|
@ -4049,16 +4042,17 @@ static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
|
||||||
/** Convert a string with the type of answer in database to type of answer ***/
|
/** Convert a string with the type of answer in database to type of answer ***/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD)
|
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB)
|
||||||
{
|
{
|
||||||
Tst_AnswerType_t AnsType;
|
Tst_AnswerType_t AnsType;
|
||||||
|
|
||||||
if (StrAnsTypeBD != NULL)
|
if (StrAnsTypeDB != NULL)
|
||||||
for (AnsType = (Tst_AnswerType_t) 0;
|
if (StrAnsTypeDB[0])
|
||||||
AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1);
|
for (AnsType = (Tst_AnswerType_t) 0;
|
||||||
AnsType++)
|
AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1);
|
||||||
if (!strcmp (StrAnsTypeBD,Tst_StrAnswerTypesDB[AnsType]))
|
AnsType++)
|
||||||
return AnsType;
|
if (!strcmp (StrAnsTypeDB,Tst_StrAnswerTypesDB[AnsType]))
|
||||||
|
return AnsType;
|
||||||
|
|
||||||
return Tst_ANS_UNKNOWN;
|
return Tst_ANS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@ -5223,18 +5217,18 @@ static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod)
|
||||||
unsigned NumMedia;
|
unsigned NumMedia;
|
||||||
|
|
||||||
/***** Get media codes associated to answers of test questions from database *****/
|
/***** Get media codes associated to answers of test questions from database *****/
|
||||||
NumMedia =
|
NumMedia = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
DB_QuerySELECT (&mysql_res,"can not get media",
|
||||||
"SELECT tst_answers.MedCod" // row[0]
|
"SELECT tst_answers.MedCod"
|
||||||
" FROM tst_answers,"
|
" FROM tst_answers,"
|
||||||
"tst_questions"
|
"tst_questions"
|
||||||
" WHERE tst_answers.QstCod=%ld"
|
" WHERE tst_answers.QstCod=%ld"
|
||||||
" AND tst_answers.QstCod=tst_questions.QstCod"
|
" AND tst_answers.QstCod=tst_questions.QstCod"
|
||||||
" AND tst_questions.CrsCod=%ld" // Extra check
|
" AND tst_questions.CrsCod=%ld" // Extra check
|
||||||
" AND tst_questions.QstCod=%ld", // Extra check
|
" AND tst_questions.QstCod=%ld", // Extra check
|
||||||
QstCod,
|
QstCod,
|
||||||
CrsCod,
|
CrsCod,
|
||||||
QstCod);
|
QstCod);
|
||||||
|
|
||||||
/***** Go over result removing media *****/
|
/***** Go over result removing media *****/
|
||||||
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
||||||
|
@ -5277,14 +5271,14 @@ static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod)
|
||||||
unsigned NumMedia;
|
unsigned NumMedia;
|
||||||
|
|
||||||
/***** Get names of media files associated to answers of test questions from database *****/
|
/***** Get names of media files associated to answers of test questions from database *****/
|
||||||
NumMedia =
|
NumMedia = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
DB_QuerySELECT (&mysql_res,"can not get media",
|
||||||
"SELECT tst_answers.MedCod" // row[0]
|
"SELECT tst_answers.MedCod"
|
||||||
" FROM tst_questions,"
|
" FROM tst_questions,"
|
||||||
"tst_answers"
|
"tst_answers"
|
||||||
" WHERE tst_questions.CrsCod=%ld"
|
" WHERE tst_questions.CrsCod=%ld"
|
||||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||||
CrsCod);
|
CrsCod);
|
||||||
|
|
||||||
/***** Go over result removing media files *****/
|
/***** Go over result removing media files *****/
|
||||||
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
||||||
|
|
|
@ -143,7 +143,7 @@ void Tst_WriteParamQstCod (unsigned NumQst,long QstCod);
|
||||||
|
|
||||||
void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question);
|
void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question);
|
||||||
|
|
||||||
unsigned long Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res);
|
unsigned Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res);
|
||||||
void Tst_GetAndWriteTagsQst (long QstCod);
|
void Tst_GetAndWriteTagsQst (long QstCod);
|
||||||
|
|
||||||
void Tst_ShowFormConfig (void);
|
void Tst_ShowFormConfig (void);
|
||||||
|
@ -161,7 +161,7 @@ bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt
|
||||||
|
|
||||||
Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod);
|
Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod);
|
||||||
bool Tst_GetQstDataFromDB (struct Tst_Question *Question);
|
bool Tst_GetQstDataFromDB (struct Tst_Question *Question);
|
||||||
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD);
|
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB);
|
||||||
void Tst_ReceiveQst (void);
|
void Tst_ReceiveQst (void);
|
||||||
bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Question);
|
bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Question);
|
||||||
|
|
||||||
|
|
|
@ -301,16 +301,16 @@ static void TsI_ExportQuestion (struct Tst_Question *Question,FILE *FileXML)
|
||||||
static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
|
static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
|
||||||
{
|
{
|
||||||
extern const char *Txt_NEW_LINE;
|
extern const char *Txt_NEW_LINE;
|
||||||
unsigned long NumRow;
|
unsigned NumTags;
|
||||||
unsigned long NumRows;
|
unsigned NumTag;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
if ((NumRows = Tst_GetTagsQst (QstCod,&mysql_res))) // Result: TagTxt
|
if ((NumTags = Tst_GetTagsQst (QstCod,&mysql_res))) // Result: TagTxt
|
||||||
/***** Write the tags *****/
|
/***** Write the tags *****/
|
||||||
for (NumRow = 1;
|
for (NumTag = 1;
|
||||||
NumRow <= NumRows;
|
NumTag <= NumTags;
|
||||||
NumRow++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
fprintf (FileXML,"<tag>%s</tag>%s",
|
fprintf (FileXML,"<tag>%s</tag>%s",
|
||||||
|
|
|
@ -872,12 +872,12 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question)
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM tst_answers"
|
" FROM tst_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
Question->QstCod);
|
Question->QstCod);
|
||||||
|
|
||||||
/***** Check if number of rows is correct *****/
|
/***** Check if number of rows is correct *****/
|
||||||
Tst_CheckIfNumberOfAnswersIsOne (Question);
|
Tst_CheckIfNumberOfAnswersIsOne (Question);
|
||||||
|
@ -899,12 +899,12 @@ static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question)
|
||||||
double Tmp;
|
double Tmp;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM tst_answers"
|
" FROM tst_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
Question->QstCod);
|
Question->QstCod);
|
||||||
|
|
||||||
/***** Check if number of rows is correct *****/
|
/***** Check if number of rows is correct *****/
|
||||||
if (Question->Answer.NumOptions != 2)
|
if (Question->Answer.NumOptions != 2)
|
||||||
|
@ -937,12 +937,12 @@ static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question)
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM tst_answers"
|
" FROM tst_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
Question->QstCod);
|
Question->QstCod);
|
||||||
|
|
||||||
/***** Check if number of rows is correct *****/
|
/***** Check if number of rows is correct *****/
|
||||||
Tst_CheckIfNumberOfAnswersIsOne (Question);
|
Tst_CheckIfNumberOfAnswersIsOne (Question);
|
||||||
|
@ -962,13 +962,13 @@ static void TstPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Correct" // row[0]
|
"SELECT Correct" // row[0]
|
||||||
" FROM tst_answers"
|
" FROM tst_answers"
|
||||||
" WHERE QstCod=%ld"
|
" WHERE QstCod=%ld"
|
||||||
" ORDER BY AnsInd",
|
" ORDER BY AnsInd",
|
||||||
Question->QstCod);
|
Question->QstCod);
|
||||||
for (NumOpt = 0;
|
for (NumOpt = 0;
|
||||||
NumOpt < Question->Answer.NumOptions;
|
NumOpt < Question->Answer.NumOptions;
|
||||||
NumOpt++)
|
NumOpt++)
|
||||||
|
@ -991,12 +991,12 @@ static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM tst_answers"
|
" FROM tst_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
Question->QstCod);
|
Question->QstCod);
|
||||||
|
|
||||||
/***** Get text and correctness of answers for this question from database (one row per answer) *****/
|
/***** Get text and correctness of answers for this question from database (one row per answer) *****/
|
||||||
for (NumOpt = 0;
|
for (NumOpt = 0;
|
||||||
|
@ -2067,19 +2067,19 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
||||||
-----|______Exam_|_____|-----------------|_____|_Exam______|-----> time
|
-----|______Exam_|_____|-----------------|_____|_Exam______|-----> time
|
||||||
Start | End Start | End
|
Start | End Start | End
|
||||||
*/
|
*/
|
||||||
NumPrints =
|
NumPrints = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test exams of a user",
|
DB_QuerySELECT (&mysql_res,"can not get test exams of a user",
|
||||||
"SELECT ExaCod" // row[0]
|
"SELECT ExaCod" // row[0]
|
||||||
" FROM tst_exams"
|
" FROM tst_exams"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod=%ld"
|
" AND UsrCod=%ld"
|
||||||
" AND EndTime>=FROM_UNIXTIME(%ld)"
|
" AND EndTime>=FROM_UNIXTIME(%ld)"
|
||||||
" AND StartTime<=FROM_UNIXTIME(%ld)"
|
" AND StartTime<=FROM_UNIXTIME(%ld)"
|
||||||
" ORDER BY ExaCod",
|
" ORDER BY ExaCod",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
UsrDat->UsrCod,
|
UsrDat->UsrCod,
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
|
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
|
||||||
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]);
|
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME ]);
|
||||||
|
|
||||||
/***** Show user's data *****/
|
/***** Show user's data *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -2752,17 +2752,16 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
||||||
unsigned NumQst;
|
unsigned NumQst;
|
||||||
|
|
||||||
/***** Get questions of a test exam print from database *****/
|
/***** Get questions of a test exam print from database *****/
|
||||||
NumQsts =
|
NumQsts = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get questions"
|
DB_QuerySELECT (&mysql_res,"can not get questions of a test exam",
|
||||||
" of a test exam",
|
"SELECT QstCod," // row[0]
|
||||||
"SELECT QstCod," // row[0]
|
"Score," // row[1]
|
||||||
"Score," // row[1]
|
"Indexes," // row[2]
|
||||||
"Indexes," // row[2]
|
"Answers" // row[3]
|
||||||
"Answers" // row[3]
|
" FROM tst_exam_questions"
|
||||||
" FROM tst_exam_questions"
|
" WHERE ExaCod=%ld"
|
||||||
" WHERE ExaCod=%ld"
|
" ORDER BY QstInd",
|
||||||
" ORDER BY QstInd",
|
Print->PrnCod);
|
||||||
Print->PrnCod);
|
|
||||||
|
|
||||||
/***** Get questions *****/
|
/***** Get questions *****/
|
||||||
if (NumQsts == Print->NumQsts.All)
|
if (NumQsts == Print->NumQsts.All)
|
||||||
|
|
|
@ -691,8 +691,8 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
extern const char *Txt_Incomplete_timetable_for_lack_of_space;
|
extern const char *Txt_Incomplete_timetable_for_lack_of_space;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
unsigned NumRows = 0; // Initialized to avoid warning
|
||||||
unsigned long NumRow;
|
unsigned NumRow;
|
||||||
unsigned Weekday;
|
unsigned Weekday;
|
||||||
unsigned Interval;
|
unsigned Interval;
|
||||||
unsigned i; // To iterate through intervals
|
unsigned i; // To iterate through intervals
|
||||||
|
@ -715,7 +715,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
switch (Gbl.Crs.Grps.WhichGrps)
|
switch (Gbl.Crs.Grps.WhichGrps)
|
||||||
{
|
{
|
||||||
case Grp_MY_GROUPS:
|
case Grp_MY_GROUPS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
||||||
"SELECT tmt_courses.Weekday," // row[0]
|
"SELECT tmt_courses.Weekday," // row[0]
|
||||||
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
||||||
|
@ -763,7 +763,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
UsrCod);
|
UsrCod);
|
||||||
break;
|
break;
|
||||||
case Grp_ALL_GROUPS:
|
case Grp_ALL_GROUPS:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
||||||
"SELECT tmt_courses.Weekday," // row[0]
|
"SELECT tmt_courses.Weekday," // row[0]
|
||||||
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
||||||
|
@ -802,7 +802,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
if (Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS ||
|
if (Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS ||
|
||||||
Gbl.Action.Act == ActEdiCrsTT ||
|
Gbl.Action.Act == ActEdiCrsTT ||
|
||||||
Gbl.Action.Act == ActChgCrsTT) // If we are editing, all groups are shown
|
Gbl.Action.Act == ActChgCrsTT) // If we are editing, all groups are shown
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
||||||
"SELECT Weekday," // row[0]
|
"SELECT Weekday," // row[0]
|
||||||
"TIME_TO_SEC(StartTime) AS S," // row[1]
|
"TIME_TO_SEC(StartTime) AS S," // row[1]
|
||||||
|
@ -820,7 +820,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
"D DESC",
|
"D DESC",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
else
|
else
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
||||||
"SELECT tmt_courses.Weekday," // row[0]
|
"SELECT tmt_courses.Weekday," // row[0]
|
||||||
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
"TIME_TO_SEC(tmt_courses.StartTime) AS S," // row[1]
|
||||||
|
@ -856,7 +856,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
|
||||||
Gbl.Hierarchy.Crs.CrsCod,UsrCod);
|
Gbl.Hierarchy.Crs.CrsCod,UsrCod);
|
||||||
break;
|
break;
|
||||||
case Tmt_TUTORING_TIMETABLE:
|
case Tmt_TUTORING_TIMETABLE:
|
||||||
NumRows =
|
NumRows = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
DB_QuerySELECT (&mysql_res,"can not get timetable",
|
||||||
"SELECT Weekday," // row[0]
|
"SELECT Weekday," // row[0]
|
||||||
"TIME_TO_SEC(StartTime) AS S," // row[1]
|
"TIME_TO_SEC(StartTime) AS S," // row[1]
|
||||||
|
|
636
swad_user.c
636
swad_user.c
|
@ -457,17 +457,15 @@ void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
if (UsrDat->EnUsrCod[0])
|
if (UsrDat->EnUsrCod[0])
|
||||||
{
|
{
|
||||||
/***** Get user's code from database *****/
|
/***** Get user's code from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's code",
|
if (DB_QuerySELECT (&mysql_res,"can not get user's code",
|
||||||
"SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE EncryptedUsrCod='%s'",
|
" WHERE EncryptedUsrCod='%s'",
|
||||||
UsrDat->EnUsrCod);
|
UsrDat->EnUsrCod) != 1)
|
||||||
if (NumRows != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting user's code.");
|
Lay_ShowErrorAndExit ("Error when getting user's code.");
|
||||||
|
|
||||||
/***** Get user's code *****/
|
/***** Get user's code *****/
|
||||||
|
@ -494,7 +492,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat,Usr_GetPrefs_t GetPrefs)
|
||||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
The_Theme_t Theme;
|
The_Theme_t Theme;
|
||||||
Ico_IconSet_t IconSet;
|
Ico_IconSet_t IconSet;
|
||||||
Lan_Language_t Lan;
|
Lan_Language_t Lan;
|
||||||
|
@ -503,76 +501,78 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat,Usr_GetPrefs_t GetPrefs)
|
||||||
switch (GetPrefs)
|
switch (GetPrefs)
|
||||||
{
|
{
|
||||||
case Usr_DONT_GET_PREFS:
|
case Usr_DONT_GET_PREFS:
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's data",
|
NumRows = (unsigned)
|
||||||
"SELECT EncryptedUsrCod," // row[ 0]
|
DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||||
"Password," // row[ 1]
|
"SELECT EncryptedUsrCod," // row[ 0]
|
||||||
"Surname1," // row[ 2]
|
"Password," // row[ 1]
|
||||||
"Surname2," // row[ 3]
|
"Surname1," // row[ 2]
|
||||||
"FirstName," // row[ 4]
|
"Surname2," // row[ 3]
|
||||||
"Sex," // row[ 5]
|
"FirstName," // row[ 4]
|
||||||
"Photo," // row[ 6]
|
"Sex," // row[ 5]
|
||||||
"PhotoVisibility," // row[ 7]
|
"Photo," // row[ 6]
|
||||||
"BaPrfVisibility," // row[ 8]
|
"PhotoVisibility," // row[ 7]
|
||||||
"ExPrfVisibility," // row[ 9]
|
"BaPrfVisibility," // row[ 8]
|
||||||
"CtyCod," // row[10]
|
"ExPrfVisibility," // row[ 9]
|
||||||
"InsCtyCod," // row[11]
|
"CtyCod," // row[10]
|
||||||
"InsCod," // row[12]
|
"InsCtyCod," // row[11]
|
||||||
"DptCod," // row[13]
|
"InsCod," // row[12]
|
||||||
"CtrCod," // row[14]
|
"DptCod," // row[13]
|
||||||
"Office," // row[15]
|
"CtrCod," // row[14]
|
||||||
"OfficePhone," // row[16]
|
"Office," // row[15]
|
||||||
"LocalPhone," // row[17]
|
"OfficePhone," // row[16]
|
||||||
"FamilyPhone," // row[18]
|
"LocalPhone," // row[17]
|
||||||
"DATE_FORMAT(Birthday,"
|
"FamilyPhone," // row[18]
|
||||||
"'%%Y%%m%%d')," // row[19]
|
"DATE_FORMAT(Birthday,"
|
||||||
"Comments," // row[20]
|
"'%%Y%%m%%d')," // row[19]
|
||||||
"NotifNtfEvents," // row[21]
|
"Comments," // row[20]
|
||||||
"EmailNtfEvents" // row[22]
|
"NotifNtfEvents," // row[21]
|
||||||
" FROM usr_data"
|
"EmailNtfEvents" // row[22]
|
||||||
" WHERE UsrCod=%ld",
|
" FROM usr_data"
|
||||||
UsrDat->UsrCod);
|
" WHERE UsrCod=%ld",
|
||||||
|
UsrDat->UsrCod);
|
||||||
break;
|
break;
|
||||||
case Usr_GET_PREFS:
|
case Usr_GET_PREFS:
|
||||||
default:
|
default:
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's data",
|
NumRows = (unsigned)
|
||||||
"SELECT EncryptedUsrCod," // row[ 0]
|
DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||||
"Password," // row[ 1]
|
"SELECT EncryptedUsrCod," // row[ 0]
|
||||||
"Surname1," // row[ 2]
|
"Password," // row[ 1]
|
||||||
"Surname2," // row[ 3]
|
"Surname1," // row[ 2]
|
||||||
"FirstName," // row[ 4]
|
"Surname2," // row[ 3]
|
||||||
"Sex," // row[ 5]
|
"FirstName," // row[ 4]
|
||||||
"Photo," // row[ 6]
|
"Sex," // row[ 5]
|
||||||
"PhotoVisibility," // row[ 7]
|
"Photo," // row[ 6]
|
||||||
"BaPrfVisibility," // row[ 8]
|
"PhotoVisibility," // row[ 7]
|
||||||
"ExPrfVisibility," // row[ 9]
|
"BaPrfVisibility," // row[ 8]
|
||||||
"CtyCod," // row[10]
|
"ExPrfVisibility," // row[ 9]
|
||||||
"InsCtyCod," // row[11]
|
"CtyCod," // row[10]
|
||||||
"InsCod," // row[12]
|
"InsCtyCod," // row[11]
|
||||||
"DptCod," // row[13]
|
"InsCod," // row[12]
|
||||||
"CtrCod," // row[14]
|
"DptCod," // row[13]
|
||||||
"Office," // row[15]
|
"CtrCod," // row[14]
|
||||||
"OfficePhone," // row[16]
|
"Office," // row[15]
|
||||||
"LocalPhone," // row[17]
|
"OfficePhone," // row[16]
|
||||||
"FamilyPhone," // row[18]
|
"LocalPhone," // row[17]
|
||||||
"DATE_FORMAT(Birthday,"
|
"FamilyPhone," // row[18]
|
||||||
"'%%Y%%m%%d')," // row[19]
|
"DATE_FORMAT(Birthday,"
|
||||||
"Comments," // row[20]
|
"'%%Y%%m%%d')," // row[19]
|
||||||
"NotifNtfEvents," // row[21]
|
"Comments," // row[20]
|
||||||
"EmailNtfEvents," // row[22]
|
"NotifNtfEvents," // row[21]
|
||||||
|
"EmailNtfEvents," // row[22]
|
||||||
|
|
||||||
// Settings (usually not necessary
|
// Settings (usually not necessary
|
||||||
// when getting another user's data)
|
// when getting another user's data)
|
||||||
"Language," // row[23]
|
"Language," // row[23]
|
||||||
"FirstDayOfWeek," // row[24]
|
"FirstDayOfWeek," // row[24]
|
||||||
"DateFormat," // row[25]
|
"DateFormat," // row[25]
|
||||||
"Theme," // row[26]
|
"Theme," // row[26]
|
||||||
"IconSet," // row[27]
|
"IconSet," // row[27]
|
||||||
"Menu," // row[28]
|
"Menu," // row[28]
|
||||||
"SideCols," // row[29]
|
"SideCols," // row[29]
|
||||||
"ThirdPartyCookies" // row[30]
|
"ThirdPartyCookies" // row[30]
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrDat->UsrCod);
|
UsrDat->UsrCod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,22 +743,23 @@ static void Usr_GetMyLastData (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
unsigned UnsignedNum;
|
unsigned UnsignedNum;
|
||||||
long ActCod;
|
long ActCod;
|
||||||
|
|
||||||
/***** Get user's last data from database *****/
|
/***** Get user's last data from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's last data",
|
NumRows = (unsigned)
|
||||||
"SELECT WhatToSearch," // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get user's last data",
|
||||||
"LastSco," // row[1]
|
"SELECT WhatToSearch," // row[0]
|
||||||
"LastCod," // row[2]
|
"LastSco," // row[1]
|
||||||
"LastAct," // row[3]
|
"LastCod," // row[2]
|
||||||
"LastRole," // row[4]
|
"LastAct," // row[3]
|
||||||
"UNIX_TIMESTAMP(LastTime)," // row[5]
|
"LastRole," // row[4]
|
||||||
"UNIX_TIMESTAMP(LastAccNotif)" // row[6]
|
"UNIX_TIMESTAMP(LastTime)," // row[5]
|
||||||
" FROM usr_last"
|
"UNIX_TIMESTAMP(LastAccNotif)" // row[6]
|
||||||
" WHERE UsrCod=%ld",
|
" FROM usr_last"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
" WHERE UsrCod=%ld",
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
{
|
{
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -1551,26 +1552,26 @@ void Usr_GetMyCountrs (void)
|
||||||
Gbl.Usrs.Me.MyCtys.Num = 0;
|
Gbl.Usrs.Me.MyCtys.Num = 0;
|
||||||
|
|
||||||
/***** Get my institutions from database *****/
|
/***** Get my institutions from database *****/
|
||||||
if ((NumCtys = (unsigned) Usr_GetCtysFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_res)) > 0) // Countries found
|
NumCtys = Usr_GetCtysFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_res);
|
||||||
for (NumCty = 0;
|
for (NumCty = 0;
|
||||||
NumCty < NumCtys;
|
NumCty < NumCtys;
|
||||||
NumCty++)
|
NumCty++)
|
||||||
{
|
{
|
||||||
/* Get next country */
|
/* Get next country */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get country code */
|
/* Get country code */
|
||||||
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.MyCtys.Num == Cty_MAX_COUNTRS_PER_USR)
|
if (Gbl.Usrs.Me.MyCtys.Num == Cty_MAX_COUNTRS_PER_USR)
|
||||||
Lay_ShowErrorAndExit ("Maximum number of countries of a user exceeded.");
|
Lay_ShowErrorAndExit ("Maximum number of countries of a user exceeded.");
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyCtys.Ctys[Gbl.Usrs.Me.MyCtys.Num].CtyCod = CtyCod;
|
Gbl.Usrs.Me.MyCtys.Ctys[Gbl.Usrs.Me.MyCtys.Num].CtyCod = CtyCod;
|
||||||
Gbl.Usrs.Me.MyCtys.Ctys[Gbl.Usrs.Me.MyCtys.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
Gbl.Usrs.Me.MyCtys.Ctys[Gbl.Usrs.Me.MyCtys.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyCtys.Num++;
|
Gbl.Usrs.Me.MyCtys.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1598,26 +1599,26 @@ void Usr_GetMyInstits (void)
|
||||||
Gbl.Usrs.Me.MyInss.Num = 0;
|
Gbl.Usrs.Me.MyInss.Num = 0;
|
||||||
|
|
||||||
/***** Get my institutions from database *****/
|
/***** Get my institutions from database *****/
|
||||||
if ((NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res)) > 0) // Institutions found
|
NumInss = Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res);
|
||||||
for (NumIns = 0;
|
for (NumIns = 0;
|
||||||
NumIns < NumInss;
|
NumIns < NumInss;
|
||||||
NumIns++)
|
NumIns++)
|
||||||
{
|
{
|
||||||
/* Get next institution */
|
/* Get next institution */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get institution code */
|
/* Get institution code */
|
||||||
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.MyInss.Num == Ins_MAX_INSTITS_PER_USR)
|
if (Gbl.Usrs.Me.MyInss.Num == Ins_MAX_INSTITS_PER_USR)
|
||||||
Lay_ShowErrorAndExit ("Maximum number of institutions of a user exceeded.");
|
Lay_ShowErrorAndExit ("Maximum number of institutions of a user exceeded.");
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyInss.Inss[Gbl.Usrs.Me.MyInss.Num].InsCod = InsCod;
|
Gbl.Usrs.Me.MyInss.Inss[Gbl.Usrs.Me.MyInss.Num].InsCod = InsCod;
|
||||||
Gbl.Usrs.Me.MyInss.Inss[Gbl.Usrs.Me.MyInss.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
Gbl.Usrs.Me.MyInss.Inss[Gbl.Usrs.Me.MyInss.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyInss.Num++;
|
Gbl.Usrs.Me.MyInss.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1645,26 +1646,26 @@ void Usr_GetMyCenters (void)
|
||||||
Gbl.Usrs.Me.MyCtrs.Num = 0;
|
Gbl.Usrs.Me.MyCtrs.Num = 0;
|
||||||
|
|
||||||
/***** Get my centers from database *****/
|
/***** Get my centers from database *****/
|
||||||
if ((NumCtrs = (unsigned) Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res)) > 0) // Centers found
|
NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res);
|
||||||
for (NumCtr = 0;
|
for (NumCtr = 0;
|
||||||
NumCtr < NumCtrs;
|
NumCtr < NumCtrs;
|
||||||
NumCtr++)
|
NumCtr++)
|
||||||
{
|
{
|
||||||
/* Get next center */
|
/* Get next center */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get center code */
|
/* Get center code */
|
||||||
if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.MyCtrs.Num == Ctr_MAX_CENTERS_PER_USR)
|
if (Gbl.Usrs.Me.MyCtrs.Num == Ctr_MAX_CENTERS_PER_USR)
|
||||||
Lay_ShowErrorAndExit ("Maximum number of centers of a user exceeded.");
|
Lay_ShowErrorAndExit ("Maximum number of centers of a user exceeded.");
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyCtrs.Ctrs[Gbl.Usrs.Me.MyCtrs.Num].CtrCod = CtrCod;
|
Gbl.Usrs.Me.MyCtrs.Ctrs[Gbl.Usrs.Me.MyCtrs.Num].CtrCod = CtrCod;
|
||||||
Gbl.Usrs.Me.MyCtrs.Ctrs[Gbl.Usrs.Me.MyCtrs.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
Gbl.Usrs.Me.MyCtrs.Ctrs[Gbl.Usrs.Me.MyCtrs.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyCtrs.Num++;
|
Gbl.Usrs.Me.MyCtrs.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1692,26 +1693,26 @@ void Usr_GetMyDegrees (void)
|
||||||
Gbl.Usrs.Me.MyDegs.Num = 0;
|
Gbl.Usrs.Me.MyDegs.Num = 0;
|
||||||
|
|
||||||
/***** Get my degrees from database *****/
|
/***** Get my degrees from database *****/
|
||||||
if ((NumDegs = (unsigned) Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res)) > 0) // Degrees found
|
NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res);
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
NumDeg < NumDegs;
|
NumDeg < NumDegs;
|
||||||
NumDeg++)
|
NumDeg++)
|
||||||
{
|
{
|
||||||
/* Get next degree */
|
/* Get next degree */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get degree code */
|
/* Get degree code */
|
||||||
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.MyDegs.Num == Deg_MAX_DEGREES_PER_USR)
|
if (Gbl.Usrs.Me.MyDegs.Num == Deg_MAX_DEGREES_PER_USR)
|
||||||
Lay_ShowErrorAndExit ("Maximum number of degrees of a user exceeded.");
|
Lay_ShowErrorAndExit ("Maximum number of degrees of a user exceeded.");
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyDegs.Degs[Gbl.Usrs.Me.MyDegs.Num].DegCod = DegCod;
|
Gbl.Usrs.Me.MyDegs.Degs[Gbl.Usrs.Me.MyDegs.Num].DegCod = DegCod;
|
||||||
Gbl.Usrs.Me.MyDegs.Degs[Gbl.Usrs.Me.MyDegs.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
Gbl.Usrs.Me.MyDegs.Degs[Gbl.Usrs.Me.MyDegs.Num].MaxRole = Rol_ConvertUnsignedStrToRole (row[1]);
|
||||||
|
|
||||||
Gbl.Usrs.Me.MyDegs.Num++;
|
Gbl.Usrs.Me.MyDegs.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1764,13 +1765,12 @@ void Usr_GetMyCourses (void)
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
|
||||||
/***** Get my courses from database *****/
|
/***** Get my courses from database *****/
|
||||||
NumCrss =
|
NumCrss = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get which courses"
|
DB_QuerySELECT (&mysql_res,"can not get which courses you belong to",
|
||||||
" you belong to",
|
"SELECT CrsCod," // row[0]
|
||||||
"SELECT CrsCod," // row[0]
|
"Role," // row[1]
|
||||||
"Role," // row[1]
|
"DegCod" // row[2]
|
||||||
"DegCod" // row[2]
|
" FROM my_courses_tmp");
|
||||||
" FROM my_courses_tmp");
|
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < NumCrss;
|
NumCrs < NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
|
@ -2264,46 +2264,47 @@ unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns the number of rows of the result
|
// Returns the number of rows of the result
|
||||||
|
|
||||||
unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res)
|
unsigned Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get the institutions a user belongs to from database *****/
|
/***** Get the institutions a user belongs to from database *****/
|
||||||
if (CtyCod > 0)
|
if (CtyCod > 0)
|
||||||
return DB_QuerySELECT (mysql_res,"can not get the institutions"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not get the institutions a user belongs to",
|
||||||
"SELECT ins_instits.InsCod," // row[0]
|
"SELECT ins_instits.InsCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
"ins_instits"
|
"ins_instits"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
" AND ins_instits.CtyCod=%ld"
|
" AND ins_instits.CtyCod=%ld"
|
||||||
" GROUP BY ins_instits.InsCod"
|
" GROUP BY ins_instits.InsCod"
|
||||||
" ORDER BY ins_instits.ShortName",
|
" ORDER BY ins_instits.ShortName",
|
||||||
UsrCod,CtyCod);
|
UsrCod,
|
||||||
|
CtyCod);
|
||||||
else
|
else
|
||||||
return DB_QuerySELECT (mysql_res,"can not get the ins_instits"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not get the institutions a user belongs to",
|
||||||
"SELECT ins_instits.InsCod," // row[0]
|
"SELECT ins_instits.InsCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
"ins_instits"
|
"ins_instits"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||||
" GROUP BY ins_instits.InsCod"
|
" GROUP BY ins_instits.InsCod"
|
||||||
" ORDER BY ins_instits.ShortName",
|
" ORDER BY ins_instits.ShortName",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2311,42 +2312,43 @@ unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns the number of rows of the result
|
// Returns the number of rows of the result
|
||||||
|
|
||||||
unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res)
|
unsigned Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get from database the centers a user belongs to *****/
|
/***** Get from database the centers a user belongs to *****/
|
||||||
if (InsCod > 0)
|
if (InsCod > 0)
|
||||||
return DB_QuerySELECT (mysql_res,"can not check the centers"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not check the centers a user belongs to",
|
||||||
"SELECT ctr_centers.CtrCod," // row[0]
|
"SELECT ctr_centers.CtrCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"ctr_centers"
|
"ctr_centers"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" AND ctr_centers.InsCod=%ld"
|
" AND ctr_centers.InsCod=%ld"
|
||||||
" GROUP BY ctr_centers.CtrCod"
|
" GROUP BY ctr_centers.CtrCod"
|
||||||
" ORDER BY ctr_centers.ShortName",
|
" ORDER BY ctr_centers.ShortName",
|
||||||
UsrCod,InsCod);
|
UsrCod,
|
||||||
|
InsCod);
|
||||||
else
|
else
|
||||||
return DB_QuerySELECT (mysql_res,"can not check the centers"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not check the centers a user belongs to",
|
||||||
"SELECT deg_degrees.CtrCod," // row[0]
|
"SELECT deg_degrees.CtrCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"ctr_centers"
|
"ctr_centers"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||||
" GROUP BY ctr_centers.CtrCod"
|
" GROUP BY ctr_centers.CtrCod"
|
||||||
" ORDER BY ctr_centers.ShortName",
|
" ORDER BY ctr_centers.ShortName",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2354,38 +2356,39 @@ unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns the number of rows of the result
|
// Returns the number of rows of the result
|
||||||
|
|
||||||
unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res)
|
unsigned Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get from database the degrees a user belongs to *****/
|
/***** Get from database the degrees a user belongs to *****/
|
||||||
if (CtrCod > 0)
|
if (CtrCod > 0)
|
||||||
return DB_QuerySELECT (mysql_res,"can not check the degrees"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not check the degrees a user belongs to",
|
||||||
"SELECT deg_degrees.DegCod," // row[0]
|
"SELECT deg_degrees.DegCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" AND deg_degrees.CtrCod=%ld"
|
" AND deg_degrees.CtrCod=%ld"
|
||||||
" GROUP BY deg_degrees.DegCod"
|
" GROUP BY deg_degrees.DegCod"
|
||||||
" ORDER BY deg_degrees.ShortName",
|
" ORDER BY deg_degrees.ShortName",
|
||||||
UsrCod,CtrCod);
|
UsrCod,
|
||||||
|
CtrCod);
|
||||||
else
|
else
|
||||||
return DB_QuerySELECT (mysql_res,"can not check the degrees"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not check the degrees a user belongs to",
|
||||||
"SELECT deg_degrees.DegCod," // row[0]
|
"SELECT deg_degrees.DegCod," // row[0]
|
||||||
"MAX(crs_users.Role)" // row[1]
|
"MAX(crs_users.Role)" // row[1]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" GROUP BY deg_degrees.DegCod"
|
" GROUP BY deg_degrees.DegCod"
|
||||||
" ORDER BY deg_degrees.ShortName",
|
" ORDER BY deg_degrees.ShortName",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2393,37 +2396,38 @@ unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Returns the number of rows of the result
|
// Returns the number of rows of the result
|
||||||
|
|
||||||
unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res)
|
unsigned Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
/***** Get from database the courses a user belongs to *****/
|
/***** Get from database the courses a user belongs to *****/
|
||||||
if (DegCod > 0) // Courses in a degree
|
if (DegCod > 0) // Courses in a degree
|
||||||
return DB_QuerySELECT (mysql_res,"can not get the courses"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not get the courses a user belongs to",
|
||||||
"SELECT crs_users.CrsCod," // row[0]
|
"SELECT crs_users.CrsCod," // row[0]
|
||||||
"crs_users.Role," // row[1]
|
"crs_users.Role," // row[1]
|
||||||
"crs_courses.DegCod" // row[2]
|
"crs_courses.DegCod" // row[2]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses"
|
"crs_courses"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=%ld"
|
" AND crs_courses.DegCod=%ld"
|
||||||
" ORDER BY crs_courses.ShortName",
|
" ORDER BY crs_courses.ShortName",
|
||||||
UsrCod,DegCod);
|
UsrCod,
|
||||||
|
DegCod);
|
||||||
else // All the courses
|
else // All the courses
|
||||||
return DB_QuerySELECT (mysql_res,"can not get the courses"
|
return (unsigned)
|
||||||
" a user belongs to",
|
DB_QuerySELECT (mysql_res,"can not get the courses a user belongs to",
|
||||||
"SELECT crs_users.CrsCod," // row[0]
|
"SELECT crs_users.CrsCod," // row[0]
|
||||||
"crs_users.Role," // row[1]
|
"crs_users.Role," // row[1]
|
||||||
"crs_courses.DegCod" // row[2]
|
"crs_courses.DegCod" // row[2]
|
||||||
" FROM crs_users,"
|
" FROM crs_users,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
" WHERE crs_users.UsrCod=%ld"
|
" WHERE crs_users.UsrCod=%ld"
|
||||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||||
" ORDER BY deg_degrees.ShortName,"
|
" ORDER BY deg_degrees.ShortName,"
|
||||||
"crs_courses.ShortName",
|
"crs_courses.ShortName",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -5499,10 +5503,10 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Lvl_Level_
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
if ((Gbl.Usrs.LstUsrs[Role].NumUsrs =
|
if ((Gbl.Usrs.LstUsrs[Role].NumUsrs = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get list of users",
|
DB_QuerySELECT (&mysql_res,"can not get list of users",
|
||||||
"%s",
|
"%s",
|
||||||
Query)))
|
Query)))
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST)
|
if (Gbl.Usrs.LstUsrs[Role].NumUsrs > Cfg_MAX_USRS_IN_LIST)
|
||||||
{
|
{
|
||||||
|
@ -5831,7 +5835,7 @@ void Usr_GetListsSelectedEncryptedUsrsCods (struct SelectedUsrs *SelectedUsrs)
|
||||||
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
|
if (Gbl.Session.IsOpen) // If the session is open, get parameter from DB
|
||||||
{
|
{
|
||||||
Ses_GetParamFromDB (ParamName,SelectedUsrs->List[Rol_UNK],
|
Ses_GetParamFromDB (ParamName,SelectedUsrs->List[Rol_UNK],
|
||||||
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
|
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS);
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,SelectedUsrs->List[Rol_UNK],
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,SelectedUsrs->List[Rol_UNK],
|
||||||
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS,true);
|
Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS,true);
|
||||||
}
|
}
|
||||||
|
@ -7757,17 +7761,18 @@ static void Usr_GetMyUsrListTypeFromDB (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
Usr_ShowUsrsType_t ListType;
|
Usr_ShowUsrsType_t ListType;
|
||||||
|
|
||||||
/***** Get type of listing of users from database *****/
|
/***** Get type of listing of users from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get type of listing of users",
|
NumRows = (unsigned)
|
||||||
"SELECT UsrListType" // row[0]
|
DB_QuerySELECT (&mysql_res,"can not get type of listing of users",
|
||||||
" FROM crs_user_settings"
|
"SELECT UsrListType" // row[0]
|
||||||
" WHERE UsrCod=%ld"
|
" FROM crs_user_settings"
|
||||||
" AND CrsCod=%ld",
|
" WHERE UsrCod=%ld"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
" AND CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
if (NumRows == 1) // Should be one only row
|
if (NumRows == 1) // Should be one only row
|
||||||
{
|
{
|
||||||
/* Get type of users' listing used to select some of them */
|
/* Get type of users' listing used to select some of them */
|
||||||
|
@ -7860,7 +7865,7 @@ static void Usr_GetMyColsClassPhotoFromDB (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF;
|
Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF;
|
||||||
|
|
||||||
|
@ -7869,14 +7874,14 @@ static void Usr_GetMyColsClassPhotoFromDB (void)
|
||||||
Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
|
Gbl.Hierarchy.Level == Hie_Lvl_CRS) // Course selected
|
||||||
{
|
{
|
||||||
/***** Get number of columns in class photo from database *****/
|
/***** Get number of columns in class photo from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get number of columns"
|
NumRows = (unsigned)
|
||||||
" in class photo",
|
DB_QuerySELECT (&mysql_res,"can not get number of columns in class photo",
|
||||||
"SELECT ColsClassPhoto" // row[0]
|
"SELECT ColsClassPhoto" // row[0]
|
||||||
" FROM crs_user_settings"
|
" FROM crs_user_settings"
|
||||||
" WHERE UsrCod=%ld"
|
" WHERE UsrCod=%ld"
|
||||||
" AND CrsCod=%ld",
|
" AND CrsCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
if (NumRows == 1) // Should be one only row
|
if (NumRows == 1) // Should be one only row
|
||||||
{
|
{
|
||||||
/* Get number of columns in class photo */
|
/* Get number of columns in class photo */
|
||||||
|
@ -7970,7 +7975,7 @@ void Usr_GetMyPrefAboutListWithPhotosFromDB (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
Gbl.Usrs.Listing.WithPhotos = Usr_LIST_WITH_PHOTOS_DEF;
|
Gbl.Usrs.Listing.WithPhotos = Usr_LIST_WITH_PHOTOS_DEF;
|
||||||
|
|
||||||
|
@ -7978,14 +7983,15 @@ void Usr_GetMyPrefAboutListWithPhotosFromDB (void)
|
||||||
if (Gbl.Usrs.Me.Logged && Gbl.Hierarchy.Crs.CrsCod)
|
if (Gbl.Usrs.Me.Logged && Gbl.Hierarchy.Crs.CrsCod)
|
||||||
{
|
{
|
||||||
/***** Get if listing of users must show photos from database *****/
|
/***** Get if listing of users must show photos from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not check if listing of users"
|
NumRows = (unsigned)
|
||||||
" must show photos",
|
DB_QuerySELECT (&mysql_res,"can not check if listing of users"
|
||||||
"SELECT ListWithPhotos" // row[0]
|
" must show photos",
|
||||||
" FROM crs_user_settings"
|
"SELECT ListWithPhotos" // row[0]
|
||||||
" WHERE UsrCod=%ld"
|
" FROM crs_user_settings"
|
||||||
" AND CrsCod=%ld",
|
" WHERE UsrCod=%ld"
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
" AND CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
if (NumRows == 1) // Should be one only row
|
if (NumRows == 1) // Should be one only row
|
||||||
{
|
{
|
||||||
/* Get number of columns in class photo */
|
/* Get number of columns in class photo */
|
||||||
|
|
|
@ -358,10 +358,10 @@ bool Usr_CheckIfIBelongToDeg (long DegCod);
|
||||||
bool Usr_CheckIfIBelongToCrs (long CrsCod);
|
bool Usr_CheckIfIBelongToCrs (long CrsCod);
|
||||||
|
|
||||||
unsigned Usr_GetCtysFromUsr (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 Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res);
|
||||||
unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);
|
unsigned Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);
|
||||||
unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res);
|
unsigned Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res);
|
||||||
unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res);
|
unsigned Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res);
|
||||||
void Usr_GetMainDeg (long UsrCod,
|
void Usr_GetMainDeg (long UsrCod,
|
||||||
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||||
Rol_Role_t *MaxRole);
|
Rol_Role_t *MaxRole);
|
||||||
|
|
Loading…
Reference in New Issue