Version 16.78

This commit is contained in:
Antonio Cañas Vargas 2016-11-30 01:20:38 +01:00
parent c899d13400
commit 5db0ce249d
7 changed files with 303 additions and 313 deletions

View File

@ -602,10 +602,15 @@ CREATE TABLE IF NOT EXISTS links (
-- --
CREATE TABLE IF NOT EXISTS locations ( CREATE TABLE IF NOT EXISTS locations (
LocCod INT NOT NULL AUTO_INCREMENT, LocCod INT NOT NULL AUTO_INCREMENT,
StartDate DATE NOT NULL, UsrCod INT NOT NULL,
EndDate DATE NOT NULL, Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
Location VARCHAR(255) NOT NULL, NumNotif INT NOT NULL DEFAULT 0,
UNIQUE INDEX(LocCod)); StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
Title VARCHAR(255) NOT NULL,
Txt TEXT NOT NULL,
UNIQUE INDEX(LocCod),
INDEX(UsrCod,Hidden));
-- --
-- Table log_banners: stores the log of clicked banners -- Table log_banners: stores the log of clicked banners
-- --

View File

@ -2794,14 +2794,14 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActAnnSee */{1234,-1,TabUnk,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Ann_MarkAnnouncementAsSeen ,NULL}, /* ActAnnSee */{1234,-1,TabUnk,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Ann_MarkAnnouncementAsSeen ,NULL},
/* ActChgMyRol */{ 589,-1,TabUnk,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Rol_ChangeMyRole ,Usr_ShowFormsLogoutAndRole ,NULL}, /* ActChgMyRol */{ 589,-1,TabUnk,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONT_NORM,Act_THIS_WINDOW,Rol_ChangeMyRole ,Usr_ShowFormsLogoutAndRole ,NULL},
/* ActFrmNewLoc */{1603,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RequestCreatOrEditLoc ,NULL}, /* ActFrmNewLoc */{1603,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RequestCreatOrEditLoc ,NULL},
/* ActEdiOneLoc */{1604,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RequestCreatOrEditLoc ,NULL}, /* ActEdiOneLoc */{1604,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RequestCreatOrEditLoc ,NULL},
/* ActNewLoc */{1605,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RecFormLocation ,NULL}, /* ActNewLoc */{1605,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RecFormLocation ,NULL},
/* ActChgLoc */{1606,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RecFormLocation ,NULL}, /* ActChgLoc */{1606,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RecFormLocation ,NULL},
/* ActReqRemLoc */{1607,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_AskRemLocation ,NULL}, /* ActReqRemLoc */{1607,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_AskRemLocation ,NULL},
/* ActRemLoc */{1608,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RemoveLocation ,NULL}, /* ActRemLoc */{1608,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_RemoveLocation ,NULL},
/* ActHidLoc */{1609,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_HideLocation ,NULL}, /* ActHidLoc */{1609,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_HideLocation ,NULL},
/* ActShoLoc */{1610,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x000,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_ShowLocation ,NULL}, /* ActShoLoc */{1610,-1,TabUnk,ActSeeMyLoc ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Loc_ShowLocation ,NULL},
/* ActChkUsrAcc */{1584,-1,TabUnk,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Acc_CheckIfEmptyAccountExists ,NULL}, /* ActChkUsrAcc */{1584,-1,TabUnk,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Acc_CheckIfEmptyAccountExists ,NULL},
/* ActCreUsrAcc */{1163,-1,TabUnk,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Acc_AfterCreationNewAccount ,NULL}, /* ActCreUsrAcc */{1163,-1,TabUnk,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Acc_AfterCreationNewAccount ,NULL},

View File

@ -172,6 +172,8 @@
// TODO: List only confirmed emails to send a message with MESSAGES > Email ? // TODO: List only confirmed emails to send a message with MESSAGES > Email ?
// TODO: Add SWAD API to https://www.programmableweb.com/add/api
// TODO: When activating folders in groups, go to section for that type of group // TODO: When activating folders in groups, go to section for that type of group
// TODO: I can not remove a folder inside assignments (see swad.ugr.es -> EC -> assignment acanas) // TODO: I can not remove a folder inside assignments (see swad.ugr.es -> EC -> assignment acanas)
// TODO: When teacher sees "No hay estudiantes", put a button to add students // TODO: When teacher sees "No hay estudiantes", put a button to add students
@ -181,13 +183,18 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.77 (2016-11-29)" #define Log_PLATFORM_VERSION "SWAD 16.78 (2016-11-30)"
#define CSS_FILE "swad16.69.css" #define CSS_FILE "swad16.69.css"
#define JS_FILE "swad16.46.1.js" #define JS_FILE "swad16.46.1.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.78: Nov 30, 2016 Changes in location. Not finished. (209486 lines)
2 changes necessary in database:
DROP TABLE IF EXISTS locations;
CREATE TABLE IF NOT EXISTS locations (LocCod INT NOT NULL AUTO_INCREMENT,UsrCod INT NOT NULL,Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',NumNotif INT NOT NULL DEFAULT 0,StartTime DATETIME NOT NULL,EndTime DATETIME NOT NULL,Title VARCHAR(255) NOT NULL,Txt TEXT NOT NULL,UNIQUE INDEX(LocCod),INDEX(UsrCod,Hidden));
Version 16.77: Nov 29, 2016 Changes in location. Not finished. (209483 lines) Version 16.77: Nov 29, 2016 Changes in location. Not finished. (209483 lines)
Version 16.76: Nov 29, 2016 New form to create location. Not finished. (208936 lines) Version 16.76: Nov 29, 2016 New form to create location. Not finished. (208936 lines)
8 changes necessary in database: 8 changes necessary in database:

View File

@ -1300,22 +1300,31 @@ mysql> DESCRIBE links;
/***** Table locations *****/ /***** Table locations *****/
/* /*
mysql> DESCRIBE locations; mysql> DESCRIBE locations;
+-----------+--------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| LocCod | int(11) | NO | PRI | NULL | auto_increment | | LocCod | int(11) | NO | PRI | NULL | auto_increment |
| StartDate | date | NO | | NULL | | | UsrCod | int(11) | NO | MUL | NULL | |
| EndDate | date | NO | | NULL | | | Hidden | enum('N','Y') | NO | | N | |
| Location | varchar(255) | NO | | NULL | | | NumNotif | int(11) | NO | | 0 | |
+-----------+--------------+------+-----+---------+----------------+ | StartTime | datetime | NO | | NULL | |
4 rows in set (0,01 sec) | EndTime | datetime | NO | | NULL | |
| Title | varchar(255) | NO | | NULL | |
| Txt | text | NO | | NULL | |
+-----------+---------------+------+-----+---------+----------------+
8 rows in set (0,01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS locations (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS locations ("
"LocCod INT NOT NULL AUTO_INCREMENT," "LocCod INT NOT NULL AUTO_INCREMENT,"
"StartDate DATE NOT NULL," "UsrCod INT NOT NULL,"
"EndDate DATE NOT NULL," "Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',"
"Location VARCHAR(255) NOT NULL," "NumNotif INT NOT NULL DEFAULT 0,"
"UNIQUE INDEX (LocCod))"); "StartTime DATETIME NOT NULL,"
"EndTime DATETIME NOT NULL,"
"Title VARCHAR(255) NOT NULL,"
"Txt TEXT NOT NULL,"
"UNIQUE INDEX(LocCod),"
"INDEX(UsrCod,Hidden))");
/***** Table log_banners *****/ /***** Table log_banners *****/
/* /*

View File

@ -78,10 +78,8 @@ static void Loc_GetDataOfLocation (struct Location *Loc,const char *Query);
static void Loc_GetLocationTxtFromDB (long LocCod,char *Txt); static void Loc_GetLocationTxtFromDB (long LocCod,char *Txt);
static void Loc_PutParamLocCod (long LocCod); static void Loc_PutParamLocCod (long LocCod);
static bool Loc_CheckIfSimilarLocationExists (const char *Field,const char *Value,long LocCod); static bool Loc_CheckIfSimilarLocationExists (const char *Field,const char *Value,long LocCod);
static void Loc_UpdateNumUsrsNotifiedByEMailAboutLocation (long LocCod,unsigned NumUsrsToBeNotifiedByEMail);
static void Loc_CreateLocation (struct Location *Loc,const char *Txt); static void Loc_CreateLocation (struct Location *Loc,const char *Txt);
static void Loc_UpdateLocation (struct Location *Loc,const char *Txt); static void Loc_UpdateLocation (struct Location *Loc,const char *Txt);
static bool Loc_CheckIfIBelongToCrsThisLocation (long LocCod);
/*****************************************************************************/ /*****************************************************************************/
/************************* List all the locations ****************************/ /************************* List all the locations ****************************/
@ -109,8 +107,6 @@ static void Loc_ShowAllLocations (void)
extern const char *Txt_ASG_ATT_OR_SVY_HELP_ORDER[2]; extern const char *Txt_ASG_ATT_OR_SVY_HELP_ORDER[2];
extern const char *Txt_ASG_ATT_OR_SVY_ORDER[2]; extern const char *Txt_ASG_ATT_OR_SVY_ORDER[2];
extern const char *Txt_Location; extern const char *Txt_Location;
extern const char *Txt_Upload_files_QUESTION;
extern const char *Txt_Folder;
extern const char *Txt_No_locations; extern const char *Txt_No_locations;
Loc_Order_t Order; Loc_Order_t Order;
struct Pagination Pagination; struct Pagination Pagination;
@ -158,18 +154,10 @@ static void Loc_ShowAllLocations (void)
fprintf (Gbl.F.Out,"</th>"); fprintf (Gbl.F.Out,"</th>");
} }
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">" fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">"
"%s"
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s" "%s"
"</th>" "</th>"
"</tr>", "</tr>",
Txt_Location, Txt_Location);
Txt_Upload_files_QUESTION,
Txt_Folder);
/***** Write all the locations *****/ /***** Write all the locations *****/
for (NumLoc = Pagination.FirstItemVisible; for (NumLoc = Pagination.FirstItemVisible;
@ -270,9 +258,6 @@ static void Loc_PutParamsToCreateNewLoc (void)
static void Loc_ShowOneLocation (long LocCod) static void Loc_ShowOneLocation (long LocCod)
{ {
extern const char *Txt_Today; extern const char *Txt_Today;
extern const char *Txt_ASSIGNMENT_TYPES[Loc_NUM_TYPES_SEND_WORK];
extern const char *Txt_Yes;
extern const char *Txt_No;
static unsigned UniqueId = 0; static unsigned UniqueId = 0;
struct Location Loc; struct Location Loc;
char Txt[Cns_MAX_BYTES_TEXT+1]; char Txt[Cns_MAX_BYTES_TEXT+1];
@ -320,24 +305,8 @@ static void Loc_ShowOneLocation (long LocCod)
Loc.Hidden ? "ASG_TITLE_LIGHT" : Loc.Hidden ? "ASG_TITLE_LIGHT" :
"ASG_TITLE", "ASG_TITLE",
Loc.Title); Loc.Title);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>"
"</tr>");
/* Send work? */
fprintf (Gbl.F.Out,"<td rowspan=\"2\" class=\"%s CENTER_TOP COLOR%u\">"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\" class=\"ICO20x20\" />"
"<br />%s"
"</td>",
(Loc.SendWork == Loc_SEND_WORK) ? "DAT_N" :
"DAT",
Gbl.RowEvenOdd,
Gbl.Prefs.IconsURL,
(Loc.SendWork == Loc_SEND_WORK) ? "file_on" :
"file_off",
Txt_ASSIGNMENT_TYPES[Loc.SendWork],
Txt_ASSIGNMENT_TYPES[Loc.SendWork],
(Loc.SendWork == Loc_SEND_WORK) ? Txt_Yes :
Txt_No);
/***** Write second row of data of this location *****/ /***** Write second row of data of this location *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -377,11 +346,6 @@ static void Loc_ShowOneLocation (long LocCod)
Txt); Txt);
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
/***** Mark possible notification as seen *****/
Ntf_MarkNotifAsSeen (Ntf_EVENT_ASSIGNMENT,
LocCod,Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -546,9 +510,9 @@ void Loc_GetListLocations (void)
} }
sprintf (Query,"SELECT LocCod" sprintf (Query,"SELECT LocCod"
" FROM locations" " FROM locations"
" WHERE CrsCod='%ld'%s" " WHERE UsrCod='%ld'%s"
" ORDER BY %s", " ORDER BY %s",
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,OrderBySubQuery); Gbl.Usrs.Me.UsrDat.UsrCod,HiddenSubQuery,OrderBySubQuery);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get locations"); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get locations");
if (NumRows) // Locations found... if (NumRows) // Locations found...
@ -588,14 +552,14 @@ void Loc_GetDataOfLocationByCod (struct Location *Loc)
char Query[1024]; char Query[1024];
/***** Build query *****/ /***** Build query *****/
sprintf (Query,"SELECT LocCod,Hidden,UsrCod," sprintf (Query,"SELECT LocCod,UsrCod,Hidden,"
"UNIX_TIMESTAMP(StartTime)," "UNIX_TIMESTAMP(StartTime),"
"UNIX_TIMESTAMP(EndTime)," "UNIX_TIMESTAMP(EndTime),"
"NOW() BETWEEN StartTime AND EndTime," "NOW() BETWEEN StartTime AND EndTime,"
"Title,Folder" "Title"
" FROM locations" " FROM locations"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
Loc->LocCod,Gbl.CurrentCrs.Crs.CrsCod); Loc->LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Get data of location *****/ /***** Get data of location *****/
Loc_GetDataOfLocation (Loc,Query); Loc_GetDataOfLocation (Loc,Query);
@ -613,15 +577,12 @@ static void Loc_GetDataOfLocation (struct Location *Loc,const char *Query)
/***** Clear all location data *****/ /***** Clear all location data *****/
Loc->LocCod = -1L; Loc->LocCod = -1L;
Loc->Hidden = false;
Loc->UsrCod = -1L; Loc->UsrCod = -1L;
Loc->Hidden = false;
Loc->TimeUTC[Loc_START_TIME] = Loc->TimeUTC[Loc_START_TIME] =
Loc->TimeUTC[Loc_END_TIME ] = (time_t) 0; Loc->TimeUTC[Loc_END_TIME ] = (time_t) 0;
Loc->Open = false; Loc->Open = false;
Loc->Title[0] = '\0'; Loc->Title[0] = '\0';
Loc->SendWork = false;
Loc->Folder[0] = '\0';
Loc->IBelongToCrsOrGrps = false;
/***** Get data of location from database *****/ /***** Get data of location from database *****/
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get location data"); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get location data");
@ -634,11 +595,11 @@ static void Loc_GetDataOfLocation (struct Location *Loc,const char *Query)
/* Get code of the location (row[0]) */ /* Get code of the location (row[0]) */
Loc->LocCod = Str_ConvertStrCodToLongCod (row[0]); Loc->LocCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get whether the location is hidden or not (row[1]) */ /* Get author of the location (row[1]) */
Loc->Hidden = (row[1][0] == 'Y'); Loc->UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get author of the location (row[2]) */ /* Get whether the location is hidden or not (row[2]) */
Loc->UsrCod = Str_ConvertStrCodToLongCod (row[2]); Loc->Hidden = (row[2][0] == 'Y');
/* Get start date (row[3] holds the start UTC time) */ /* Get start date (row[3] holds the start UTC time) */
Loc->TimeUTC[Loc_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]); Loc->TimeUTC[Loc_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]);
@ -651,13 +612,6 @@ static void Loc_GetDataOfLocation (struct Location *Loc,const char *Query)
/* Get the title of the location (row[6]) */ /* Get the title of the location (row[6]) */
strcpy (Loc->Title,row[6]); strcpy (Loc->Title,row[6]);
/* Get the folder for the location files (row[7]) */
strcpy (Loc->Folder,row[7]);
Loc->SendWork = (Loc->Folder[0] != '\0');
/* Can I do this location? */
Loc->IBelongToCrsOrGrps = Loc_CheckIfIBelongToCrsThisLocation (Loc->LocCod);
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -693,8 +647,8 @@ static void Loc_GetLocationTxtFromDB (long LocCod,char *Txt)
/***** Get text of location from database *****/ /***** Get text of location from database *****/
sprintf (Query,"SELECT Txt FROM locations" sprintf (Query,"SELECT Txt FROM locations"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
LocCod,Gbl.CurrentCrs.Crs.CrsCod); LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get location text"); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get location text");
/***** The result of the query must have one row or none *****/ /***** The result of the query must have one row or none *****/
@ -714,49 +668,6 @@ static void Loc_GetLocationTxtFromDB (long LocCod,char *Txt)
Lay_ShowErrorAndExit ("Error when getting location text."); Lay_ShowErrorAndExit ("Error when getting location text.");
} }
/*****************************************************************************/
/****************** Get summary and content of a location *******************/
/*****************************************************************************/
// This function may be called inside a web service
void Loc_GetNotifLocation (char *SummaryStr,char **ContentStr,
long LocCod,unsigned MaxChars,bool GetContent)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
SummaryStr[0] = '\0'; // Return nothing on error
/***** Build query *****/
sprintf (Query,"SELECT Title,Txt FROM locations WHERE LocCod='%ld'",
LocCod);
if (!mysql_query (&Gbl.mysql,Query))
if ((mysql_res = mysql_store_result (&Gbl.mysql)) != NULL)
{
/***** Result should have a unique row *****/
if (mysql_num_rows (mysql_res) == 1)
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get summary *****/
strcpy (SummaryStr,row[0]);
if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
/***** Get content *****/
if (GetContent)
{
if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
strcpy (*ContentStr,row[1]);
}
}
mysql_free_result (mysql_res);
}
}
/*****************************************************************************/ /*****************************************************************************/
/****************** Write parameter with code of location ********************/ /****************** Write parameter with code of location ********************/
/*****************************************************************************/ /*****************************************************************************/
@ -838,13 +749,10 @@ void Loc_RemoveLocation (void)
/***** Remove location *****/ /***** Remove location *****/
sprintf (Query,"DELETE FROM locations" sprintf (Query,"DELETE FROM locations"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
Loc.LocCod,Gbl.CurrentCrs.Crs.CrsCod); Loc.LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryDELETE (Query,"can not remove location"); DB_QueryDELETE (Query,"can not remove location");
/***** Mark possible notifications as removed *****/
Ntf_MarkNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Loc.LocCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
sprintf (Gbl.Message,Txt_Location_X_removed, sprintf (Gbl.Message,Txt_Location_X_removed,
Loc.Title); Loc.Title);
@ -873,8 +781,8 @@ void Loc_HideLocation (void)
/***** Hide location *****/ /***** Hide location *****/
sprintf (Query,"UPDATE locations SET Hidden='Y'" sprintf (Query,"UPDATE locations SET Hidden='Y'"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
Loc.LocCod,Gbl.CurrentCrs.Crs.CrsCod); Loc.LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not hide location"); DB_QueryUPDATE (Query,"can not hide location");
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -905,8 +813,8 @@ void Loc_ShowLocation (void)
/***** Hide location *****/ /***** Hide location *****/
sprintf (Query,"UPDATE locations SET Hidden='N'" sprintf (Query,"UPDATE locations SET Hidden='N'"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
Loc.LocCod,Gbl.CurrentCrs.Crs.CrsCod); Loc.LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not show location"); DB_QueryUPDATE (Query,"can not show location");
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -928,8 +836,8 @@ static bool Loc_CheckIfSimilarLocationExists (const char *Field,const char *Valu
/***** Get number of locations with a field value from database *****/ /***** Get number of locations with a field value from database *****/
sprintf (Query,"SELECT COUNT(*) FROM locations" sprintf (Query,"SELECT COUNT(*) FROM locations"
" WHERE CrsCod='%ld' AND %s='%s' AND LocCod<>'%ld'", " WHERE UsrCod='%ld' AND %s='%s' AND LocCod<>'%ld'",
Gbl.CurrentCrs.Crs.CrsCod,Field,Value,LocCod); Gbl.Usrs.Me.UsrDat.UsrCod,Field,Value,LocCod);
return (DB_QueryCOUNT (Query,"can not get similar locations") != 0); return (DB_QueryCOUNT (Query,"can not get similar locations") != 0);
} }
@ -945,8 +853,6 @@ void Loc_RequestCreatOrEditLoc (void)
extern const char *Txt_New_location; extern const char *Txt_New_location;
extern const char *Txt_Edit_location; extern const char *Txt_Edit_location;
extern const char *Txt_Title; extern const char *Txt_Title;
extern const char *Txt_Upload_files_QUESTION;
extern const char *Txt_Folder;
extern const char *Txt_Description; extern const char *Txt_Description;
extern const char *Txt_Create_location; extern const char *Txt_Create_location;
extern const char *Txt_Save; extern const char *Txt_Save;
@ -967,13 +873,11 @@ void Loc_RequestCreatOrEditLoc (void)
{ {
/* Initialize to empty location */ /* Initialize to empty location */
Loc.LocCod = -1L; Loc.LocCod = -1L;
Loc.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
Loc.TimeUTC[Loc_START_TIME] = Gbl.StartExecutionTimeUTC; Loc.TimeUTC[Loc_START_TIME] = Gbl.StartExecutionTimeUTC;
Loc.TimeUTC[Loc_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours Loc.TimeUTC[Loc_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours
Loc.Open = true; Loc.Open = true;
Loc.Title[0] = '\0'; Loc.Title[0] = '\0';
Loc.SendWork = false;
Loc.Folder[0] = '\0';
Loc.IBelongToCrsOrGrps = false;
} }
else else
{ {
@ -986,7 +890,7 @@ void Loc_RequestCreatOrEditLoc (void)
/***** Start form *****/ /***** Start form *****/
if (ItsANewLocation) if (ItsANewLocation)
Act_FormStart (ActFrmNewLoc); Act_FormStart (ActNewLoc);
else else
{ {
Act_FormStart (ActChgLoc); Act_FormStart (ActChgLoc);
@ -1023,22 +927,6 @@ void Loc_RequestCreatOrEditLoc (void)
/***** Location start and end dates *****/ /***** Location start and end dates *****/
Dat_PutFormStartEndClientLocalDateTimes (Loc.TimeUTC); Dat_PutFormStartEndClientLocalDateTimes (Loc.TimeUTC);
/***** Send work? *****/
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\">"
"%s:"
"</td>"
"<td class=\"DAT LEFT_MIDDLE\">"
"%s: "
"<input type=\"text\" name=\"Folder\""
" size=\"%u\" maxlength=\"%u\" value=\"%s\" />"
"</td>"
"</tr>",
The_ClassForm[Gbl.Prefs.Theme],
Txt_Upload_files_QUESTION,
Txt_Folder,
Loc_MAX_LENGTH_FOLDER,Loc_MAX_LENGTH_FOLDER,Loc.Folder);
/***** Location text *****/ /***** Location text *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_TOP\">" "<td class=\"%s RIGHT_TOP\">"
@ -1071,7 +959,7 @@ void Loc_RequestCreatOrEditLoc (void)
void Loc_RecFormLocation (void) void Loc_RecFormLocation (void)
{ {
extern const char *Txt_Already_existed_an_location_with_the_title_X; extern const char *Txt_Already_existed_a_location_with_the_title_X;
extern const char *Txt_You_must_specify_the_title_of_the_location; extern const char *Txt_You_must_specify_the_title_of_the_location;
extern const char *Txt_Created_new_location_X; extern const char *Txt_Created_new_location_X;
extern const char *Txt_The_location_has_been_modified; extern const char *Txt_The_location_has_been_modified;
@ -1079,7 +967,6 @@ void Loc_RecFormLocation (void)
struct Location NewLoc; struct Location NewLoc;
bool ItsANewLocation; bool ItsANewLocation;
bool NewLocationIsCorrect = true; bool NewLocationIsCorrect = true;
unsigned NumUsrsToBeNotifiedByEMail;
char Txt[Cns_MAX_BYTES_TEXT+1]; char Txt[Cns_MAX_BYTES_TEXT+1];
/***** Get the code of the location *****/ /***** Get the code of the location *****/
@ -1099,11 +986,6 @@ void Loc_RecFormLocation (void)
/***** Get location title *****/ /***** Get location title *****/
Par_GetParToText ("Title",NewLoc.Title,Loc_MAX_LENGTH_ASSIGNMENT_TITLE); Par_GetParToText ("Title",NewLoc.Title,Loc_MAX_LENGTH_ASSIGNMENT_TITLE);
/***** Get folder name where to send works of the location *****/
Par_GetParToText ("Folder",NewLoc.Folder,Loc_MAX_LENGTH_FOLDER);
NewLoc.SendWork = (NewLoc.Folder[0]) ? Loc_SEND_WORK :
Loc_DO_NOT_SEND_WORK;
/***** Get location text *****/ /***** Get location text *****/
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous) Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
@ -1120,7 +1002,7 @@ void Loc_RecFormLocation (void)
if (Loc_CheckIfSimilarLocationExists ("Title",NewLoc.Title,NewLoc.LocCod)) if (Loc_CheckIfSimilarLocationExists ("Title",NewLoc.Title,NewLoc.LocCod))
{ {
NewLocationIsCorrect = false; NewLocationIsCorrect = false;
sprintf (Gbl.Message,Txt_Already_existed_an_location_with_the_title_X, sprintf (Gbl.Message,Txt_Already_existed_a_location_with_the_title_X,
NewLoc.Title); NewLoc.Title);
Lay_ShowAlert (Lay_WARNING,Gbl.Message); Lay_ShowAlert (Lay_WARNING,Gbl.Message);
} }
@ -1144,26 +1026,15 @@ void Loc_RecFormLocation (void)
} }
else else
{ {
if (OldLoc.Folder[0] && NewLoc.Folder[0]) Loc_UpdateLocation (&NewLoc,Txt);
if (strcmp (OldLoc.Folder,NewLoc.Folder)) // Folder name has changed
NewLocationIsCorrect = Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (OldLoc.Folder,NewLoc.Folder);
if (NewLocationIsCorrect)
{
Loc_UpdateLocation (&NewLoc,Txt);
/***** Write success message *****/ /***** Write success message *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_The_location_has_been_modified); Lay_ShowAlert (Lay_SUCCESS,Txt_The_location_has_been_modified);
}
} }
/* Free memory for list of selected groups */ /* Free memory for list of selected groups */
Grp_FreeListCodSelectedGrps (); Grp_FreeListCodSelectedGrps ();
/***** Notify by email about the new location *****/
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_ASSIGNMENT,NewLoc.LocCod)))
Loc_UpdateNumUsrsNotifiedByEMailAboutLocation (NewLoc.LocCod,NumUsrsToBeNotifiedByEMail);
Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail);
/***** Show locations again *****/ /***** Show locations again *****/
Loc_SeeLocations (); Loc_SeeLocations ();
} }
@ -1172,21 +1043,6 @@ void Loc_RecFormLocation (void)
Loc_RequestCreatOrEditLoc (); Loc_RequestCreatOrEditLoc ();
} }
/*****************************************************************************/
/********* Update number of users notified in table of locations *************/
/*****************************************************************************/
static void Loc_UpdateNumUsrsNotifiedByEMailAboutLocation (long LocCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char Query[512];
/***** Update number of users notified *****/
sprintf (Query,"UPDATE locations SET NumNotif=NumNotif+'%u'"
" WHERE LocCod='%ld'",
NumUsrsToBeNotifiedByEMail,LocCod);
DB_QueryUPDATE (Query,"can not update the number of notifications of an location");
}
/*****************************************************************************/ /*****************************************************************************/
/************************* Create a new location *****************************/ /************************* Create a new location *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -1197,16 +1053,14 @@ static void Loc_CreateLocation (struct Location *Loc,const char *Txt)
/***** Create a new location *****/ /***** Create a new location *****/
sprintf (Query,"INSERT INTO locations" sprintf (Query,"INSERT INTO locations"
" (CrsCod,UsrCod,StartTime,EndTime,Title,Folder,Txt)" " (UsrCod,StartTime,EndTime,Title,Txt)"
" VALUES" " VALUES"
" ('%ld','%ld',FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld')," " ('%ld',FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld'),"
"'%s','%s','%s')", "'%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Loc->TimeUTC[Loc_START_TIME], Loc->TimeUTC[Loc_START_TIME],
Loc->TimeUTC[Loc_END_TIME ], Loc->TimeUTC[Loc_END_TIME ],
Loc->Title, Loc->Title,
Loc->Folder,
Txt); Txt);
Loc->LocCod = DB_QueryINSERTandReturnCode (Query,"can not create new location"); Loc->LocCod = DB_QueryINSERTandReturnCode (Query,"can not create new location");
} }
@ -1223,155 +1077,135 @@ static void Loc_UpdateLocation (struct Location *Loc,const char *Txt)
sprintf (Query,"UPDATE locations SET " sprintf (Query,"UPDATE locations SET "
"StartTime=FROM_UNIXTIME('%ld')," "StartTime=FROM_UNIXTIME('%ld'),"
"EndTime=FROM_UNIXTIME('%ld')," "EndTime=FROM_UNIXTIME('%ld'),"
"Title='%s',Folder='%s',Txt='%s'" "Title='%s',Txt='%s'"
" WHERE LocCod='%ld' AND CrsCod='%ld'", " WHERE LocCod='%ld' AND UsrCod='%ld'",
Loc->TimeUTC[Loc_START_TIME], Loc->TimeUTC[Loc_START_TIME],
Loc->TimeUTC[Loc_END_TIME ], Loc->TimeUTC[Loc_END_TIME ],
Loc->Title, Loc->Title,
Loc->Folder,
Txt, Txt,
Loc->LocCod,Gbl.CurrentCrs.Crs.CrsCod); Loc->LocCod,Gbl.Usrs.Me.UsrDat.UsrCod);
DB_QueryUPDATE (Query,"can not update location"); DB_QueryUPDATE (Query,"can not update location");
} }
/*****************************************************************************/ /*****************************************************************************/
/******************* Remove all the locations of a course ********************/ /******************** Remove all the locations of a user *********************/
/*****************************************************************************/ /*****************************************************************************/
void Loc_RemoveCrsLocations (long CrsCod) void Loc_RemoveUsrLocations (long UsrCod)
{ {
char Query[128]; char Query[128];
/***** Remove locations *****/ /***** Remove locations *****/
sprintf (Query,"DELETE FROM locations WHERE CrsCod='%ld'",CrsCod); sprintf (Query,"DELETE FROM locations WHERE UsrCod='%ld'",UsrCod);
DB_QueryDELETE (Query,"can not remove all the locations of a course"); DB_QueryDELETE (Query,"can not remove all the locations of a user");
} }
/*****************************************************************************/ /*****************************************************************************/
/********** Check if I belong to any of the groups of an location ************/ /******************* Get number of locations from a user *********************/
/*****************************************************************************/ /*****************************************************************************/
static bool Loc_CheckIfIBelongToCrsThisLocation (long LocCod) unsigned Loc_GetNumLocationsFromUsr (long UsrCod)
{ {
char Query[512]; char Query[128];
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT ||
Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
{
// Students and teachers can edit locations depending on groups
/***** Get if I can edit an location from database *****/
sprintf (Query,"SELECT COUNT(*) FROM locations"
" WHERE LocCod='%ld'",
LocCod);
return (DB_QueryCOUNT (Query,"can not check if I can do an location") != 0);
}
else
return (Gbl.Usrs.Me.LoggedRole > Rol_TEACHER); // Admins can edit locations
}
/*****************************************************************************/
/******************* Get number of locations in a course *********************/
/*****************************************************************************/
unsigned Loc_GetNumLocationsInCrs (long CrsCod)
{
char Query[256];
/***** Get number of locations in a course from database *****/ /***** Get number of locations in a course from database *****/
sprintf (Query,"SELECT COUNT(*) FROM locations WHERE CrsCod='%ld'", sprintf (Query,"SELECT COUNT(*) FROM locations WHERE UsrCod='%ld'",
CrsCod); UsrCod);
return (unsigned) DB_QueryCOUNT (Query,"can not get number of locations in course"); return (unsigned) DB_QueryCOUNT (Query,"can not get number of locations from user");
} }
/*****************************************************************************/ /*****************************************************************************/
/******************* Get number of courses with locations ********************/ /******************** Get number of users with locations *********************/
/*****************************************************************************/ /*****************************************************************************/
// Returns the number of courses with locations // Returns the number of users with locations in a given scope
// in this location (all the platform, current degree or current course)
unsigned Loc_GetNumCoursesWithLocations (Sco_Scope_t Scope) unsigned Loc_GetNumUsrsWithLocations (Sco_Scope_t Scope)
{ {
char Query[1024]; char Query[1024];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumCourses; unsigned NumUsrs;
/***** Get number of courses with locations from database *****/ /***** Get number of courses with locations from database *****/
switch (Scope) switch (Scope)
{ {
case Sco_SCOPE_SYS: case Sco_SCOPE_SYS:
sprintf (Query,"SELECT COUNT(DISTINCT CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
" FROM locations" " FROM locations"
" WHERE CrsCod>'0'"); " WHERE UsrCod>'0'");
break; break;
case Sco_SCOPE_CTY: case Sco_SCOPE_CTY:
sprintf (Query,"SELECT COUNT(DISTINCT locations.CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT locations.UsrCod)"
" FROM institutions,centres,degrees,courses,locations" " FROM institutions,centres,degrees,courses,crs_usr,locations"
" WHERE institutions.CtyCod='%ld'" " WHERE institutions.CtyCod='%ld'"
" AND institutions.InsCod=centres.InsCod" " AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod" " AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.Status=0" " AND courses.Status=0"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCty.Cty.CtyCod); Gbl.CurrentCty.Cty.CtyCod);
break; break;
case Sco_SCOPE_INS: case Sco_SCOPE_INS:
sprintf (Query,"SELECT COUNT(DISTINCT locations.CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT locations.UsrCod)"
" FROM centres,degrees,courses,locations" " FROM centres,degrees,courses,crs_usr,locations"
" WHERE centres.InsCod='%ld'" " WHERE centres.InsCod='%ld'"
" AND centres.CtrCod=degrees.CtrCod" " AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.Status=0" " AND courses.Status=0"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentIns.Ins.InsCod); Gbl.CurrentIns.Ins.InsCod);
break; break;
case Sco_SCOPE_CTR: case Sco_SCOPE_CTR:
sprintf (Query,"SELECT COUNT(DISTINCT locations.CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT locations.UsrCod)"
" FROM degrees,courses,locations" " FROM degrees,courses,crs_usr,locations"
" WHERE degrees.CtrCod='%ld'" " WHERE degrees.CtrCod='%ld'"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.Status=0" " AND courses.Status=0"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCtr.Ctr.CtrCod); Gbl.CurrentCtr.Ctr.CtrCod);
break; break;
case Sco_SCOPE_DEG: case Sco_SCOPE_DEG:
sprintf (Query,"SELECT COUNT(DISTINCT locations.CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT locations.UsrCod)"
" FROM courses,locations" " FROM courses,crs_usr,locations"
" WHERE courses.DegCod='%ld'" " WHERE courses.DegCod='%ld'"
" AND courses.Status=0" " AND courses.Status=0"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentDeg.Deg.DegCod); Gbl.CurrentDeg.Deg.DegCod);
break; break;
case Sco_SCOPE_CRS: case Sco_SCOPE_CRS:
sprintf (Query,"SELECT COUNT(DISTINCT CrsCod)" sprintf (Query,"SELECT COUNT(DISTINCT locations.UsrCod)"
" FROM locations" " FROM crs_usr,locations"
" WHERE CrsCod='%ld'", " WHERE crs_usr.CrsCod='%ld'"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCrs.Crs.CrsCod); Gbl.CurrentCrs.Crs.CrsCod);
break; break;
default: default:
Lay_ShowErrorAndExit ("Wrong scope."); Lay_ShowErrorAndExit ("Wrong scope.");
break; break;
} }
DB_QuerySELECT (Query,&mysql_res,"can not get number of courses with locations"); DB_QuerySELECT (Query,&mysql_res,"can not get number of users with locations");
/***** Get number of courses *****/ /***** Get number of users *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%u",&NumCourses) != 1) if (sscanf (row[0],"%u",&NumUsrs) != 1)
Lay_ShowErrorAndExit ("Error when getting number of courses with locations."); Lay_ShowErrorAndExit ("Error when getting number of users with locations.");
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
return NumCourses; return NumUsrs;
} }
/*****************************************************************************/ /*****************************************************************************/
/************************* Get number of locations ***************************/ /************************* Get number of locations ***************************/
/*****************************************************************************/ /*****************************************************************************/
// Returns the number of locations // Returns the number of locations in a given scope
// in this location (all the platform, current degree or current course)
unsigned Loc_GetNumLocations (Sco_Scope_t Scope,unsigned *NumNotif) unsigned Loc_GetNumLocations (Sco_Scope_t Scope)
{ {
char Query[1024]; char Query[1024];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -1382,48 +1216,53 @@ unsigned Loc_GetNumLocations (Sco_Scope_t Scope,unsigned *NumNotif)
switch (Scope) switch (Scope)
{ {
case Sco_SCOPE_SYS: case Sco_SCOPE_SYS:
sprintf (Query,"SELECT COUNT(*),SUM(NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM locations" " FROM locations"
" WHERE CrsCod>'0'"); " WHERE UsrCod>'0'");
break; break;
case Sco_SCOPE_CTY: case Sco_SCOPE_CTY:
sprintf (Query,"SELECT COUNT(*),SUM(locations.NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM institutions,centres,degrees,courses,locations" " FROM institutions,centres,degrees,courses,crs_usr,locations"
" WHERE institutions.CtyCod='%ld'" " WHERE institutions.CtyCod='%ld'"
" AND institutions.InsCod=centres.InsCod" " AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod" " AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCty.Cty.CtyCod); Gbl.CurrentCty.Cty.CtyCod);
break; break;
case Sco_SCOPE_INS: case Sco_SCOPE_INS:
sprintf (Query,"SELECT COUNT(*),SUM(locations.NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM centres,degrees,courses,locations" " FROM centres,degrees,courses,crs_usr,locations"
" WHERE centres.InsCod='%ld'" " WHERE centres.InsCod='%ld'"
" AND centres.CtrCod=degrees.CtrCod" " AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentIns.Ins.InsCod); Gbl.CurrentIns.Ins.InsCod);
break; break;
case Sco_SCOPE_CTR: case Sco_SCOPE_CTR:
sprintf (Query,"SELECT COUNT(*),SUM(locations.NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM degrees,courses,locations" " FROM degrees,courses,crs_usr,locations"
" WHERE degrees.CtrCod='%ld'" " WHERE degrees.CtrCod='%ld'"
" AND degrees.DegCod=courses.DegCod" " AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCtr.Ctr.CtrCod); Gbl.CurrentCtr.Ctr.CtrCod);
break; break;
case Sco_SCOPE_DEG: case Sco_SCOPE_DEG:
sprintf (Query,"SELECT COUNT(*),SUM(locations.NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM courses,locations" " FROM courses,crs_usr,locations"
" WHERE courses.DegCod='%ld'" " WHERE courses.DegCod='%ld'"
" AND courses.CrsCod=locations.CrsCod", " AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentDeg.Deg.DegCod); Gbl.CurrentDeg.Deg.DegCod);
break; break;
case Sco_SCOPE_CRS: case Sco_SCOPE_CRS:
sprintf (Query,"SELECT COUNT(*),SUM(NumNotif)" sprintf (Query,"SELECT COUNT(*)"
" FROM locations" " FROM crs_usr,locations"
" WHERE CrsCod='%ld'", " WHERE crs_usr.CrsCod='%ld'"
" AND crs_usr.UsrCod=locations.UsrCod",
Gbl.CurrentCrs.Crs.CrsCod); Gbl.CurrentCrs.Crs.CrsCod);
break; break;
default: default:
@ -1437,15 +1276,6 @@ unsigned Loc_GetNumLocations (Sco_Scope_t Scope,unsigned *NumNotif)
if (sscanf (row[0],"%u",&NumLocations) != 1) if (sscanf (row[0],"%u",&NumLocations) != 1)
Lay_ShowErrorAndExit ("Error when getting number of locations."); Lay_ShowErrorAndExit ("Error when getting number of locations.");
/***** Get number of notifications by email *****/
if (row[1])
{
if (sscanf (row[1],"%u",NumNotif) != 1)
Lay_ShowErrorAndExit ("Error when getting number of notifications of locations.");
}
else
*NumNotif = 0;
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);

View File

@ -60,12 +60,6 @@ struct Location
time_t TimeUTC[Loc_NUM_DATES]; time_t TimeUTC[Loc_NUM_DATES];
bool Open; bool Open;
char Title[Loc_MAX_LENGTH_ASSIGNMENT_TITLE+1]; char Title[Loc_MAX_LENGTH_ASSIGNMENT_TITLE+1];
Loc_SendWork_t SendWork;
char Folder[Loc_MAX_LENGTH_FOLDER+1];
bool IBelongToCrsOrGrps; // I can do this location
// (it is associated to no groups
// or, if associated to groups,
// I belong to any of the groups)
}; };
typedef enum typedef enum
@ -87,18 +81,16 @@ void Loc_GetListLocations (void);
void Loc_GetDataOfLocationByCod (struct Location *Loc); void Loc_GetDataOfLocationByCod (struct Location *Loc);
void Loc_FreeListLocations (void); void Loc_FreeListLocations (void);
void Loc_GetNotifLocation (char *SummaryStr,char **ContentStr,long LocCod,unsigned MaxChars,bool GetContent);
long Loc_GetParamLocCod (void); long Loc_GetParamLocCod (void);
void Loc_AskRemLocation (void); void Loc_AskRemLocation (void);
void Loc_RemoveLocation (void); void Loc_RemoveLocation (void);
void Loc_HideLocation (void); void Loc_HideLocation (void);
void Loc_ShowLocation (void); void Loc_ShowLocation (void);
void Loc_RecFormLocation (void); void Loc_RecFormLocation (void);
void Loc_RemoveCrsLocations (long CrsCod); void Loc_RemoveUsrLocations (long UsrCod);
unsigned Loc_GetNumLocationsInCrs(long CrsCod); unsigned Loc_GetNumLocationsFromUsr (long UsrCod);
unsigned Loc_GetNumCoursesWithLocations (Sco_Scope_t Scope); unsigned Loc_GetNumUsrsWithLocations (Sco_Scope_t Scope);
unsigned Loc_GetNumLocations (Sco_Scope_t Scope,unsigned *NumNotif); unsigned Loc_GetNumLocations (Sco_Scope_t Scope);
#endif #endif

View File

@ -2321,6 +2321,27 @@ const char *Txt_Alphabetic_BR_code_BR_ISO_3166_1 =
"C&oacute;d.<br />alfab&eacute;tico<br />ISO 3166-1"; "C&oacute;d.<br />alfab&eacute;tico<br />ISO 3166-1";
#endif #endif
const char *Txt_Already_existed_a_location_with_the_title_X = // Warning: it is very important to include %s in the following sentences
#if L==1
"Ja existia una ubicaci&oacute; amb el t&iacute;tol <strong>%s</strong>.";
#elif L==2
"Es gibt bereits einen Standort mit dem Namen <strong>%s</strong>.";
#elif L==3
"Already existed a location with the title <strong>%s</strong>.";
#elif L==4
"Ya exist&iacute;a una ubicaci&oacute;n con el t&iacute;tulo <strong>%s</strong>.";
#elif L==5
"Il existe d&eacute;j&agrave; un emplacement du titre <strong>%s</strong>.";
#elif L==6
"Ya exist&iacute;a una ubicaci&oacute;n con el t&iacute;tulo <strong>%s</strong>."; // Okoteve traducción
#elif L==7
"Esiste gi&agrave; una posizione con il titolo <strong>%s</strong>.";
#elif L==8
"Istniala juz lokalizacj&eogon; z tytulu <strong>%s</strong>.";
#elif L==9
"J&aacute; existe uma localiza&ccedil;&atilde;o com o t&iacute;tulo <strong>%s</strong>.";
#endif
const char *Txt_Already_existed_an_assignment_with_the_folder_X = // Warning: it is very important to include %s in the following sentences const char *Txt_Already_existed_an_assignment_with_the_folder_X = // Warning: it is very important to include %s in the following sentences
#if L==1 #if L==1
"Ja existia una activitat amb la carpeta <strong>%s</strong>."; "Ja existia una activitat amb la carpeta <strong>%s</strong>.";
@ -9172,6 +9193,27 @@ const char *Txt_Do_you_really_want_to_remove_the_group_X_Y_students_ = // Warnin
"Doing so will remove %u students from that group."; // Necessita de tradução "Doing so will remove %u students from that group."; // Necessita de tradução
#endif #endif
const char *Txt_Do_you_really_want_to_remove_the_location_X = // Warning: it is very important to include %s in the following sentences
#if L==1
"&iquest;De veres voleu eliminar la ubicaci&oacute; <strong>%s</strong>?";
#elif L==2
"Wollen Sie die Standort <strong>%s</strong> wirklich entfernen?";
#elif L==3
"Do you really want to remove the location <strong>%s</strong>?";
#elif L==4
"&iquest;Realmente desea eliminar la ubicaci&oacute;n <strong>%s</strong>?";
#elif L==5
"Voulez-vous vraiment supprimer l'emplacement <strong>%s</strong>?";
#elif L==6
"&iquest;Realmente desea eliminar la ubicaci&oacute;n <strong>%s</strong>?"; // Okoteve traducción
#elif L==7
"Vuoi realmente rimuovere la posizione <strong>%s</strong>?";
#elif L==8
"Czy na pewno chcesz usunac lokacja <strong>%s</strong>?";
#elif L==9
"Voc&ecirc; realmente deseja remover a localiza&ccedil;&atilde;o <strong>%s</strong>?";
#endif
const char *Txt_Do_you_really_want_to_remove_the_photo_of_X = // Warning: it is very important to include %s in the following sentences const char *Txt_Do_you_really_want_to_remove_the_photo_of_X = // Warning: it is very important to include %s in the following sentences
#if L==1 #if L==1
"De veres voleu eliminar la foto de <strong>%s</strong>?"; "De veres voleu eliminar la foto de <strong>%s</strong>?";
@ -9780,7 +9822,7 @@ const char *Txt_Edit =
const char *Txt_Edit_assignment = const char *Txt_Edit_assignment =
#if L==1 #if L==1
"Editar actividad"; // Necessita traduccio "Editar activitat";
#elif L==2 #elif L==2
"Aufgabe bearbeiten"; "Aufgabe bearbeiten";
#elif L==3 #elif L==3
@ -9820,6 +9862,27 @@ const char *Txt_Edit_event =
"Editar evento"; "Editar evento";
#endif #endif
const char *Txt_Edit_location =
#if L==1
"Editar ubicaci&oacute;";
#elif L==2
"Aufgabe Standort";
#elif L==3
"Edit location";
#elif L==4
"Editar ubicaci&oacute;n";
#elif L==5
"&Eacute;diter emplacement";
#elif L==6
"Editar ubicaci&oacute;n"; // Okoteve traducción
#elif L==7
"Editare posizione";
#elif L==8
"Edytuj lokacja";
#elif L==9
"Editar localiza&ccedil;&atilde;o";
#endif
const char *Txt_Edit_my_institution = const char *Txt_Edit_my_institution =
#if L==1 #if L==1
"Edita la meva instituci&oacute;"; "Edita la meva instituci&oacute;";
@ -17110,6 +17173,48 @@ const char *Txt_Location =
"Localiza&ccedil;&atilde;o"; "Localiza&ccedil;&atilde;o";
#endif #endif
const char *Txt_Location_X_is_now_hidden = // Warning: it is very important to include %s in the following sentences
#if L==1
"La ubicaci&oacute; <strong>%s</strong> ara est&agrave; oculta.";
#elif L==2
"Die Standort <strong>%s</strong> ist jetzt ausgeblendet.";
#elif L==3
"Location <strong>%s</strong> is now hidden.";
#elif L==4
"La ubicaci&oacute;n <strong>%s</strong> ahora est&aacute; oculta.";
#elif L==5
"L'emplacement <strong>%s</strong> est maintenant cach&eacute;e.";
#elif L==6
"La ubicaci&oacute;n <strong>%s</strong> ahora est&aacute; oculta."; // Okoteve traducción
#elif L==7
"La posizione <strong>%s</strong> &egrave; ora nascosta.";
#elif L==8
"Lokacja <strong>%s</strong> jest ukryte.";
#elif L==9
"A localiza&ccedil;&atilde;o <strong>%s</strong> &eacute; agora oculta.";
#endif
const char *Txt_Location_X_is_now_visible = // Warning: it is very important to include %s in the following sentences
#if L==1
"La ubicaci&oacute; <strong>%s</strong> ara est&agrave; visible.";
#elif L==2
"Die Standort <strong>%s</strong> ist jetzt sichtbar.";
#elif L==3
"Location <strong>%s</strong> is now visible.";
#elif L==4
"La ubicaci&oacute;n <strong>%s</strong> ahora est&aacute; visible.";
#elif L==5
"L'emplacement <strong>%s</strong> est maintenant visible.";
#elif L==6
"La ubicaci&oacute;n <strong>%s</strong> ahora est&aacute; visible."; // Okoteve traducción
#elif L==7
"La posizione <strong>%s</strong> &egrave; ora visibile.";
#elif L==8
"Lokacja <strong>%s</strong> jest teraz widoczny.";
#elif L==9
"A localiza&ccedil;&atilde;o <strong>%s</strong> &eacute; agora vis&iacute;vel.";
#endif
const char *Txt_Location_X_removed = // Warning: it is very important to include %s in the following sentences const char *Txt_Location_X_removed = // Warning: it is very important to include %s in the following sentences
#if L==1 #if L==1
"Ubicaci&oacute; <strong>%s</strong> eliminada."; "Ubicaci&oacute; <strong>%s</strong> eliminada.";
@ -43601,6 +43706,27 @@ const char *Txt_The_list_of_X_users_is_too_large_to_be_displayed = // Warning: i
"The list of %u users is too large to be displayed."; // Necessita de tradução "The list of %u users is too large to be displayed."; // Necessita de tradução
#endif #endif
const char *Txt_The_location_has_been_modified =
#if L==1
"La ubicaci&oacute; s'ha modificat.";
#elif L==2
"Die Standort wurde ge&auml;ndert.";
#elif L==3
"The location has been modified.";
#elif L==4
"La ubicaci&oacute;n ha sido modificada.";
#elif L==5
"L'emplacement a &eacute;t&eacute; modifi&eacute;.";
#elif L==6
"La ubicaci&oacute;n ha sido modificada."; // Okoteve traducción
#elif L==7
"La posizione &egrave; stata modificata.";
#elif L==8
"Lokalizacja zosta&lstrok;a zmodyfikowana.";
#elif L==9
"A localiza&ccedil;&atilde;o foi modificada.";
#endif
const char *Txt_The_lower_limit_of_correct_answers_must_be_less_than_or_equal_to_the_upper_limit = const char *Txt_The_lower_limit_of_correct_answers_must_be_less_than_or_equal_to_the_upper_limit =
#if L==1 #if L==1
"El l&iacute;mite inferior del intervalo de respuestas correctas" "El l&iacute;mite inferior del intervalo de respuestas correctas"
@ -54301,7 +54427,7 @@ const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_pla
const char *Txt_You_must_specify_the_title_of_the_assignment = const char *Txt_You_must_specify_the_title_of_the_assignment =
#if L==1 #if L==1
"Debe especificar el t&iacute;tulo de la actividad."; // Necessita traduccio "Cal especificar el t&iacute;tol de l'activitat.";
#elif L==2 #elif L==2
"Die Aufgabe muss angegeben werden."; "Die Aufgabe muss angegeben werden.";
#elif L==3 #elif L==3
@ -54315,7 +54441,7 @@ const char *Txt_You_must_specify_the_title_of_the_assignment =
#elif L==7 #elif L==7
"&Egrave; necessario specificare il titolo dell'attivit&agrave;."; "&Egrave; necessario specificare il titolo dell'attivit&agrave;.";
#elif L==8 #elif L==8
"You must specify the title of the assignment."; // Potrzebujesz tlumaczenie "Musisz poda&cacute; tytu&lstrok; zadania.";
#elif L==9 #elif L==9
"Voc&ecirc; deve especificar o t&iacute;tulo da atividade."; "Voc&ecirc; deve especificar o t&iacute;tulo da atividade.";
#endif #endif
@ -54341,6 +54467,27 @@ const char *Txt_You_must_specify_the_title_of_the_event =
"Voc&ecirc; deve especificar o t&iacute;tulo do evento."; "Voc&ecirc; deve especificar o t&iacute;tulo do evento.";
#endif #endif
const char *Txt_You_must_specify_the_title_of_the_location =
#if L==1
"Cal especificar el t&iacute;tol de la ubicaci&oacute;.";
#elif L==2
"Sie m&uuml;ssen den Titel des Standorts angeben.";
#elif L==3
"You must specify the title of the location.";
#elif L==4
"Debe especificar el t&iacute;tulo de la ubicaci&oacute;n.";
#elif L==5
"Vous devez sp&eacute;cifier le titre du emplacement.";
#elif L==6
"Debe especificar el t&iacute;tulo de la ubicaci&oacute;n."; // Okoteve traducción
#elif L==7
"&Egrave; necessario specificare il titolo della posizione.";
#elif L==8
"Musisz poda&cacute; tytu&lstrok; lokalizacji.";
#elif L==9
"Voc&ecirc; deve especificar o t&iacute;tulo da localiza&ccedil;&atilde;o.";
#endif
const char *Txt_You_must_specify_the_title_of_the_survey = const char *Txt_You_must_specify_the_title_of_the_survey =
#if L==1 #if L==1
"Debe especificar el t&iacute;tulo de la encuesta."; // Necessita traduccio "Debe especificar el t&iacute;tulo de la encuesta."; // Necessita traduccio