From 2e2af1057ad72b981f5fb6b1d9c34c8898bc64d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 11 May 2017 20:55:04 +0200 Subject: [PATCH] Version 16.213 --- swad_centre.c | 179 +++++++++++++++++++++++------------------------ swad_changelog.h | 3 +- swad_course.c | 31 ++++---- swad_degree.c | 10 +-- 4 files changed, 112 insertions(+), 111 deletions(-) diff --git a/swad_centre.c b/swad_centre.c index ea08b31a3..b625ccb8a 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -107,13 +107,14 @@ static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *N static void Ctr_UpdateCtrWWWDB (long CtrCod, const char NewWWW[Cns_MAX_BYTES_WWW + 1]); -static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr); +static void Ctr_ShowAlertAndButtonToGoToCtr (void); +static void Ctr_PutParamGoToCtr (void); static void Ctr_PutFormToCreateCentre (void); static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable); static void Ctr_PutHeadCentresForEdition (void); static void Ctr_RecFormRequestOrCreateCtr (unsigned Status); -static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status); +static void Ctr_CreateCentre (unsigned Status); /*****************************************************************************/ /******************* List centres with pending degrees ***********************/ @@ -1840,33 +1841,30 @@ static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod) void Ctr_ChangeCentrePlace (void) { extern const char *Txt_The_place_of_the_centre_has_changed; - struct Centre *Ctr; long NewPlcCod; char Query[512]; - Ctr = &Gbl.Ctrs.EditingCtr; - /***** Get parameters from form *****/ /* Get centre code */ - Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); + Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); /* Get parameter with centre code */ NewPlcCod = Plc_GetParamPlcCod (); /***** Get data of centre from database *****/ - Ctr_GetDataOfCentreByCod (Ctr); + Ctr_GetDataOfCentreByCod (&Gbl.Ctrs.EditingCtr); /***** Update place in table of centres *****/ sprintf (Query,"UPDATE centres SET PlcCod=%ld WHERE CtrCod=%ld", - NewPlcCod,Ctr->CtrCod); + NewPlcCod,Gbl.Ctrs.EditingCtr.CtrCod); DB_QueryUPDATE (Query,"can not update the place of a centre"); - Ctr->PlcCod = NewPlcCod; + Gbl.Ctrs.EditingCtr.PlcCod = NewPlcCod; - /***** Write message to show the change made *****/ - Lay_ShowAlert (Lay_SUCCESS,Txt_The_place_of_the_centre_has_changed); - - /***** Put button to go to centre changed *****/ - Ctr_PutButtonToGoToCtr (Ctr); + /***** Write message to show the change made + and put button to go to centre changed *****/ + Gbl.Alert.Type = Lay_SUCCESS; + sprintf (Gbl.Alert.Txt,"%s",Txt_The_place_of_the_centre_has_changed); + Ctr_ShowAlertAndButtonToGoToCtr (); /***** Show the form again *****/ Ctr_EditCentres (); @@ -2020,36 +2018,31 @@ void Ctr_ChangeCtrWWW (void) { extern const char *Txt_The_new_web_address_is_X; extern const char *Txt_You_can_not_leave_the_web_address_empty; - struct Centre *Ctr; char NewWWW[Cns_MAX_BYTES_WWW + 1]; - Ctr = &Gbl.Ctrs.EditingCtr; - /***** Get parameters from form *****/ /* Get the code of the centre */ - Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); + Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); /* Get the new WWW for the centre */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); /***** Get data of centre *****/ - Ctr_GetDataOfCentreByCod (Ctr); + Ctr_GetDataOfCentreByCod (&Gbl.Ctrs.EditingCtr); /***** Check if new WWW is empty *****/ if (NewWWW[0]) { /***** Update database changing old WWW by new WWW *****/ - Ctr_UpdateCtrWWWDB (Ctr->CtrCod,NewWWW); - - Str_Copy (Ctr->WWW,NewWWW, + Ctr_UpdateCtrWWWDB (Gbl.Ctrs.EditingCtr.CtrCod,NewWWW); + Str_Copy (Gbl.Ctrs.EditingCtr.WWW,NewWWW, Cns_MAX_BYTES_WWW); - /***** Write message to show the change made *****/ + /***** Write message to show the change made + and put button to go to centre changed *****/ + Gbl.Alert.Type = Lay_SUCCESS; sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt); - - /***** Put button to go to centre changed *****/ - Ctr_PutButtonToGoToCtr (Ctr); + Ctr_ShowAlertAndButtonToGoToCtr (); } else Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty); @@ -2109,16 +2102,13 @@ static void Ctr_UpdateCtrWWWDB (long CtrCod, void Ctr_ChangeCtrStatus (void) { extern const char *Txt_The_status_of_the_centre_X_has_changed; - struct Centre *Ctr; char Query[256]; Ctr_Status_t Status; Ctr_StatusTxt_t StatusTxt; - Ctr = &Gbl.Ctrs.EditingCtr; - /***** Get parameters from form *****/ /* Get centre code */ - Ctr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); + Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (); /* Get parameter with status */ Status = (Ctr_Status_t) @@ -2132,22 +2122,20 @@ void Ctr_ChangeCtrStatus (void) Status = Ctr_GetStatusBitsFromStatusTxt (StatusTxt); // New status /***** Get data of centre *****/ - Ctr_GetDataOfCentreByCod (Ctr); + Ctr_GetDataOfCentreByCod (&Gbl.Ctrs.EditingCtr); /***** Update status in table of centres *****/ sprintf (Query,"UPDATE centres SET Status=%u WHERE CtrCod=%ld", - (unsigned) Status,Ctr->CtrCod); + (unsigned) Status,Gbl.Ctrs.EditingCtr.CtrCod); DB_QueryUPDATE (Query,"can not update the status of a centre"); + Gbl.Ctrs.EditingCtr.Status = Status; - Ctr->Status = Status; - - /***** Write message to show the change made *****/ + /***** Write message to show the change made + and put button to go to centre changed *****/ + Gbl.Alert.Type = Lay_SUCCESS; sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_centre_X_has_changed, - Ctr->ShrtName); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt); - - /***** Put button to go to centre changed *****/ - Ctr_PutButtonToGoToCtr (Ctr); + Gbl.Ctrs.EditingCtr.ShrtName); + Ctr_ShowAlertAndButtonToGoToCtr (); /***** Show the form again *****/ Ctr_EditCentres (); @@ -2159,36 +2147,44 @@ void Ctr_ChangeCtrStatus (void) void Ctr_ContEditAfterChgCtr (void) { - /***** Write success / warning message *****/ - Lay_ShowPendingAlert (); - - if (Gbl.Alert.Type == Lay_SUCCESS) - /***** Put button to go to centre changed *****/ - Ctr_PutButtonToGoToCtr (&Gbl.Ctrs.EditingCtr); + /***** Write message to show the change made + and put button to go to centre changed *****/ + Ctr_ShowAlertAndButtonToGoToCtr (); /***** Show the form again *****/ Ctr_EditCentres (); } /*****************************************************************************/ -/************************ Put button to go to centre *************************/ +/***************** Write message to show the change made ********************/ +/***************** and put button to go to centre changed ********************/ /*****************************************************************************/ +// Gbl.Ctrs.EditingCtr is the centre that is beeing edited +// Gbl.CurrentCtr.Ctr is the current centre -static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr) +static void Ctr_ShowAlertAndButtonToGoToCtr (void) { extern const char *Txt_Go_to_X; - // If the centre is different to the current one... - if (Ctr->CtrCod != Gbl.CurrentCtr.Ctr.CtrCod) + /***** Start alert *****/ + Lay_ShowAlertAndButton1 (Gbl.Alert.Type,Gbl.Alert.Txt); + + // If the centre being edited is different to the current one... + if (Gbl.Ctrs.EditingCtr.CtrCod != Gbl.CurrentCtr.Ctr.CtrCod) { - fprintf (Gbl.F.Out,"
"); - Act_FormStart (ActSeeDeg); - Ctr_PutParamCtrCod (Ctr->CtrCod); - sprintf (Gbl.Title,Txt_Go_to_X,Ctr->ShrtName); - Lay_PutConfirmButtonInline (Gbl.Title); - Act_FormEnd (); - fprintf (Gbl.F.Out,"
"); + /***** Put button to go to centre and end alert *****/ + sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Ctrs.EditingCtr.ShrtName); + Lay_ShowAlertAndButton2 (ActSeeDeg,NULL,Ctr_PutParamGoToCtr, + Lay_CONFIRM_BUTTON,Gbl.Title); } + else + /***** End alert *****/ + Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL); + } + +static void Ctr_PutParamGoToCtr (void) + { + Ctr_PutParamCtrCod (Gbl.Ctrs.EditingCtr.CtrCod); } /*****************************************************************************/ @@ -2418,12 +2414,8 @@ static void Ctr_PutFormToCreateCentre (void) extern const char *Txt_New_centre; extern const char *Txt_Another_place; extern const char *Txt_Create_centre; - struct Centre *Ctr; unsigned NumPlc; - /***** Centre data *****/ - Ctr = &Gbl.Ctrs.EditingCtr; - /***** Start form *****/ if (Gbl.Usrs.Me.LoggedRole >= Rol_INS_ADM) Act_FormStart (ActNewCtr); @@ -2454,7 +2446,7 @@ static void Ctr_PutFormToCreateCentre (void) fprintf (Gbl.F.Out,"" "" ""); @@ -2475,7 +2467,7 @@ static void Ctr_PutFormToCreateCentre (void) " class=\"INPUT_SHORT_NAME\"" " required=\"required\" />" "", - Hie_MAX_CHARS_SHRT_NAME,Ctr->ShrtName); + Hie_MAX_CHARS_SHRT_NAME,Gbl.Ctrs.EditingCtr.ShrtName); /***** Centre full name *****/ fprintf (Gbl.F.Out,"" @@ -2484,7 +2476,7 @@ static void Ctr_PutFormToCreateCentre (void) " class=\"INPUT_FULL_NAME\"" " required=\"required\" />" "", - Hie_MAX_CHARS_FULL_NAME,Ctr->FullName); + Hie_MAX_CHARS_FULL_NAME,Gbl.Ctrs.EditingCtr.FullName); /***** Centre WWW *****/ fprintf (Gbl.F.Out,"" @@ -2493,7 +2485,7 @@ static void Ctr_PutFormToCreateCentre (void) " class=\"INPUT_WWW\"" " required=\"required\" />" "", - Cns_MAX_CHARS_WWW,Ctr->WWW); + Cns_MAX_CHARS_WWW,Gbl.Ctrs.EditingCtr.WWW); /***** Number of users who claim to belong to this centre *****/ fprintf (Gbl.F.Out,"" @@ -2678,46 +2670,44 @@ static void Ctr_RecFormRequestOrCreateCtr (unsigned Status) extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_You_must_specify_the_web_address_of_the_new_centre; extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_centre; - struct Centre *Ctr; - - Ctr = &Gbl.Ctrs.EditingCtr; /***** Get parameters from form *****/ /* Set centre institution */ - Ctr->InsCod = Gbl.CurrentIns.Ins.InsCod; + Gbl.Ctrs.EditingCtr.InsCod = Gbl.CurrentIns.Ins.InsCod; /* Get place */ - if ((Ctr->PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place" + if ((Gbl.Ctrs.EditingCtr.PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place" Lay_ShowAlert (Lay_ERROR,"Wrong place."); /* Get centre short name */ - Par_GetParToText ("ShortName",Ctr->ShrtName,Hie_MAX_BYTES_SHRT_NAME); + Par_GetParToText ("ShortName",Gbl.Ctrs.EditingCtr.ShrtName,Hie_MAX_BYTES_SHRT_NAME); /* Get centre full name */ - Par_GetParToText ("FullName",Ctr->FullName,Hie_MAX_BYTES_FULL_NAME); + Par_GetParToText ("FullName",Gbl.Ctrs.EditingCtr.FullName,Hie_MAX_BYTES_FULL_NAME); /* Get centre WWW */ - Par_GetParToText ("WWW",Ctr->WWW,Cns_MAX_BYTES_WWW); + Par_GetParToText ("WWW",Gbl.Ctrs.EditingCtr.WWW,Cns_MAX_BYTES_WWW); - if (Ctr->ShrtName[0] && Ctr->FullName[0]) // If there's a centre name + if (Gbl.Ctrs.EditingCtr.ShrtName[0] && + Gbl.Ctrs.EditingCtr.FullName[0]) // If there's a centre name { - if (Ctr->WWW[0]) + if (Gbl.Ctrs.EditingCtr.WWW[0]) { /***** If name of centre was in database... *****/ - if (Ctr_CheckIfCtrNameExistsInIns ("ShortName",Ctr->ShrtName,-1L,Gbl.CurrentIns.Ins.InsCod)) + if (Ctr_CheckIfCtrNameExistsInIns ("ShortName",Gbl.Ctrs.EditingCtr.ShrtName,-1L,Gbl.CurrentIns.Ins.InsCod)) { sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Ctr->ShrtName); + Gbl.Ctrs.EditingCtr.ShrtName); Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt); } - else if (Ctr_CheckIfCtrNameExistsInIns ("FullName",Ctr->FullName,-1L,Gbl.CurrentIns.Ins.InsCod)) + else if (Ctr_CheckIfCtrNameExistsInIns ("FullName",Gbl.Ctrs.EditingCtr.FullName,-1L,Gbl.CurrentIns.Ins.InsCod)) { sprintf (Gbl.Alert.Txt,Txt_The_centre_X_already_exists, - Ctr->FullName); + Gbl.Ctrs.EditingCtr.FullName); Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt); } else // Add new centre to database - Ctr_CreateCentre (Ctr,Status); + Ctr_CreateCentre (Status); } else // If there is not a web { @@ -2738,8 +2728,9 @@ static void Ctr_RecFormRequestOrCreateCtr (unsigned Status) /*****************************************************************************/ /***************************** Create a new centre ***************************/ /*****************************************************************************/ +// Gbl.Ctrs.EditingCtr must hold the centre beeing edited -static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status) +static void Ctr_CreateCentre (unsigned Status) { extern const char *Txt_Created_new_centre_X; char Query[512 + @@ -2754,19 +2745,21 @@ static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status) " VALUES" " (%ld,%ld,%u,%ld," "'%s','%s','%s','')", - Ctr->InsCod,Ctr->PlcCod, + Gbl.Ctrs.EditingCtr.InsCod, + Gbl.Ctrs.EditingCtr.PlcCod, Status, Gbl.Usrs.Me.UsrDat.UsrCod, - Ctr->ShrtName,Ctr->FullName,Ctr->WWW); - Ctr->CtrCod = DB_QueryINSERTandReturnCode (Query,"can not create a new centre"); + Gbl.Ctrs.EditingCtr.ShrtName, + Gbl.Ctrs.EditingCtr.FullName, + Gbl.Ctrs.EditingCtr.WWW); + Gbl.Ctrs.EditingCtr.CtrCod = DB_QueryINSERTandReturnCode (Query,"can not create a new centre"); - /***** Write success message *****/ + /***** Write message to show the change made + and put button to go to centre created *****/ + Gbl.Alert.Type = Lay_SUCCESS; sprintf (Gbl.Alert.Txt,Txt_Created_new_centre_X, - Ctr->FullName); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt); - - /***** Put button to go to centre created *****/ - Ctr_PutButtonToGoToCtr (Ctr); + Gbl.Ctrs.EditingCtr.FullName); + Ctr_ShowAlertAndButtonToGoToCtr (); } /*****************************************************************************/ diff --git a/swad_changelog.h b/swad_changelog.h index fb6522838..acc36a84b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -235,13 +235,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.212 (2017-05-10)" +#define Log_PLATFORM_VERSION "SWAD 16.213 (2017-05-10)" #define CSS_FILE "swad16.209.3.css" #define JS_FILE "swad16.206.3.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.213: May 11, 2017 Changes in edition of centres. (218881 lines) Version 16.212: May 11, 2017 Changes in edition of courses and degrees. (218870 lines) Version 16.211.2: May 11, 2017 Fixed bug in alerts. (218879 lines) Version 16.211.1: May 11, 2017 Change in layout of forms to edit groups. (218882 lines) diff --git a/swad_course.c b/swad_course.c index 3575093c3..74c79b798 100644 --- a/swad_course.c +++ b/swad_course.c @@ -113,8 +113,8 @@ static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const cha long DegCod,unsigned Year); static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName); -static void Crs_PutButtonToGoToCrs (struct Course *Crs); -static void Crs_PutButtonToRegisterInCrs (struct Course *Crs); +static void Crs_PutButtonToGoToCrs (void); +static void Crs_PutButtonToRegisterInCrs (void); static void Crs_PutLinkToSearchCourses (void); static void Sch_PutLinkToSearchCoursesParams (void); @@ -2763,7 +2763,7 @@ void Crs_ContEditAfterChgCrs (void) if (Gbl.Alert.Type == Lay_SUCCESS) { /***** Put button to go to course changed *****/ - Crs_PutButtonToGoToCrs (&Gbl.Degs.EditingCrs); + Crs_PutButtonToGoToCrs (); /***** Put button to request my registration in course *****/ PutButtonToRequestRegistration = false; @@ -2789,7 +2789,7 @@ void Crs_ContEditAfterChgCrs (void) } if (PutButtonToRequestRegistration) - Crs_PutButtonToRegisterInCrs (&Gbl.Degs.EditingCrs); + Crs_PutButtonToRegisterInCrs (); } /***** End alert *****/ @@ -2802,17 +2802,19 @@ void Crs_ContEditAfterChgCrs (void) /*****************************************************************************/ /************************ Put button to go to course *************************/ /*****************************************************************************/ +// Gbl.Degs.EditingCrs is the course that is beeing edited +// Gbl.CurrentCrs.Crs is the current course -static void Crs_PutButtonToGoToCrs (struct Course *Crs) +static void Crs_PutButtonToGoToCrs (void) { extern const char *Txt_Go_to_X; - // If the course is different to the current one... - if (Crs->CrsCod != Gbl.CurrentCrs.Crs.CrsCod) + // If the course being edited is different to the current one... + if (Gbl.Degs.EditingCrs.CrsCod != Gbl.CurrentCrs.Crs.CrsCod) { Act_FormStart (ActSeeCrsInf); - Crs_PutParamCrsCod (Crs->CrsCod); - sprintf (Gbl.Title,Txt_Go_to_X,Crs->ShrtName); + Crs_PutParamCrsCod (Gbl.Degs.EditingCrs.CrsCod); + sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Degs.EditingCrs.ShrtName); Lay_PutConfirmButton (Gbl.Title); Act_FormEnd (); } @@ -2821,15 +2823,18 @@ static void Crs_PutButtonToGoToCrs (struct Course *Crs) /*****************************************************************************/ /************************ Put button to go to course *************************/ /*****************************************************************************/ +// Gbl.Degs.EditingCrs is the course that is beeing edited +// Gbl.CurrentCrs.Crs is the current course -static void Crs_PutButtonToRegisterInCrs (struct Course *Crs) +static void Crs_PutButtonToRegisterInCrs (void) { extern const char *Txt_Register_me_in_X; Act_FormStart (ActReqSignUp); - if (Crs->CrsCod != Gbl.CurrentCrs.Crs.CrsCod) // If the course is different to the current one... - Crs_PutParamCrsCod (Crs->CrsCod); - sprintf (Gbl.Title,Txt_Register_me_in_X,Crs->ShrtName); + // If the course beeing edited is different to the current one... + if (Gbl.Degs.EditingCrs.CrsCod != Gbl.CurrentCrs.Crs.CrsCod) + Crs_PutParamCrsCod (Gbl.Degs.EditingCrs.CrsCod); + sprintf (Gbl.Title,Txt_Register_me_in_X,Gbl.Degs.EditingCrs.ShrtName); Lay_PutCreateButton (Gbl.Title); Act_FormEnd (); } diff --git a/swad_degree.c b/swad_degree.c index d24568ac4..310af11b2 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1119,7 +1119,7 @@ unsigned Deg_ConvStrToYear (const char *StrYear) /*****************************************************************************/ /***************************** Create a new degree ***************************/ /*****************************************************************************/ -// Gbl.Degs.EditingDeg must hold the degree +// Gbl.Degs.EditingDeg must hold the degree beeing edited static void Deg_CreateDegree (unsigned Status) { @@ -2247,7 +2247,8 @@ void Deg_ChangeDegStatus (void) void Deg_ContEditAfterChgDeg (void) { - /***** Put button to go to degree changed *****/ + /***** Write message to show the change made + and put button to go to degree changed *****/ Deg_ShowAlertAndButtonToGoToDeg (); /***** Show the form again *****/ @@ -2255,10 +2256,11 @@ void Deg_ContEditAfterChgDeg (void) } /*****************************************************************************/ -/************************ Put button to go to degree *************************/ +/***************** Write message to show the change made ********************/ +/***************** and put button to go to degree changed ********************/ /*****************************************************************************/ // Gbl.Degs.EditingDeg is the degree that is beeing edited -// Gbl.CurrentDeg.Deg.DegCod is the current degree +// Gbl.CurrentDeg.Deg is the current degree void Deg_ShowAlertAndButtonToGoToDeg (void) {