diff --git a/swad_ID.c b/swad_ID.c index b51ac0a7..03a3cfd7 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -592,11 +592,11 @@ static void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat, /***** Show possible alert *****/ if (Gbl.Alert.Section == (const char *) ID_ID_SECTION_ID) - Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt); + Ale_ShowA_old (Gbl.Alert.Type,Gbl.Alert.Txt); /***** Help message *****/ if (IShouldFillInID) - Ale_ShowAlert (Ale_WARNING,Txt_Please_fill_in_your_ID); + Ale_ShowA_old (Ale_WARNING,Txt_Please_fill_in_your_ID); /***** Start table *****/ Tbl_StartTableWide (2); @@ -676,7 +676,7 @@ static void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat, /***** Write help text *****/ fprintf (Gbl.F.Out,"" ""); - Ale_ShowAlert (Ale_INFO,Txt_The_ID_is_used_in_order_to_facilitate_); + Ale_ShowA_old (Ale_INFO,Txt_The_ID_is_used_in_order_to_facilitate_); fprintf (Gbl.F.Out,"" ""); @@ -767,10 +767,10 @@ void ID_RemoveOtherUsrID (void) Acc_ShowFormChgOtherUsrAccount (); } else - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_old (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } else // User not found - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_old (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ @@ -898,10 +898,10 @@ void ID_NewOtherUsrID (void) Acc_ShowFormChgOtherUsrAccount (); } else - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_old (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } else // User not found - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_old (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ diff --git a/swad_account.c b/swad_account.c index 082ae604..66a0c946 100644 --- a/swad_account.c +++ b/swad_account.c @@ -25,8 +25,6 @@ /*********************************** Headers *********************************/ /*****************************************************************************/ -#define _GNU_SOURCE // For asprintf -#include // For asprintf #include // For string functions #include "swad_account.h" @@ -147,7 +145,7 @@ static void Acc_ShowFormCheckIfIHaveAccount (const char *Title) Hlp_PROFILE_SignUp,Box_CLOSABLE); /***** Help alert *****/ - Ale_ShowAlert (Ale_INFO,Txt_If_you_think_you_may_have_been_registered_); + Ale_ShowA_fmt (Ale_INFO,Txt_If_you_think_you_may_have_been_registered_); /***** Form to request user's ID for possible account already created *****/ Frm_StartForm (ActChkUsrAcc); @@ -184,7 +182,6 @@ void Acc_CheckIfEmptyAccountExists (void) struct UsrData UsrDat; MYSQL_RES *mysql_res; MYSQL_ROW row; - char *Txt; /***** Links to other actions *****/ fprintf (Gbl.F.Out,"
"); @@ -246,13 +243,8 @@ void Acc_CheckIfEmptyAccountExists (void) Box_EndBoxTable (); } else - { - if (asprintf (&Txt,Txt_There_is_no_empty_account_associated_with_your_ID_X, - ID) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_INFO,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_INFO,Txt_There_is_no_empty_account_associated_with_your_ID_X, + ID); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -263,7 +255,7 @@ void Acc_CheckIfEmptyAccountExists (void) else // ID not valid { /**** Show again form to check if I have an account *****/ - Ale_ShowAlert (Ale_WARNING,Txt_Please_enter_your_ID); + Ale_ShowA_fmt (Ale_WARNING,Txt_Please_enter_your_ID); Acc_ShowFormCheckIfIHaveAccount (Txt_Before_creating_a_new_account_check_if_you_have_been_already_registered); } @@ -450,19 +442,19 @@ void Acc_ShowFormChgMyAccount (void) /***** Check nickname, email and ID *****/ IMustCreateMyPasswordNow = (Gbl.Usrs.Me.UsrDat.Password[0] == '\0'); if (IMustCreateMyPasswordNow) - Ale_ShowAlert (Ale_WARNING, + Ale_ShowA_fmt (Ale_WARNING, Txt_Before_going_to_any_other_option_you_must_create_your_password); else { IMustCreateMyNicknameNow = (Gbl.Usrs.Me.UsrDat.Nickname[0] == '\0'); if (IMustCreateMyNicknameNow) - Ale_ShowAlert (Ale_WARNING, + Ale_ShowA_fmt (Ale_WARNING, Txt_Before_going_to_any_other_option_you_must_fill_your_nickname); else { IMustFillInMyEmailNow = (Gbl.Usrs.Me.UsrDat.Email[0] == '\0'); if (IMustFillInMyEmailNow) - Ale_ShowAlert (Ale_WARNING, + Ale_ShowA_fmt (Ale_WARNING, Txt_Before_going_to_any_other_option_you_must_fill_in_your_email_address); else { @@ -533,10 +525,10 @@ void Acc_ShowFormChgOtherUsrAccount (void) fprintf (Gbl.F.Out,"
"); } else - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } else // User not found - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ @@ -627,7 +619,6 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES extern const char *Txt_The_email_address_entered_X_is_not_valid; char NewNicknameWithArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1]; char NewPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]; - char *Txt; bool Error = false; /***** Step 1/3: Get new nickname from form *****/ @@ -655,23 +646,17 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname { Error = true; - if (asprintf (&Txt,Txt_The_nickname_X_had_been_registered_by_another_user, - NewNicknameWithoutArroba) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_WARNING,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_WARNING,Txt_The_nickname_X_had_been_registered_by_another_user, + NewNicknameWithoutArroba); } } else // New nickname is not valid { Error = true; - if (asprintf (&Txt,Txt_The_nickname_entered_X_is_not_valid_, - NewNicknameWithArroba, - Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, - Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_WARNING,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_WARNING,Txt_The_nickname_entered_X_is_not_valid_, + NewNicknameWithArroba, + Nck_MIN_CHARS_NICKNAME_WITHOUT_ARROBA, + Nck_MAX_CHARS_NICKNAME_WITHOUT_ARROBA); } /***** Step 2/3: Get new email from form *****/ @@ -687,21 +672,15 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES NewEmail)) // An email of another user is the same that my email { Error = true; - if (asprintf (&Txt,Txt_The_email_address_X_had_been_registered_by_another_user, - NewEmail) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_WARNING,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_WARNING,Txt_The_email_address_X_had_been_registered_by_another_user, + NewEmail); } } else // New email is not valid { Error = true; - if (asprintf (&Txt,Txt_The_email_address_entered_X_is_not_valid, - NewEmail) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_WARNING,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_WARNING,Txt_The_email_address_entered_X_is_not_valid, + NewEmail); } /***** Step 3/3: Get new password from form *****/ @@ -710,7 +689,7 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES if (!Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword,NewEncryptedPassword,-1L)) // New password is good? { Error = true; - Ale_ShowAlert (Ale_WARNING,Gbl.AlertToShowLater.Txt); // Error message is set in Pwd_SlowCheckIfPasswordIsGood + Ale_ShowA_new (Ale_WARNING,Gbl.AlertToShowLater.Txt); // Error message is set in Pwd_SlowCheckIfPasswordIsGood } return !Error; @@ -851,17 +830,13 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat) void Acc_AfterCreationNewAccount (void) { extern const char *Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_; - char *Txt; if (Gbl.Usrs.Me.Logged) // If account has been created without problem, I am logged { /***** Show message of success *****/ - if (asprintf (&Txt,Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_, - Gbl.Usrs.Me.UsrDat.Nickname, - Cfg_PLATFORM_SHORT_NAME) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Congratulations_You_have_created_your_account_X_Now_Y_will_request_you_, + Gbl.Usrs.Me.UsrDat.Nickname, + Cfg_PLATFORM_SHORT_NAME); /***** Show form with account data *****/ Acc_ShowFormChgMyAccount (); @@ -888,7 +863,7 @@ void Acc_GetUsrCodAndRemUsrGbl (void) Error = true; if (Error) - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ @@ -998,7 +973,7 @@ static void Acc_AskIfRemoveOtherUsrAccount (void) Ale_ShowAlertAndButton2 (ActUnk,NULL,NULL,NULL,Btn_NO_BUTTON,NULL); } else - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ @@ -1027,7 +1002,6 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, extern const char *Txt_Briefcase_of_THE_USER_X_has_been_removed; extern const char *Txt_Photo_of_THE_USER_X_has_been_removed; extern const char *Txt_Record_card_of_THE_USER_X_has_been_removed; - char *Txt; bool PhotoRemoved = false; /***** Remove the works zones of the user in all courses *****/ @@ -1059,13 +1033,8 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, UsrDat->UsrCod); if (QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_from_all_his_her_courses, + UsrDat->FullName); /***** Remove user as administrator of any degree *****/ DB_QueryDELETE ("can not remove a user as administrator", @@ -1073,13 +1042,8 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, UsrDat->UsrCod); if (QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_THE_USER_X_has_been_removed_as_administrator, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator, + UsrDat->FullName); /***** Remove user's clipboard in forums *****/ For_RemoveUsrFromThrClipboard (UsrDat->UsrCod); @@ -1090,13 +1054,8 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, /***** Remove the file tree of a user *****/ Acc_RemoveUsrBriefcase (UsrDat); if (QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_Briefcase_of_THE_USER_X_has_been_removed, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Briefcase_of_THE_USER_X_has_been_removed, + UsrDat->FullName); /***** Remove test results made by user in all courses *****/ Tst_RemoveTestResultsMadeByUsrInAllCrss (UsrDat->UsrCod); @@ -1108,13 +1067,8 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, Gbl.Msg.FilterContent[0] = '\0'; Msg_DelAllRecAndSntMsgsUsr (UsrDat->UsrCod); if (QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_Messages_of_THE_USER_X_have_been_deleted, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Messages_of_THE_USER_X_have_been_deleted, + UsrDat->FullName); /***** Remove user from tables of banned users *****/ Usr_RemoveUsrFromUsrBanned (UsrDat->UsrCod); @@ -1157,24 +1111,14 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, /***** Remove user's photo *****/ PhotoRemoved = Pho_RemovePhoto (UsrDat); if (PhotoRemoved && QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_Photo_of_THE_USER_X_has_been_removed, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Photo_of_THE_USER_X_has_been_removed, + UsrDat->FullName); /***** Remove user *****/ Acc_RemoveUsr (UsrDat); if (QuietOrVerbose == Cns_VERBOSE) - { - if (asprintf (&Txt,Txt_Record_card_of_THE_USER_X_has_been_removed, - UsrDat->FullName) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); - } + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Record_card_of_THE_USER_X_has_been_removed, + UsrDat->FullName); } /*****************************************************************************/ diff --git a/swad_agenda.c b/swad_agenda.c index 6bea64d8..76d22632 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -371,7 +371,7 @@ void Agd_ShowUsrAgenda (void) } if (Error) - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ @@ -415,12 +415,12 @@ void Agd_ShowOtherAgendaAfterLogIn (void) Box_EndBox (); } else - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); + Ale_ShowA_fmt (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } else /* The current language is not my preferred language ==> change automatically to my language */ - Ale_ShowAlert (Ale_INFO,Txt_Switching_to_LANGUAGE[Gbl.Usrs.Me.UsrDat.Prefs.Language]); + Ale_ShowA_fmt (Ale_INFO,Txt_Switching_to_LANGUAGE[Gbl.Usrs.Me.UsrDat.Prefs.Language]); } } @@ -480,7 +480,7 @@ static void Agd_ShowEvents (Agd_AgendaType_t AgendaType) Tbl_EndTable (); } else - Ale_ShowAlert (Ale_INFO,Txt_No_events); + Ale_ShowA_fmt (Ale_INFO,Txt_No_events); /***** Write again links to pages *****/ if (Pagination.MoreThanOnePage) @@ -1296,7 +1296,6 @@ void Agd_RemoveEvent (void) { extern const char *Txt_Event_X_removed; struct AgendaEvent AgdEvent; - char *Txt; /***** Get event code *****/ if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) @@ -1312,11 +1311,8 @@ void Agd_RemoveEvent (void) AgdEvent.AgdCod,AgdEvent.UsrCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Event_X_removed, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_removed, + AgdEvent.Event); /***** Show events again *****/ Agd_ShowMyAgenda (); @@ -1330,7 +1326,6 @@ void Agd_HideEvent (void) { extern const char *Txt_Event_X_is_now_hidden; struct AgendaEvent AgdEvent; - char *Txt; /***** Get event code *****/ if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) @@ -1347,11 +1342,8 @@ void Agd_HideEvent (void) AgdEvent.AgdCod,AgdEvent.UsrCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Event_X_is_now_hidden, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_hidden, + AgdEvent.Event); /***** Show events again *****/ Agd_ShowMyAgenda (); @@ -1365,7 +1357,6 @@ void Agd_UnhideEvent (void) { extern const char *Txt_Event_X_is_now_visible; struct AgendaEvent AgdEvent; - char *Txt; /***** Get event code *****/ if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) @@ -1382,11 +1373,8 @@ void Agd_UnhideEvent (void) AgdEvent.AgdCod,AgdEvent.UsrCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Event_X_is_now_visible, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_visible, + AgdEvent.Event); /***** Show events again *****/ Agd_ShowMyAgenda (); @@ -1400,7 +1388,6 @@ void Agd_MakeEventPrivate (void) { extern const char *Txt_Event_X_is_now_private; struct AgendaEvent AgdEvent; - char *Txt; /***** Get event code *****/ if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) @@ -1417,11 +1404,8 @@ void Agd_MakeEventPrivate (void) AgdEvent.AgdCod,AgdEvent.UsrCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Event_X_is_now_private, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_private, + AgdEvent.Event); /***** Show events again *****/ Agd_ShowMyAgenda (); @@ -1435,7 +1419,6 @@ void Agd_MakeEventPublic (void) { extern const char *Txt_Event_X_is_now_visible_to_users_of_your_courses; struct AgendaEvent AgdEvent; - char *Txt; /***** Get event code *****/ if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L) @@ -1452,11 +1435,8 @@ void Agd_MakeEventPublic (void) AgdEvent.AgdCod,AgdEvent.UsrCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Event_X_is_now_visible_to_users_of_your_courses, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_visible_to_users_of_your_courses, + AgdEvent.Event); /***** Show events again *****/ Agd_ShowMyAgenda (); @@ -1606,7 +1586,6 @@ void Agd_RecFormEvent (void) bool ItsANewEvent; bool NewEventIsCorrect = true; char EventTxt[Cns_MAX_BYTES_TEXT + 1]; - char *Txt; /***** Set author of the event *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1637,14 +1616,14 @@ void Agd_RecFormEvent (void) if (!AgdEvent.Location[0]) // If there is no event { NewEventIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); } /***** Check if event is correct *****/ if (!AgdEvent.Event[0]) // If there is no event { NewEventIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); } /***** Create a new event or update an existing one *****/ @@ -1655,18 +1634,15 @@ void Agd_RecFormEvent (void) Agd_CreateEvent (&AgdEvent,EventTxt); // Add new event to database /***** Write success message *****/ - if (asprintf (&Txt,Txt_Created_new_event_X, - AgdEvent.Event) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Created_new_event_X, + AgdEvent.Event); } else { Agd_UpdateEvent (&AgdEvent,EventTxt); /***** Write success message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_event_has_been_modified); } /* Free memory for list of selected groups */ diff --git a/swad_alert.c b/swad_alert.c index 75c60d65..3a025c8f 100644 --- a/swad_alert.c +++ b/swad_alert.c @@ -25,7 +25,11 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#define _GNU_SOURCE // For vasprintf #include // For NULL +#include // For va_start, va_end +#include // For FILE, fprintf, vasprintf +#include // For free #include "swad_alert.h" #include "swad_form.h" @@ -86,7 +90,7 @@ void Ale_ShowPendingAlert (void) /***** Anything to show? *****/ if (Gbl.Alert.Type != Ale_NONE) /***** Show alert *****/ - Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt); + Ale_ShowA_old (Gbl.Alert.Type,Gbl.Alert.Txt); Ale_ResetAlert (); } @@ -95,7 +99,39 @@ void Ale_ShowPendingAlert (void) /******************** Show an alert message to the user **********************/ /*****************************************************************************/ -void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *Txt) +void Ale_ShowA_fmt (Ale_AlertType_t AlertType, + const char *fmt,...) + { + va_list ap; + int NumBytesPrinted; + char *Txt; + + if (AlertType != Ale_NONE) + { + va_start (ap,fmt); + NumBytesPrinted = vasprintf (&Txt,fmt,ap); + va_end (ap); + + if (NumBytesPrinted < 0) // If memory allocation wasn't possible, + // or some other error occurs, + // vasprintf will return -1 + Lay_NotEnoughMemoryExit (); + + Ale_ShowAlertAndButton (AlertType,Txt, + ActUnk,NULL,NULL,NULL,Btn_NO_BUTTON,NULL); + + free ((void *) Txt); + } + } + +void Ale_ShowA_new (Ale_AlertType_t AlertType,const char *Txt) + { + if (AlertType != Ale_NONE) + Ale_ShowAlertAndButton (AlertType,Txt, + ActUnk,NULL,NULL,NULL,Btn_NO_BUTTON,NULL); + } + +void Ale_ShowA_old (Ale_AlertType_t AlertType,const char *Txt) { if (AlertType != Ale_NONE) Ale_ShowAlertAndButton (AlertType,Txt, diff --git a/swad_alert.h b/swad_alert.h index 093893f3..e006cfe5 100644 --- a/swad_alert.h +++ b/swad_alert.h @@ -61,7 +61,10 @@ typedef enum void Ale_ResetAlert (void); void Ale_ShowPendingAlert (void); -void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *Txt); +void Ale_ShowA_fmt (Ale_AlertType_t AlertType, + const char *fmt,...); +void Ale_ShowA_new (Ale_AlertType_t AlertType,const char *Txt); +void Ale_ShowA_old (Ale_AlertType_t AlertType,const char *Txt); void Ale_ShowAlertAndButton (Ale_AlertType_t AlertType,const char *Txt, Act_Action_t NextAction,const char *Anchor,const char *OnSubmit, void (*FuncParams) (), diff --git a/swad_announcement.c b/swad_announcement.c index b8b46063..e2b035d8 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -131,7 +131,7 @@ void Ann_ShowAllAnnouncements (void) NULL, Hlp_MESSAGES_Announcements,Box_NOT_CLOSABLE); if (!NumAnnouncements) - Ale_ShowAlert (Ale_INFO,Txt_No_announcements); + Ale_ShowA_fmt (Ale_INFO,Txt_No_announcements); /***** Show the announcements *****/ for (NumAnn = 0; @@ -495,7 +495,7 @@ void Ann_ReceiveAnnouncement (void) Ann_CreateAnnouncement (Roles,Subject,Content); /***** Write message of success *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Announcement_created); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Announcement_created); /***** Refresh list of announcements *****/ Ann_ShowAllAnnouncements (); @@ -575,7 +575,7 @@ void Ann_RemoveAnnouncement (void) AnnCod); /***** Write message of success *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Announcement_removed); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Announcement_removed); /***** Refresh list of announcements *****/ Ann_ShowAllAnnouncements (); diff --git a/swad_assignment.c b/swad_assignment.c index e6a08a8c..02ab5578 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -167,7 +167,7 @@ static void Asg_ShowAllAssignments (void) Tbl_EndTable (); } else // No assignments created - Ale_ShowAlert (Ale_INFO,Txt_No_assignments); + Ale_ShowA_fmt (Ale_INFO,Txt_No_assignments); /***** Button to create a new assignment *****/ if (Asg_CheckIfICanCreateAssignments ()) @@ -965,7 +965,6 @@ void Asg_RemoveAssignment (void) { extern const char *Txt_Assignment_X_removed; struct Assignment Asg; - char *Txt; /***** Get assignment code *****/ if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) @@ -990,11 +989,8 @@ void Asg_RemoveAssignment (void) Ntf_MarkNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Asg.AsgCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Assignment_X_removed, - Asg.Title) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Assignment_X_removed, + Asg.Title); /***** Show assignments again *****/ Asg_SeeAssignments (); @@ -1008,7 +1004,6 @@ void Asg_HideAssignment (void) { extern const char *Txt_Assignment_X_is_now_hidden; struct Assignment Asg; - char *Txt; /***** Get assignment code *****/ if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) @@ -1024,11 +1019,8 @@ void Asg_HideAssignment (void) Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Assignment_X_is_now_hidden, - Asg.Title) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Assignment_X_is_now_hidden, + Asg.Title); /***** Show assignments again *****/ Asg_SeeAssignments (); @@ -1042,7 +1034,6 @@ void Asg_ShowAssignment (void) { extern const char *Txt_Assignment_X_is_now_visible; struct Assignment Asg; - char *Txt; /***** Get assignment code *****/ if ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L) @@ -1058,11 +1049,8 @@ void Asg_ShowAssignment (void) Asg.AsgCod,Gbl.CurrentCrs.Crs.CrsCod); /***** Write message to show the change made *****/ - if (asprintf (&Txt,Txt_Assignment_X_is_now_visible, - Asg.Title) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_SUCCESS,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Assignment_X_is_now_visible, + Asg.Title); /***** Show assignments again *****/ Asg_SeeAssignments (); @@ -1302,7 +1290,6 @@ void Asg_RecFormAssignment (void) bool NewAssignmentIsCorrect = true; unsigned NumUsrsToBeNotifiedByEMail; char Description[Cns_MAX_BYTES_TEXT + 1]; - char *Txt; /***** Get the code of the assignment *****/ NewAsg.AsgCod = Asg_GetParamAsgCod (); @@ -1350,11 +1337,8 @@ void Asg_RecFormAssignment (void) { NewAssignmentIsCorrect = false; - if (asprintf (&Txt,Txt_Already_existed_an_assignment_with_the_title_X, - NewAsg.Title) < 0) - Lay_NotEnoughMemoryExit (); - Ale_ShowAlert (Ale_WARNING,Txt); - free ((void *) Txt); + Ale_ShowA_fmt (Ale_WARNING,Txt_Already_existed_an_assignment_with_the_title_X, + NewAsg.Title); } else // Title is correct { @@ -1365,16 +1349,15 @@ void Asg_RecFormAssignment (void) if (Asg_CheckIfSimilarAssignmentExists ("Folder",NewAsg.Folder,NewAsg.AsgCod)) // If folder of assignment was in database... { NewAssignmentIsCorrect = false; - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Already_existed_an_assignment_with_the_folder_X, - NewAsg.Folder); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); + + Ale_ShowA_fmt (Ale_WARNING,Txt_Already_existed_an_assignment_with_the_folder_X, + NewAsg.Folder); } } else // Folder name not valid { NewAssignmentIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); + Ale_ShowA_new (Ale_WARNING,Gbl.AlertToShowLater.Txt); } } else // NewAsg.SendWork == Asg_DO_NOT_SEND_WORK @@ -1384,7 +1367,7 @@ void Asg_RecFormAssignment (void) if (Brw_CheckIfExistsFolderAssigmentForAnyUsr (OldAsg.Folder)) { NewAssignmentIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_disable_file_uploading_once_folders_have_been_created); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_can_not_disable_file_uploading_once_folders_have_been_created); } } } @@ -1393,7 +1376,7 @@ void Asg_RecFormAssignment (void) else // If there is not an assignment title { NewAssignmentIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_assignment); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_title_of_the_assignment); } /***** Create a new assignment or update an existing one *****/ @@ -1407,10 +1390,8 @@ void Asg_RecFormAssignment (void) Asg_CreateAssignment (&NewAsg,Description); // Add new assignment to database /***** Write success message *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Created_new_assignment_X, - NewAsg.Title); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Created_new_assignment_X, + NewAsg.Title); } else { @@ -1422,7 +1403,7 @@ void Asg_RecFormAssignment (void) Asg_UpdateAssignment (&NewAsg,Description); /***** Write success message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_The_assignment_has_been_modified); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_assignment_has_been_modified); } } diff --git a/swad_attendance.c b/swad_attendance.c index 2867b28c..c6cfebc5 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -276,7 +276,7 @@ static void Att_ShowAllAttEvents (void) Tbl_EndTable (); } else // No events created - Ale_ShowAlert (Ale_INFO,Txt_No_events); + Ale_ShowA_fmt (Ale_INFO,Txt_No_events); /***** Button to create a new attendance event *****/ if (ICanEdit) @@ -896,11 +896,10 @@ void Att_AskRemAttEvent (void) Grp_PutParamWhichGrps (); Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,Gbl.AttEvents.CurrentPage); - /***** Ask for confirmation of removing *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Do_you_really_want_to_remove_the_event_X, - Att.Title); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); + /* Ask for confirmation of removing */ + Ale_ShowA_fmt (Ale_WARNING,Txt_Do_you_really_want_to_remove_the_event_X, + Att.Title); + Btn_PutRemoveButton (Txt_Remove_event); Frm_EndForm (); @@ -929,10 +928,8 @@ void Att_GetAndRemAttEvent (void) Att_RemoveAttEventFromDB (Att.AttCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Event_X_removed, - Att.Title); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_removed, + Att.Title); /***** Show attendance events again *****/ Att_SeeAttEvents (); @@ -977,10 +974,8 @@ void Att_HideAttEvent (void) Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Event_X_is_now_hidden, - Att.Title); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_hidden, + Att.Title); /***** Show attendance events again *****/ Att_SeeAttEvents (); @@ -1009,10 +1004,8 @@ void Att_ShowAttEvent (void) Att.AttCod,Gbl.CurrentCrs.Crs.CrsCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Event_X_is_now_visible, - Att.Title); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Event_X_is_now_visible, + Att.Title); /***** Show attendance events again *****/ Att_SeeAttEvents (); @@ -1296,16 +1289,15 @@ void Att_RecFormAttEvent (void) if (Att_CheckIfSimilarAttEventExists ("Title",ReceivedAtt.Title,ReceivedAtt.AttCod)) { ReceivedAttEventIsCorrect = false; - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Already_existed_an_event_with_the_title_X, - ReceivedAtt.Title); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); + + Ale_ShowA_fmt (Ale_WARNING,Txt_Already_existed_an_event_with_the_title_X, + ReceivedAtt.Title); } } else // If there is not an attendance event title { ReceivedAttEventIsCorrect = false; - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event); } /***** Create a new attendance event or update an existing one *****/ @@ -1320,17 +1312,15 @@ void Att_RecFormAttEvent (void) Att_CreateAttEvent (&ReceivedAtt,Description); // Add new attendance event to database /***** Write success message *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Created_new_event_X, - ReceivedAtt.Title); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Created_new_event_X, + ReceivedAtt.Title); } else { Att_UpdateAttEvent (&ReceivedAtt,Description); /***** Write success message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_event_has_been_modified); } /* Free memory for list of selected groups */ @@ -2292,7 +2282,7 @@ void Att_RegisterMeAsStdInAttEvent (void) Att_RemoveUsrFromAttEvent (Att.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod); /***** Write final message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Your_comment_has_been_updated); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Your_comment_has_been_updated); } /***** Show the attendance event again *****/ @@ -2417,12 +2407,10 @@ void Att_RegisterStudentsInAttEvent (void) Usr_FreeUsrsList (Rol_STD); /***** Write final message *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - "%s: %u
" - "%s: %u", - Txt_Presents,NumStdsPresent, - Txt_Absents ,NumStdsAbsent ); - Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_INFO,"%s: %u
" + "%s: %u", + Txt_Presents,NumStdsPresent, + Txt_Absents ,NumStdsAbsent ); } else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 /***** Show warning indicating no students found *****/ @@ -2928,7 +2916,7 @@ static void Usr_ListOrPrintStdsAttendanceCrs (Att_TypeOfView_t TypeOfView) } else // No students selected { - Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_students); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_select_one_ore_more_students); Usr_ReqListStdsAttendanceCrs (); // ...show again the form } diff --git a/swad_banner.c b/swad_banner.c index 88c87aa5..3d7227c9 100644 --- a/swad_banner.c +++ b/swad_banner.c @@ -25,9 +25,7 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -#define _GNU_SOURCE // For asprintf #include // For NULL -#include // For asprintf #include // For calloc #include // For string functions @@ -113,7 +111,7 @@ void Ban_SeeBanners (void) if (Gbl.Banners.Num) // There are banners Ban_WriteListOfBanners (); else // No banners created - Ale_ShowAlert (Ale_INFO,Txt_No_banners); + Ale_ShowA_fmt (Ale_INFO,Txt_No_banners); /***** Button to create banner *****/ if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) @@ -523,10 +521,8 @@ void Ban_RemoveBanner (void) Ban.BanCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Banner_X_removed, - Ban.ShrtName); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Banner_X_removed, + Ban.ShrtName); /***** Show the form again *****/ Ban_EditBanners (); @@ -579,11 +575,9 @@ static void Ban_ShowOrHideBanner (bool Hide) Ban.BanCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Hide ? Txt_The_banner_X_is_now_hidden : - Txt_The_banner_X_is_now_visible, - Ban.ShrtName); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Hide ? Txt_The_banner_X_is_now_hidden : + Txt_The_banner_X_is_now_visible, + Ban.ShrtName); /***** Show the form again *****/ Ban_EditBanners (); @@ -654,12 +648,8 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Check if new name is empty *****/ if (!NewBanName[0]) - { - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_You_can_not_leave_the_name_of_the_banner_X_empty, - CurrentBanName); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); - } + Ale_ShowA_fmt (Ale_WARNING,Txt_You_can_not_leave_the_name_of_the_banner_X_empty, + CurrentBanName); else { /***** Check if old and new names are the same @@ -668,31 +658,21 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) { /***** If banner was in database... *****/ if (Ban_CheckIfBannerNameExists (ParamName,NewBanName,Ban->BanCod)) - { - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_banner_X_already_exists, - NewBanName); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); - } + Ale_ShowA_fmt (Ale_WARNING,Txt_The_banner_X_already_exists, + NewBanName); else { /* Update the table changing old name by new name */ Ban_UpdateBanNameDB (Ban->BanCod,FieldName,NewBanName); /* Write message to show the change made */ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_banner_X_has_been_renamed_as_Y, - CurrentBanName,NewBanName); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_banner_X_has_been_renamed_as_Y, + CurrentBanName,NewBanName); } } else // The same name - { - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_name_of_the_banner_X_has_not_changed, - CurrentBanName); - Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); - } + Ale_ShowA_fmt (Ale_INFO,Txt_The_name_of_the_banner_X_has_not_changed, + CurrentBanName); } /***** Show the form again *****/ @@ -759,13 +739,11 @@ void Ban_ChangeBannerImg (void) NewImg,Ban->BanCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_new_image_is_X, - NewImg); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_new_image_is_X, + NewImg); } else - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_image_empty); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_can_not_leave_the_image_empty); /***** Show the form again *****/ Str_Copy (Ban->Img,NewImg, @@ -804,13 +782,11 @@ void Ban_ChangeBannerWWW (void) NewWWW,Ban->BanCod); /***** Write message to show the change made *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_new_web_address_is_X, - NewWWW); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_The_new_web_address_is_X, + NewWWW); } else - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); /***** Show the form again *****/ Str_Copy (Ban->WWW,NewWWW, @@ -950,28 +926,20 @@ void Ban_RecFormNewBanner (void) { /***** If name of banner was in database... *****/ if (Ban_CheckIfBannerNameExists ("ShortName",Ban->ShrtName,-1L)) - { - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_banner_X_already_exists, - Ban->ShrtName); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); - } + Ale_ShowA_fmt (Ale_WARNING,Txt_The_banner_X_already_exists, + Ban->ShrtName); else if (Ban_CheckIfBannerNameExists ("FullName",Ban->FullName,-1L)) - { - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_The_banner_X_already_exists, - Ban->FullName); - Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt); - } + Ale_ShowA_fmt (Ale_WARNING,Txt_The_banner_X_already_exists, + Ban->FullName); else if (!Ban->Img[0]) - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_image_of_the_new_banner); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_image_of_the_new_banner); else if (!Ban->WWW[0]) - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_URL_of_the_new_banner); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_URL_of_the_new_banner); else // Add new banner to database Ban_CreateBanner (Ban); } else // If there is not a banner name - Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_banner); + Ale_ShowA_fmt (Ale_WARNING,Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_banner); /***** Show the form again *****/ Ban_EditBanners (); @@ -994,10 +962,8 @@ static void Ban_CreateBanner (struct Banner *Ban) Ban->ShrtName,Ban->FullName,Ban->Img,Ban->WWW); /***** Write success message *****/ - snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), - Txt_Created_new_banner_X, - Ban->ShrtName); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_fmt (Ale_SUCCESS,Txt_Created_new_banner_X, + Ban->ShrtName); } /*****************************************************************************/ diff --git a/swad_centre.c b/swad_centre.c index 13c28f74..4af465a2 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -225,7 +225,7 @@ void Ctr_SeeCtrWithPendingDegs (void) Box_EndBoxTable (); } else - Ale_ShowAlert (Ale_INFO,Txt_There_are_no_centres_with_requests_for_degrees_to_be_confirmed); + Ale_ShowA_old (Ale_INFO,Txt_There_are_no_centres_with_requests_for_degrees_to_be_confirmed); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -816,7 +816,7 @@ static void Ctr_ListCentres (void) Tbl_EndTable (); } else // No centres created in the current institution - Ale_ShowAlert (Ale_INFO,Txt_No_centres); + Ale_ShowA_old (Ale_INFO,Txt_No_centres); /***** Button to create centre *****/ if (Ctr_CheckIfICanCreateCentres ()) @@ -1766,7 +1766,7 @@ void Ctr_RemoveCentre (void) if (Ctr.Degs.Num || Ctr.NumUsrsWhoClaimToBelongToCtr || Ctr.NumUsrs) // Centre has degrees or users ==> don't remove - Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre); + Ale_ShowA_old (Ale_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre); else // Centre has no teachers ==> remove it { /***** Remove all the threads and posts in forums of the centre *****/ @@ -1798,7 +1798,7 @@ void Ctr_RemoveCentre (void) snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), Txt_Centre_X_removed, Ctr.FullName); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_old (Ale_SUCCESS,Gbl.Alert.Txt); } /***** Show the form again *****/ @@ -1935,7 +1935,7 @@ void Ctr_ChangeCtrPlcInConfig (void) Gbl.CurrentCtr.Ctr.PlcCod = NewPlcCod; /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_The_place_of_the_centre_has_changed); + Ale_ShowA_old (Ale_SUCCESS,Txt_The_place_of_the_centre_has_changed); /***** Show the form again *****/ Ctr_ShowConfiguration (); @@ -2130,7 +2130,7 @@ void Ctr_ChangeCtrWWW (void) Ctr_ShowAlertAndButtonToGoToCtr (); } else - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); + Ale_ShowA_old (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); /***** Show the form again *****/ Ctr_EditCentres (); @@ -2158,10 +2158,10 @@ void Ctr_ChangeCtrWWWInConfig (void) snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), Txt_The_new_web_address_is_X, NewWWW); - Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); + Ale_ShowA_old (Ale_SUCCESS,Gbl.Alert.Txt); } else - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); + Ale_ShowA_old (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty); /***** Show the form again *****/ Ctr_ShowConfiguration (); @@ -2263,7 +2263,7 @@ static void Ctr_ShowAlertAndButtonToGoToCtr (void) } else /***** Alert *****/ - Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt); + Ale_ShowA_old (Gbl.Alert.Type,Gbl.Alert.Txt); } static void Ctr_PutParamGoToCtr (void) @@ -2328,7 +2328,7 @@ void Ctr_RequestPhoto (void) Ctr_PHOTO_SAVED_MAX_WIDTH, Ctr_PHOTO_SAVED_MAX_HEIGHT, Txt_XxY_pixels_or_higher); - Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); + Ale_ShowA_old (Ale_INFO,Gbl.Alert.Txt); /***** Upload photo *****/ fprintf (Gbl.F.Out,"