Version 18.49

This commit is contained in:
Antonio Cañas Vargas 2019-02-18 14:41:46 +01:00
parent 9eb7a17d30
commit 264394d5d6
43 changed files with 265 additions and 448 deletions

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <ctype.h> // For isalnum, isdigit, etc.
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
#include <string.h> // For string functions

View File

@ -25,9 +25,7 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <mysql/mysql.h> // To access MySQL databases
#include <stdio.h> // For asprintf
#include <stdlib.h> // For malloc and free
#include <string.h> // For string functions

View File

@ -25,10 +25,8 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <string.h>
#include "swad_changelog.h"

View File

@ -1488,7 +1488,7 @@ Profile:
1289. ActSeeMyAgd Show my full agenda (personal organizer)
1290. ActFrmMyAcc Show form to the creation or change of user's account
1291. ActReqEdiRecSha Request the edition of the record with the personal data of the user
1292. ActEdiPrf Show forms to edit preferences
1292. ActReqEdiPrf Show forms to edit preferences
1300. ActChgMyRol Change type of logged user
@ -1525,10 +1525,6 @@ Profile:
1329. ActReqRemMyPho Request the removal of my photo
1330. ActRemMyPho Remove my photo
1331. ActEdiPri Edit my privacy
1332. ActChgPriPho Change privacy of my photo
1333. ActChgPriPrf Change privacy of my public profile
1335. ActChgCtyMyIns Change the country of my institution
1336. ActChgMyIns Change my institution
1337. ActChgMyCtr Change my centre
@ -1551,6 +1547,8 @@ Profile:
1352. ActShoRgtCol Show right side column
1353. ActChgIco Change icon set
1354. ActChgMnu Change menu
1332. ActChgPriPho Change privacy of my photo
1333. ActChgPriPrf Change privacy of my public profile
1355. ActChgNtfPrf Change whether to notify by email new messages
1356. ActPrnUsrQR Show my QR code ready to print
@ -3060,7 +3058,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActSeeMyAgd */{1602, 3,TabPrf,ActSeeMyAgd ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Agd_ShowMyAgenda ,"calendar" },
/* ActFrmMyAcc */{ 36, 4,TabPrf,ActFrmMyAcc ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_ShowFormMyAccount ,"at" },
/* ActReqEdiRecSha */{ 285, 5,TabPrf,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowMySharedRecordAndMore ,"card" },
/* ActEdiPrf */{ 673, 6,TabPrf,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pre_EditPrefs ,"cog" },
/* ActReqEdiPrf */{ 673, 6,TabPrf,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pre_EditPrefs ,"cog" },
// Actions not in menu:
/* ActChgMyRol */{ 589,-1,TabUnk,ActFrmRolSes ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Rol_ChangeMyRole ,Usr_ShowFormsLogoutAndRole ,NULL},
@ -3103,10 +3101,6 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActReqRemMyPho */{1577,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ReqRemoveMyPhoto ,NULL},
/* ActRemMyPho */{ 428,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pho_RemoveMyPhoto1 ,Pho_RemoveMyPhoto2 ,NULL},
/* ActEdiPri */{1403,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pre_EditPrefs ,NULL},
/* ActChgPriPho */{ 774,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ChangePhotoVisibility ,NULL},
/* ActChgPriPrf */{1404,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_ChangeProfileVisibility ,NULL},
/* ActChgCtyMyIns */{1166,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ChgCountryOfMyInstitution ,NULL},
/* ActChgMyIns */{1167,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyInstitution ,NULL},
/* ActChgMyCtr */{1168,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_UpdateMyCentre ,NULL},
@ -3117,19 +3111,21 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActReqEdiMyNet */{1172,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rec_ShowMySharedRecordAndMore ,NULL},
/* ActChgMyNet */{1173,-1,TabUnk,ActReqEdiRecSha ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Net_UpdateMyWebsAndSocialNets ,NULL},
/* ActChgThe */{ 841,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,The_ChangeTheme ,Pre_EditPrefs ,NULL},
/* ActReqChgLan */{ 992,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Lan_AskChangeLanguage ,NULL},
/* ActChgLan */{ 654,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Lan_ChangeLanguage ,Pre_EditPrefs ,NULL},
/* ActChg1stDay */{1484,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Cal_ChangeFirstDayOfWeek ,Pre_EditPrefs ,NULL},
/* ActChgDatFmt */{1638,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_ChangeDateFormat ,Pre_EditPrefs ,NULL},
/* ActChgCol */{ 674,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ChangeSideCols ,Pre_EditPrefs ,NULL},
/* ActHidLftCol */{ 668,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_HideLeftCol ,Pre_EditPrefs ,NULL},
/* ActHidRgtCol */{ 669,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_HideRightCol ,Pre_EditPrefs ,NULL},
/* ActShoLftCol */{ 670,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ShowLeftCol ,Pre_EditPrefs ,NULL},
/* ActShoRgtCol */{ 671,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ShowRightCol ,Pre_EditPrefs ,NULL},
/* ActChgIco */{1092,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Ico_ChangeIconSet ,Pre_EditPrefs ,NULL},
/* ActChgMnu */{1243,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Mnu_ChangeMenu ,Pre_EditPrefs ,NULL},
/* ActChgNtfPrf */{ 775,-1,TabUnk,ActEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Ntf_ChangeNotifyEvents ,Pre_EditPrefs ,NULL},
/* ActChgThe */{ 841,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,The_ChangeTheme ,Pre_EditPrefs ,NULL},
/* ActReqChgLan */{ 992,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Lan_AskChangeLanguage ,NULL},
/* ActChgLan */{ 654,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Lan_ChangeLanguage ,Pre_EditPrefs ,NULL},
/* ActChg1stDay */{1484,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Cal_ChangeFirstDayOfWeek ,Pre_EditPrefs ,NULL},
/* ActChgDatFmt */{1638,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_ChangeDateFormat ,Pre_EditPrefs ,NULL},
/* ActChgCol */{ 674,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ChangeSideCols ,Pre_EditPrefs ,NULL},
/* ActHidLftCol */{ 668,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_HideLeftCol ,Pre_EditPrefs ,NULL},
/* ActHidRgtCol */{ 669,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_HideRightCol ,Pre_EditPrefs ,NULL},
/* ActShoLftCol */{ 670,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ShowLeftCol ,Pre_EditPrefs ,NULL},
/* ActShoRgtCol */{ 671,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Pre_ShowRightCol ,Pre_EditPrefs ,NULL},
/* ActChgIco */{1092,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Ico_ChangeIconSet ,Pre_EditPrefs ,NULL},
/* ActChgMnu */{1243,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,Mnu_ChangeMenu ,Pre_EditPrefs ,NULL},
/* ActChgPriPho */{ 774,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pho_ChangePhotoVisibility ,NULL},
/* ActChgPriPrf */{1404,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_ChangeProfileVisibility ,NULL},
/* ActChgNtfPrf */{ 775,-1,TabUnk,ActReqEdiPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Ntf_ChangeNotifyEvents ,Pre_EditPrefs ,NULL},
/* ActPrnUsrQR */{1022,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Usr_PrintUsrQRCode ,NULL},
@ -3814,7 +3810,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActShoLftCol, // #670
ActShoRgtCol, // #671
-1, // #672 (obsolete action)
ActEdiPrf, // #673
ActReqEdiPrf, // #673
ActChgCol, // #674
ActSeeDpt, // #675
ActSeeCtr, // #676
@ -4544,7 +4540,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActDowShaIns, // #1400
ActReqOthPubPrf, // #1401
ActSeeOthPubPrf, // #1402
ActEdiPri, // #1403
-1, // #1403 (obsolete action)
ActChgPriPrf, // #1404
ActCal1stClkTim, // #1405
ActCalNumClk, // #1406
@ -5128,238 +5124,177 @@ void Act_AdjustActionWhenNoUsrLogged (void)
void Act_AdjustCurrentAction (void)
{
bool IAmATeacher;
bool IAmATeacherInAnyCrs;
bool JustAfterLogin = Gbl.Action.Act == ActLogIn ||
Gbl.Action.Act == ActLogInLan ||
Gbl.Action.Act == ActAnnSee;
/***** Don't adjust anything when current action is not a menu option *****/
// if (Gbl.Action.Act != Act_GetSuperAction (Gbl.Action.Act)) // It is not a menu option
// return;
/***** Don't adjust anything when current action is not a menu option
(except some actions just after login) *****/
if (!JustAfterLogin && // Not just after login
Gbl.Action.Act != Act_GetSuperAction (Gbl.Action.Act)) // It is not a menu option
return;
/***** Don't adjust anything when refreshing users or on a web service *****/
/***** Don't adjust anything when:
- refreshing users
- web service *****/
if (Gbl.Action.UsesAJAX ||
Gbl.WebService.IsWebService)
return;
/***** If I have no password in database,
the only action possible is show a form to change my account *****/
/***** Adjustment 1:
-------------
If I have no password in database,
the only action possible
is to show a form to change my account *****/
if (!Gbl.Usrs.Me.UsrDat.Password[0])
{
switch (Gbl.Action.Act)
{
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
break;
default:
Gbl.Action.Act = ActFrmMyAcc;
Tab_SetCurrentTab ();
return;
}
Gbl.Action.Act = ActFrmMyAcc;
Tab_SetCurrentTab ();
return;
}
/***** Just after login, check if my password seems good *****/
/***** Adjustment 2:
-------------
Just after login, check if my password seems good.
If my password is not enough secure,
the only action possible
is to show a form to change my account *****/
if (Gbl.Action.Act == ActLogIn)
if (!Pwd_FastCheckIfPasswordSeemsGood (Gbl.Usrs.Me.LoginPlainPassword))
/* If my login password is not enough secure,
the only action possible is show a form to change my account */
{
Gbl.Action.Act = ActFrmMyAcc;
Tab_SetCurrentTab ();
return;
}
/***** If I have no nickname or email in database,
the only action possible is show a form to change my account *****/
/***** Adjustment 3:
-------------
If I have no nickname or email in database,
the only action possible
is to show a form to change my account *****/
if (!Gbl.Usrs.Me.UsrDat.Nickname[0] ||
!Gbl.Usrs.Me.UsrDat.Email[0])
{
switch (Gbl.Action.Act)
{
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
break;
default:
Gbl.Action.Act = ActFrmMyAcc;
Tab_SetCurrentTab ();
return;
}
Gbl.Action.Act = ActFrmMyAcc;
Tab_SetCurrentTab ();
return;
}
/***** If I haven't filled my sex, first name, surname 1 or country,
the only action possible is to show a form to change my common record *****/
/***** Check if I am a teacher in any course *****/
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
IAmATeacherInAnyCrs = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher...
(1 << Rol_TCH))); // ...or a teacher in any course
/***** Adjustment 4:
-------------
If I haven't filled
- my sex
- my first name
- my surname 1
- my country
- my institution
or if I'm a teacher and I haven't filled
- my centre
- my department,
the only action possible
is to show a form to change my shared record card *****/
if ( Gbl.Usrs.Me.UsrDat.Sex == Usr_SEX_UNKNOWN ||
!Gbl.Usrs.Me.UsrDat.FirstName[0] ||
!Gbl.Usrs.Me.UsrDat.Surname1[0] ||
Gbl.Usrs.Me.UsrDat.CtyCod <= 0)
switch (Gbl.Action.Act)
!Gbl.Usrs.Me.UsrDat.Surname1 [0] ||
Gbl.Usrs.Me.UsrDat.CtyCod <= 0 ||
Gbl.Usrs.Me.UsrDat.InsCod < 0 ||
(IAmATeacherInAnyCrs && (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0 ||
Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)))
{
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
/* Actions related with my record card */
case ActReqEdiRecSha: case ActChgMyData: case ActChgCtyMyIns: case ActChgMyIns:
break;
default:
Gbl.Action.Act = ActReqEdiRecSha;
Tab_SetCurrentTab ();
return;
Gbl.Action.Act = ActReqEdiRecSha;
Tab_SetCurrentTab ();
return;
}
/***** Check if I am a teacher *****/
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Me.UsrDat);
IAmATeacher = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) | // I am a non-editing teacher...
(1 << Rol_TCH))); // ...or a teacher in any course
/***** If I haven't filled my institution,
or if I'm a teacher and I haven't filled my centre or department,
the only action possible is to show a form to change my common record *****/
if (Gbl.Usrs.Me.UsrDat.InsCod < 0 ||
(IAmATeacher && (Gbl.Usrs.Me.UsrDat.Tch.CtrCod < 0 ||
Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)))
switch (Gbl.Action.Act)
{
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
/* Actions related with my record card */
case ActReqEdiRecSha: case ActChgMyData: case ActChgCtyMyIns: case ActChgMyIns:
break;
default:
Gbl.Action.Act = ActReqEdiRecSha;
Tab_SetCurrentTab ();
return;
}
/***** If any of my preferences about privacy is unknown *****/
/***** Adjustment 5:
-------------
If any of my preferences about privacy is unknown
the only action possible
is to show a form to change my preferences *****/
if (Gbl.Usrs.Me.UsrDat.PhotoVisibility == Pri_VISIBILITY_UNKNOWN ||
Gbl.Usrs.Me.UsrDat.ProfileVisibility == Pri_VISIBILITY_UNKNOWN)
switch (Gbl.Action.Act)
{
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
/* Actions related with my record card */
case ActReqEdiRecSha: case ActChgMyData: case ActChgCtyMyIns: case ActChgMyIns:
/* Action to edit privacy */
case ActEdiPri:
break;
default:
Gbl.Action.Act = ActEdiPri;
Tab_SetCurrentTab ();
return;
Gbl.Action.Act = ActReqEdiPrf;
Tab_SetCurrentTab ();
return;
}
/***** If I belong to current course *****/
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
{
/***** If I have not accepted the enrolment,
the only action possible is show a form to ask for enrolment *****/
if (!Gbl.Usrs.Me.UsrDat.Accepted && Gbl.Action.Act != ActLogOut)
/***** Adjustment 6:
-------------
If I have not accepted my enrolment in the current course,
the only action possible
is to show a form to ask for enrolment *****/
if (!Gbl.Usrs.Me.UsrDat.Accepted)
{
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role)
{
case Rol_STD:
switch (Gbl.Action.Act)
{
/* Actions related with enrolment as student */
case ActReqAccEnrStd: case ActAccEnrStd: case ActRemMe_Std:
return;
default:
Gbl.Action.Act = ActReqAccEnrStd;
Tab_SetCurrentTab ();
return;
}
Gbl.Action.Act = ActReqAccEnrStd;
break;
case Rol_NET:
switch (Gbl.Action.Act)
{
/* Actions related with enrolment as non-editing teacher */
case ActReqAccEnrNET: case ActAccEnrNET: case ActRemMe_NET:
return;
default:
Gbl.Action.Act = ActReqAccEnrNET;
Tab_SetCurrentTab ();
return;
}
Gbl.Action.Act = ActReqAccEnrNET;
break;
case Rol_TCH:
switch (Gbl.Action.Act)
{
/* Actions related with enrolment as teacher */
case ActReqAccEnrTch: case ActAccEnrTch: case ActRemMe_Tch:
return;
default:
Gbl.Action.Act = ActReqAccEnrTch;
Tab_SetCurrentTab ();
return;
}
Gbl.Action.Act = ActReqAccEnrTch;
break;
default:
break;
}
Tab_SetCurrentTab ();
return;
}
/***** Depending on the role I am logged... *****/
/***** Depending on the role I am logged in the current course... *****/
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
switch (Gbl.Action.Act)
{
case ActLogInNew:
case ActMnu:
/* Action to log out */
case ActLogOut:
/* Actions related with my account */
case ActFrmMyAcc: case ActChgMyPwd: case ActChgMyNck: case ActChgMyMai:
/* Actions related with my record card */
case ActReqEdiRecSha: case ActChgMyData: case ActChgCtyMyIns: case ActChgMyIns:
/* Action to edit privacy */
case ActEdiPri:
/* Actions related with my group registration */
case ActReqSelGrp: case ActChgGrp:
case ActReqMdfOneStd: // A student use this action to remove him/herself from current course
/* Actions allowed in order to students could see/print timetable before register in groups */
case ActSeeCrsTT: case ActPrnCrsTT: case ActChgCrsTT1stDay:
break;
default:
/* If there are some group types with groups in wich I must register,
the the only action possible is show a form to register in groups */
if (Grp_GetIfAnyMandatoryGrpTypIsAvailable ()) // This query may be slow
/* Action allowed for students to see/print
the timetable before registering in groups */
if (Gbl.Action.Act == ActSeeCrsTT)
return;
/***** Adjustment 7:
-------------
If there are some group types
with available groups in which I must register,
the only action possible
is show a form to register in groups *****/
if (Grp_GetIfAnyMandatoryGrpTypIsAvailable (-1L)) // This query may be slow
{
Gbl.Action.Act = ActReqSelGrp;
Tab_SetCurrentTab ();
return;
}
/***** Adjustment 8:
-------------
If I have no photo
and current action is not available for unknown users,
then update number of clicks without photo.
If limit of clicks is reached,
the only action possible
is to show a form to send my photo *****/
if (!Gbl.Usrs.Me.MyPhotoExists)
if (!(Act_Actions[Gbl.Action.Act].PermissionCrsIfIBelong & (1 << Rol_UNK)))
if ((Gbl.Usrs.Me.NumAccWithoutPhoto =
Pho_UpdateMyClicksWithoutPhoto ()) > Pho_MAX_CLICKS_WITHOUT_PHOTO)
{
Gbl.Action.Act = ActReqSelGrp;
/* If limit of clicks has been reached,
the only action possible is show a form to send my photo */
Gbl.Action.Act = ActReqMyPho;
Tab_SetCurrentTab ();
return;
}
/* If I have no photo, and current action is not available for unknown users,
then update number of clicks without photo */
if (!Gbl.Usrs.Me.MyPhotoExists)
if (!(Act_Actions[Gbl.Action.Act].PermissionCrsIfIBelong & (1 << Rol_UNK))) // If current action is not available for unknown users...
switch (Gbl.Action.Act)
{
/* Actions related to sending my photo */
case ActReqMyPho: case ActDetMyPho: case ActUpdMyPho:
break;
default:
if ((Gbl.Usrs.Me.NumAccWithoutPhoto =
Pho_UpdateMyClicksWithoutPhoto ()) > Pho_MAX_CLICKS_WITHOUT_PHOTO)
{
/* If limit of clicks has been reached,
the only action possible is show a form to send my photo */
Gbl.Action.Act = ActReqMyPho;
Tab_SetCurrentTab ();
return;
}
break;
}
break;
}
/***** Check if it is mandatory to read any information about course *****/
if (Gbl.Action.Act == ActMnu) // Do the following check sometimes, for example when the user changes the current tab
Gbl.CurrentCrs.Info.ShowMsgMustBeRead = Inf_GetIfIMustReadAnyCrsInfoInThisCrs ();
@ -5367,38 +5302,28 @@ void Act_AdjustCurrentAction (void)
case Rol_NET:
break;
case Rol_TCH:
switch (Gbl.Action.Act)
{
/* Actions related with test configuration */
case ActCfgTst: case ActRcvCfgTst:
break;
default:
/***** If current course has tests and pluggable is unknown,
the only action possible is configure tests *****/
if (Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown ())
{
Gbl.Action.Act = ActCfgTst;
Tab_SetCurrentTab ();
return;
}
break;
}
/***** Adjustment 9:
-------------
If current course has tests and pluggable is unknown,
the only action possible is configure tests *****/
if (Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown ())
{
Gbl.Action.Act = ActCfgTst;
Tab_SetCurrentTab ();
return;
}
break;
default:
break;
}
}
/***** Just after login with all checks OK ==> go to timeline *****/
switch (Gbl.Action.Act)
/***** Adjustment 10:
--------------
Just after login with all checks OK ==> go to timeline *****/
if (JustAfterLogin)
{
case ActLogIn:
case ActLogInLan:
case ActAnnSee:
Gbl.Action.Act = ActSeeSocTmlGbl;
Tab_SetCurrentTab ();
return;
default:
break;
Gbl.Action.Act = ActSeeSocTmlGbl;
Tab_SetCurrentTab ();
}
}

