diff --git a/sql/cambios.sql b/sql/cambios.sql index 22b075a73..3c8e0f2a1 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -10612,3 +10612,55 @@ ALTER TABLE usr_webs CHANGE Web Web ENUM('www','500px','delicious','deviantart', ALTER TABLE usr_webs CHANGE Web Web ENUM('www','500px','delicious','deviantart','diaspora','edmodo','facebook','flickr','foursquare','github','gnusocial','googleplus','googlescholar','identica','instagram','linkedin','orcid','paperli','pinterest','quitter','researchgate','researcherid','scoopit','slideshare','storify','tumblr','twitter','wikipedia','youtube') NOT NULL; + +----- 2015-09-17, swad14.134 +/* +UPDATE notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE notif SET NotifyEvent=8 WHERE NotifyEvent=7; + +UPDATE sta_notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE sta_notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE sta_notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE sta_notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE sta_notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE sta_notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE sta_notif SET NotifyEvent=8 WHERE NotifyEvent=7; + +UPDATE usr_data SET NotifNtfEvents=(((NotifNtfEvents & ~0x7F) << 1) | (NotifNtfEvents & 0x7F) | 0x80); +UPDATE usr_data SET EmailNtfEvents=(((EmailNtfEvents & ~0x7F) << 1) | (EmailNtfEvents & 0x7F)); + + + + + Ntf_EVENT_UNKNOWN = 0, // old 0 + + /* Course tab */ + Ntf_EVENT_DOCUMENT_FILE = 1, // old 1 + Ntf_EVENT_SHARED_FILE = 2, // old 2 + + /* Assessment tab */ + Ntf_EVENT_ASSIGNMENT = 3, // old 3 + Ntf_EVENT_EXAM_ANNOUNCEMENT = 4, // old 4 + Ntf_EVENT_MARKS_FILE = 5, // old 5 + + /* Enrollment tab */ + Ntf_EVENT_ENROLLMENT_STUDENT = 6, // old 6 + Ntf_EVENT_ENROLLMENT_TEACHER = 7, + Ntf_EVENT_ENROLLMENT_REQUEST = 8, // old 7 + + /* Messages tab */ + Ntf_EVENT_NOTICE = 9, // old 8 + Ntf_EVENT_FORUM_POST_COURSE = 10, // old 9 + Ntf_EVENT_FORUM_REPLY = 11, // old 10 + Ntf_EVENT_MESSAGE = 12, // old 11 + + /* Statistics tab */ + Ntf_EVENT_SURVEY = 13, // old 12 + + /* Profile tab */ + Ntf_EVENT_FOLLOWER = 14, // old 13 diff --git a/swad_action.c b/swad_action.c index f7f7bc26f..31a3336e4 100644 --- a/swad_action.c +++ b/swad_action.c @@ -942,12 +942,16 @@ Users: 768b. ActCreOth Create a new user 768c. ActCreStd Create a new user 768d. ActCreTch Create a new user - 769b. ActUpdOth Update another user's data and groups - 769c. ActUpdStd Update another user's data and groups - 769d. ActUpdTch Update another user's data and groups - 770. ActReqAccEnrCrs Confirm acceptation / refusion of enrollment in current course - 771. ActAccEnrCrs Accept enrollment in current course - 772. ActRemMeCrs Refuse enrollment in current course + 769b. ActUpdOth Update another user's data and groups + 769c. ActUpdStd Update another user's data and groups + 769d. ActUpdTch Update another user's data and groups + 770b. ActReqAccEnrStd Confirm acceptation / refusion of enrollment as student in current course + 770c. ActReqAccEnrTch Confirm acceptation / refusion of enrollment as teacher in current course + 771b. ActAccEnrStd Accept enrollment as student in current course + 771c. ActAccEnrTch Accept enrollment as teacher in current course + 772b. ActRemMe_Std Reject enrollment as student in current course + 772b. ActRemMe_Tch Reject enrollment as teacher in current course + 773. ActNewAdmIns Register an administrador in this institution 774. ActRemAdmIns Remove an administrador of this institution 775. ActNewAdmCtr Register an administrador in this centre @@ -2364,9 +2368,12 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActUpdStd */{1423,-1,TabUsr,ActLstStd ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ModifyUsr ,NULL}, /* ActUpdTch */{1424,-1,TabUsr,ActLstTch ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ModifyUsr ,NULL}, - /* ActReqAccEnrCrs */{ 592,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, - /* ActAccEnrCrs */{ 558,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, - /* ActRemMeCrs */{ 559,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, + /* ActReqAccEnrStd */{1456,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, + /* ActReqAccEnrTch */{1457,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, + /* ActAccEnrStd */{1458,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, + /* ActAccEnrTch */{1459,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, + /* ActRemMe_Std */{1460,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, + /* ActRemMe_Tch */{1461,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, /* ActNewAdmIns */{1337,-1,TabUsr,ActLstOth ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AddAdmToIns ,NULL}, /* ActRemAdmIns */{1338,-1,TabUsr,ActLstOth ,0x180,0x180,0x180,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemAdmIns ,NULL}, @@ -3302,8 +3309,8 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActEdiCrs, // #555 ActNewCrs, // #556 -1, // #557 (obsolete action) - ActAccEnrCrs, // #558 - ActRemMeCrs, // #559 + -1, // #558 (obsolete action) + -1, // #559 (obsolete action) ActRemCrs, // #560 ActChgCrsYea, // #561 ActChgCrsSem, // #562 @@ -3336,7 +3343,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActChgMyRol, // #589 ActReqRemOldUsr, // #590 ActReqAccGbl, // #591 - ActReqAccEnrCrs, // #592 + -1, // #592 (obsolete action) ActReqDelAllRcvMsg, // #593 ActReqAccCrs, // #594 ActReqRemFilMrkCrs, // #595 @@ -4194,15 +4201,21 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActCreOth, // #1444 ActCreStd, // #1445 ActCreTch, // #1446 - ActFrmIDsOth, // #1447 - ActFrmIDsStd, // #1448 - ActFrmIDsTch, // #1449 + ActFrmIDsOth, // #1447 + ActFrmIDsStd, // #1448 + ActFrmIDsTch, // #1449 ActRemID_Oth, // #1450 ActRemID_Std, // #1451 ActRemID_Tch, // #1452 ActNewID_Oth, // #1453 ActNewID_Std, // #1454 ActNewID_Tch, // #1455 + ActReqAccEnrStd, // #1456 + ActReqAccEnrTch, // #1457 + ActAccEnrStd, // #1458 + ActAccEnrTch, // #1459 + ActRemMe_Std, // #1460 + ActRemMe_Tch, // #1461 }; /*****************************************************************************/ @@ -4578,7 +4591,8 @@ void Act_AdjustCurrentAction (void) the only action possible is show a form to ask for enrollment *****/ if (!Gbl.Usrs.Me.UsrDat.Accepted && Gbl.CurrentAct != ActLogOut) { - Gbl.CurrentAct = ActReqAccEnrCrs; + Gbl.CurrentAct = (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT) ? ActReqAccEnrStd : + ActReqAccEnrTch; Tab_SetCurrentTab (); return; } diff --git a/swad_action.h b/swad_action.h index eb3c415e4..dda5f1da4 100644 --- a/swad_action.h +++ b/swad_action.h @@ -69,9 +69,9 @@ typedef enum typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+134+168+28+79) +#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+137+168+28+79) -#define Act_MAX_ACTION_COD 1455 +#define Act_MAX_ACTION_COD 1461 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -974,51 +974,54 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActUpdStd (ActChgNumRowFooGrp+ 95) #define ActUpdTch (ActChgNumRowFooGrp+ 96) -#define ActReqAccEnrCrs (ActChgNumRowFooGrp+ 97) -#define ActAccEnrCrs (ActChgNumRowFooGrp+ 98) -#define ActRemMeCrs (ActChgNumRowFooGrp+ 99) +#define ActReqAccEnrStd (ActChgNumRowFooGrp+ 97) +#define ActReqAccEnrTch (ActChgNumRowFooGrp+ 98) +#define ActAccEnrStd (ActChgNumRowFooGrp+ 99) +#define ActAccEnrTch (ActChgNumRowFooGrp+100) +#define ActRemMe_Std (ActChgNumRowFooGrp+101) +#define ActRemMe_Tch (ActChgNumRowFooGrp+102) -#define ActNewAdmIns (ActChgNumRowFooGrp+100) -#define ActRemAdmIns (ActChgNumRowFooGrp+101) -#define ActNewAdmCtr (ActChgNumRowFooGrp+102) -#define ActRemAdmCtr (ActChgNumRowFooGrp+103) -#define ActNewAdmDeg (ActChgNumRowFooGrp+104) -#define ActRemAdmDeg (ActChgNumRowFooGrp+105) +#define ActNewAdmIns (ActChgNumRowFooGrp+103) +#define ActRemAdmIns (ActChgNumRowFooGrp+104) +#define ActNewAdmCtr (ActChgNumRowFooGrp+105) +#define ActRemAdmCtr (ActChgNumRowFooGrp+106) +#define ActNewAdmDeg (ActChgNumRowFooGrp+107) +#define ActRemAdmDeg (ActChgNumRowFooGrp+108) -#define ActRcvFrmEnrSevStd (ActChgNumRowFooGrp+106) -#define ActRcvFrmEnrSevTch (ActChgNumRowFooGrp+107) +#define ActRcvFrmEnrSevStd (ActChgNumRowFooGrp+109) +#define ActRcvFrmEnrSevTch (ActChgNumRowFooGrp+110) -#define ActFrmIDsOth (ActChgNumRowFooGrp+108) -#define ActFrmIDsStd (ActChgNumRowFooGrp+109) -#define ActFrmIDsTch (ActChgNumRowFooGrp+110) -#define ActRemID_Oth (ActChgNumRowFooGrp+111) -#define ActRemID_Std (ActChgNumRowFooGrp+112) -#define ActRemID_Tch (ActChgNumRowFooGrp+113) -#define ActNewID_Oth (ActChgNumRowFooGrp+114) -#define ActNewID_Std (ActChgNumRowFooGrp+115) -#define ActNewID_Tch (ActChgNumRowFooGrp+116) -#define ActFrmPwdOthUsr (ActChgNumRowFooGrp+117) -#define ActChgPwdOthUsr (ActChgNumRowFooGrp+118) -#define ActRemUsrCrs (ActChgNumRowFooGrp+119) -#define ActRemUsrGbl (ActChgNumRowFooGrp+120) +#define ActFrmIDsOth (ActChgNumRowFooGrp+111) +#define ActFrmIDsStd (ActChgNumRowFooGrp+112) +#define ActFrmIDsTch (ActChgNumRowFooGrp+113) +#define ActRemID_Oth (ActChgNumRowFooGrp+114) +#define ActRemID_Std (ActChgNumRowFooGrp+115) +#define ActRemID_Tch (ActChgNumRowFooGrp+116) +#define ActNewID_Oth (ActChgNumRowFooGrp+117) +#define ActNewID_Std (ActChgNumRowFooGrp+118) +#define ActNewID_Tch (ActChgNumRowFooGrp+119) +#define ActFrmPwdOthUsr (ActChgNumRowFooGrp+120) +#define ActChgPwdOthUsr (ActChgNumRowFooGrp+121) +#define ActRemUsrCrs (ActChgNumRowFooGrp+122) +#define ActRemUsrGbl (ActChgNumRowFooGrp+123) -#define ActReqRemAllStdCrs (ActChgNumRowFooGrp+121) -#define ActRemAllStdCrs (ActChgNumRowFooGrp+122) +#define ActReqRemAllStdCrs (ActChgNumRowFooGrp+124) +#define ActRemAllStdCrs (ActChgNumRowFooGrp+125) -#define ActReqRemOldUsr (ActChgNumRowFooGrp+123) -#define ActRemOldUsr (ActChgNumRowFooGrp+124) +#define ActReqRemOldUsr (ActChgNumRowFooGrp+126) +#define ActRemOldUsr (ActChgNumRowFooGrp+127) -#define ActSeePubPrf (ActChgNumRowFooGrp+125) -#define ActCal1stClkTim (ActChgNumRowFooGrp+126) -#define ActCalNumClk (ActChgNumRowFooGrp+127) -#define ActCalNumFilVie (ActChgNumRowFooGrp+128) -#define ActCalNumForPst (ActChgNumRowFooGrp+129) -#define ActCalNumMsgSnt (ActChgNumRowFooGrp+130) +#define ActSeePubPrf (ActChgNumRowFooGrp+128) +#define ActCal1stClkTim (ActChgNumRowFooGrp+129) +#define ActCalNumClk (ActChgNumRowFooGrp+130) +#define ActCalNumFilVie (ActChgNumRowFooGrp+131) +#define ActCalNumForPst (ActChgNumRowFooGrp+132) +#define ActCalNumMsgSnt (ActChgNumRowFooGrp+133) -#define ActFolUsr (ActChgNumRowFooGrp+131) -#define ActUnfUsr (ActChgNumRowFooGrp+132) -#define ActSeeFlg (ActChgNumRowFooGrp+133) -#define ActSeeFlr (ActChgNumRowFooGrp+134) +#define ActFolUsr (ActChgNumRowFooGrp+134) +#define ActUnfUsr (ActChgNumRowFooGrp+135) +#define ActSeeFlg (ActChgNumRowFooGrp+136) +#define ActSeeFlr (ActChgNumRowFooGrp+137) /*****************************************************************************/ /******************************* Messages tab ********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 564aa6924..fe41a198a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -98,11 +98,40 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.133.1 (2015/09/17)" +#define Log_PLATFORM_VERSION "SWAD 14.134 (2015/09/17)" // 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 14.134: Sep 17, 2015 Changes in user enrollment. + Changes in notifications about enrollment. (184823 lines) + 25 changes necessary in database: +UPDATE actions SET Obsolete='Y' WHERE ActCod='592'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1456','es','N','Solicitar acept. inscrip. estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1457','es','N','Solicitar acept. inscrip. profesor'); +UPDATE actions SET Obsolete='Y' WHERE ActCod='558'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1458','es','N','Aceptar inscrip. como estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1459','es','N','Aceptar inscrip. como profesor'); +UPDATE actions SET Obsolete='Y' WHERE ActCod='559'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1460','es','N','Rechazar inscrip. como estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1461','es','N','Rechazar inscrip. como profesor'); +UPDATE notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE notif SET NotifyEvent=8 WHERE NotifyEvent=7; +UPDATE sta_notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE sta_notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE sta_notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE sta_notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE sta_notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE sta_notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE sta_notif SET NotifyEvent=8 WHERE NotifyEvent=7; +UPDATE usr_data SET NotifNtfEvents=(((NotifNtfEvents & ~0x7F) << 1) | (NotifNtfEvents & 0x7F) | 0x80); +UPDATE usr_data SET EmailNtfEvents=(((EmailNtfEvents & ~0x7F) << 1) | (EmailNtfEvents & 0x7F)); + Version 14.133.1: Sep 17, 2015 Changes in user enrollment. (184669 lines) Version 14.133: Sep 17, 2015 Changes in user enrollment. (184665 lines) 1 change necessary in database: diff --git a/swad_enrollment.c b/swad_enrollment.c index 93baf6942..bc04f7550 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -86,6 +86,8 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void Enr_NotifyAfterEnrollment (struct UsrData *UsrDat,Rol_Role_t NewRole); + static void Enr_ReqAdminUsrs (Rol_Role_t Role); static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role); @@ -156,9 +158,14 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat, if (NewRole != OldRole) // The role must be updated { /***** Check if user's role is allowed *****/ - if (!(NewRole == Rol_STUDENT || - NewRole == Rol_TEACHER)) - Lay_ShowErrorAndExit ("Wrong role."); + switch (NewRole) + { + case Rol_STUDENT: + case Rol_TEACHER: + break; + default: + Lay_ShowErrorAndExit ("Wrong role."); + } /***** Update the role of a user in a course *****/ sprintf (Query,"UPDATE crs_usr SET Role='%u'" @@ -166,6 +173,11 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat, (unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); DB_QueryUPDATE (Query,"can not modify user's role in course"); + /***** Create notification for this user. + If this user wants to receive notifications by e-mail, + activate the sending of a notification *****/ + Enr_NotifyAfterEnrollment (UsrDat,NewRole); + /***** Show info message *****/ if (QuietOrVerbose == Cns_VERBOSE) { @@ -194,13 +206,16 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES]; extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y; char Query[1024]; - bool CreateNotif; - bool NotifyByEmail; /***** Check if user's role is allowed *****/ - if (!(NewRole == Rol_STUDENT || - NewRole == Rol_TEACHER)) - Lay_ShowErrorAndExit ("Wrong role."); + switch (NewRole) + { + case Rol_STUDENT: + case Rol_TEACHER: + break; + default: + Lay_ShowErrorAndExit ("Wrong role."); + } /***** Register user in current course in database *****/ sprintf (Query,"INSERT INTO crs_usr (CrsCod,UsrCod,Role,Accepted," @@ -220,20 +235,10 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, UsrDat->RoleInCurrentCrsDB = NewRole; UsrDat->Roles |= NewRole; - /***** Remove possible inscription request ******/ - Enr_RemoveEnrollmentRequest (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); - /***** Create notification for this user. If this user wants to receive notifications by e-mail, activate the sending of a notification *****/ - CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << Ntf_EVENT_ENROLLMENT)); - NotifyByEmail = CreateNotif && - (UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) && - (UsrDat->Prefs.EmailNtfEvents & (1 << Ntf_EVENT_ENROLLMENT)); - if (CreateNotif) - Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_ENROLLMENT,UsrDat,-1L, - (Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL : - 0)); + Enr_NotifyAfterEnrollment (UsrDat,NewRole); /***** Show info message *****/ if (QuietOrVerbose == Cns_VERBOSE) @@ -244,6 +249,48 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, } } +/*****************************************************************************/ +/********* Create notification after register user in current course *********/ +/*****************************************************************************/ + +static void Enr_NotifyAfterEnrollment (struct UsrData *UsrDat,Rol_Role_t NewRole) + { + bool CreateNotif; + bool NotifyByEmail; + Ntf_NotifyEvent_t NotifyEvent; + + /***** Check if user's role is allowed *****/ + switch (NewRole) + { + case Rol_STUDENT: + NotifyEvent = Ntf_EVENT_ENROLLMENT_STUDENT; + break; + case Rol_TEACHER: + NotifyEvent = Ntf_EVENT_ENROLLMENT_TEACHER; + break; + default: + NotifyEvent = Ntf_EVENT_UNKNOWN; + Lay_ShowErrorAndExit ("Wrong role."); + } + + /***** Remove possible enrollment request ******/ + Enr_RemoveEnrollmentRequest (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); + + /***** Remove old enrollment notifications before inserting the new one ******/ + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1,UsrDat->UsrCod); + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1,UsrDat->UsrCod); + + /***** Create new notification ******/ + CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << NotifyEvent)); + NotifyByEmail = CreateNotif && + (UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) && + (UsrDat->Prefs.EmailNtfEvents & (1 << NotifyEvent)); + if (CreateNotif) + Ntf_StoreNotifyEventToOneUser (NotifyEvent,UsrDat,-1L, + (Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL : + 0)); + } + /*****************************************************************************/ /****** Write a form to request another user's ID, @nickname or e-mail *******/ /*****************************************************************************/ @@ -288,17 +335,20 @@ void Enr_ReqAcceptRegisterInCrs (void) fprintf (Gbl.F.Out,"