From 49d5db793d69693d228594a1a0c5747b0e7ccd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 10 Mar 2019 00:34:16 +0100 Subject: [PATCH] Version18.69.2 --- swad_alert.c | 61 +++++++++++++++++++++++++++++++++++++++--------- swad_alert.h | 2 +- swad_changelog.h | 3 ++- swad_enrolment.c | 13 ++++++----- swad_follow.c | 10 +++++--- 5 files changed, 67 insertions(+), 22 deletions(-) diff --git a/swad_alert.c b/swad_alert.c index 562c5328f..d378765bd 100644 --- a/swad_alert.c +++ b/swad_alert.c @@ -137,7 +137,7 @@ const char *Ale_GetTextOfLastAlert (void) } /*****************************************************************************/ -/******************************* Reset alerts ********************************/ +/***************************** Reset all alerts ******************************/ /*****************************************************************************/ void Ale_ResetAllAlerts (void) @@ -150,12 +150,20 @@ void Ale_ResetAllAlerts (void) Ale_ResetAlert (i); } +/*****************************************************************************/ +/************************* Reset more recent alert ***************************/ +/*****************************************************************************/ + static void Ale_ResetLastAlert (void) { if (Gbl.Alerts.Num) // There are pending alerts no shown Ale_ResetAlert (Gbl.Alerts.Num - 1); // Reset the last one } +/*****************************************************************************/ +/********************* Reset one alert given its index ***********************/ +/*****************************************************************************/ + static void Ale_ResetAlert (size_t i) { bool NoMoreAlertsPending; @@ -201,7 +209,7 @@ void Ale_ShowAlertsAndExit () } /*****************************************************************************/ -/**************************** Show alert messages ****************************/ +/****** Show several alert messages stored in vector of delayed alerts *******/ /*****************************************************************************/ // If Section == NULL ==> show all alerts // If Section != NULL ==> shown only the alerts assigned to Section @@ -228,6 +236,10 @@ void Ale_ShowAlerts (const char *Section) } } +/*****************************************************************************/ +/****************** Show one formatted-text alert message ********************/ +/*****************************************************************************/ + void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *fmt,...) { va_list ap; @@ -253,6 +265,10 @@ void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *fmt,...) } } +/*****************************************************************************/ +/********************** Show one fix-text alert message **********************/ +/*****************************************************************************/ + static void Ale_ShowFixAlert (Ale_AlertType_t AlertType,const char *Txt) { if (AlertType != Ale_NONE) @@ -264,6 +280,10 @@ static void Ale_ShowFixAlert (Ale_AlertType_t AlertType,const char *Txt) } } +/*****************************************************************************/ +/**************** Show the more recent alert with a button *******************/ +/*****************************************************************************/ + void Ale_ShowLastAlertAndButton (Act_Action_t NextAction,const char *Anchor, const char *OnSubmit,void (*FuncParams) (), Btn_Button_t Button,const char *TxtButton) @@ -276,6 +296,23 @@ void Ale_ShowLastAlertAndButton (Act_Action_t NextAction,const char *Anchor, FuncParams,Button,TxtButton); } +/*****************************************************************************/ +/********** Show the first part of more recent alert with a button ***********/ +/*****************************************************************************/ + +void Ale_ShowLastAlertAndButton1 (void) + { + /***** Show last alert *****/ + Ale_ShowFixAlertAndButton1 (Ale_GetTypeOfLastAlert (),Ale_GetTextOfLastAlert ()); + + /***** Reset last alert *****/ + Ale_ResetLastAlert (); + } + +/*****************************************************************************/ +/*********************** Show an alert with a button *************************/ +/*****************************************************************************/ + void Ale_ShowAlertAndButton (Act_Action_t NextAction,const char *Anchor, const char *OnSubmit,void (*FuncParams) (), Btn_Button_t Button,const char *TxtButton, @@ -303,14 +340,9 @@ void Ale_ShowAlertAndButton (Act_Action_t NextAction,const char *Anchor, free ((void *) Txt); } -void Ale_ShowLastAlertAndButton1 (void) - { - /***** Show last alert *****/ - Ale_ShowFixAlertAndButton1 (Ale_GetTypeOfLastAlert (),Ale_GetTextOfLastAlert ()); - - /***** Reset last alert *****/ - Ale_ResetLastAlert (); - } +/*****************************************************************************/ +/******** Show the first part of a formatted-text alert with a button ********/ +/*****************************************************************************/ void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *fmt,...) { @@ -334,6 +366,10 @@ void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *fmt,...) free ((void *) Txt); } +/*****************************************************************************/ +/*********** Show the first part of a fix-text alert with a button ***********/ +/*****************************************************************************/ + static void Ale_ShowFixAlertAndButton1 (Ale_AlertType_t AlertType,const char *Txt) { extern const char *Txt_Close; @@ -388,6 +424,10 @@ static void Ale_ShowFixAlertAndButton1 (Ale_AlertType_t AlertType,const char *Tx Txt); } +/*****************************************************************************/ +/*************** Show the second part of an alert with a button **************/ +/*****************************************************************************/ + void Ale_ShowAlertAndButton2 (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit, void (*FuncParams) (), Btn_Button_t Button,const char *TxtButton) @@ -438,4 +478,3 @@ void Ale_ShowAlertUserNotFoundOrYouDoNotHavePermission (void) Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } - diff --git a/swad_alert.h b/swad_alert.h index e327ab2ad..55b49a2d1 100644 --- a/swad_alert.h +++ b/swad_alert.h @@ -72,11 +72,11 @@ void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *fmt,...); void Ale_ShowLastAlertAndButton (Act_Action_t NextAction,const char *Anchor, const char *OnSubmit,void (*FuncParams) (), Btn_Button_t Button,const char *TxtButton); +void Ale_ShowLastAlertAndButton1 (void); void Ale_ShowAlertAndButton (Act_Action_t NextAction,const char *Anchor, const char *OnSubmit,void (*FuncParams) (), Btn_Button_t Button,const char *TxtButton, Ale_AlertType_t AlertType,const char *fmt,...); -void Ale_ShowLastAlertAndButton1 (void); void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *fmt,...); void Ale_ShowAlertAndButton2 (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit, void (*FuncParams) (), diff --git a/swad_changelog.h b/swad_changelog.h index 7a1b3c571..7962153aa 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -447,10 +447,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.69.1 (2019-03-09)" +#define Log_PLATFORM_VERSION "SWAD 18.69.2 (2019-03-10)" #define CSS_FILE "swad18.68.3.css" #define JS_FILE "swad18.64.js" /* + Version 18.69.2: Mar 10, 2019 Changes related to alerts. (238842 lines) Version 18.69.1: Mar 09, 2019 Changes in forms to register/remove users. (238805 lines) Version 18.69: Mar 09, 2019 Code refactoring related to alerts. (238779 lines) Version 18.68.3: Mar 08, 2019 Changes in styles of connected users. diff --git a/swad_enrolment.c b/swad_enrolment.c index 3138e8ed2..1ed08e58d 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -3808,8 +3808,9 @@ void Enr_CreateNewUsr2 (void) Ale_ShowAlerts (NULL); else // User's ID valid { - if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected - Ale_ShowAlerts (NULL); + // if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected + /***** Show possible alerts *****/ + Ale_ShowAlerts (NULL); /***** Show user's record *****/ Rec_ShowSharedRecordUnmodifiable (&Gbl.Usrs.Other.UsrDat); @@ -3980,10 +3981,10 @@ void Enr_ModifyUsr2 (void) { if (Ale_GetTypeOfLastAlert () == Ale_WARNING) { - /* Show possible alerts */ + /***** Show possible alerts *****/ Ale_ShowAlerts (NULL); - /* Show form to edit user again */ + /***** Show form to edit user again *****/ Enr_ShowFormToEditOtherUsr (); } else // No error @@ -3991,10 +3992,10 @@ void Enr_ModifyUsr2 (void) { case Enr_REGISTER_MODIFY_ONE_USR_IN_CRS: // if (Gbl.CurrentCrs.Crs.CrsCod > 0) - /* Show possible alerts */ + /***** Show possible alerts *****/ Ale_ShowAlerts (NULL); - /* Show form to edit user again */ + /***** Show form to edit user again *****/ Enr_ShowFormToEditOtherUsr (); break; case Enr_REGISTER_ONE_DEGREE_ADMIN: diff --git a/swad_follow.c b/swad_follow.c index 62819ca71..c31d0ac08 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -1054,11 +1054,15 @@ void Fol_FollowUsr1 (void) void Fol_FollowUsr2 (void) { if (Ale_GetTypeOfLastAlert () == Ale_SUCCESS) + { /***** Show user's profile again *****/ if (!Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat)) - Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission (); - - if (Ale_GetTypeOfLastAlert () != Ale_SUCCESS) + /* 1) I had permission to follow the user and I've just follow him/her + 2) User restricted permission, so now I can not view his/her profile + 3) Now I can not view his/her profile ==> show users I follow */ + Fol_ListFollowingUsr (&Gbl.Usrs.Me.UsrDat); // List users I follow + } + else Ale_ShowAlerts (NULL); }