View File

@ -61,7 +61,7 @@ typedef enum
typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
#define Act_NUM_ACTIONS (1 + 8 + 59 + 38 + 12 + 42 + 36 + 19 + 110 + 157 + 437 + 165 + 168 + 15 + 66)
#define Act_NUM_ACTIONS (1 + 8 + 59 + 38 + 12 + 42 + 36 + 19 + 110 + 157 + 437 + 165 + 168 + 15 + 65)
#define Act_MAX_ACTION_COD 1752
@ -1522,7 +1522,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActSeeMyAgd (ActSeeMyUsgRep + 4)
#define ActFrmMyAcc (ActSeeMyUsgRep + 5)
#define ActReqEdiRecSha (ActSeeMyUsgRep + 6)
#define ActEdiPrf (ActSeeMyUsgRep + 7)
#define ActReqEdiPrf (ActSeeMyUsgRep + 7)
// Secondary actions
#define ActChgMyRol (ActSeeMyUsgRep + 8)
#define ActFrmNewEvtMyAgd (ActSeeMyUsgRep + 9)
@ -1558,40 +1558,38 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActReqRemMyPho (ActSeeMyUsgRep + 36)
#define ActRemMyPho (ActSeeMyUsgRep + 37)
#define ActEdiPri (ActSeeMyUsgRep + 38)
#define ActChgPriPho (ActSeeMyUsgRep + 39)
#define ActChgPriPrf (ActSeeMyUsgRep + 40)
#define ActChgCtyMyIns (ActSeeMyUsgRep + 38)
#define ActChgMyIns (ActSeeMyUsgRep + 39)
#define ActChgMyCtr (ActSeeMyUsgRep + 40)
#define ActChgMyDpt (ActSeeMyUsgRep + 41)
#define ActChgMyOff (ActSeeMyUsgRep + 42)
#define ActChgMyOffPho (ActSeeMyUsgRep + 43)
#define ActChgCtyMyIns (ActSeeMyUsgRep + 41)
#define ActChgMyIns (ActSeeMyUsgRep + 42)
#define ActChgMyCtr (ActSeeMyUsgRep + 43)
#define ActChgMyDpt (ActSeeMyUsgRep + 44)
#define ActChgMyOff (ActSeeMyUsgRep + 45)
#define ActChgMyOffPho (ActSeeMyUsgRep + 46)
#define ActReqEdiMyNet (ActSeeMyUsgRep + 44)
#define ActChgMyNet (ActSeeMyUsgRep + 45)
#define ActReqEdiMyNet (ActSeeMyUsgRep + 47)
#define ActChgMyNet (ActSeeMyUsgRep + 48)
#define ActChgThe (ActSeeMyUsgRep + 46)
#define ActReqChgLan (ActSeeMyUsgRep + 47)
#define ActChgLan (ActSeeMyUsgRep + 48)
#define ActChg1stDay (ActSeeMyUsgRep + 49)
#define ActChgDatFmt (ActSeeMyUsgRep + 50)
#define ActChgCol (ActSeeMyUsgRep + 51)
#define ActHidLftCol (ActSeeMyUsgRep + 52)
#define ActHidRgtCol (ActSeeMyUsgRep + 53)
#define ActShoLftCol (ActSeeMyUsgRep + 54)
#define ActShoRgtCol (ActSeeMyUsgRep + 55)
#define ActChgIco (ActSeeMyUsgRep + 56)
#define ActChgMnu (ActSeeMyUsgRep + 67)
#define ActChgPriPho (ActSeeMyUsgRep + 58)
#define ActChgPriPrf (ActSeeMyUsgRep + 59)
#define ActChgNtfPrf (ActSeeMyUsgRep + 60)
#define ActChgThe (ActSeeMyUsgRep + 49)
#define ActReqChgLan (ActSeeMyUsgRep + 50)
#define ActChgLan (ActSeeMyUsgRep + 51)
#define ActChg1stDay (ActSeeMyUsgRep + 52)
#define ActChgDatFmt (ActSeeMyUsgRep + 53)
#define ActChgCol (ActSeeMyUsgRep + 54)
#define ActHidLftCol (ActSeeMyUsgRep + 55)
#define ActHidRgtCol (ActSeeMyUsgRep + 56)
#define ActShoLftCol (ActSeeMyUsgRep + 57)
#define ActShoRgtCol (ActSeeMyUsgRep + 58)
#define ActChgIco (ActSeeMyUsgRep + 59)
#define ActChgMnu (ActSeeMyUsgRep + 60)
#define ActChgNtfPrf (ActSeeMyUsgRep + 61)
#define ActPrnUsrQR (ActSeeMyUsgRep + 61)
#define ActPrnUsrQR (ActSeeMyUsgRep + 62)
#define ActPrnMyTT (ActSeeMyUsgRep + 63)
#define ActEdiTut (ActSeeMyUsgRep + 64)
#define ActChgTut (ActSeeMyUsgRep + 65)
#define ActChgMyTT1stDay (ActSeeMyUsgRep + 66)
#define ActPrnMyTT (ActSeeMyUsgRep + 62)
#define ActEdiTut (ActSeeMyUsgRep + 63)
#define ActChgTut (ActSeeMyUsgRep + 64)
#define ActChgMyTT1stDay (ActSeeMyUsgRep + 65)
/*****************************************************************************/
/******************************** Public types *******************************/

