mirror of https://github.com/acanas/swad-core.git
Version18.93
This commit is contained in:
parent
cd04ddb7ea
commit
f37095da1c
|
@ -1412,8 +1412,8 @@ CREATE TABLE IF NOT EXISTS usr_IDs (
|
|||
CREATE TABLE IF NOT EXISTS usr_last (
|
||||
UsrCod INT NOT NULL,
|
||||
WhatToSearch TINYINT NOT NULL DEFAULT 0,
|
||||
LastCrs INT NOT NULL DEFAULT -1,
|
||||
LastTab TINYINT NOT NULL,
|
||||
LastSco ENUM('Unk','Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Unk',
|
||||
LastCod INT NOT NULL DEFAULT -1,
|
||||
LastAct INT NOT NULL DEFAULT -1,
|
||||
LastRole TINYINT NOT NULL DEFAULT 0,
|
||||
LastTime DATETIME NOT NULL,
|
||||
|
|
|
@ -5180,6 +5180,7 @@ void Act_AdjustCurrentAction (void)
|
|||
bool IAmATeacherInAnyCrs;
|
||||
bool JustAfterLogin = Gbl.Action.Act == ActLogIn ||
|
||||
Gbl.Action.Act == ActLogInLan ||
|
||||
Gbl.Action.Act == ActLogInNew ||
|
||||
Gbl.Action.Act == ActAnnSee;
|
||||
|
||||
/***** Don't adjust anything when:
|
||||
|
|
|
@ -464,10 +464,18 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.92.3 (2019-04-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.93 (2019-04-01)"
|
||||
#define CSS_FILE "swad18.92.css"
|
||||
#define JS_FILE "swad18.92.js"
|
||||
/*
|
||||
Version 18.93: Apr 01, 2019 When a user logs in, hierarchy, action and role are got from database. (241533 lines)
|
||||
5 changes necessary in database:
|
||||
ALTER TABLE usr_last ADD COLUMN LastSco ENUM('Unk','Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Unk' AFTER LastCrs;
|
||||
ALTER TABLE usr_last ADD COLUMN LastCod INT NOT NULL DEFAULT -1 AFTER LastSco;
|
||||
UPDATE usr_last SET LastSco='Crs',LastCod=LastCrs WHERE LastCrs>0;
|
||||
ALTER TABLE usr_last DROP COLUMN LastCrs;
|
||||
ALTER TABLE usr_last DROP COLUMN LastTab;
|
||||
|
||||
Version 18.92.3: Apr 01, 2019 Last action and role are saved in database. (241410 lines)
|
||||
2 changes necessary in database:
|
||||
ALTER TABLE usr_last ADD COLUMN LastAct INT NOT NULL DEFAULT -1 AFTER LastTab;
|
||||
|
|
|
@ -2970,26 +2970,26 @@ mysql> DESCRIBE usr_IDs;
|
|||
/***** Table usr_last *****/
|
||||
/*
|
||||
mysql> DESCRIBE usr_last;
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
+--------------+-------------------------------------------------+------+-----+---------+-------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
+--------------+-------------------------------------------------+------+-----+---------+-------+
|
||||
| UsrCod | int(11) | NO | PRI | NULL | |
|
||||
| WhatToSearch | tinyint(4) | NO | | 0 | |
|
||||
| LastCrs | int(11) | NO | | -1 | |
|
||||
| LastTab | tinyint(4) | NO | | NULL | |
|
||||
| LastSco | enum('Unk','Sys','Cty','Ins','Ctr','Deg','Crs') | NO | | Unk | |
|
||||
| LastCod | int(11) | NO | | -1 | |
|
||||
| LastAct | int(11) | NO | | -1 | |
|
||||
| LastRole | tinyint(4) | NO | | 0 | |
|
||||
| LastTime | datetime | NO | MUL | NULL | |
|
||||
| LastAccNotif | datetime | NO | | NULL | |
|
||||
| TimelineUsrs | tinyint(4) | NO | | 0 | |
|
||||
+--------------+------------+------+-----+---------+-------+
|
||||
9 rows in set (0.00 sec)
|
||||
+--------------+-------------------------------------------------+------+-----+---------+-------+
|
||||
9 rows in set (0.01 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS usr_last ("
|
||||
"UsrCod INT NOT NULL,"
|
||||
"WhatToSearch TINYINT NOT NULL DEFAULT 0,"
|
||||
"LastCrs INT NOT NULL DEFAULT -1,"
|
||||
"LastTab TINYINT NOT NULL,"
|
||||
"LastSco ENUM('Unk','Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Unk',"
|
||||
"LastCod INT NOT NULL DEFAULT -1,"
|
||||
"LastAct INT NOT NULL DEFAULT -1,"
|
||||
"LastRole TINYINT NOT NULL DEFAULT 0,"
|
||||
"LastTime DATETIME NOT NULL,"
|
||||
|
|
|
@ -128,7 +128,6 @@ static void Deg_PutParamGoToDeg (void);
|
|||
void Deg_SeeDegWithPendingCrss (void)
|
||||
{
|
||||
extern const char *Hlp_SYSTEM_Hierarchy_pending;
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_Degrees_with_pending_courses;
|
||||
extern const char *Txt_Degree;
|
||||
extern const char *Txt_Courses_ABBREVIATION;
|
||||
|
@ -153,7 +152,8 @@ void Deg_SeeDegWithPendingCrss (void)
|
|||
" AND (courses.Status & %u)<>0"
|
||||
" AND courses.DegCod=degrees.DegCod"
|
||||
" GROUP BY courses.DegCod ORDER BY degrees.ShortName",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),
|
||||
(unsigned) Crs_STATUS_BIT_PENDING);
|
||||
break;
|
||||
case Rol_SYS_ADM:
|
||||
|
@ -1838,7 +1838,6 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
|||
|
||||
void Deg_RemoveDegreeCompletely (long DegCod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRow,NumRows;
|
||||
|
@ -1890,7 +1889,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
/***** Remove administrators of this degree *****/
|
||||
DB_QueryDELETE ("can not remove administrators of a degree",
|
||||
"DELETE FROM admin WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],DegCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),DegCod);
|
||||
|
||||
/***** Remove the degree *****/
|
||||
DB_QueryDELETE ("can not remove a degree",
|
||||
|
@ -2406,7 +2405,6 @@ unsigned Deg_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
|||
|
||||
void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_all_degrees;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -2443,10 +2441,10 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
" AND admin.Scope='%s'"
|
||||
" AND admin.Cod=degrees.DegCod)"
|
||||
" ORDER BY S,FullName",
|
||||
(unsigned) Sco_SCOPE_SYS,UsrCod,Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
(unsigned) Sco_SCOPE_INS,UsrCod,Sco_ScopeDB[Sco_SCOPE_INS],
|
||||
(unsigned) Sco_SCOPE_CTR,UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
(unsigned) Sco_SCOPE_DEG,UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG]);
|
||||
(unsigned) Sco_SCOPE_SYS,UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
(unsigned) Sco_SCOPE_INS,UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_INS),
|
||||
(unsigned) Sco_SCOPE_CTR,UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_CTR),
|
||||
(unsigned) Sco_SCOPE_DEG,UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_DEG));
|
||||
if (NumRows)
|
||||
/***** Get the list of degrees *****/
|
||||
for (NumRow = 1;
|
||||
|
|
|
@ -2236,7 +2236,6 @@ void Enr_UpdateEnrolmentRequests (void)
|
|||
static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||
{
|
||||
extern const char *Hlp_USERS_Requests;
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
||||
extern const char *Txt_Enrolment_requests;
|
||||
extern const char *Txt_Scope;
|
||||
|
@ -2358,7 +2357,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_DEG),
|
||||
RolesSelected);
|
||||
break;
|
||||
case Rol_CTR_ADM:
|
||||
|
@ -2377,7 +2376,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_CTR),
|
||||
RolesSelected);
|
||||
break;
|
||||
case Rol_INS_ADM:
|
||||
|
@ -2397,7 +2396,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_INS],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_INS),
|
||||
RolesSelected);
|
||||
break;
|
||||
case Rol_SYS_ADM:
|
||||
|
@ -2466,7 +2465,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_DEG),
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -2489,7 +2488,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_CTR),
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -2512,7 +2511,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_INS],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_INS),
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -2586,7 +2585,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_DEG),
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -2608,7 +2607,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_CTR],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_CTR),
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -2680,7 +2679,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
" AND courses.CrsCod=crs_usr_requests.CrsCod"
|
||||
" AND ((1<<crs_usr_requests.Role)&%u)<>0"
|
||||
" ORDER BY crs_usr_requests.RequestTime DESC",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_ScopeDB[Sco_SCOPE_DEG],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_DEG),
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
RolesSelected);
|
||||
break;
|
||||
|
@ -3399,7 +3398,6 @@ static void Enr_AddAdm (Sco_Scope_t Scope,long Cod,const char *InsCtrDegName)
|
|||
|
||||
static void Enr_RegisterAdmin (struct UsrData *UsrDat,Sco_Scope_t Scope,long Cod,const char *InsCtrDegName)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_THE_USER_X_is_already_an_administrator_of_Y;
|
||||
extern const char *Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y;
|
||||
|
||||
|
@ -3415,7 +3413,7 @@ static void Enr_RegisterAdmin (struct UsrData *UsrDat,Sco_Scope_t Scope,long Cod
|
|||
" (UsrCod,Scope,Cod)"
|
||||
" VALUES"
|
||||
" (%ld,'%s',%ld)",
|
||||
UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod);
|
||||
UsrDat->UsrCod,Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
|
@ -4242,7 +4240,6 @@ static void Enr_AskIfRemAdm (bool ItsMe,Sco_Scope_t Scope,
|
|||
static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope,
|
||||
long Cod,const char *InsCtrDegName)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y;
|
||||
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y;
|
||||
|
||||
|
@ -4252,7 +4249,7 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope,
|
|||
DB_QueryDELETE ("can not remove an administrator",
|
||||
"DELETE FROM admin"
|
||||
" WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld",
|
||||
UsrDat->UsrCod,Sco_ScopeDB[Scope],Cod);
|
||||
UsrDat->UsrCod,Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
|
|
68
swad_game.c
68
swad_game.c
|
@ -877,7 +877,6 @@ static void Gam_PutParams (void)
|
|||
|
||||
void Gam_GetListGames (void)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char *SubQuery[Sco_NUM_SCOPES];
|
||||
static const char *OrderBySubQuery[Gam_NUM_ORDERS] =
|
||||
{
|
||||
|
@ -918,7 +917,7 @@ void Gam_GetListGames (void)
|
|||
if (asprintf (&SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
Sco_GetDBStrFromScope (Scope),Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
@ -949,7 +948,7 @@ void Gam_GetListGames (void)
|
|||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
|
@ -960,7 +959,7 @@ void Gam_GetListGames (void)
|
|||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
@ -1707,14 +1706,12 @@ void Gam_UnhideGame (void)
|
|||
|
||||
static bool Gam_CheckIfSimilarGameExists (struct Game *Game)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
/***** Get number of games with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar games",
|
||||
"SELECT COUNT(*) FROM games"
|
||||
" WHERE Scope='%s' AND Cod=%ld"
|
||||
" AND Title='%s' AND GamCod<>%ld",
|
||||
Sco_ScopeDB[Game->Scope],Game->Cod,
|
||||
Sco_GetDBStrFromScope (Game->Scope),Game->Cod,
|
||||
Game->Title,Game->GamCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -2172,7 +2169,6 @@ void Gam_RecFormGame (void)
|
|||
|
||||
static void Gam_CreateGame (struct Game *Game,const char *Txt)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_Created_new_game_X;
|
||||
|
||||
/***** Create a new game *****/
|
||||
|
@ -2184,7 +2180,7 @@ static void Gam_CreateGame (struct Game *Game,const char *Txt)
|
|||
" ('%s',%ld,'N',%u,%ld,"
|
||||
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
||||
"'%s','%s')",
|
||||
Sco_ScopeDB[Game->Scope],Game->Cod,
|
||||
Sco_GetDBStrFromScope (Game->Scope),Game->Cod,
|
||||
Game->Roles,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Game->TimeUTC[Gam_START_TIME],
|
||||
|
@ -2207,7 +2203,6 @@ static void Gam_CreateGame (struct Game *Game,const char *Txt)
|
|||
|
||||
static void Gam_UpdateGame (struct Game *Game,const char *Txt)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_The_game_has_been_modified;
|
||||
|
||||
/***** Update the data of the game *****/
|
||||
|
@ -2218,7 +2213,7 @@ static void Gam_UpdateGame (struct Game *Game,const char *Txt)
|
|||
"EndTime=FROM_UNIXTIME(%ld),"
|
||||
"Title='%s',Txt='%s'"
|
||||
" WHERE GamCod=%ld",
|
||||
Sco_ScopeDB[Game->Scope],Game->Cod,
|
||||
Sco_GetDBStrFromScope (Game->Scope),Game->Cod,
|
||||
Game->Roles,
|
||||
Game->TimeUTC[Gam_START_TIME],
|
||||
Game->TimeUTC[Gam_END_TIME ],
|
||||
|
@ -2398,8 +2393,6 @@ static void Gam_GetAndWriteNamesOfGrpsAssociatedToGame (struct Game *Game)
|
|||
|
||||
void Gam_RemoveGames (Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
/***** Remove all the users in course games *****/
|
||||
DB_QueryDELETE ("can not remove users who had answered games"
|
||||
" in a place on the hierarchy",
|
||||
|
@ -2407,7 +2400,7 @@ void Gam_RemoveGames (Sco_Scope_t Scope,long Cod)
|
|||
" USING games,gam_users"
|
||||
" WHERE games.Scope='%s' AND games.Cod=%ld"
|
||||
" AND games.GamCod=gam_users.GamCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove all the answers in course games *****/
|
||||
DB_QueryDELETE ("can not remove answers of games"
|
||||
|
@ -2417,7 +2410,7 @@ void Gam_RemoveGames (Sco_Scope_t Scope,long Cod)
|
|||
" WHERE games.Scope='%s' AND games.Cod=%ld"
|
||||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" AND gam_questions.QstCod=gam_answers.QstCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove all the questions in course games *****/
|
||||
DB_QueryDELETE ("can not remove questions of games"
|
||||
|
@ -2426,7 +2419,7 @@ void Gam_RemoveGames (Sco_Scope_t Scope,long Cod)
|
|||
" USING games,gam_questions"
|
||||
" WHERE games.Scope='%s' AND games.Cod=%ld"
|
||||
" AND games.GamCod=gam_questions.GamCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove groups *****/
|
||||
DB_QueryDELETE ("can not remove all the groups"
|
||||
|
@ -2435,12 +2428,12 @@ void Gam_RemoveGames (Sco_Scope_t Scope,long Cod)
|
|||
" USING games,gam_grp"
|
||||
" WHERE games.Scope='%s' AND games.Cod=%ld"
|
||||
" AND games.GamCod=gam_grp.GamCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove course games *****/
|
||||
DB_QueryDELETE ("can not remove all the games in a place on the hierarchy",
|
||||
"DELETE FROM games WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3796,7 +3789,6 @@ static unsigned Gam_GetNumUsrsWhoHaveAnsweredGame (long GamCod)
|
|||
|
||||
unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumCourses;
|
||||
|
@ -3809,7 +3801,7 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM games"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with games",
|
||||
|
@ -3822,7 +3814,7 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with games",
|
||||
|
@ -3834,7 +3826,7 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with games",
|
||||
|
@ -3844,7 +3836,7 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with games",
|
||||
|
@ -3854,14 +3846,14 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM games"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -3887,7 +3879,6 @@ unsigned Gam_GetNumCoursesWithGames (Sco_Scope_t Scope)
|
|||
|
||||
unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumGames;
|
||||
|
@ -3900,7 +3891,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
"SELECT COUNT(*)"
|
||||
" FROM games"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of games",
|
||||
|
@ -3913,7 +3904,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of games",
|
||||
|
@ -3925,7 +3916,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of games",
|
||||
|
@ -3936,7 +3927,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of games",
|
||||
|
@ -3946,7 +3937,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=games.Cod"
|
||||
" AND games.Scope='%s'",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of games",
|
||||
|
@ -3954,7 +3945,7 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
" FROM games"
|
||||
" WHERE games.Scope='%s'"
|
||||
" AND CrsCod=%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -3979,7 +3970,6 @@ unsigned Gam_GetNumGames (Sco_Scope_t Scope)
|
|||
|
||||
float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
float NumQstsPerGame;
|
||||
|
@ -3995,7 +3985,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" WHERE games.Scope='%s'"
|
||||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
|
@ -4011,7 +4001,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
|
@ -4026,7 +4016,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
|
@ -4040,7 +4030,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
|
@ -4053,7 +4043,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
|
@ -4063,7 +4053,7 @@ float Gam_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
" WHERE games.Scope='%s' AND games.Cod=%ld"
|
||||
" AND games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Gbl.CurrentCrs.Crs.CrsCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
|
|
|
@ -242,6 +242,9 @@ void Gbl_InitializeGlobals (void)
|
|||
Gbl.CurrentCrs.Info.ShowMsgMustBeRead = 0;
|
||||
Gbl.CurrentCrs.Notices.HighlightNotCod = -1L; // No notice highlighted
|
||||
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_UNK;
|
||||
Gbl.Hierarchy.Cod = -1L;
|
||||
|
||||
Gbl.Inss.Num = 0;
|
||||
Gbl.Inss.Lst = NULL;
|
||||
Gbl.Inss.SelectedOrder = Ins_ORDER_DEFAULT;
|
||||
|
|
|
@ -450,6 +450,11 @@ struct Globals
|
|||
Sco_Scope_t Default;
|
||||
unsigned Allowed;
|
||||
} Scope;
|
||||
struct
|
||||
{
|
||||
Sco_Scope_t Scope;
|
||||
long Cod;
|
||||
} Hierarchy;
|
||||
struct
|
||||
{
|
||||
struct Country Cty;
|
||||
|
|
|
@ -448,6 +448,83 @@ void Hie_WriteBigNameCtyInsCtrDegCrs (void)
|
|||
"</h1>");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Set current hierarchy depending on course code, degree code, etc. *****/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Hie_SetCurrentHierarchy (void)
|
||||
{
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_CRS;
|
||||
Gbl.Hierarchy.Cod = Gbl.CurrentCrs.Crs.CrsCod;
|
||||
}
|
||||
else if (Gbl.CurrentDeg.Deg.DegCod > 0) // Degree selected
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_DEG;
|
||||
Gbl.Hierarchy.Cod = Gbl.CurrentDeg.Deg.DegCod;
|
||||
}
|
||||
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) // Centre selected
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_CTR;
|
||||
Gbl.Hierarchy.Cod = Gbl.CurrentCtr.Ctr.CtrCod;
|
||||
}
|
||||
else if (Gbl.CurrentIns.Ins.InsCod > 0) // Institution selected
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_INS;
|
||||
Gbl.Hierarchy.Cod = Gbl.CurrentIns.Ins.InsCod;
|
||||
}
|
||||
else if (Gbl.CurrentCty.Cty.CtyCod > 0) // Country selected
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_CTY;
|
||||
Gbl.Hierarchy.Cod = Gbl.CurrentCty.Cty.CtyCod;
|
||||
}
|
||||
else
|
||||
{
|
||||
Gbl.Hierarchy.Scope = Sco_SCOPE_SYS;
|
||||
Gbl.Hierarchy.Cod = -1L;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Copy last hierarchy to current hierarchy *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Hie_SetHierarchyFromUsrLastHierarchy (void)
|
||||
{
|
||||
/***** Initialize all codes to -1 *****/
|
||||
Gbl.CurrentCty.Cty.CtyCod =
|
||||
Gbl.CurrentIns.Ins.InsCod =
|
||||
Gbl.CurrentCtr.Ctr.CtrCod =
|
||||
Gbl.CurrentDeg.Deg.DegCod =
|
||||
Gbl.CurrentCrs.Crs.CrsCod = -1L;
|
||||
|
||||
/***** Copy last hierarchy scope and code to current hierarchy *****/
|
||||
switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope)
|
||||
{
|
||||
case Sco_SCOPE_CTY: // Country
|
||||
Gbl.CurrentCty.Cty.CtyCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
|
||||
break;
|
||||
case Sco_SCOPE_INS: // Institution
|
||||
Gbl.CurrentIns.Ins.InsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
|
||||
break;
|
||||
case Sco_SCOPE_CTR: // Centre
|
||||
Gbl.CurrentCtr.Ctr.CtrCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
|
||||
break;
|
||||
case Sco_SCOPE_DEG: // Degree
|
||||
Gbl.CurrentDeg.Deg.DegCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
|
||||
break;
|
||||
case Sco_SCOPE_CRS: // Course
|
||||
Gbl.CurrentCrs.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastHie.Cod;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/****** Initialize again current course, degree, centre... ******/
|
||||
Hie_InitHierarchy ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**** Initialize current country, institution, centre, degree and course *****/
|
||||
/*****************************************************************************/
|
||||
|
@ -533,6 +610,9 @@ void Hie_InitHierarchy (void)
|
|||
}
|
||||
}
|
||||
|
||||
/***** Set current hierarchy depending on course code, degree code, etc. *****/
|
||||
Hie_SetCurrentHierarchy ();
|
||||
|
||||
/***** Initialize default fields for edition to current values *****/
|
||||
Gbl.Inss.EditingIns.CtyCod = Gbl.CurrentCty.Cty.CtyCod;
|
||||
Gbl.Ctrs.EditingCtr.InsCod =
|
||||
|
|
|
@ -50,6 +50,9 @@ void Hie_SeePending (void);
|
|||
void Hie_WriteMenuHierarchy (void);
|
||||
void Hie_WriteHierarchyInBreadcrumb (void);
|
||||
void Hie_WriteBigNameCtyInsCtrDegCrs (void);
|
||||
|
||||
void Hie_SetCurrentHierarchy (void);
|
||||
void Hie_SetHierarchyFromUsrLastHierarchy (void);
|
||||
void Hie_InitHierarchy (void);
|
||||
|
||||
void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan);
|
||||
|
|
17
swad_main.c
17
swad_main.c
|
@ -31,6 +31,7 @@
|
|||
#include <unistd.h> // For sleep
|
||||
|
||||
#include "swad_action.h"
|
||||
#include "swad_announcement.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_connected.h"
|
||||
#include "swad_database.h"
|
||||
|
@ -41,6 +42,7 @@
|
|||
#include "swad_notification.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_setting.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Constants **********************************/
|
||||
|
@ -155,6 +157,21 @@ int main (void)
|
|||
/***** Start writing HTML output *****/
|
||||
Lay_WriteStartOfPage ();
|
||||
|
||||
/***** If I am been redirected from another action... *****/
|
||||
switch (Gbl.Action.Original)
|
||||
{
|
||||
case ActLogIn:
|
||||
case ActLogInNew:
|
||||
case ActLogInLan:
|
||||
Usr_WelcomeUsr ();
|
||||
break;
|
||||
case ActAnnSee:
|
||||
Ann_MarkAnnouncementAsSeen ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Make a processing or other depending on the action *****/
|
||||
FunctionPosteriori = Act_GetFunctionPosteriori (Gbl.Action.Act);
|
||||
if (FunctionPosteriori != NULL)
|
||||
|
|
|
@ -1167,7 +1167,6 @@ void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod)
|
|||
|
||||
unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRow;
|
||||
|
@ -1303,10 +1302,10 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
|||
" OR (Scope='%s' AND Cod=%ld)"
|
||||
" OR (Scope='%s' AND Cod=%ld))"
|
||||
" AND UsrCod<>%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_INS),Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CTR),Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),Gbl.CurrentDeg.Deg.DegCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
break;
|
||||
|
@ -1390,11 +1389,11 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
|||
" AND (surveys.Roles&(1<<crs_usr.Role))<>0)",
|
||||
Cod,
|
||||
Cod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Cod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
28
swad_role.c
28
swad_role.c
|
@ -93,10 +93,25 @@ void Rol_SetMyRoles (void)
|
|||
/***** Set the user's role I am logged *****/
|
||||
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat); // Get my roles if not yet got
|
||||
Gbl.Usrs.Me.Role.Max = Rol_GetMaxRoleInCrss ((unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss);
|
||||
Gbl.Usrs.Me.Role.Logged = (Gbl.Usrs.Me.Role.FromSession == Rol_UNK) ? // If no logged role retrieved from session...
|
||||
((Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_UNK) ? Rol_USR :
|
||||
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role) :
|
||||
Gbl.Usrs.Me.Role.FromSession; // Get logged role from session
|
||||
|
||||
/***** Set the user's role I am logged *****/
|
||||
// My logged role is retrieved in this order from:
|
||||
// 1. It may have been retrieved from last data stored in database just after login
|
||||
// 2. If it is not known, it will be retrieved from current session
|
||||
// 3. If a course is selected, it will be retrieved from my role in this course
|
||||
// 4. If none of the former options is satisfied, it will be set to user role
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_UNK) // No role from last data
|
||||
{
|
||||
if (Gbl.Usrs.Me.Role.FromSession == Rol_UNK) // No role from session
|
||||
{
|
||||
if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_UNK) // No role in current course
|
||||
Gbl.Usrs.Me.Role.Logged = Rol_USR; // User
|
||||
else
|
||||
Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role; // Role in current course
|
||||
}
|
||||
else
|
||||
Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.Role.FromSession; // Role from session
|
||||
}
|
||||
|
||||
/***** Check if I am administrator of current institution/centre/degree *****/
|
||||
if (Gbl.CurrentIns.Ins.InsCod > 0)
|
||||
|
@ -191,8 +206,9 @@ void Rol_SetMyRoles (void)
|
|||
if (Usr_CheckIfUsrIsSuperuser (Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||
Gbl.Usrs.Me.Role.Available |= (1 << Rol_SYS_ADM);
|
||||
|
||||
/***** Check if the role I am logged is now available for me *****/
|
||||
if (!(Gbl.Usrs.Me.Role.Available & (1 << Gbl.Usrs.Me.Role.Logged))) // Current type I am logged is not available for me
|
||||
/***** Check if the role I am logged is now available for me (it's not forbidden) *****/
|
||||
if (!(Gbl.Usrs.Me.Role.Available &
|
||||
(1 << Gbl.Usrs.Me.Role.Logged))) // Current type I am logged is not available for me
|
||||
/* Set the lowest role available for me */
|
||||
for (Gbl.Usrs.Me.Role.Logged = Rol_UNK;
|
||||
Gbl.Usrs.Me.Role.Logged <= (Rol_Role_t) (Rol_NUM_ROLES - 1);
|
||||
|
|
36
swad_scope.c
36
swad_scope.c
|
@ -36,17 +36,6 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *Sco_ScopeDB[Sco_NUM_SCOPES] =
|
||||
{
|
||||
"Unk", // Sco_SCOPE_UNK
|
||||
"Sys", // Sco_SCOPE_SYS
|
||||
"Cty", // Sco_SCOPE_CTY
|
||||
"Ins", // Sco_SCOPE_INS
|
||||
"Ctr", // Sco_SCOPE_CTR
|
||||
"Deg", // Sco_SCOPE_DEG
|
||||
"Crs", // Sco_SCOPE_CRS
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Internal constants ****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -334,8 +323,31 @@ Sco_Scope_t Sco_GetScopeFromDBStr (const char *ScopeDBStr)
|
|||
for (Scope = Sco_SCOPE_UNK;
|
||||
Scope < Sco_NUM_SCOPES;
|
||||
Scope++)
|
||||
if (!strcmp (Sco_ScopeDB[Scope],ScopeDBStr))
|
||||
if (!strcmp (Sco_GetDBStrFromScope (Scope),ScopeDBStr))
|
||||
return Scope;
|
||||
|
||||
return Sco_SCOPE_UNK;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get scope from database string **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *Sco_GetDBStrFromScope (Sco_Scope_t Scope)
|
||||
{
|
||||
static const char *Sco_ScopeDB[Sco_NUM_SCOPES] =
|
||||
{
|
||||
"Unk", // Sco_SCOPE_UNK
|
||||
"Sys", // Sco_SCOPE_SYS
|
||||
"Cty", // Sco_SCOPE_CTY
|
||||
"Ins", // Sco_SCOPE_INS
|
||||
"Ctr", // Sco_SCOPE_CTR
|
||||
"Deg", // Sco_SCOPE_DEG
|
||||
"Crs", // Sco_SCOPE_CRS
|
||||
};
|
||||
|
||||
if (Scope >= Sco_NUM_SCOPES)
|
||||
Scope = Sco_SCOPE_UNK;
|
||||
|
||||
return Sco_ScopeDB[Scope];
|
||||
}
|
||||
|
|
|
@ -64,5 +64,6 @@ void Sco_SetScopesForListingStudents (void);
|
|||
|
||||
Sco_Scope_t Sco_GetScopeFromUnsignedStr (const char *UnsignedStr);
|
||||
Sco_Scope_t Sco_GetScopeFromDBStr (const char *ScopeDBStr);
|
||||
const char *Sco_GetDBStrFromScope (Sco_Scope_t Scope);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -841,7 +841,6 @@ static void Svy_PutParams (void)
|
|||
|
||||
void Svy_GetListSurveys (void)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char *SubQuery[Sco_NUM_SCOPES];
|
||||
static const char *OrderBySubQuery[Svy_NUM_ORDERS] =
|
||||
{
|
||||
|
@ -882,7 +881,7 @@ void Svy_GetListSurveys (void)
|
|||
if (asprintf (&SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
Sco_GetDBStrFromScope (Scope),Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
@ -913,7 +912,7 @@ void Svy_GetListSurveys (void)
|
|||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
|
@ -924,7 +923,7 @@ void Svy_GetListSurveys (void)
|
|||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
@ -1752,14 +1751,12 @@ void Svy_UnhideSurvey (void)
|
|||
|
||||
static bool Svy_CheckIfSimilarSurveyExists (struct Survey *Svy)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar surveys",
|
||||
"SELECT COUNT(*) FROM surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld"
|
||||
" AND Title='%s' AND SvyCod<>%ld",
|
||||
Sco_ScopeDB[Svy->Scope],Svy->Cod,
|
||||
Sco_GetDBStrFromScope (Svy->Scope),Svy->Cod,
|
||||
Svy->Title,Svy->SvyCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -2245,7 +2242,6 @@ static void Svy_UpdateNumUsrsNotifiedByEMailAboutSurvey (long SvyCod,
|
|||
|
||||
static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_Created_new_survey_X;
|
||||
|
||||
/***** Create a new survey *****/
|
||||
|
@ -2257,7 +2253,7 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
|
|||
" ('%s',%ld,'N',%u,%ld,"
|
||||
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
|
||||
"'%s','%s')",
|
||||
Sco_ScopeDB[Svy->Scope],Svy->Cod,
|
||||
Sco_GetDBStrFromScope (Svy->Scope),Svy->Cod,
|
||||
Svy->Roles,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Svy->TimeUTC[Svy_START_TIME],
|
||||
|
@ -2280,7 +2276,6 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
|
|||
|
||||
static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
extern const char *Txt_The_survey_has_been_modified;
|
||||
|
||||
/***** Update the data of the survey *****/
|
||||
|
@ -2291,7 +2286,7 @@ static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
|
|||
"EndTime=FROM_UNIXTIME(%ld),"
|
||||
"Title='%s',Txt='%s'"
|
||||
" WHERE SvyCod=%ld",
|
||||
Sco_ScopeDB[Svy->Scope],Svy->Cod,
|
||||
Sco_GetDBStrFromScope (Svy->Scope),Svy->Cod,
|
||||
Svy->Roles,
|
||||
Svy->TimeUTC[Svy_START_TIME],
|
||||
Svy->TimeUTC[Svy_END_TIME ],
|
||||
|
@ -2472,8 +2467,6 @@ static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Survey *Svy)
|
|||
|
||||
void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
/***** Remove all the users in course surveys *****/
|
||||
DB_QueryDELETE ("can not remove users"
|
||||
" who had answered surveys in a place on the hierarchy",
|
||||
|
@ -2481,7 +2474,7 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
|||
" USING surveys,svy_users"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_users.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove all the answers in course surveys *****/
|
||||
DB_QueryDELETE ("can not remove answers of surveys"
|
||||
|
@ -2491,7 +2484,7 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
|||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove all the questions in course surveys *****/
|
||||
DB_QueryDELETE ("can not remove questions of surveys"
|
||||
|
@ -2500,7 +2493,7 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
|||
" USING surveys,svy_questions"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove groups *****/
|
||||
DB_QueryDELETE ("can not remove all the groups"
|
||||
|
@ -2509,14 +2502,14 @@ void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
|||
" USING surveys,svy_grp"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_grp.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
|
||||
/***** Remove course surveys *****/
|
||||
DB_QueryDELETE ("can not remove all the surveys"
|
||||
" in a place on the hierarchy",
|
||||
"DELETE FROM surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3774,7 +3767,6 @@ static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod)
|
|||
|
||||
unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumCourses;
|
||||
|
@ -3788,7 +3780,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM surveys"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses"
|
||||
|
@ -3802,7 +3794,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses"
|
||||
|
@ -3815,7 +3807,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses"
|
||||
|
@ -3827,7 +3819,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses"
|
||||
|
@ -3838,7 +3830,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses"
|
||||
|
@ -3846,7 +3838,7 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -3873,7 +3865,6 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Sco_Scope_t Scope)
|
|||
|
||||
unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumSurveys;
|
||||
|
@ -3886,7 +3877,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
"SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM surveys"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
|
@ -3899,7 +3890,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
|
@ -3911,7 +3902,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
|
@ -3922,7 +3913,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
|
@ -3932,7 +3923,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
" AND courses.CrsCod=surveys.Cod"
|
||||
" AND surveys.Scope='%s'",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
|
@ -3940,7 +3931,7 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
" FROM surveys"
|
||||
" WHERE surveys.Scope='%s'"
|
||||
" AND CrsCod=%ld",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -3974,7 +3965,6 @@ unsigned Svy_GetNumCrsSurveys (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
|
||||
float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
float NumQstsPerSurvey;
|
||||
|
@ -3991,7 +3981,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" WHERE surveys.Scope='%s'"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
|
@ -4008,7 +3998,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
|
@ -4024,7 +4014,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
|
@ -4039,7 +4029,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
|
@ -4053,7 +4043,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS]);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS));
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
|
@ -4064,7 +4054,7 @@ float Svy_GetNumQstsPerCrsSurvey (Sco_Scope_t Scope)
|
|||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Gbl.CurrentCrs.Crs.CrsCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CRS),Gbl.CurrentCrs.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
|
|
|
@ -370,20 +370,6 @@ void TL_ShowTimelineGbl2 (void)
|
|||
TL_TOP_MESSAGE_NONE, // Ntf_EVENT_ENROLMENT_NET // TODO: Move to users tab (also necessary in database) !!!!!!!!!
|
||||
};
|
||||
|
||||
/***** If I am been redirected from another action... *****/
|
||||
switch (Gbl.Action.Original)
|
||||
{
|
||||
case ActLogIn:
|
||||
case ActLogInLan:
|
||||
Usr_WelcomeUsr ();
|
||||
break;
|
||||
case ActAnnSee:
|
||||
Ann_MarkAnnouncementAsSeen ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Initialize note code to -1 ==> no highlighted note *****/
|
||||
SocNot.NotCod = -1L;
|
||||
|
||||
|
|
177
swad_user.c
177
swad_user.c
|
@ -365,8 +365,10 @@ void Usr_ResetUsrDataExceptUsrCodAndIDs (struct UsrData *UsrDat)
|
|||
void Usr_ResetMyLastData (void)
|
||||
{
|
||||
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
||||
Gbl.Usrs.Me.UsrLast.LastCrs = -1L;
|
||||
Gbl.Usrs.Me.UsrLast.LastTab = TabUnk;
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_SCOPE_UNK;
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L;
|
||||
Gbl.Usrs.Me.UsrLast.LastAct = ActUnk;
|
||||
Gbl.Usrs.Me.UsrLast.LastRole = Rol_UNK;
|
||||
Gbl.Usrs.Me.UsrLast.LastAccNotif = 0;
|
||||
}
|
||||
|
||||
|
@ -760,8 +762,8 @@ static void Usr_GetMyLastData (void)
|
|||
/***** Get user's last data from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's last data",
|
||||
"SELECT WhatToSearch," // row[0]
|
||||
"LastCrs," // row[1]
|
||||
"LastTab," // row[2]
|
||||
"LastSco," // row[1]
|
||||
"LastCod," // row[2]
|
||||
"LastAct," // row[3]
|
||||
"LastRole," // row[4]
|
||||
"UNIX_TIMESTAMP(LastAccNotif)" // row[5]
|
||||
|
@ -788,21 +790,36 @@ static void Usr_GetMyLastData (void)
|
|||
if (Gbl.Usrs.Me.UsrLast.WhatToSearch == Sch_SEARCH_UNKNOWN)
|
||||
Gbl.Usrs.Me.UsrLast.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
|
||||
|
||||
/* Get last course (row[1]) */
|
||||
Gbl.Usrs.Me.UsrLast.LastCrs = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
||||
/* Get last tab (row[2]) */
|
||||
Gbl.Usrs.Me.UsrLast.LastTab = TabStr; // By default, set last tab to the start tab
|
||||
if (sscanf (row[2],"%u",&UnsignedNum) == 1)
|
||||
if (UnsignedNum >= 1 ||
|
||||
UnsignedNum <= Tab_NUM_TABS)
|
||||
Gbl.Usrs.Me.UsrLast.LastTab = (Tab_Tab_t) UnsignedNum;
|
||||
/* Get last hierarchy: scope (row[1]) and code (row[2]) */
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_GetScopeFromDBStr (row[1]);
|
||||
switch (Gbl.Usrs.Me.UsrLast.LastHie.Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS: // System
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L;
|
||||
break;
|
||||
case Sco_SCOPE_CTY: // Country
|
||||
case Sco_SCOPE_INS: // Institution
|
||||
case Sco_SCOPE_CTR: // Centre
|
||||
case Sco_SCOPE_DEG: // Degree
|
||||
case Sco_SCOPE_CRS: // Course
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Cod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
if (Gbl.Usrs.Me.UsrLast.LastHie.Cod <= 0)
|
||||
{
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_SCOPE_UNK;
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Scope = Sco_SCOPE_UNK;
|
||||
Gbl.Usrs.Me.UsrLast.LastHie.Cod = -1L;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get last action (row[3]) */
|
||||
ActCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
Gbl.Usrs.Me.UsrLast.LastAct = Act_GetActionFromActCod (ActCod);
|
||||
|
||||
/* Get last rolw (row[4]) */
|
||||
/* Get last role (row[4]) */
|
||||
Gbl.Usrs.Me.UsrLast.LastRole = Rol_ConvertUnsignedStrToRole (row[4]);
|
||||
|
||||
/* Get last access to notifications (row[5]) */
|
||||
|
@ -896,18 +913,12 @@ void Usr_FlushCachesUsr (void)
|
|||
/*****************************************************************************/
|
||||
|
||||
bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
if (Sco_ScopeDB[Scope])
|
||||
{
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if a user is administrator",
|
||||
"SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld",
|
||||
UsrCod,Sco_ScopeDB[Scope],Cod) != 0);
|
||||
}
|
||||
return false;
|
||||
UsrCod,Sco_GetDBStrFromScope (Scope),Cod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -922,8 +933,6 @@ void Usr_FlushCacheUsrIsSuperuser (void)
|
|||
|
||||
bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
|
||||
/***** 1. Fast check: Trivial case *****/
|
||||
if (UsrCod <= 0)
|
||||
return false;
|
||||
|
@ -938,7 +947,7 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
|||
(DB_QueryCOUNT ("can not check if a user is superuser",
|
||||
"SELECT COUNT(*) FROM admin"
|
||||
" WHERE UsrCod=%ld AND Scope='%s'",
|
||||
UsrCod,Sco_ScopeDB[Sco_SCOPE_SYS]) != 0);
|
||||
UsrCod,Sco_GetDBStrFromScope (Sco_SCOPE_SYS)) != 0);
|
||||
return Gbl.Cache.UsrIsSuperuser.IsSuperuser;
|
||||
}
|
||||
|
||||
|
@ -3093,19 +3102,8 @@ void Usr_ChkUsrAndGetUsrData (void)
|
|||
/***** Adjust tab and action *****/
|
||||
if (!Gbl.Action.UsesAJAX)
|
||||
{
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
/***** Set default tab when unknown *****/
|
||||
if (Gbl.Action.Tab == TabUnk)
|
||||
{
|
||||
// Don't adjust Gbl.Action.Act here
|
||||
Gbl.Action.Tab = ((Gbl.Usrs.Me.UsrLast.LastTab == TabCrs) &&
|
||||
(Gbl.CurrentCrs.Crs.CrsCod <= 0)) ? TabStr :
|
||||
Gbl.Usrs.Me.UsrLast.LastTab;
|
||||
Tab_DisableIncompatibleTabs ();
|
||||
}
|
||||
}
|
||||
else if (Gbl.Action.Act == ActUnk) // No user logged and unknown action
|
||||
if (!Gbl.Usrs.Me.Logged && // No user logged...
|
||||
Gbl.Action.Act == ActUnk) // ...and unknown action
|
||||
Act_AdjustActionWhenNoUsrLogged ();
|
||||
|
||||
/***** When I change to another tab, go to:
|
||||
|
@ -3125,13 +3123,6 @@ void Usr_ChkUsrAndGetUsrData (void)
|
|||
Action;
|
||||
Tab_SetCurrentTab ();
|
||||
}
|
||||
|
||||
/***** Update last data for next time *****/
|
||||
// if (Gbl.Usrs.Me.Logged)
|
||||
// {
|
||||
// Usr_UpdateMyLastData ();
|
||||
// Crs_UpdateCrsLast ();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3339,6 +3330,12 @@ static void Usr_SetMyPrefsAndRoles (void)
|
|||
extern const char *The_ThemeId[The_NUM_THEMES];
|
||||
extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS];
|
||||
char URL[PATH_MAX + 1];
|
||||
bool GetActionAndRoleFromLastData;
|
||||
Act_Action_t LastSuperAction;
|
||||
bool JustAfterLogin = Gbl.Action.Act == ActLogIn ||
|
||||
Gbl.Action.Act == ActLogInLan ||
|
||||
Gbl.Action.Act == ActLogInNew ||
|
||||
Gbl.Action.Act == ActAnnSee;
|
||||
|
||||
// In this point I am logged
|
||||
|
||||
|
@ -3374,29 +3371,54 @@ static void Usr_SetMyPrefsAndRoles (void)
|
|||
|
||||
/***** Get my last data *****/
|
||||
Usr_GetMyLastData ();
|
||||
if (Gbl.Action.Act == ActLogIn ||
|
||||
Gbl.Action.Act == ActLogInNew) // If I just logged in...
|
||||
if (JustAfterLogin) // If I just logged in...
|
||||
{
|
||||
/***** WhatToSearch is stored in session,
|
||||
but in login it is got from user's last data *****/
|
||||
Gbl.Search.WhatToSearch = Gbl.Usrs.Me.UsrLast.WhatToSearch;
|
||||
|
||||
/***** If no course selected, go to my last visited course *****/
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod <= 0 &&
|
||||
Gbl.Usrs.Me.UsrLast.LastCrs > 0)
|
||||
/***** Location in hierarchy and role are stored in session,
|
||||
but in login the are got from user's last data *****/
|
||||
if (Gbl.Hierarchy.Scope == Sco_SCOPE_SYS) // No country selected
|
||||
{
|
||||
Gbl.CurrentCrs.Crs.CrsCod = Gbl.Usrs.Me.UsrLast.LastCrs;
|
||||
/***** Copy last hierarchy to current hierarchy *****/
|
||||
Hie_SetHierarchyFromUsrLastHierarchy ();
|
||||
|
||||
/* Initialize again current course, degree, centre... */
|
||||
Hie_InitHierarchy ();
|
||||
|
||||
/* Get again my role in this course */
|
||||
/* Course may have changed ==> get my role in current course again */
|
||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
|
||||
{
|
||||
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role = Rol_GetRoleUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Valid = true;
|
||||
}
|
||||
|
||||
// Action and role will be got from last data
|
||||
GetActionAndRoleFromLastData = true;
|
||||
}
|
||||
else // Country (and may be institution, centre, degree or course) selected
|
||||
// Action and role will be got from last data
|
||||
// only if I am in the same hierarchy location that the stored one
|
||||
GetActionAndRoleFromLastData =
|
||||
(Gbl.Hierarchy.Scope == Gbl.Usrs.Me.UsrLast.LastHie.Scope && // The same scope...
|
||||
Gbl.Hierarchy.Cod == Gbl.Usrs.Me.UsrLast.LastHie.Cod); // ...and code in hierarchy
|
||||
|
||||
/***** Get action and role from last data *****/
|
||||
if (GetActionAndRoleFromLastData)
|
||||
{
|
||||
/* Get action from last data */
|
||||
LastSuperAction = Act_GetSuperAction (Gbl.Usrs.Me.UsrLast.LastAct);
|
||||
if (LastSuperAction != ActUnk)
|
||||
{
|
||||
Gbl.Action.Act = LastSuperAction;
|
||||
Tab_SetCurrentTab ();
|
||||
}
|
||||
|
||||
/* Get role from last data */
|
||||
Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrLast.LastRole;
|
||||
}
|
||||
}
|
||||
|
||||
/***** Set my roles *****/
|
||||
Rol_SetMyRoles ();
|
||||
}
|
||||
|
||||
|
@ -3494,10 +3516,10 @@ void Usr_UpdateMyLastData (void)
|
|||
// WhatToSearch, LastAccNotif remain unchanged
|
||||
DB_QueryUPDATE ("can not update last user's data",
|
||||
"UPDATE usr_last"
|
||||
" SET LastCrs=%ld,LastTab=%u,LastAct=%ld,LastRole=%u,LastTime=NOW()"
|
||||
" SET LastSco='%s',LastCod=%ld,LastAct=%ld,LastRole=%u,LastTime=NOW()"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
(unsigned) Gbl.Action.Tab,
|
||||
Sco_GetDBStrFromScope (Gbl.Hierarchy.Scope),
|
||||
Gbl.Hierarchy.Cod,
|
||||
Act_GetActCod (Gbl.Action.Act),
|
||||
(unsigned) Gbl.Usrs.Me.Role.Logged,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
@ -3514,13 +3536,13 @@ static void Usr_InsertMyLastData (void)
|
|||
/***** Insert my last accessed course, tab and time of click in database *****/
|
||||
DB_QueryINSERT ("can not insert last user's data",
|
||||
"INSERT INTO usr_last"
|
||||
" (UsrCod,WhatToSearch,LastCrs,LastTab,LastAct,LastRole,LastTime,LastAccNotif)"
|
||||
" (UsrCod,WhatToSearch,LastSco,LastCod,LastAct,LastRole,LastTime,LastAccNotif)"
|
||||
" VALUES"
|
||||
" (%ld,%u,%ld,%u,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
|
||||
" (%ld,%u,'%s',%ld,%ld,%u,NOW(),FROM_UNIXTIME(%ld))",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Sch_SEARCH_ALL,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
(unsigned) Gbl.Action.Tab,
|
||||
Sco_GetDBStrFromScope (Gbl.Hierarchy.Scope),
|
||||
Gbl.Hierarchy.Cod,
|
||||
Act_GetActCod (Gbl.Action.Act),
|
||||
(unsigned) Gbl.Usrs.Me.Role.Logged,
|
||||
(long) (time_t) 0); // The user never accessed to notifications
|
||||
|
@ -5004,7 +5026,6 @@ void Usr_DropTmpTableWithCandidateUsrs (void)
|
|||
|
||||
static void Usr_GetAdmsLst (Sco_Scope_t Scope)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
const char *QueryFields =
|
||||
"UsrCod,"
|
||||
"EncryptedUsrCod,"
|
||||
|
@ -5074,10 +5095,10 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
|
|||
" AND institutions.CtyCod=%ld)"
|
||||
" ORDER BY Surname1,Surname2,FirstName,UsrCod",
|
||||
QueryFields,
|
||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentCty.Cty.CtyCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_INS),Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CTR),Gbl.CurrentCty.Cty.CtyCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS: // System admins,
|
||||
// admins of the current institution,
|
||||
|
@ -5103,10 +5124,10 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
|
|||
" AND centres.InsCod=%ld)"
|
||||
" ORDER BY Surname1,Surname2,FirstName,UsrCod",
|
||||
QueryFields,
|
||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentIns.Ins.InsCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_INS),Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CTR),Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),Gbl.CurrentIns.Ins.InsCod);
|
||||
break;
|
||||
case Sco_SCOPE_CTR: // System admins,
|
||||
// admins of the current institution,
|
||||
|
@ -5130,10 +5151,10 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
|
|||
" AND degrees.CtrCod=%ld)"
|
||||
" ORDER BY Surname1,Surname2,FirstName,UsrCod",
|
||||
QueryFields,
|
||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_INS),Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CTR),Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
break;
|
||||
case Sco_SCOPE_DEG: // System admins
|
||||
// and admins of the current institution, centre or degree
|
||||
|
@ -5153,10 +5174,10 @@ static void Usr_GetAdmsLst (Sco_Scope_t Scope)
|
|||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" ORDER BY Surname1,Surname2,FirstName,UsrCod",
|
||||
QueryFields,
|
||||
Sco_ScopeDB[Sco_SCOPE_SYS],
|
||||
Sco_ScopeDB[Sco_SCOPE_INS],Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_CTR],Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_ScopeDB[Sco_SCOPE_DEG],Gbl.CurrentDeg.Deg.DegCod);
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_SYS),
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_INS),Gbl.CurrentIns.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_CTR),Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Sco_SCOPE_DEG),Gbl.CurrentDeg.Deg.DegCod);
|
||||
break;
|
||||
default: // not aplicable
|
||||
Lay_WrongScopeExit ();
|
||||
|
|
|
@ -212,8 +212,12 @@ struct UsrData
|
|||
struct UsrLast
|
||||
{
|
||||
Sch_WhatToSearch_t WhatToSearch; // Search courses, teachers, documents...?
|
||||
long LastCrs;
|
||||
Tab_Tab_t LastTab;
|
||||
// long LastCrs;
|
||||
struct
|
||||
{
|
||||
Sco_Scope_t Scope; // Course, degree, centre, etc.
|
||||
long Cod; // Course code, degree code, centre code, etc.
|
||||
} LastHie;
|
||||
Act_Action_t LastAct;
|
||||
Rol_Role_t LastRole;
|
||||
long LastAccNotif;
|
||||
|
|
Loading…
Reference in New Issue