diff --git a/swad_action.c b/swad_action.c index fc77e57e..6848c3e2 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1469,8 +1469,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActRemCtr */{ 686,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RemoveCentre ,NULL}, /* ActChgCtrIns */{ 720,-1,TabIns,ActSeeCtr ,0x180,0x180,0x180,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCentreIns ,NULL}, /* ActChgDegPlc */{ 706,-1,TabIns,ActSeeCtr ,0x180,0x180,0x180,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCentrePlace ,NULL}, - /* ActRenCtrSho */{ 682,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RenameCentreShort ,NULL}, - /* ActRenCtrFul */{ 684,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RenameCentreFull ,NULL}, + /* ActRenCtrSho */{ 682,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Ctr_RenameCentreShort ,Ctr_ContEditAfterChgCtr ,NULL}, + /* ActRenCtrFul */{ 684,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,Ctr_RenameCentreFull ,Ctr_ContEditAfterChgCtr ,NULL}, /* ActChgCtrWWW */{ 683,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCtrWWW ,NULL}, /* ActChgCtrSta */{1209,-1,TabIns,ActSeeCtr ,0x180,0x180,0x180,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCtrStatus ,NULL}, diff --git a/swad_centre.c b/swad_centre.c index 74d86d83..0beefaa1 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -82,8 +82,9 @@ static bool Ctr_CheckIfICanEdit (struct Centre *Ctr); 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_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName); +static bool Ctr_RenameCentre (struct Centre *Ctr,Cns_ShortOrFullName_t ShortOrFullName); static bool Ctr_CheckIfCentreNameExistsInCurrentIns (const char *FieldName,const char *Name,long CtrCod); +static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr); static void Ctr_PutFormToChangeCtrPhoto (bool PhotoExists); static void Ctr_PutFormToCreateCentre (void); @@ -1580,8 +1581,9 @@ void Ctr_RemoveCentre (void) void Ctr_ChangeCentreIns (void) { - extern const char *Txt_The_institution_of_the_centre_has_changed; + extern const char *Txt_The_centre_X_has_been_moved_to_the_institution_Y; struct Centre *Ctr; + struct Institution NewIns; char Query[512]; Ctr = &Gbl.Ctrs.EditingCtr; @@ -1592,15 +1594,25 @@ void Ctr_ChangeCentreIns (void) Lay_ShowErrorAndExit ("Code of centre is missing."); /* Get parameter with institution code */ - Ctr->InsCod = Ins_GetParamOtherInsCod (); + NewIns.InsCod = Ins_GetParamOtherInsCod (); + + /***** Get data of centre and new institution *****/ + Ctr_GetDataOfCentreByCod (Ctr); + Ins_GetDataOfInstitutionByCod (&NewIns,Ins_GET_BASIC_DATA); /***** Update institution in table of centres *****/ sprintf (Query,"UPDATE centres SET InsCod='%ld' WHERE CtrCod='%ld'", - Ctr->InsCod,Ctr->CtrCod); + NewIns.InsCod,Ctr->CtrCod); DB_QueryUPDATE (Query,"can not update the institution of a centre"); + Ctr->InsCod = NewIns.InsCod; /***** Write message to show the change made *****/ - Lay_ShowAlert (Lay_SUCCESS,Txt_The_institution_of_the_centre_has_changed); + sprintf (Gbl.Message,Txt_The_centre_X_has_been_moved_to_the_institution_Y, + Ctr->FullName,NewIns.FullName); + Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); + + /***** Put button to go to centre changed *****/ + Ctr_PutButtonToGoToCtr (Ctr); /***** Show the form again *****/ Ctr_EditCentres (); @@ -1634,6 +1646,9 @@ void Ctr_ChangeCentrePlace (void) /***** 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); + /***** Show the form again *****/ Ctr_EditCentres (); } @@ -1644,7 +1659,13 @@ void Ctr_ChangeCentrePlace (void) void Ctr_RenameCentreShort (void) { - Ctr_RenameCentre (Cns_SHORT_NAME); + 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 } /*****************************************************************************/ @@ -1653,28 +1674,35 @@ void Ctr_RenameCentreShort (void) void Ctr_RenameCentreFull (void) { - Ctr_RenameCentre (Cns_FULL_NAME); + struct Centre *Ctr; + + Ctr = &Gbl.Ctrs.EditingCtr; + + 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 } /*****************************************************************************/ /************************ Change the name of a degree ************************/ /*****************************************************************************/ +// Returns true if the degree is renamed +// Returns false if the degree is not renamed -static void Ctr_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName) +static bool 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; extern const char *Txt_The_centre_X_has_been_renamed_as_Y; extern const char *Txt_The_name_of_the_centre_X_has_not_changed; char Query[512]; - struct Centre *Ctr; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning 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; - Ctr = &Gbl.Ctrs.EditingCtr; switch (ShortOrFullName) { case Cns_SHORT_NAME: @@ -1707,7 +1735,7 @@ static void Ctr_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName) { sprintf (Gbl.Message,Txt_You_can_not_leave_the_name_of_the_centre_X_empty, CurrentCtrName); - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Gbl.Error = true; } else { @@ -1719,7 +1747,7 @@ static void Ctr_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName) { sprintf (Gbl.Message,Txt_The_centre_X_already_exists, NewCtrName); - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Gbl.Error = true; } else { @@ -1728,23 +1756,23 @@ static void Ctr_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName) FieldName,NewCtrName,Ctr->CtrCod); DB_QueryUPDATE (Query,"can not update the name of a centre"); - /***** Write message to show the change made *****/ + /* Write message to show the change made */ sprintf (Gbl.Message,Txt_The_centre_X_has_been_renamed_as_Y, CurrentCtrName,NewCtrName); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); + + /* Change current degree 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); - Lay_ShowAlert (Lay_INFO,Gbl.Message); - } } - /***** Show the form again *****/ - strcpy (CurrentCtrName,NewCtrName); - Ctr_EditCentres (); + return CentreHasBeenRenamed; } /*****************************************************************************/ @@ -1796,6 +1824,9 @@ void Ctr_ChangeCtrWWW (void) sprintf (Gbl.Message,Txt_The_new_web_address_is_X, NewWWW); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); + + /***** Put button to go to centre changed *****/ + Ctr_PutButtonToGoToCtr (Ctr); } else { @@ -1850,10 +1881,51 @@ void Ctr_ChangeCtrStatus (void) Ctr->ShortName); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); + /***** Put button to go to centre changed *****/ + Ctr_PutButtonToGoToCtr (Ctr); + /***** Show the form again *****/ Ctr_EditCentres (); } +/*****************************************************************************/ +/************* Show message of success after changing a centre ***************/ +/*****************************************************************************/ + +void Ctr_ContEditAfterChgCtr (void) + { + if (Gbl.Error) + /***** Write error message *****/ + Lay_ShowAlert (Lay_WARNING,Gbl.Message); + else + { + /***** Write success message showing the change made *****/ + Lay_ShowAlert (Lay_INFO,Gbl.Message); + + /***** Put button to go to centre changed *****/ + if (Gbl.Ctrs.EditingCtr.CtrCod != Gbl.CurrentCtr.Ctr.CtrCod) // If changing other centre different than the current one... + Ctr_PutButtonToGoToCtr (&Gbl.Ctrs.EditingCtr); + } + + /***** Show the form again *****/ + Ctr_EditCentres (); + } + +/*****************************************************************************/ +/************************ Put button to go to centre *************************/ +/*****************************************************************************/ + +static void Ctr_PutButtonToGoToCtr (struct Centre *Ctr) + { + extern const char *Txt_Go_to_X; + + Act_FormStart (ActSeeCtrInf); + Ctr_PutParamCtrCod (Ctr->CtrCod); + sprintf (Gbl.Title,Txt_Go_to_X,Ctr->ShortName); + Lay_PutConfirmButton (Gbl.Title); + Act_FormEnd (); + } + /*****************************************************************************/ /*********** Show a form for sending a logo of the current centre ************/ /*****************************************************************************/ @@ -2401,12 +2473,15 @@ static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status) Status, Gbl.Usrs.Me.UsrDat.UsrCod, Ctr->ShortName,Ctr->FullName,Ctr->WWW); - DB_QueryINSERT (Query,"can not create a new centre"); + Ctr->CtrCod = DB_QueryINSERTandReturnCode (Query,"can not create a new centre"); /***** Write success message *****/ sprintf (Gbl.Message,Txt_Created_new_centre_X, Ctr->FullName); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); + + /***** Put button to go to centre created *****/ + Ctr_PutButtonToGoToCtr (Ctr); } /*****************************************************************************/ diff --git a/swad_centre.h b/swad_centre.h index 4f6cbd6f..ada371c2 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -110,6 +110,7 @@ void Ctr_RenameCentreShort (void); void Ctr_RenameCentreFull (void); void Ctr_ChangeCtrWWW (void); void Ctr_ChangeCtrStatus (void); +void Ctr_ContEditAfterChgCtr (void); void Ctr_RequestLogo (void); void Ctr_ReceiveLogo (void); diff --git a/swad_changelog.h b/swad_changelog.h index 56ef3b7a..f2f74188 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -119,19 +119,20 @@ // TODO: If a follower follows a user whose profile is no longer visible ==> put icon to unfollow in list of followed // TODO: FIX BUG: In results of search of students, no mark of confirmation is shown even if the student really has confirmed his/her registration in the course // TODO: Insert "http://" to WWW when WWW does not start with "*://" -// TODO: Put link "Ir a ..." after editing a centre or institution (similar to course and degree) +// TODO: Put link "Ir a ..." after editing an institution (similar to course, degree and centre) /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.141.1 (2016-03-01)" +#define Log_PLATFORM_VERSION "SWAD 15.142 (2016-03-01)" #define CSS_FILE "swad15.137.2.css" #define JS_FILE "swad15.131.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 15.142: Mar 01, 2016 Button to go to another centre after editing. (195984 lines) Version 15.141.1: Mar 01, 2016 Fixed bug when creating a new degree. (195897 lines) Version 15.141: Mar 01, 2016 Button to go to another degree after editing. (195898 lines) Version 15.140.1: Mar 01, 2016 The link to go to another course after editing is replaced by a button. (195817 lines) diff --git a/swad_text.c b/swad_text.c index 4d0f0b05..0638cf1b 100644 --- a/swad_text.c +++ b/swad_text.c @@ -40101,6 +40101,36 @@ const char *Txt_The_centre_X_already_exists = // Warning: it is very important t "The centre %s already exists."; // Necessita de tradução #endif +const char *Txt_The_centre_X_has_been_moved_to_the_institution_Y = // Warning: it is very important to include two %s in the following sentences +#if L==1 + "El centro %s se ha movido" + " a la institución %s."; // Necessita traduccio +#elif L==2 + "The centre %s has been moved" + " to the institution %s."; // Need Übersetzung +#elif L==3 + "The centre %s has been moved" + " to the institution %s."; +#elif L==4 + "El centro %s se ha movido" + " a la institución %s."; +#elif L==5 + "The centre %s has been moved" + " to the institution %s."; // Besoin de traduction +#elif L==6 + "El centro %s se ha movido" + " a la institución %s."; // Okoteve traducción +#elif L==7 + "Il centre %s è stato spostato" + " alla istituzione %s."; +#elif L==8 + "The centre %s has been moved" + " to the institution %s."; // Potrzebujesz tlumaczenie +#elif L==9 + "The centre %s has been moved" + " to the institution %s."; // Necessita de tradução +#endif + const char *Txt_The_centre_X_has_been_renamed_as_Y = // Warning: it is very important to include two %s in the following sentences #if L==1 "El centro %s ha pasado a denominarse %s."; // Necessita traduccio