From 31d41db0364ed291592f03dd16b58b0615b0ccf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 12 Oct 2016 14:02:56 +0200 Subject: [PATCH] Version 16.21 --- swad_ID.c | 2 +- swad_account.c | 6 +++--- swad_account.h | 2 +- swad_action.c | 46 +++++++++++++++++++-------------------- swad_action.h | 23 +++----------------- swad_changelog.h | 4 +++- swad_global.h | 2 +- swad_help.c | 2 +- swad_mail.c | 49 +++++++++++++++++++++++++++++++++++++++--- swad_mail.h | 5 ++++- swad_menu.c | 2 +- swad_notification.c | 25 ++++++++++++++-------- swad_parameter.c | 2 +- swad_preference.c | 6 ------ swad_report.c | 2 +- swad_tab.c | 10 ++++----- swad_tab.h | 17 +++++++++++++++ swad_text.c | 52 ++++++++++++++++++++++----------------------- swad_user.c | 2 +- swad_user.h | 2 +- 20 files changed, 155 insertions(+), 106 deletions(-) diff --git a/swad_ID.c b/swad_ID.c index 91537d43..3ea1b6e2 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -480,7 +480,7 @@ void ID_PutLinkToChangeUsrIDs (void) /***** Link for changing the password *****/ if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me - Lay_PutContextualLink (ActFrmUsrAcc,NULL, + Lay_PutContextualLink (ActFrmMyAcc,NULL, "arroba64x64.gif", Txt_Change_IDs,Txt_Change_IDs, NULL); diff --git a/swad_account.c b/swad_account.c index d236e62d..8ec66c0f 100644 --- a/swad_account.c +++ b/swad_account.c @@ -97,7 +97,7 @@ void Acc_PutLinkToCreateAccount (void) { extern const char *Txt_Create_account; - Lay_PutContextualLink (ActFrmUsrAcc,NULL, + Lay_PutContextualLink (ActFrmMyAcc,NULL, "arroba64x64.gif", Txt_Create_account,Txt_Create_account, NULL); @@ -107,7 +107,7 @@ void Acc_PutLinkToCreateAccount (void) /******** Show form to change my account or to create a new account **********/ /*****************************************************************************/ -void Acc_ShowFormAccount (void) +void Acc_ShowFormMyAccount (void) { extern const char *Txt_Before_creating_a_new_account_check_if_you_have_been_already_registered_with_your_ID; @@ -394,7 +394,7 @@ void Acc_ShowFormGoToRequestNewAccount (void) Lay_StartRoundFrame (NULL,Gbl.Title,NULL); /***** Button to go to request the creation of a new account *****/ - Act_FormStart (ActFrmUsrAcc); + Act_FormStart (ActFrmMyAcc); Lay_PutCreateButton (Txt_Create_a_new_account); Act_FormEnd (); diff --git a/swad_account.h b/swad_account.h index 40affae8..b4e9d3ab 100644 --- a/swad_account.h +++ b/swad_account.h @@ -51,7 +51,7 @@ typedef enum /*****************************************************************************/ void Acc_PutLinkToCreateAccount (void); -void Acc_ShowFormAccount (void); +void Acc_ShowFormMyAccount (void); void Acc_CheckIfEmptyAccountExists (void); diff --git a/swad_action.c b/swad_action.c index 6c78923c..1b63a160 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1315,7 +1315,7 @@ Profile: 1128. ActMyCrs Select one of my courses 1129. ActSeeMyTT Show the timetable of all courses of the logged user NEW. ActSeeMyAgd Show my agenda (personal organizer) - 1130. ActFrmUsrAcc Show form to the creation or change of user's account + 1130. ActFrmMyAcc Show form to the creation or change of user's account 1131. ActReqEdiRecCom Request the edition of the record with the personal data of the user 1132. ActEdiPrf Show forms to edit preferences 1133. ActAdmBrf Show the briefcase of private archives @@ -2744,7 +2744,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActMyCrs */{ 987, 2,TabPrf,ActMyCrs ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Crs_ReqSelectOneOfMyCourses ,"mygroups64x64.gif" }, /* ActSeeMyTT */{ 408, 3,TabPrf,ActSeeMyTT ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,TT_ShowClassTimeTable ,"clock64x64.gif" }, /* ActSeeMyAgd */{1581, 4,TabPrf,ActSeeMyAgd ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Agd_ShowMyAgenda ,"date64x64.gif" }, - /* ActFrmUsrAcc */{ 36, 5,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_ShowFormAccount ,"arroba64x64.gif" }, + /* ActFrmMyAcc */{ 36, 5,TabPrf,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_ShowFormMyAccount ,"arroba64x64.gif" }, /* ActReqEdiRecCom */{ 285, 6,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ShowFormMyCommRecord ,"card64x64.gif" }, /* ActEdiPrf */{ 673, 7,TabPrf,ActEdiPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pre_EditPrefs ,"heart64x64.gif" }, /* ActAdmBrf */{ 23, 8,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"pendrive64x64.gif" }, @@ -2761,24 +2761,24 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActAnnSee */{1234,-1,TabPrf,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ann_MarkAnnouncementAsSeen ,NULL}, /* ActChgMyRol */{ 589,-1,TabPrf,ActFrmRolSes ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Rol_ChangeMyRole ,Usr_ShowFormsLogoutAndRole ,NULL}, - /* ActChkUsrAcc */{1584,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_CheckIfEmptyAccountExists ,NULL}, - /* ActCreUsrAcc */{1163,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AfterCreationNewAccount ,NULL}, + /* ActChkUsrAcc */{1584,-1,TabPrf,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_CheckIfEmptyAccountExists ,NULL}, + /* ActCreUsrAcc */{1163,-1,TabPrf,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AfterCreationNewAccount ,NULL}, - /* ActRemID_Me */{1147,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_RemoveMyUsrID ,NULL}, - /* ActNewIDMe */{1148,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_NewMyUsrID ,NULL}, + /* ActRemID_Me */{1147,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_RemoveMyUsrID ,NULL}, + /* ActNewIDMe */{1148,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,ID_NewMyUsrID ,NULL}, - /* ActRemOldNic */{1089,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Nck_RemoveNick ,NULL}, - /* ActChgNic */{ 37,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Nck_UpdateNick ,NULL}, + /* ActRemOldNic */{1089,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Nck_RemoveNick ,NULL}, + /* ActChgNic */{ 37,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Nck_UpdateNick ,NULL}, - /* ActRemMaiMe */{1090,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Mai_RemoveMyUsrEmail ,NULL}, - /* ActNewMaiMe */{1088,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,May_NewMyUsrEmail ,NULL}, - /* ActCnfMai */{1091,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Mai_ConfirmEmail ,NULL}, + /* ActRemMaiMe */{1090,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Mai_RemoveMyUsrEmail ,NULL}, + /* ActNewMaiMe */{1088,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,May_NewMyUsrEmail ,NULL}, + /* ActCnfMai */{1091,-1,TabPrf,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Mai_ConfirmEmail ,NULL}, - /* ActFrmChgMyPwd */{ 34,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pwd_ShowFormChgPwd ,NULL}, - /* ActChgPwd */{ 35,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Pwd_ActChgMyPwd1 ,Pwd_ActChgMyPwd2 ,NULL}, + /* ActFrmChgMyPwd */{ 34,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Pwd_ShowFormChgPwd ,NULL}, + /* ActChgPwd */{ 35,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Pwd_ActChgMyPwd1 ,Pwd_ActChgMyPwd2 ,NULL}, - /* ActReqRemMyAcc */{1430,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AskIfRemoveMyAccount ,NULL}, - /* ActRemMyAcc */{1431,-1,TabPrf,ActFrmUsrAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_RemoveMyAccount ,NULL}, + /* ActReqRemMyAcc */{1430,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_AskIfRemoveMyAccount ,NULL}, + /* ActRemMyAcc */{1431,-1,TabPrf,ActFrmMyAcc ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Acc_RemoveMyAccount ,NULL}, /* ActChgMyData */{ 298,-1,TabPrf,ActReqEdiRecCom ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Rec_UpdateMyRecord ,Rec_ShowMyCommonRecordUpd ,NULL}, @@ -2816,7 +2816,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActChgMnu */{1243,-1,TabPrf,ActEdiPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,Mnu_ChangeMenu ,Pre_EditPrefs ,NULL}, /* ActChgNtfPrf */{ 775,-1,TabPrf,ActEdiPrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Ntf_ChangeNotifyEvents ,Pre_EditPrefs ,NULL}, - /* ActPrnUsrQR */{1022,-1,TabPrf,ActFrmUsrAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,QR_PrintQRCode ,NULL}, + /* ActPrnUsrQR */{1022,-1,TabPrf,ActFrmMyAcc ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,QR_PrintQRCode ,NULL}, /* ActPrnMyTT */{ 409,-1,TabPrf,ActSeeMyTT ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,TT_ShowClassTimeTable ,NULL}, /* ActEdiTut */{ 65,-1,TabPrf,ActSeeMyTT ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,TT_ShowMyTutTimeTable ,NULL}, @@ -2883,7 +2883,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq -1, // #33 (obsolete action) ActFrmChgMyPwd, // #34 ActChgPwd, // #35 - ActFrmUsrAcc, // #36 + ActFrmMyAcc, // #36 ActChgNic, // #37 -1, // #38 (obsolete action) -1, // #39 (obsolete action) @@ -4495,7 +4495,7 @@ void Act_GetBreadcrumbStrForAction (Act_Action_t Action,bool HTML,char *Breadcru extern const char *Txt_TABS_FULL_TXT[Tab_NUM_TABS]; extern const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB]; Act_Action_t Superaction = Act_Actions[Action].SuperAction; - Act_Tab_t Tab = Act_Actions[Superaction].Tab; + Tab_Tab_t Tab = Act_Actions[Superaction].Tab; char *Arrow; Arrow = HTML ? ">" : @@ -4837,7 +4837,7 @@ void Act_AdjustCurrentAction (void) case ActFrmChgMyPwd: break; default: - Gbl.Action.Act = ActFrmUsrAcc; + Gbl.Action.Act = ActFrmMyAcc; Tab_SetCurrentTab (); return; } @@ -4852,7 +4852,7 @@ void Act_AdjustCurrentAction (void) switch (Gbl.Action.Act) { case ActHom: case ActLogOut: - case ActFrmUsrAcc: case ActFrmChgMyPwd: + case ActFrmMyAcc: case ActFrmChgMyPwd: break; default: Gbl.Action.Act = ActReqEdiRecCom; @@ -4869,7 +4869,7 @@ void Act_AdjustCurrentAction (void) switch (Gbl.Action.Act) { case ActHom: case ActLogOut: - case ActFrmUsrAcc: case ActFrmChgMyPwd: + case ActFrmMyAcc: case ActFrmChgMyPwd: case ActReqEdiRecCom: break; default: @@ -4884,7 +4884,7 @@ void Act_AdjustCurrentAction (void) switch (Gbl.Action.Act) { case ActHom: case ActLogOut: - case ActFrmUsrAcc: case ActFrmChgMyPwd: + case ActFrmMyAcc: case ActFrmChgMyPwd: case ActReqEdiRecCom: case ActReqEdiMyIns: break; default: @@ -4917,7 +4917,7 @@ void Act_AdjustCurrentAction (void) case ActHom: case ActMnu: case ActLogOut: - case ActFrmUsrAcc: + case ActFrmMyAcc: case ActFrmChgMyPwd: case ActReqEdiRecCom: case ActReqEdiMyIns: diff --git a/swad_action.h b/swad_action.h index 15340890..f1ae861d 100644 --- a/swad_action.h +++ b/swad_action.h @@ -30,6 +30,7 @@ #include // For boolean type #include "swad_cryptography.h" +#include "swad_tab.h" #include "swad_text.h" /*****************************************************************************/ @@ -38,24 +39,6 @@ #define Act_MAX_LENGTH_ACTION_TXT 255 -// Related with tabs and actions -typedef enum - { - TabUnk = 0, - TabSys = 1, - TabCty = 2, - TabIns = 3, - TabCtr = 4, - TabDeg = 5, - TabCrs = 6, - TabAss = 7, - TabUsr = 8, - TabSoc = 9, - TabMsg = 10, - TabSta = 11, - TabPrf = 12, - } Act_Tab_t; - typedef enum { Act_CONTENT_NORM, @@ -1372,7 +1355,7 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActMyCrs (ActSeeMyUsgRep+ 3) #define ActSeeMyTT (ActSeeMyUsgRep+ 4) #define ActSeeMyAgd (ActSeeMyUsgRep+ 5) -#define ActFrmUsrAcc (ActSeeMyUsgRep+ 6) +#define ActFrmMyAcc (ActSeeMyUsgRep+ 6) #define ActReqEdiRecCom (ActSeeMyUsgRep+ 7) #define ActEdiPrf (ActSeeMyUsgRep+ 8) #define ActAdmBrf (ActSeeMyUsgRep+ 9) @@ -1478,7 +1461,7 @@ struct Act_Actions { long ActCod; // Unique, time-persistent numerical code for the action signed int IndexInMenu; - Act_Tab_t Tab; + Tab_Tab_t Tab; Act_Action_t SuperAction; unsigned PermisIfIBelongToCrs; unsigned PermisIfIDontBelongToCrs; diff --git a/swad_changelog.h b/swad_changelog.h index 5e890fc1..ea666572 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -148,13 +148,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.20 (2016-10-11)" +#define Log_PLATFORM_VERSION "SWAD 16.21 (2016-10-12)" #define CSS_FILE "swad15.229.css" #define JS_FILE "swad15.238.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 16.21: Oct 12, 2016 Code refactoring related with warning about e-mail notifications. + Notification mail is sent only if e-mail is confirmed. (205278 lines) Version 16.20: Oct 11, 2016 New button to edit/view file browser. (205241 lines) Version 16.19.3: Oct 11, 2016 Code optimization in file browser. (205210 lines) Version 16.19.2: Oct 11, 2016 Code optimization in file browser. (205198 lines) diff --git a/swad_global.h b/swad_global.h index 7698132f..0ca73de6 100644 --- a/swad_global.h +++ b/swad_global.h @@ -168,7 +168,7 @@ struct Globals bool YearOK; struct { - Act_Tab_t Tab; + Tab_Tab_t Tab; Act_Action_t Act; bool UsesAJAX; } Action; diff --git a/swad_help.c b/swad_help.c index 14e9ff83..7b1020cf 100644 --- a/swad_help.c +++ b/swad_help.c @@ -231,7 +231,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up, Cfg_PLATFORM_SHORT_NAME); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, - ActFrmUsrAcc, + ActFrmMyAcc, "BT_CREATE",Txt_Create_account); } diff --git a/swad_mail.c b/swad_mail.c index bc7ec193..c0ac6128 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -37,6 +37,7 @@ #include "swad_mail.h" #include "swad_parameter.h" #include "swad_QR.h" +#include "swad_tab.h" #include "swad_text.h" /*****************************************************************************/ @@ -66,6 +67,8 @@ extern struct Globals Gbl; static void Mai_GetParamMaiOrderType (void); static void Mai_PutIconToEditMailDomains (void); static void Mai_GetListMailDomainsAllowedForNotif (void); +static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain); + static void Mai_ListMailDomainsForEdition (void); static void Mai_PutParamMaiCod (long MaiCod); static void Mai_RenameMailDomain (Cns_ShortOrFullName_t ShortOrFullName); @@ -307,11 +310,28 @@ static void Mai_GetListMailDomainsAllowedForNotif (void) DB_ExitOnMySQLError ("can not remove temporary tables"); } +/*****************************************************************************/ +/************ Check if user can receive notifications via e-mail *************/ +/*****************************************************************************/ + +bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat) + { + char MailDomain[Usr_MAX_BYTES_USR_EMAIL+1]; + + /***** Check #1: is my e-mail address confirmed? *****/ + if (!UsrDat->EmailConfirmed) + return false; + + /***** Check #2: if my mail domain allowed? *****/ + Str_GetMailBox (UsrDat->Email,MailDomain,Usr_MAX_BYTES_USR_EMAIL); + return Mai_CheckIfMailDomainIsAllowedForNotif (MailDomain); + } + /*****************************************************************************/ /************ Check if a mail domain is allowed for notifications ************/ /*****************************************************************************/ -bool Mai_CheckIfMailDomainIsAllowedForNotifications (const char *MailDomain) +static bool Mai_CheckIfMailDomainIsAllowedForNotif (const char *MailDomain) { char Query[512]; @@ -321,6 +341,29 @@ bool Mai_CheckIfMailDomainIsAllowedForNotifications (const char *MailDomain) return (DB_QueryCOUNT (Query,"can not check if a mail domain is allowed for notifications") != 0); } +/*****************************************************************************/ +/***************** Show warning about notifications via e-mail ***************/ +/*****************************************************************************/ + +void Mai_WriteWarningEmailNotifications (void) + { + extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; + extern const char *Txt_You_can_only_receive_email_notifications_if_; + extern const char *Txt_TABS_SHORT_TXT[Tab_NUM_TABS]; + extern const char *Txt_MENU_TITLE[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB]; + Act_Action_t SuperActionMyAccount = Act_Actions[ActFrmMyAcc].SuperAction; + Act_Action_t SuperActionMailDomains = Act_Actions[ActSeeMai ].SuperAction; + Tab_Tab_t TabMyAccount = Act_Actions[SuperActionMyAccount ].Tab; + Tab_Tab_t TabMailDomains = Act_Actions[SuperActionMailDomains].Tab; + + sprintf (Gbl.Message,Txt_You_can_only_receive_email_notifications_if_, + Txt_TABS_SHORT_TXT[TabMyAccount ], + Txt_MENU_TITLE[TabMyAccount ][Act_Actions[SuperActionMyAccount ].IndexInMenu], + Txt_TABS_SHORT_TXT[TabMailDomains], + Txt_MENU_TITLE[TabMailDomains][Act_Actions[SuperActionMailDomains].IndexInMenu]); + Lay_ShowAlert (Lay_WARNING,Gbl.Message); + } + /*****************************************************************************/ /**************************** Get mail domain data ***************************/ /*****************************************************************************/ @@ -1050,7 +1093,7 @@ void Mai_PutLinkToChangeOtherUsrEmail (void) /***** Link for changing the password *****/ if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me - Lay_PutContextualLink (ActFrmUsrAcc,NULL, + Lay_PutContextualLink (ActFrmMyAcc,NULL, "msg64x64.gif", Txt_Change_email,Txt_Change_email, NULL); @@ -1478,7 +1521,7 @@ void Mai_PutButtonToCheckEmailAddress (void) extern const char *Txt_Check; /***** Start form *****/ - Act_FormStart (ActFrmUsrAcc); + Act_FormStart (ActFrmMyAcc); /***** Frame with button to go to account *****/ Lay_StartRoundFrame (NULL,Txt_Email_unconfirmed,NULL); diff --git a/swad_mail.h b/swad_mail.h index c26a21cd..a10aae3d 100644 --- a/swad_mail.h +++ b/swad_mail.h @@ -58,7 +58,10 @@ struct Mail void Mai_SeeMailDomains (void); void Mai_EditMailDomains (void); void Mai_FreeListMailDomains (void); -bool Mai_CheckIfMailDomainIsAllowedForNotifications (const char *MailDomain); + +bool Mai_CheckIfUsrCanReceiveEmailNotif (const struct UsrData *UsrDat); +void Mai_WriteWarningEmailNotifications (void); + void Mai_GetDataOfMailDomainByCod (struct Mail *Plc); long Mai_GetParamMaiCod (void); void Mai_RemoveMailDomain (void); diff --git a/swad_menu.c b/swad_menu.c index a1ecf207..effbf506 100644 --- a/swad_menu.c +++ b/swad_menu.c @@ -186,7 +186,7 @@ const Act_Action_t Mnu_MenuActions[Tab_NUM_TABS][Act_MAX_OPTIONS_IN_MENU_PER_TAB ActMyCrs, ActSeeMyTT, ActSeeMyAgd, - ActFrmUsrAcc, + ActFrmMyAcc, ActReqEdiRecCom, ActEdiPrf, ActAdmBrf, diff --git a/swad_notification.c b/swad_notification.c index a12380df..99a8bbf2 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -1527,7 +1527,6 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign extern const char *Txt_TAB_Messages_NO_HTML[1+Txt_NUM_LANGUAGES]; extern const char *Txt_Notifications_NO_HTML[1+Txt_NUM_LANGUAGES]; extern const char *Txt_If_you_no_longer_wish_to_receive_email_notifications_NO_HTML[1+Txt_NUM_LANGUAGES]; - char MailDomain[Usr_MAX_BYTES_USR_EMAIL+1]; char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1549,8 +1548,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign /***** Return 0 notifications and 0 mails when error *****/ *NumNotif = *NumMails = 0; - Str_GetMailBox (ToUsrDat->Email,MailDomain,Usr_MAX_BYTES_USR_EMAIL); - if (Mai_CheckIfMailDomainIsAllowedForNotifications (MailDomain)) + if (Mai_CheckIfUsrCanReceiveEmailNotif (ToUsrDat)) { /***** Get pending notifications of this user from database ******/ sprintf (Query,"SELECT NotifyEvent,FromUsrCod,InsCod,CtrCod,DegCod,CrsCod,Cod" @@ -1620,7 +1618,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign /* Get forum type */ if (NotifyEvent == Ntf_EVENT_FORUM_POST_COURSE || - NotifyEvent == Ntf_EVENT_FORUM_REPLY) + NotifyEvent == Ntf_EVENT_FORUM_REPLY) ForumType = For_GetForumTypeOfAPost (Cod); /* Information about the type of this event */ @@ -1699,7 +1697,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign Cfg_AUTOMATIC_EMAIL_SMTP_SERVER, Cfg_AUTOMATIC_EMAIL_SMTP_PORT, Cfg_AUTOMATIC_EMAIL_FROM, - Gbl.Config.SMTPPassword, + Gbl.Config.SMTPPassword, ToUsrDat->Email, Cfg_PLATFORM_SHORT_NAME, Txt_Notifications_NO_HTML[ToUsrLanguage], @@ -1724,7 +1722,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign /***** Mark all the pending notifications of this user as 'sent' *****/ sprintf (Query,"UPDATE notif SET Status=(Status | %u)" - " WHERE ToUsrCod='%ld'" + " WHERE ToUsrCod='%ld'" " AND (Status & %u)<>0 AND (Status & %u)=0 AND (Status & %u)=0", (unsigned) Ntf_STATUS_BIT_SENT,ToUsrDat->UsrCod, (unsigned) Ntf_STATUS_BIT_EMAIL, @@ -1862,8 +1860,15 @@ void Ntf_PutFormChangeNotifSentByEMail (void) Act_FormStart (ActChgNtfPrf); /***** Start frame *****/ - Lay_StartRoundFrameTable (NULL,2,Txt_Notifications); - fprintf (Gbl.F.Out,"" + Lay_StartRoundFrame (NULL,Txt_Notifications,NULL); + + /***** Warning if I can not receive e-mail notifications *****/ + if (!Mai_CheckIfUsrCanReceiveEmailNotif (&Gbl.Usrs.Me.UsrDat)) + Mai_WriteWarningEmailNotifications (); + + /***** List of notifications *****/ + fprintf (Gbl.F.Out,"" + "" "" ""); } + fprintf (Gbl.F.Out,"
" "%s" @@ -1903,8 +1908,10 @@ void Ntf_PutFormChangeNotifSentByEMail (void) "
"); + /***** Button to save changes and end frame *****/ - Lay_EndRoundFrameTableWithButton (Lay_CONFIRM_BUTTON,Txt_Save_changes); + Lay_EndRoundFrameWithButton (Lay_CONFIRM_BUTTON,Txt_Save_changes); /***** End form *****/ Act_FormEnd (); diff --git a/swad_parameter.c b/swad_parameter.c index 9c114424..b156fcb6 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -848,7 +848,7 @@ void Par_GetMainParameters (void) if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) if (UnsignedNum < Tab_NUM_TABS) { - Gbl.Action.Tab = (Act_Tab_t) UnsignedNum; + Gbl.Action.Tab = (Tab_Tab_t) UnsignedNum; Tab_DisableIncompatibleTabs (); } } diff --git a/swad_preference.c b/swad_preference.c index 55183ed2..59a8637f 100644 --- a/swad_preference.c +++ b/swad_preference.c @@ -65,8 +65,6 @@ static void Pre_UpdateSideColsOnUsrDataTable (void); void Pre_EditPrefs (void) { extern const char *Txt_Language; - extern const char *Txt_You_can_only_receive_email_notifications_if_; - char MailDomain[Usr_MAX_BYTES_USR_EMAIL+1]; /***** Language, first day of week *****/ fprintf (Gbl.F.Out,"" @@ -115,10 +113,6 @@ void Pre_EditPrefs (void) /***** Automatic e-mail to notify of new events *****/ Ntf_PutFormChangeNotifSentByEMail (); - - Str_GetMailBox (Gbl.Usrs.Me.UsrDat.Email,MailDomain,Usr_MAX_BYTES_USR_EMAIL); - if (!Mai_CheckIfMailDomainIsAllowedForNotifications (MailDomain)) - Lay_ShowAlert (Lay_WARNING,Txt_You_can_only_receive_email_notifications_if_); } } diff --git a/swad_report.c b/swad_report.c index 3dd219c7..48288e95 100644 --- a/swad_report.c +++ b/swad_report.c @@ -763,7 +763,7 @@ static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report) unsigned long NumRow; long ActCod; Act_Action_t Action; - Act_Tab_t Tab; + Tab_Tab_t Tab; char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1]; unsigned long NumClicks; diff --git a/swad_tab.c b/swad_tab.c index 8dc355c2..14216235 100644 --- a/swad_tab.c +++ b/swad_tab.c @@ -68,7 +68,7 @@ const char *Tab_TabIcons[Tab_NUM_TABS] = /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static bool Tab_CheckIfICanViewTab (Act_Tab_t Tab); +static bool Tab_CheckIfICanViewTab (Tab_Tab_t Tab); static void Tab_WriteBreadcrumbHome (void); static void Tab_WriteBreadcrumbTab (void); @@ -86,7 +86,7 @@ void Tab_DrawTabs (void) extern const char *The_TabOffBgColors[The_NUM_THEMES]; extern const char *Txt_TABS_FULL_TXT[Tab_NUM_TABS]; extern const char *Txt_TABS_SHORT_TXT[Tab_NUM_TABS]; - Act_Tab_t NumTab; + Tab_Tab_t NumTab; bool ICanViewTab; /***** Table start *****/ @@ -94,8 +94,8 @@ void Tab_DrawTabs (void) "