diff --git a/swad_agenda.c b/swad_agenda.c
index 4afb0f5e1..de067fb7a 100644
--- a/swad_agenda.c
+++ b/swad_agenda.c
@@ -1298,15 +1298,12 @@ void Agd_AskRemEvent (void)
Agd_GetDataOfEventByCod (&AgdEvent);
/***** Show question and button to remove event *****/
- /* Start alert */
+ Gbl.Agenda.AgdCodToEdit = AgdEvent.AgdCod;
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_event_X,
AgdEvent.Event);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Gbl.Agenda.AgdCodToEdit = AgdEvent.AgdCod;
- Lay_ShowAlertAndButton2 (ActRemEvtMyAgd,NULL,Agd_PutCurrentParamsMyAgenda,
- Lay_REMOVE_BUTTON,Txt_Remove_event);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemEvtMyAgd,NULL,Agd_PutCurrentParamsMyAgenda,
+ Lay_REMOVE_BUTTON,Txt_Remove_event);
/***** Show events again *****/
Agd_ShowMyAgenda ();
diff --git a/swad_assignment.c b/swad_assignment.c
index 4c94bcc60..276b5dc56 100644
--- a/swad_assignment.c
+++ b/swad_assignment.c
@@ -969,15 +969,12 @@ void Asg_ReqRemAssignment (void)
Asg_GetDataOfAssignmentByCod (&Asg);
/***** Show question and button to remove the assignment *****/
- /* Start alert */
+ Gbl.Asgs.AsgCodToEdit = Asg.AsgCod;
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_assignment_X,
Asg.Title);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Gbl.Asgs.AsgCodToEdit = Asg.AsgCod;
- Lay_ShowAlertAndButton2 (ActRemAsg,NULL,Asg_PutParams,
- Lay_REMOVE_BUTTON,Txt_Remove_assignment);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemAsg,NULL,Asg_PutParams,
+ Lay_REMOVE_BUTTON,Txt_Remove_assignment);
/***** Show assignments again *****/
Asg_SeeAssignments ();
diff --git a/swad_centre.c b/swad_centre.c
index b625ccb8a..9869dc07e 100644
--- a/swad_centre.c
+++ b/swad_centre.c
@@ -2166,20 +2166,18 @@ static void Ctr_ShowAlertAndButtonToGoToCtr (void)
{
extern const char *Txt_Go_to_X;
- /***** 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)
{
- /***** Put button to go to centre and end alert *****/
+ /***** Alert with button to go to centre *****/
sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Ctrs.EditingCtr.ShrtName);
- Lay_ShowAlertAndButton2 (ActSeeDeg,NULL,Ctr_PutParamGoToCtr,
- Lay_CONFIRM_BUTTON,Gbl.Title);
+ Lay_ShowAlertAndButton (Gbl.Alert.Type,Gbl.Alert.Txt,
+ ActSeeDeg,NULL,Ctr_PutParamGoToCtr,
+ Lay_CONFIRM_BUTTON,Gbl.Title);
}
else
- /***** End alert *****/
- Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
+ /***** Alert *****/
+ Lay_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
}
static void Ctr_PutParamGoToCtr (void)
diff --git a/swad_changelog.h b/swad_changelog.h
index acc36a84b..bc8bd518c 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -235,13 +235,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.213 (2017-05-10)"
+#define Log_PLATFORM_VERSION "SWAD 16.214 (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.214: May 11, 2017 Changes in edition of institutions.
+ Code refactoring related to alerts. (218867 lines)
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)
diff --git a/swad_degree.c b/swad_degree.c
index 310af11b2..b9fac91b1 100644
--- a/swad_degree.c
+++ b/swad_degree.c
@@ -2266,20 +2266,18 @@ void Deg_ShowAlertAndButtonToGoToDeg (void)
{
extern const char *Txt_Go_to_X;
- /***** Start alert *****/
- Lay_ShowAlertAndButton1 (Gbl.Alert.Type,Gbl.Alert.Txt);
-
// If the degree being edited is different to the current one...
if (Gbl.Degs.EditingDeg.DegCod != Gbl.CurrentDeg.Deg.DegCod)
{
- /***** Put button to go to degree and end alert *****/
+ /***** Alert with button to go to degree *****/
sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Degs.EditingDeg.ShrtName);
- Lay_ShowAlertAndButton2 (ActSeeCrs,NULL,Deg_PutParamGoToDeg,
- Lay_CONFIRM_BUTTON,Gbl.Title);
+ Lay_ShowAlertAndButton (Gbl.Alert.Type,Gbl.Alert.Txt,
+ ActSeeCrs,NULL,Deg_PutParamGoToDeg,
+ Lay_CONFIRM_BUTTON,Gbl.Title);
}
else
- /***** End alert *****/
- Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
+ /***** Alert *****/
+ Lay_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
}
static void Deg_PutParamGoToDeg (void)
diff --git a/swad_file_browser.c b/swad_file_browser.c
index ba621c01e..e5c10f9e0 100644
--- a/swad_file_browser.c
+++ b/swad_file_browser.c
@@ -6184,20 +6184,17 @@ void Brw_AskRemFileFromTree (void)
if (Brw_CheckIfICanEditFileOrFolder (Gbl.FileBrowser.Level)) // Can I remove this file?
{
/***** Show question and button to remove file/link *****/
- /* Start alert */
Brw_GetFileNameToShowDependingOnLevel (Gbl.FileBrowser.FileType,Gbl.FileBrowser.Level,
Gbl.FileBrowser.FileType,
Gbl.FileBrowser.FilFolLnkName,FileNameToShow);
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_FILE_OR_LINK_X,
FileNameToShow);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (Brw_ActRemoveFile[Gbl.FileBrowser.Type],NULL,
- Brw_PutParamsRemFile,
- Lay_REMOVE_BUTTON,
- Gbl.FileBrowser.FileType == Brw_IS_FILE ? Txt_Remove_file :
- Txt_Remove_link);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ Brw_ActRemoveFile[Gbl.FileBrowser.Type],NULL,
+ Brw_PutParamsRemFile,
+ Lay_REMOVE_BUTTON,
+ Gbl.FileBrowser.FileType == Brw_IS_FILE ? Txt_Remove_file :
+ Txt_Remove_link);
}
else
Lay_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
@@ -6335,15 +6332,12 @@ static void Brw_AskConfirmRemoveFolderNotEmpty (void)
extern const char *Txt_Remove_folder;
/***** Show question and button to remove not empty folder *****/
- /* Start alert */
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_folder_X,
Gbl.FileBrowser.FilFolLnkName);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (Brw_ActRemoveFolderNotEmpty[Gbl.FileBrowser.Type],NULL,
- Brw_PutParamsRemFolder,
- Lay_REMOVE_BUTTON,Txt_Remove_folder);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ Brw_ActRemoveFolderNotEmpty[Gbl.FileBrowser.Type],NULL,
+ Brw_PutParamsRemFolder,
+ Lay_REMOVE_BUTTON,Txt_Remove_folder);
}
/*****************************************************************************/
diff --git a/swad_forum.c b/swad_forum.c
index 10be10022..1b490983d 100644
--- a/swad_forum.c
+++ b/swad_forum.c
@@ -4105,22 +4105,18 @@ void For_RequestRemoveThread (void)
For_ShowForumList ();
/***** Show question and button to remove the thread *****/
- /* Start alert */
fprintf (Gbl.F.Out,"",For_ID_REMOVE_THREAD_SECTION);
if (Subject[0])
- {
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_entire_thread_X,
Subject);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
- }
else
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (For_ActionsDelThrFor[Gbl.Forum.ForumSelected.Type],
- For_ID_FORUM_THREADS_SECTION,
- For_PutAllHiddenParamsRemThread,
- Lay_REMOVE_BUTTON,Txt_Remove_thread);
+ sprintf (Gbl.Alert.Txt,"%s",
+ Txt_Do_you_really_want_to_remove_the_entire_thread);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ For_ActionsDelThrFor[Gbl.Forum.ForumSelected.Type],
+ For_ID_FORUM_THREADS_SECTION,
+ For_PutAllHiddenParamsRemThread,
+ Lay_REMOVE_BUTTON,Txt_Remove_thread);
fprintf (Gbl.F.Out,"");
/***** Show the threads again *****/
diff --git a/swad_group.c b/swad_group.c
index 0370b79bb..97d35433b 100644
--- a/swad_group.c
+++ b/swad_group.c
@@ -3502,19 +3502,16 @@ static void Grp_AskConfirmRemGrpTypWithGrps (unsigned NumGrps)
Grp_ReqEditGroupsInternal0 ();
/***** Show question and button to remove type of group *****/
- /* Start alert */
if (NumGrps == 1)
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_type_of_group_X_1_group_,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName);
else
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_type_of_group_X_Y_groups_,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,NumGrps);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (ActRemGrpTyp,Grp_SECTION_GROUP_TYPES,
- Grp_PutParamRemGrpTyp,
- Lay_REMOVE_BUTTON,Txt_Remove_type_of_group);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemGrpTyp,Grp_SECTION_GROUP_TYPES,
+ Grp_PutParamRemGrpTyp,
+ Lay_REMOVE_BUTTON,Txt_Remove_type_of_group);
/***** Show the form to edit group types and groups again *****/
Grp_ReqEditGroupsInternal1 (Lay_INFO,NULL);
@@ -3555,7 +3552,6 @@ static void Grp_AskConfirmRemGrp (void)
Grp_ReqEditGroupsInternal1 (Lay_INFO,NULL);
/***** Show question and button to remove group *****/
- /* Start alert */
if (NumStds == 0)
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_group_X,
GrpDat.GrpName);
@@ -3565,11 +3561,9 @@ static void Grp_AskConfirmRemGrp (void)
else
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_group_X_Y_students_,
GrpDat.GrpName,NumStds);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (ActRemGrp,Grp_SECTION_GROUPS,Grp_PutParamRemGrp,
- Lay_REMOVE_BUTTON,Txt_Remove_group);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemGrp,Grp_SECTION_GROUPS,Grp_PutParamRemGrp,
+ Lay_REMOVE_BUTTON,Txt_Remove_group);
/***** Show the form to edit groups again *****/
Grp_ReqEditGroupsInternal2 (Lay_INFO,NULL);
diff --git a/swad_institution.c b/swad_institution.c
index c8697d2b1..df2206f00 100644
--- a/swad_institution.c
+++ b/swad_institution.c
@@ -94,12 +94,13 @@ static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *N
static void Ins_UpdateInsCtyDB (long InsCod,long CtyCod);
static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
-static void Ins_PutButtonToGoToIns (struct Instit *Ins);
+static void Ins_ShowAlertAndButtonToGoToIns (void);
+static void Ins_PutParamGoToIns (void);
static void Ins_PutFormToCreateInstitution (void);
static void Ins_PutHeadInstitutionsForEdition (void);
static void Ins_RecFormRequestOrCreateIns (unsigned Status);
-static void Ins_CreateInstitution (struct Instit *Ins,unsigned Status);
+static void Ins_CreateInstitution (unsigned Status);
/*****************************************************************************/
/***************** List institutions with pending centres ********************/
@@ -1950,35 +1951,31 @@ void Ins_ChangeInsWWW (void)
{
extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_You_can_not_leave_the_web_address_empty;
- struct Instit *Ins;
char NewWWW[Cns_MAX_BYTES_WWW + 1];
- Ins = &Gbl.Inss.EditingIns;
-
/***** Get parameters from form *****/
/* Get the code of the institution */
- Ins->InsCod = Ins_GetAndCheckParamOtherInsCod ();
+ Gbl.Inss.EditingIns.InsCod = Ins_GetAndCheckParamOtherInsCod ();
/* Get the new WWW for the institution */
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
/***** Get data of institution *****/
- Ins_GetDataOfInstitutionByCod (Ins,Ins_GET_BASIC_DATA);
+ Ins_GetDataOfInstitutionByCod (&Gbl.Inss.EditingIns,Ins_GET_BASIC_DATA);
/***** Check if new WWW is empty *****/
if (NewWWW[0])
{
/***** Update database changing old WWW by new WWW *****/
- Ins_UpdateInsWWWDB (Ins->InsCod,NewWWW);
- Str_Copy (Ins->WWW,NewWWW,
+ Ins_UpdateInsWWWDB (Gbl.Inss.EditingIns.InsCod,NewWWW);
+ Str_Copy (Gbl.Inss.EditingIns.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 institution 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 institution changed *****/
- Ins_PutButtonToGoToIns (Ins);
+ Ins_ShowAlertAndButtonToGoToIns ();
}
else
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
@@ -2037,16 +2034,13 @@ static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW
void Ins_ChangeInsStatus (void)
{
extern const char *Txt_The_status_of_the_institution_X_has_changed;
- struct Instit *Ins;
char Query[128];
Ins_Status_t Status;
Ins_StatusTxt_t StatusTxt;
- Ins = &Gbl.Inss.EditingIns;
-
/***** Get parameters from form *****/
/* Get institution code */
- Ins->InsCod = Ins_GetAndCheckParamOtherInsCod ();
+ Gbl.Inss.EditingIns.InsCod = Ins_GetAndCheckParamOtherInsCod ();
/* Get parameter with status */
Status = (Ins_Status_t)
@@ -2060,22 +2054,20 @@ void Ins_ChangeInsStatus (void)
Status = Ins_GetStatusBitsFromStatusTxt (StatusTxt); // New status
/***** Get data of institution *****/
- Ins_GetDataOfInstitutionByCod (Ins,Ins_GET_BASIC_DATA);
+ Ins_GetDataOfInstitutionByCod (&Gbl.Inss.EditingIns,Ins_GET_BASIC_DATA);
/***** Update status in table of institutions *****/
sprintf (Query,"UPDATE institutions SET Status=%u WHERE InsCod=%ld",
- (unsigned) Status,Ins->InsCod);
+ (unsigned) Status,Gbl.Inss.EditingIns.InsCod);
DB_QueryUPDATE (Query,"can not update the status of an institution");
+ Gbl.Inss.EditingIns.Status = Status;
- Ins->Status = Status;
-
- /***** Write message to show the change made *****/
+ /***** Write message to show the change made
+ and put button to go to institution changed *****/
+ Gbl.Alert.Type = Lay_SUCCESS;
sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_institution_X_has_changed,
- Ins->ShrtName);
- Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
-
- /***** Put button to go to institution changed *****/
- Ins_PutButtonToGoToIns (Ins);
+ Gbl.Inss.EditingIns.ShrtName);
+ Ins_ShowAlertAndButtonToGoToIns ();
/***** Show the form again *****/
Ins_EditInstitutions ();
@@ -2087,36 +2079,42 @@ void Ins_ChangeInsStatus (void)
void Ins_ContEditAfterChgIns (void)
{
- /***** Write success / warning message *****/
- Lay_ShowPendingAlert ();
-
- if (Gbl.Alert.Type == Lay_SUCCESS)
- /***** Put button to go to institution changed *****/
- Ins_PutButtonToGoToIns (&Gbl.Inss.EditingIns);
+ /***** Write message to show the change made
+ and put button to go to institution changed *****/
+ Ins_ShowAlertAndButtonToGoToIns ();
/***** Show the form again *****/
Ins_EditInstitutions ();
}
/*****************************************************************************/
-/********************* Put button to go to institution ***********************/
+/*************** Write message to show the change made *****************/
+/*************** and put button to go to institution changed *****************/
/*****************************************************************************/
+// Gbl.Degs.EditingDeg is the degree that is beeing edited
+// Gbl.CurrentDeg.Deg is the current degree
-static void Ins_PutButtonToGoToIns (struct Instit *Ins)
+static void Ins_ShowAlertAndButtonToGoToIns (void)
{
extern const char *Txt_Go_to_X;
- // If the institution is different to the current one...
- if (Ins->InsCod != Gbl.CurrentIns.Ins.InsCod)
+ // If the institution beeing edited is different to the current one...
+ if (Gbl.Inss.EditingIns.InsCod != Gbl.CurrentIns.Ins.InsCod)
{
- fprintf (Gbl.F.Out,"
");
- Act_FormStart (ActSeeCtr);
- Ins_PutParamInsCod (Ins->InsCod);
- sprintf (Gbl.Title,Txt_Go_to_X,Ins->ShrtName);
- Lay_PutConfirmButtonInline (Gbl.Title);
- Act_FormEnd ();
- fprintf (Gbl.F.Out,"
");
+ /***** Alert with button to go to degree *****/
+ sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Inss.EditingIns.ShrtName);
+ Lay_ShowAlertAndButton (Gbl.Alert.Type,Gbl.Alert.Txt,
+ ActSeeCtr,NULL,Ins_PutParamGoToIns,
+ Lay_CONFIRM_BUTTON,Gbl.Title);
}
+ else
+ /***** Alert *****/
+ Lay_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
+ }
+
+static void Ins_PutParamGoToIns (void)
+ {
+ Ins_PutParamInsCod (Gbl.Inss.EditingIns.InsCod);
}
/*****************************************************************************/
@@ -2154,10 +2152,6 @@ static void Ins_PutFormToCreateInstitution (void)
{
extern const char *Txt_New_institution;
extern const char *Txt_Create_institution;
- struct Instit *Ins;
-
- /***** Institution data *****/
- Ins = &Gbl.Inss.EditingIns;
/***** Start form *****/
if (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
@@ -2192,7 +2186,7 @@ static void Ins_PutFormToCreateInstitution (void)
" class=\"INPUT_SHORT_NAME\""
" required=\"required\" />"
"",
- Hie_MAX_CHARS_SHRT_NAME,Ins->ShrtName);
+ Hie_MAX_CHARS_SHRT_NAME,Gbl.Inss.EditingIns.ShrtName);
/***** Institution full name *****/
fprintf (Gbl.F.Out,""
@@ -2201,7 +2195,7 @@ static void Ins_PutFormToCreateInstitution (void)
" class=\"INPUT_FULL_NAME\""
" required=\"required\" />"
" | ",
- Hie_MAX_CHARS_FULL_NAME,Ins->FullName);
+ Hie_MAX_CHARS_FULL_NAME,Gbl.Inss.EditingIns.FullName);
/***** Institution WWW *****/
fprintf (Gbl.F.Out,""
@@ -2210,7 +2204,7 @@ static void Ins_PutFormToCreateInstitution (void)
" class=\"INPUT_WWW\""
" required=\"required\" />"
" | ",
- Cns_MAX_CHARS_WWW,Ins->WWW);
+ Cns_MAX_CHARS_WWW,Gbl.Inss.EditingIns.WWW);
/***** Number of users who claim to belong to this institution ****/
fprintf (Gbl.F.Out,""
@@ -2327,42 +2321,40 @@ static void Ins_RecFormRequestOrCreateIns (unsigned Status)
extern const char *Txt_The_institution_X_already_exists;
extern const char *Txt_You_must_specify_the_web_address_of_the_new_institution;
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_institution;
- struct Instit *Ins;
-
- Ins = &Gbl.Inss.EditingIns;
/***** Get parameters from form *****/
/* Set institution country */
- Ins->CtyCod = Gbl.CurrentCty.Cty.CtyCod;
+ Gbl.Inss.EditingIns.CtyCod = Gbl.CurrentCty.Cty.CtyCod;
/* Get institution short name */
- Par_GetParToText ("ShortName",Ins->ShrtName,Hie_MAX_BYTES_SHRT_NAME);
+ Par_GetParToText ("ShortName",Gbl.Inss.EditingIns.ShrtName,Hie_MAX_BYTES_SHRT_NAME);
/* Get institution full name */
- Par_GetParToText ("FullName",Ins->FullName,Hie_MAX_BYTES_FULL_NAME);
+ Par_GetParToText ("FullName",Gbl.Inss.EditingIns.FullName,Hie_MAX_BYTES_FULL_NAME);
/* Get institution WWW */
- Par_GetParToText ("WWW",Ins->WWW,Cns_MAX_BYTES_WWW);
+ Par_GetParToText ("WWW",Gbl.Inss.EditingIns.WWW,Cns_MAX_BYTES_WWW);
- if (Ins->ShrtName[0] && Ins->FullName[0]) // If there's a institution name
+ if (Gbl.Inss.EditingIns.ShrtName[0] &&
+ Gbl.Inss.EditingIns.FullName[0]) // If there's a institution name
{
- if (Ins->WWW[0])
+ if (Gbl.Inss.EditingIns.WWW[0])
{
/***** If name of institution was in database... *****/
- if (Ins_CheckIfInsNameExistsInCty ("ShortName",Ins->ShrtName,-1L,Gbl.CurrentCty.Cty.CtyCod))
+ if (Ins_CheckIfInsNameExistsInCty ("ShortName",Gbl.Inss.EditingIns.ShrtName,-1L,Gbl.CurrentCty.Cty.CtyCod))
{
sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists,
- Ins->ShrtName);
+ Gbl.Inss.EditingIns.ShrtName);
Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt);
}
- else if (Ins_CheckIfInsNameExistsInCty ("FullName",Ins->FullName,-1L,Gbl.CurrentCty.Cty.CtyCod))
+ else if (Ins_CheckIfInsNameExistsInCty ("FullName",Gbl.Inss.EditingIns.FullName,-1L,Gbl.CurrentCty.Cty.CtyCod))
{
sprintf (Gbl.Alert.Txt,Txt_The_institution_X_already_exists,
- Ins->FullName);
+ Gbl.Inss.EditingIns.FullName);
Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt);
}
else // Add new institution to database
- Ins_CreateInstitution (Ins,Status);
+ Ins_CreateInstitution (Status);
}
else // If there is not a web
Lay_ShowAlert (Lay_WARNING,Txt_You_must_specify_the_web_address_of_the_new_institution);
@@ -2377,8 +2369,9 @@ static void Ins_RecFormRequestOrCreateIns (unsigned Status)
/*****************************************************************************/
/************************** Create a new institution *************************/
/*****************************************************************************/
+// Gbl.Inss.EditingIns must hold the institution beeing edited
-static void Ins_CreateInstitution (struct Instit *Ins,unsigned Status)
+static void Ins_CreateInstitution (unsigned Status)
{
extern const char *Txt_Created_new_institution_X;
char Query[512 +
@@ -2391,19 +2384,20 @@ static void Ins_CreateInstitution (struct Instit *Ins,unsigned Status)
" (CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW)"
" VALUES"
" (%ld,%u,%ld,'%s','%s','%s')",
- Ins->CtyCod,
+ Gbl.Inss.EditingIns.CtyCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
- Ins->ShrtName,Ins->FullName,Ins->WWW);
- Ins->InsCod = DB_QueryINSERTandReturnCode (Query,"can not create institution");
+ Gbl.Inss.EditingIns.ShrtName,
+ Gbl.Inss.EditingIns.FullName,
+ Gbl.Inss.EditingIns.WWW);
+ Gbl.Inss.EditingIns.InsCod = DB_QueryINSERTandReturnCode (Query,"can not create institution");
- /***** Write success message *****/
+ /***** Write message to show the change made
+ and put button to go to institution created *****/
+ Gbl.Alert.Type = Lay_SUCCESS;
sprintf (Gbl.Alert.Txt,Txt_Created_new_institution_X,
- Ins->FullName);
- Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
-
- /***** Put button to go to institution created *****/
- Ins_PutButtonToGoToIns (Ins);
+ Gbl.Inss.EditingIns.FullName);
+ Ins_ShowAlertAndButtonToGoToIns ();
}
/*****************************************************************************/
diff --git a/swad_layout.c b/swad_layout.c
index 04524f5e9..e8ea6542c 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -1684,10 +1684,17 @@ void Lay_ShowPendingAlert (void)
void Lay_ShowAlert (Lay_AlertType_t AlertType,const char *Txt)
{
if (AlertType != Lay_NONE)
- {
- Lay_ShowAlertAndButton1 (AlertType,Txt);
- Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
- }
+ Lay_ShowAlertAndButton (AlertType,Txt,
+ ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
+ }
+
+void Lay_ShowAlertAndButton (Lay_AlertType_t AlertType,const char *Txt,
+ Act_Action_t NextAction,const char *Anchor,
+ void (*FuncParams) (),
+ Lay_Button_t Button,const char *TxtButton)
+ {
+ Lay_ShowAlertAndButton1 (AlertType,Txt);
+ Lay_ShowAlertAndButton2 (NextAction,Anchor,FuncParams,Button,TxtButton);
}
void Lay_ShowAlertAndButton1 (Lay_AlertType_t AlertType,const char *Txt)
diff --git a/swad_layout.h b/swad_layout.h
index 8cba680f7..e687f6872 100644
--- a/swad_layout.h
+++ b/swad_layout.h
@@ -133,6 +133,10 @@ void Lay_EndTable (void);
void Lay_ShowErrorAndExit (const char *Txt);
void Lay_ShowPendingAlert (void);
void Lay_ShowAlert (Lay_AlertType_t AlertType,const char *Txt);
+void Lay_ShowAlertAndButton (Lay_AlertType_t AlertType,const char *Txt,
+ Act_Action_t NextAction,const char *Anchor,
+ void (*FuncParams) (),
+ Lay_Button_t Button,const char *TxtButton);
void Lay_ShowAlertAndButton1 (Lay_AlertType_t AlertType,const char *Txt);
void Lay_ShowAlertAndButton2 (Act_Action_t NextAction,const char *Anchor,
void (*FuncParams) (),
diff --git a/swad_photo.c b/swad_photo.c
index 4754ca0f8..5ebd657a8 100644
--- a/swad_photo.c
+++ b/swad_photo.c
@@ -417,10 +417,8 @@ void Pho_ReqRemoveMyPhoto (void)
Lay_ShowAlertAndButton1 (Lay_QUESTION,Txt_Do_you_really_want_to_remove_your_photo);
/* Show current photo */
- fprintf (Gbl.F.Out," ");
Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,Gbl.Usrs.Me.PhotoURL,
"PHOTO186x248",Pho_NO_ZOOM,false);
- fprintf (Gbl.F.Out," ");
/* End alert */
Lay_ShowAlertAndButton2 (ActRemMyPho,NULL,NULL,
@@ -480,10 +478,8 @@ void Pho_ReqRemoveUsrPhoto (void)
Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
/* Show current photo */
- fprintf (Gbl.F.Out,"");
Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL,
"PHOTO186x248",Pho_NO_ZOOM,false);
- fprintf (Gbl.F.Out," ");
/* End alert */
Lay_ShowAlertAndButton2 ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? ActRemStdPho :
diff --git a/swad_record.c b/swad_record.c
index ff9770597..7e326bf09 100644
--- a/swad_record.c
+++ b/swad_record.c
@@ -641,7 +641,6 @@ void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
&Gbl.CurrentCrs.Records.Field.Visibility);
/***** Show question and button to remove my photo *****/
- /* Start alert */
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_field_X_from_the_records_of_X,
Gbl.CurrentCrs.Records.Field.Name,Gbl.CurrentCrs.Crs.FullName);
if (NumRecords == 1)
@@ -654,11 +653,9 @@ void Rec_AskConfirmRemFieldWithRecords (unsigned NumRecords)
Str_Concat (Gbl.Alert.Txt,Message_part2,
Lay_MAX_BYTES_ALERT);
}
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Lay_ShowAlertAndButton2 (ActRemFie,NULL,Rec_PutParamFielCod,
- Lay_REMOVE_BUTTON,Txt_Remove_record_field);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemFie,NULL,Rec_PutParamFielCod,
+ Lay_REMOVE_BUTTON,Txt_Remove_record_field);
/***** List record fields again *****/
Rec_ReqEditRecordFields ();
diff --git a/swad_survey.c b/swad_survey.c
index abf4bd37d..fcb7da858 100644
--- a/swad_survey.c
+++ b/swad_survey.c
@@ -1478,15 +1478,12 @@ void Svy_AskRemSurvey (void)
Lay_ShowErrorAndExit ("You can not remove this survey.");
/***** Show question and button to remove survey *****/
- /* Start alert */
+ Gbl.Svys.SvyCodToEdit = Svy.SvyCod;
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_survey_X,
Svy.Title);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
- Gbl.Svys.SvyCodToEdit = Svy.SvyCod;
- Lay_ShowAlertAndButton2 (ActRemSvy,NULL,Svy_PutParams,
- Lay_REMOVE_BUTTON,Txt_Remove_survey);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemSvy,NULL,Svy_PutParams,
+ Lay_REMOVE_BUTTON,Txt_Remove_survey);
/***** Show surveys again *****/
Svy_ListAllSurveys (&SvyQst);
@@ -3516,16 +3513,13 @@ void Svy_RequestRemoveQst (void)
SvyQst.QstInd = Svy_GetQstIndFromQstCod (SvyQst.QstCod);
/***** Show question and button to remove question *****/
- /* Start alert */
- sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X,
- (unsigned long) (SvyQst.QstInd + 1));
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
Gbl.Svys.SvyCodToEdit = SvyCod;
Gbl.Svys.SvyQstCodToEdit = SvyQst.QstCod;
- Lay_ShowAlertAndButton2 (ActRemSvyQst,NULL,Svy_PutParamsRemoveOneQst,
- Lay_REMOVE_BUTTON,Txt_Remove_question);
+ sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X,
+ (unsigned long) (SvyQst.QstInd + 1));
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemSvyQst,NULL,Svy_PutParamsRemoveOneQst,
+ Lay_REMOVE_BUTTON,Txt_Remove_question);
/***** Show current survey *****/
Svy_ShowOneSurvey (SvyCod,&SvyQst,true);
diff --git a/swad_test.c b/swad_test.c
index 656503839..591515499 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -5873,21 +5873,19 @@ void Tst_RequestRemoveQst (void)
Lay_ShowErrorAndExit ("Wrong test parameters.");
/***** Show question and button to remove question *****/
- /* Start alert */
sprintf (Gbl.Alert.Txt,Txt_Do_you_really_want_to_remove_the_question_X,
(unsigned long) Gbl.Test.QstCod);
- Lay_ShowAlertAndButton1 (Lay_QUESTION,Gbl.Alert.Txt);
-
- /* End alert */
if (EditingOnlyThisQst)
- Lay_ShowAlertAndButton2 (ActRemTstQst,NULL,
- Tst_PutParamsRemoveOneQst,
- Lay_REMOVE_BUTTON,Txt_Remove_question);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemTstQst,NULL,
+ Tst_PutParamsRemoveOneQst,
+ Lay_REMOVE_BUTTON,Txt_Remove_question);
else
{
- Lay_ShowAlertAndButton2 (ActRemTstQst,NULL,
- Tst_PutParamsRemoveQst,
- Lay_REMOVE_BUTTON,Txt_Remove_question);
+ Lay_ShowAlertAndButton (Lay_QUESTION,Gbl.Alert.Txt,
+ ActRemTstQst,NULL,
+ Tst_PutParamsRemoveQst,
+ Lay_REMOVE_BUTTON,Txt_Remove_question);
Tst_FreeTagsList ();
}
|