diff --git a/swad_action.c b/swad_action.c index 885882f75..24e5c0b2b 100644 --- a/swad_action.c +++ b/swad_action.c @@ -285,6 +285,7 @@ Centre: 171. ActPrnCtrInf Print information on the current centre 172. ActChgCtrInsCfg Request change of the institution of a centre in centre configuration + NEW. ActRenCtrFulCfg Change full name centre in centre configuration 173. ActReqCtrLog Show form to send the logo of the current centre 174. ActRecCtrLog Receive and store the logo of the current centre 175. ActRemCtrLog Remove the logo of the current centre @@ -1635,6 +1636,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActPrnCtrInf */{1152,-1,TabUnk,ActSeeCtrInf ,0x1FF,0x1FF,0x1FF,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Ctr_PrintConfiguration ,NULL}, /* ActChgCtrInsCfg */{1589,-1,TabUnk,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,Ctr_ChangeCtrInsInConfig ,Ctr_ContEditAfterChgCtrInConfig,NULL}, + /* ActRenCtrFulCfg */{1594,-1,TabUnk,ActSeeCtrInf ,0x180,0x180,0x180,Act_CONT_NORM,Act_THIS_WINDOW,Ctr_RenameCentreFullInConfig ,Ctr_ContEditAfterChgCtrInConfig,NULL}, /* ActReqCtrLog */{1244,-1,TabUnk,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Ctr_RequestLogo ,NULL}, /* ActRecCtrLog */{1051,-1,TabUnk,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONT_DATA,Act_THIS_WINDOW,Ctr_ReceiveLogo ,Ctr_ShowConfiguration ,NULL}, /* ActRemCtrLog */{1342,-1,TabUnk,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONT_DATA,Act_THIS_WINDOW,Ctr_RemoveLogo ,Ctr_ShowConfiguration ,NULL}, @@ -4449,6 +4451,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActRenInsFulCfg, // #1591 ActRenInsShoCfg, // #1592 ActChgInsWWWCfg, // #1593 + ActRenCtrFulCfg, // #1594 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 9102121ef..6430a9c59 100644 --- a/swad_action.h +++ b/swad_action.h @@ -55,9 +55,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 (1+9+51+14+93+70+67+247+186+155+172+36+30+86) +#define Act_NUM_ACTIONS (1+9+51+14+93+71+67+247+186+155+172+36+30+86) -#define Act_MAX_ACTION_COD 1593 +#define Act_MAX_ACTION_COD 1594 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -285,71 +285,72 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActCtrSch (ActDowShaIns+ 6) #define ActPrnCtrInf (ActDowShaIns+ 7) #define ActChgCtrInsCfg (ActDowShaIns+ 8) -#define ActReqCtrLog (ActDowShaIns+ 9) -#define ActRecCtrLog (ActDowShaIns+ 10) -#define ActRemCtrLog (ActDowShaIns+ 11) -#define ActReqCtrPho (ActDowShaIns+ 12) -#define ActRecCtrPho (ActDowShaIns+ 13) -#define ActChgCtrPhoAtt (ActDowShaIns+ 14) +#define ActRenCtrFulCfg (ActDowShaIns+ 9) +#define ActReqCtrLog (ActDowShaIns+ 10) +#define ActRecCtrLog (ActDowShaIns+ 11) +#define ActRemCtrLog (ActDowShaIns+ 12) +#define ActReqCtrPho (ActDowShaIns+ 13) +#define ActRecCtrPho (ActDowShaIns+ 14) +#define ActChgCtrPhoAtt (ActDowShaIns+ 15) -#define ActEdiDeg (ActDowShaIns+ 15) -#define ActReqDeg (ActDowShaIns+ 16) -#define ActNewDeg (ActDowShaIns+ 17) -#define ActRemDeg (ActDowShaIns+ 18) -#define ActRenDegSho (ActDowShaIns+ 19) -#define ActRenDegFul (ActDowShaIns+ 20) -#define ActChgDegTyp (ActDowShaIns+ 21) -#define ActChgDegWWW (ActDowShaIns+ 22) -#define ActChgDegSta (ActDowShaIns+ 23) +#define ActEdiDeg (ActDowShaIns+ 16) +#define ActReqDeg (ActDowShaIns+ 17) +#define ActNewDeg (ActDowShaIns+ 18) +#define ActRemDeg (ActDowShaIns+ 19) +#define ActRenDegSho (ActDowShaIns+ 20) +#define ActRenDegFul (ActDowShaIns+ 21) +#define ActChgDegTyp (ActDowShaIns+ 22) +#define ActChgDegWWW (ActDowShaIns+ 23) +#define ActChgDegSta (ActDowShaIns+ 24) -#define ActChgToSeeDocCtr (ActDowShaIns+ 24) -#define ActSeeDocCtr (ActDowShaIns+ 25) -#define ActExpSeeDocCtr (ActDowShaIns+ 26) -#define ActConSeeDocCtr (ActDowShaIns+ 27) -#define ActZIPSeeDocCtr (ActDowShaIns+ 28) -#define ActReqDatSeeDocCtr (ActDowShaIns+ 29) -#define ActDowSeeDocCtr (ActDowShaIns+ 30) -#define ActChgToAdmDocCtr (ActDowShaIns+ 31) -#define ActAdmDocCtr (ActDowShaIns+ 32) -#define ActReqRemFilDocCtr (ActDowShaIns+ 33) -#define ActRemFilDocCtr (ActDowShaIns+ 34) -#define ActRemFolDocCtr (ActDowShaIns+ 35) -#define ActCopDocCtr (ActDowShaIns+ 36) -#define ActPasDocCtr (ActDowShaIns+ 37) -#define ActRemTreDocCtr (ActDowShaIns+ 38) -#define ActFrmCreDocCtr (ActDowShaIns+ 39) -#define ActCreFolDocCtr (ActDowShaIns+ 40) -#define ActCreLnkDocCtr (ActDowShaIns+ 41) -#define ActRenFolDocCtr (ActDowShaIns+ 42) -#define ActRcvFilDocCtrDZ (ActDowShaIns+ 43) -#define ActRcvFilDocCtrCla (ActDowShaIns+ 44) -#define ActExpAdmDocCtr (ActDowShaIns+ 45) -#define ActConAdmDocCtr (ActDowShaIns+ 46) -#define ActZIPAdmDocCtr (ActDowShaIns+ 47) -#define ActShoDocCtr (ActDowShaIns+ 48) -#define ActHidDocCtr (ActDowShaIns+ 49) -#define ActReqDatAdmDocCtr (ActDowShaIns+ 50) -#define ActChgDatAdmDocCtr (ActDowShaIns+ 51) -#define ActDowAdmDocCtr (ActDowShaIns+ 52) +#define ActChgToSeeDocCtr (ActDowShaIns+ 25) +#define ActSeeDocCtr (ActDowShaIns+ 26) +#define ActExpSeeDocCtr (ActDowShaIns+ 27) +#define ActConSeeDocCtr (ActDowShaIns+ 28) +#define ActZIPSeeDocCtr (ActDowShaIns+ 29) +#define ActReqDatSeeDocCtr (ActDowShaIns+ 30) +#define ActDowSeeDocCtr (ActDowShaIns+ 31) +#define ActChgToAdmDocCtr (ActDowShaIns+ 32) +#define ActAdmDocCtr (ActDowShaIns+ 33) +#define ActReqRemFilDocCtr (ActDowShaIns+ 34) +#define ActRemFilDocCtr (ActDowShaIns+ 35) +#define ActRemFolDocCtr (ActDowShaIns+ 36) +#define ActCopDocCtr (ActDowShaIns+ 37) +#define ActPasDocCtr (ActDowShaIns+ 38) +#define ActRemTreDocCtr (ActDowShaIns+ 39) +#define ActFrmCreDocCtr (ActDowShaIns+ 40) +#define ActCreFolDocCtr (ActDowShaIns+ 41) +#define ActCreLnkDocCtr (ActDowShaIns+ 42) +#define ActRenFolDocCtr (ActDowShaIns+ 43) +#define ActRcvFilDocCtrDZ (ActDowShaIns+ 44) +#define ActRcvFilDocCtrCla (ActDowShaIns+ 45) +#define ActExpAdmDocCtr (ActDowShaIns+ 46) +#define ActConAdmDocCtr (ActDowShaIns+ 47) +#define ActZIPAdmDocCtr (ActDowShaIns+ 48) +#define ActShoDocCtr (ActDowShaIns+ 49) +#define ActHidDocCtr (ActDowShaIns+ 50) +#define ActReqDatAdmDocCtr (ActDowShaIns+ 51) +#define ActChgDatAdmDocCtr (ActDowShaIns+ 52) +#define ActDowAdmDocCtr (ActDowShaIns+ 53) -#define ActReqRemFilShaCtr (ActDowShaIns+ 53) -#define ActRemFilShaCtr (ActDowShaIns+ 54) -#define ActRemFolShaCtr (ActDowShaIns+ 55) -#define ActCopShaCtr (ActDowShaIns+ 56) -#define ActPasShaCtr (ActDowShaIns+ 57) -#define ActRemTreShaCtr (ActDowShaIns+ 58) -#define ActFrmCreShaCtr (ActDowShaIns+ 59) -#define ActCreFolShaCtr (ActDowShaIns+ 60) -#define ActCreLnkShaCtr (ActDowShaIns+ 61) -#define ActRenFolShaCtr (ActDowShaIns+ 62) -#define ActRcvFilShaCtrDZ (ActDowShaIns+ 63) -#define ActRcvFilShaCtrCla (ActDowShaIns+ 64) -#define ActExpShaCtr (ActDowShaIns+ 65) -#define ActConShaCtr (ActDowShaIns+ 66) -#define ActZIPShaCtr (ActDowShaIns+ 67) -#define ActReqDatShaCtr (ActDowShaIns+ 68) -#define ActChgDatShaCtr (ActDowShaIns+ 69) -#define ActDowShaCtr (ActDowShaIns+ 70) +#define ActReqRemFilShaCtr (ActDowShaIns+ 54) +#define ActRemFilShaCtr (ActDowShaIns+ 55) +#define ActRemFolShaCtr (ActDowShaIns+ 56) +#define ActCopShaCtr (ActDowShaIns+ 57) +#define ActPasShaCtr (ActDowShaIns+ 58) +#define ActRemTreShaCtr (ActDowShaIns+ 59) +#define ActFrmCreShaCtr (ActDowShaIns+ 60) +#define ActCreFolShaCtr (ActDowShaIns+ 61) +#define ActCreLnkShaCtr (ActDowShaIns+ 62) +#define ActRenFolShaCtr (ActDowShaIns+ 63) +#define ActRcvFilShaCtrDZ (ActDowShaIns+ 64) +#define ActRcvFilShaCtrCla (ActDowShaIns+ 65) +#define ActExpShaCtr (ActDowShaIns+ 66) +#define ActConShaCtr (ActDowShaIns+ 67) +#define ActZIPShaCtr (ActDowShaIns+ 68) +#define ActReqDatShaCtr (ActDowShaIns+ 69) +#define ActChgDatShaCtr (ActDowShaIns+ 70) +#define ActDowShaCtr (ActDowShaIns+ 71) /*****************************************************************************/ /********************************* Degree tab ********************************/ diff --git a/swad_centre.c b/swad_centre.c index 57cfe6ebf..af55f636b 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -91,7 +91,8 @@ static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status); static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); static void Ctr_PutParamOtherCtrCod (long CtrCod); static void Ctr_UpdateCtrInsDB (long CtrCod,long InsCod); -static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName); +static void Ctr_GetCtrCodFromForm (void); +static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName); static bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,long CtrCod,long InsCod); static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr); @@ -408,12 +409,21 @@ static void Ctr_Configuration (bool PrintView) "", The_ClassForm[Gbl.Prefs.Theme], Txt_Centre); - if (PutLink) - fprintf (Gbl.F.Out,"", - Gbl.CurrentCtr.Ctr.WWW); - fprintf (Gbl.F.Out,"%s",Gbl.CurrentCtr.Ctr.FullName); - if (PutLink) - fprintf (Gbl.F.Out,""); + if (!PrintView && + Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) // Only centre admins and system admins can edit centre full name + { + Act_FormStart (ActRenCtrFulCfg); + fprintf (Gbl.F.Out,"", + Ctr_MAX_LENGTH_CENTRE_FULL_NAME, + Gbl.CurrentCtr.Ctr.FullName, + Gbl.Form.Id); + Act_FormEnd (); + } + else // I can not edit centre full name + fprintf (Gbl.F.Out,"%s",Gbl.CurrentCtr.Ctr.FullName); fprintf (Gbl.F.Out,"" ""); @@ -1751,13 +1761,8 @@ void Ctr_ChangeCentrePlace (void) void Ctr_RenameCentreShort (void) { - struct Centre *Ctr; - - Ctr = &Gbl.Ctrs.EditingCtr; - - if (Ctr_RenameCentre (Ctr,Cns_SHORT_NAME)) - if (Ctr->CtrCod == Gbl.CurrentCtr.Ctr.CtrCod) // If renaming current centre... - strcpy (Gbl.CurrentCtr.Ctr.ShortName,Ctr->ShortName); // Overwrite current centre name in order to show correctly in page title and heading + Ctr_GetCtrCodFromForm (); + Ctr_RenameCentre (&Gbl.Ctrs.EditingCtr,Cns_SHORT_NAME); } /*****************************************************************************/ @@ -1766,22 +1771,31 @@ void Ctr_RenameCentreShort (void) void Ctr_RenameCentreFull (void) { - struct Centre *Ctr; + Ctr_GetCtrCodFromForm (); + Ctr_RenameCentre (&Gbl.Ctrs.EditingCtr,Cns_FULL_NAME); + } - Ctr = &Gbl.Ctrs.EditingCtr; +void Ctr_RenameCentreFullInConfig (void) + { + Ctr_RenameCentre (&Gbl.CurrentCtr.Ctr,Cns_FULL_NAME); + } - if (Ctr_RenameCentre (Ctr,Cns_FULL_NAME)) - if (Ctr->CtrCod == Gbl.CurrentCtr.Ctr.CtrCod) // If renaming current centre... - strcpy (Gbl.CurrentCtr.Ctr.FullName,Ctr->FullName); // Overwrite current centre name in order to show correctly in page title and heading +/*****************************************************************************/ +/************************ Get the code of the centre *************************/ +/*****************************************************************************/ + +static void Ctr_GetCtrCodFromForm (void) + { + /***** Get the code of the centre *****/ + if ((Gbl.Ctrs.EditingCtr.CtrCod = Ctr_GetParamOtherCtrCod ()) < 0) + Lay_ShowErrorAndExit ("Code of centre is missing."); } /*****************************************************************************/ /************************ Change the name of a centre ************************/ /*****************************************************************************/ -// Returns true if the centre is renamed -// Returns false if the centre is not renamed -static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName) +static void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName) { extern const char *Txt_You_can_not_leave_the_name_of_the_centre_X_empty; extern const char *Txt_The_centre_X_already_exists; @@ -1793,7 +1807,6 @@ static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFu unsigned MaxLength = 0; // Initialized to avoid warning char *CurrentCtrName = NULL; // Initialized to avoid warning char NewCtrName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1]; - bool CentreHasBeenRenamed = false; switch (ShortOrFullName) { @@ -1812,10 +1825,6 @@ static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFu } /***** Get parameters from form *****/ - /* Get the code of the centre */ - if ((Ctr->CtrCod = Ctr_GetParamOtherCtrCod ()) < 0) - Lay_ShowErrorAndExit ("Code of centre is missing."); - /* Get the new name for the centre */ Par_GetParToText (ParamName,NewCtrName,MaxLength); @@ -1855,16 +1864,12 @@ static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFu /* Change current centre name in order to display it properly */ strncpy (CurrentCtrName,NewCtrName,MaxLength); CurrentCtrName[MaxLength] = '\0'; - - CentreHasBeenRenamed = true; } } else // The same name sprintf (Gbl.Message,Txt_The_name_of_the_centre_X_has_not_changed, CurrentCtrName); } - - return CentreHasBeenRenamed; } /*****************************************************************************/ diff --git a/swad_centre.h b/swad_centre.h index 1a13df8b6..75e13e268 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -110,6 +110,7 @@ void Ctr_ContEditAfterChgCtrInConfig (void); void Ctr_ChangeCentrePlace (void); void Ctr_RenameCentreShort (void); void Ctr_RenameCentreFull (void); +void Ctr_RenameCentreFullInConfig (void); void Ctr_ChangeCtrWWW (void); void Ctr_ChangeCtrStatus (void); void Ctr_ContEditAfterChgCtr (void); diff --git a/swad_changelog.h b/swad_changelog.h index 073d4d826..e32db6e9b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -150,13 +150,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.33 (2016-10-22)" +#define Log_PLATFORM_VERSION "SWAD 16.34 (2016-10-22)" #define CSS_FILE "swad16.32.1.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.34: Oct 22, 2016 New form in centre configuration to change full name. (205223 lines) + 1 change necessary in database: +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1594','es','N','Cambiar nombre completo centro'); + Version 16.33: Oct 22, 2016 New form in institution configuration to change WWW. (205208 lines) 2 changes necessary in database: UPDATE actions SET Txt='Cambiar web de institución' WHERE ActCod='700' AND Language='es'; diff --git a/swad_institution.c b/swad_institution.c index 8b57fa7c7..e29f53528 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -371,8 +371,7 @@ static void Ins_Configuration (bool PrintView) Act_FormEnd (); } else // I can not edit institution full name - fprintf (Gbl.F.Out,"%s", - Gbl.CurrentIns.Ins.FullName); + fprintf (Gbl.F.Out,"%s",Gbl.CurrentIns.Ins.FullName); fprintf (Gbl.F.Out,"" ""); @@ -398,8 +397,7 @@ static void Ins_Configuration (bool PrintView) Act_FormEnd (); } else // I can not edit institution short name - fprintf (Gbl.F.Out,"%s", - Gbl.CurrentIns.Ins.ShortName); + fprintf (Gbl.F.Out,"%s",Gbl.CurrentIns.Ins.ShortName); fprintf (Gbl.F.Out,"" "");