View File

@ -25,11 +25,9 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <mysql/mysql.h> // To access MySQL databases
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include "swad_box.h"

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include <sys/wait.h> // For the macro WEXITSTATUS

View File

@ -382,6 +382,7 @@ OPTIMIZE TABLE debug;
*/
// TODO: Editar todas mis webs al mismo tiempo poniendo al final un botón "Guardar cambios"
// TODO: Chequear login para ver agenda desde código QR
/*****************************************************************************/
/****************************** Public constants *****************************/
@ -402,11 +403,16 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.48.1 (2019-02-18)"
#define Log_PLATFORM_VERSION "SWAD 18.49 (2019-02-18)"
#define CSS_FILE "swad18.41.1.css"
#define JS_FILE "swad18.32.1.js"
/*
Version 18.48.1: Feb 18, 2019 Optimization on query about available mandatory group types. (237548 lines)
Version 18.49: Feb 18, 2019 Optimizations adjusting actions.
Fixed bug in query about available mandatory group types. (237378 lines)
1 change necessary in database:
UPDATE actions SET Obsolete='Y' WHERE ActCod='1403';
Version 18.48.1: Feb 18, 2019 Optimization in query about available mandatory group types. (237548 lines)
Version 18.48: Feb 18, 2019 Fixed bugs in actions related to account.
Fixed bug related with groups. (237589 lines)
1 change necessary in database:

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <string.h>
#include "swad_box.h"

View File

@ -25,11 +25,10 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <limits.h> // For maximum values
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For fprintf, asprintf
#include <stdio.h> // For fprintf
#include <string.h> // For string functions
#include "swad_box.h"

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include <time.h> // For time functions (mktime...)

View File

@ -25,11 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <ctype.h> // For isprint, isspace, etc.
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For fprintf, asprintf, etc.
#include <stdio.h> // For fprintf, etc.
#include <stdlib.h> // For exit, system, calloc, free, etc.
#include <string.h> // For string functions
#include <mysql/mysql.h> // To access MySQL databases

View File

@ -25,11 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <ctype.h> // For isprint, isspace, etc.
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For fprintf, asprintf, etc.
#include <stdio.h> // For fprintf, etc.
#include <stdlib.h> // For exit, system, calloc, free, etc.
#include <string.h> // For string functions
#include <mysql/mysql.h> // To access MySQL databases

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -25,9 +25,6 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include "swad_account.h"
#include "swad_box.h"
#include "swad_database.h"

View File

@ -25,9 +25,7 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include "swad_box.h"

View File

@ -130,8 +130,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp);
static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod);
static long Grp_GetTypeOfGroupOfAGroup (long GrpCod);
static unsigned long Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod);
static long Grp_GetFirstCodGrpIBelongTo (long GrpTypCod);
static bool Grp_GetIfGrpTypIsAvailable (long GrpTypCod);
static bool Grp_CheckIfIBelongToGrpsOfType (long GrpTypCod);
static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,long UsrCod,
struct ListCodGrps *LstGrps);
static bool Grp_CheckIfGrpIsInList (long GrpCod,struct ListCodGrps *LstGrps);
@ -1897,9 +1896,12 @@ static void Grp_ShowWarningToStdsToChangeGrps (void)
NumGrpTyp++)
{
GrpTyp = &Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp];
if (GrpTyp->NumGrps) // If there are groups of this type
if (Grp_GetFirstCodGrpIBelongTo (GrpTyp->GrpTypCod) < 0) // If I don't belong to any group
if (Grp_GetIfGrpTypIsAvailable (GrpTyp->GrpTypCod)) // If there is any group of this type available
// If there are groups of this type...
if (GrpTyp->NumGrps)
// If I don't belong to any group
if (!Grp_CheckIfIBelongToGrpsOfType (GrpTyp->GrpTypCod)) // Fast check (not necesary, but avoid slow check)
// If there is any group of this type available
if (Grp_GetIfAnyMandatoryGrpTypIsAvailable (GrpTyp->GrpTypCod)) // Slow check
{
if (GrpTyp->MandatoryEnrolment)
Ale_ShowAlert (Ale_WARNING,GrpTyp->MultipleEnrolment ? Txt_You_have_to_register_compulsorily_at_least_in_one_group_of_type_X :
@ -3347,42 +3349,23 @@ static unsigned long Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTyp
}
/*****************************************************************************/
/**** Get the first code of group of cierto type al that pert. a student *****/
/********* Check if I belong to any groups of a given type I belong **********/
/*****************************************************************************/
// Return -GrpTypCod if I don't belong to any group of type GrpTypCod
static long Grp_GetFirstCodGrpIBelongTo (long GrpTypCod)
static bool Grp_CheckIfIBelongToGrpsOfType (long GrpTypCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
long CodGrpIBelong;
unsigned long NumGrps;
/***** Get a group which I belong to from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not check if you belong to a group",
"SELECT crs_grp.GrpCod"
" FROM crs_grp,crs_grp_usr"
" WHERE crs_grp.GrpTypCod=%ld"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=%ld", // I belong
GrpTypCod,Gbl.Usrs.Me.UsrDat.UsrCod);
NumGrps = DB_QueryCOUNT ("can not check if you belong to a group type",
"SELECT COUNT(crs_grp.GrpCod)"
" FROM crs_grp,crs_grp_usr"
" WHERE crs_grp.GrpTypCod=%ld"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=%ld", // I belong
GrpTypCod,Gbl.Usrs.Me.UsrDat.UsrCod);
/***** Get the group *****/
if (NumRows == 0)
CodGrpIBelong = -GrpTypCod;
else // If there are more than a group, only get the first one
{
row = mysql_fetch_row (mysql_res);
/* Get the code of group (row[0]) */
if ((CodGrpIBelong = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of group.");
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return CodGrpIBelong;
return (NumGrps != 0);
}
/*****************************************************************************/
@ -3498,10 +3481,27 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat)
/*****************************************************************************/
/**** Query if any mandatory group in this course is open and has vacants ****/
/*****************************************************************************/
// If GrpTypCod > 0 ==> restrict to the given group type, mandatory or not
// If GrpTypCod <= 0 ==> all mandatory group types in the current course
bool Grp_GetIfAnyMandatoryGrpTypIsAvailable (void)
bool Grp_GetIfAnyMandatoryGrpTypIsAvailable (long GrpTypCod)
{
unsigned NumGrpTypes;
char *SubQueryGrpTypes;
if (GrpTypCod > 0) // restrict to the given group type, mandatory or not
{
if (asprintf (&SubQueryGrpTypes,"crs_grp_types.GrpTypCod=%ld",
GrpTypCod) < 0)
Lay_NotEnoughMemoryExit ();
}
else // all mandatory group types in the current course
{
if (asprintf (&SubQueryGrpTypes,"crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.Mandatory='Y'",
Gbl.CurrentCrs.Crs.CrsCod) < 0)
Lay_NotEnoughMemoryExit ();
}
/***** Get the number of types of group in this course
with one or more open groups with vacants, from database *****/
@ -3510,104 +3510,60 @@ bool Grp_GetIfAnyMandatoryGrpTypIsAvailable (void)
"SELECT COUNT(GrpTypCod) FROM "
"("
// Available groups with students
// Available mandatory groups with students
"SELECT GrpTypCod FROM"
" ("
"SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"COUNT(*) AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
" FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr"
" WHERE crs_grp_types.CrsCod=%ld" // In this course
" WHERE %s" // Which group types?
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.Open='Y'" // Open
" AND crs_grp.MaxStudents > 0" // Admits students
" AND crs_grp.MaxStudents>0" // Admits students
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role=%u" // With some student
" AND crs_usr.Role=%u" // Student
" GROUP BY crs_grp.GrpCod"
" HAVING NumStudents<MaxStudents" // Not full
") AS available_grp_types_with_stds"
" UNION "
// Available groups without students
"SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"0 AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
// Available mandatory groups...
"SELECT crs_grp_types.GrpTypCod AS GrpTypCod"
" FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld" // In this course
" WHERE %s" // Which group types?
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.Open='Y'" // Open
" AND crs_grp.MaxStudents > 0" // Admits students
" AND crs_grp.GrpCod NOT IN" // Only if empty
" AND crs_grp.MaxStudents>0" // Admits students
// ...without students
" AND crs_grp.GrpCod NOT IN"
" (SELECT crs_grp_usr.GrpCod"
" FROM crs_usr,crs_grp_usr"
" WHERE crs_usr.CrsCod=%ld"
" AND crs_usr.Role=%u"
" AND crs_usr.Role=%u" // Student
" AND crs_usr.UsrCod=crs_grp_usr.UsrCod)"
") AS available_grp_types",
") AS available_grp_types"
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STD,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STD);
return (NumGrpTypes != 0);
}
/*****************************************************************************/
/********** Query if any group of a type is open and has vacants *************/
/*****************************************************************************/
static bool Grp_GetIfGrpTypIsAvailable (long GrpTypCod)
{
unsigned NumGrpTypes;
/***** Get the number of types of group (0 or 1) of a type
with one or more open groups with vacants, from database *****/
NumGrpTypes =
(unsigned) DB_QueryCOUNT ("can not check if a type of group has available groups",
"SELECT COUNT(GrpTypCod) FROM "
"("
// Available groups with students
"SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"COUNT(*) AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
" FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr"
" WHERE crs_grp_types.GrpTypCod=%ld" // Of this type
// ...to which I don't belong
" WHERE GrpTypCod NOT IN"
" (SELECT crs_grp_types.GrpTypCod"
" FROM crs_grp_types,crs_grp,crs_grp_usr"
" WHERE %s" // Which group types?
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.Open='Y'" // Open
" AND crs_grp.MaxStudents > 0" // Admits students
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role=%u" // With some student
" GROUP BY crs_grp.GrpCod"
" HAVING NumStudents<MaxStudents" // Not full
" AND crs_grp_usr.UsrCod=%ld)", // I belong
" UNION "
SubQueryGrpTypes,(unsigned) Rol_STD,
SubQueryGrpTypes,
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STD,
SubQueryGrpTypes,Gbl.Usrs.Me.UsrDat.UsrCod);
// Available groups without students
"SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"0 AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
" FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.GrpTypCod=%ld" // Of this type
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.Open='Y'" // Open
" AND crs_grp.MaxStudents > 0" // Admits students
" AND crs_grp.GrpCod NOT IN" // Only if empty
" (SELECT crs_grp_usr.GrpCod"
" FROM crs_grp_types,crs_usr,crs_grp_usr"
" WHERE crs_grp_types.GrpTypCod=%ld"
" AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=crs_grp_usr.UsrCod)"
") AS available_grp_types",
GrpTypCod,(unsigned) Rol_STD,
GrpTypCod,
GrpTypCod,(unsigned) Rol_STD);
/***** Free allocated memory for subquery *****/
free ((void *) SubQueryGrpTypes);
return (NumGrpTypes != 0);
}

View File

@ -186,7 +186,7 @@ bool Grp_GetIfIBelongToGrp (long GrpCod);
void Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs (void);
bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat);
bool Grp_GetIfAnyMandatoryGrpTypIsAvailable (void);
bool Grp_GetIfAnyMandatoryGrpTypIsAvailable (long GrpTypCod);
void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps);
void Grp_GetNamesGrpsStdBelongsTo (long GrpTypCod,long UsrCod,char *GrpNames);

View File

@ -25,9 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf, fprintf, etc.
#include <string.h>
#include "swad_box.h"

View File

@ -25,11 +25,9 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <limits.h> // For maximum values
#include <linux/limits.h> // For PATH_MAX, NAME_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For getenv, etc
#include <stdsoap2.h> // For SOAP_OK and soap functions
#include <string.h> // For string functions

View File

@ -25,9 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -25,9 +25,6 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include "swad_box.h"
#include "swad_database.h"
#include "swad_form.h"
@ -77,7 +74,7 @@ static void Lan_PutParamLanguage (void);
void Lan_PutLinkToChangeLanguage (void)
{
Lay_PutContextualLinkIconText (ActEdiPrf,NULL,NULL,
Lay_PutContextualLinkIconText (ActReqEdiPrf,NULL,NULL,
"globe.svg",
"Change language");
}

View File

@ -25,9 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -25,9 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions
#include <sys/wait.h> // For the macro WEXITSTATUS

View File

@ -25,8 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf, fprintf, etc.
#include <stdio.h> // For fprintf, etc.
#include "swad_box.h"
#include "swad_database.h"
@ -287,7 +286,7 @@ const Act_Action_t Mnu_MenuActions[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB
ActSeeMyAgd, // 3
ActFrmMyAcc, // 4
ActReqEdiRecSha, // 5
ActEdiPrf, // 6
ActReqEdiPrf, // 6
0, // 7
0, // 8
0, // 9

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <string.h>
#include "swad_box.h"

View File

@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include "swad_account.h"

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc.
#include <string.h>

View File

@ -25,9 +25,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For system
#include <string.h>
#include <sys/wait.h> // For the macro WEXITSTATUS
@ -373,7 +371,7 @@ void Ntf_ShowMyNotifications (void)
Txt_Mark_all_NOTIFICATIONS_as_read);
/* Put form to change notification preferences */
Lay_PutContextualLinkIconText (ActEdiPrf,NULL,NULL,
Lay_PutContextualLinkIconText (ActReqEdiPrf,NULL,NULL,
"cog.svg",
Txt_Settings);

View File

@ -25,9 +25,7 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include "swad_action.h"
#include "swad_database.h"

View File

@ -25,11 +25,9 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <math.h> // For log10, floor, ceil, modf, sqrt...
#include <stdio.h> // For asprintf
#include <stdlib.h> // For system, getenv, etc.
#include <string.h> // For string functions
#include <sys/wait.h> // For the macro WEXITSTATUS

View File

@ -25,9 +25,7 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h> // For string functions

View File

@ -28,10 +28,9 @@ TODO: Check if web service is called from an authorized IP.
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf, fprintf
#include <stdio.h> // For fprintf
#include <stdlib.h> // For calloc, free
#include <string.h>

View File

@ -25,10 +25,9 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdbool.h> // For boolean type
#include <stdio.h> // For asprintf, fprintf, etc.
#include <stdio.h> // For fprintf, etc.
#include <string.h>
#include "swad_box.h"

View File

@ -25,9 +25,7 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <string.h> // For string functions
#include "swad_box.h"

View File

@ -25,10 +25,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For calloc
#include <string.h>

View File

@ -25,8 +25,7 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For fprintf, asprintf...
#include <stdio.h> // For fprintf...
#include <string.h> // For string functions...
#include "swad_box.h"

View File

@ -25,8 +25,6 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, free, etc
#include <string.h> // For string functions
#include <sys/stat.h> // For mkdir

View File

@ -19476,7 +19476,7 @@ const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] =
"Cart&atilde;o"
#endif
,
// 6: ActEdiPrf
// 6: ActReqEdiPrf
#if L==1 // ca
"Configuraci&oacute;"
#elif L==2 // de
@ -21343,7 +21343,7 @@ const char *Txt_MENU_SUBTITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB] =
"Cart&atilde;o"
#endif
,
// 6: ActEdiPrf
// 6: ActReqEdiPrf
#if L==1 // ca
"Les meves prefer&egrave;ncies (idioma, colors, notificacions &hellip;)"
#elif L==2 // de

View File

@ -25,8 +25,7 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <stdio.h> // For fprintf, asprintf, etc.
#include <stdio.h> // For fprintf, etc.
#include <string.h>
#include "swad_box.h"

View File

@ -25,12 +25,10 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
#define _GNU_SOURCE // For asprintf
#include <ctype.h> // For isalnum, isdigit, etc.
#include <limits.h> // For maximum values
#include <linux/limits.h> // For PATH_MAX
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For asprintf
#include <stdlib.h> // For exit, system, malloc, free, rand, etc.
#include <string.h> // For string functions
#include <sys/wait.h> // For the macro WEXITSTATUS