diff --git a/swad_RSS.c b/swad_RSS.c index 99ebf9fe..8d02812e 100644 --- a/swad_RSS.c +++ b/swad_RSS.c @@ -186,7 +186,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs) /* Get notice code */ if (sscanf (row[0],"%ld",&NotCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of notice."); + Lay_WrongNoticeExit (); /* Get UTC date-time of publication */ CreatTimeUTC = 0L; @@ -285,12 +285,12 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs) NumExa < NumExams; NumExa++) { - /***** Get data of the exam announcement *****/ + /***** Get data of the call for exam *****/ row = mysql_fetch_row (mysql_res); - /* Get exam announcement code */ + /* Get call for exam code */ if (sscanf (row[0],"%ld",&ExaCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of exam announcement."); + Lay_WrongCallForExamExit (); /* Get UTC date-time of publication */ CallTimeUTC = 0L; diff --git a/swad_agenda.c b/swad_agenda.c index d22c4036..7a1dbc74 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -1571,7 +1571,7 @@ void Agd_RequestCreatOrEditEvent (void) Agd_GetParams (&Agenda,Agd_MY_AGENDA); /***** Get the code of the event *****/ - ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L); + ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) <= 0); /***** Get from the database the data of the event *****/ AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; @@ -1709,7 +1709,7 @@ void Agd_ReceiveFormEvent (void) AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; /***** Get the code of the event *****/ - ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) == -1L); + ItsANewEvent = ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) <= 0); /***** Get start/end date-times *****/ AgdEvent.TimeUTC[Dat_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC"); diff --git a/swad_announcement.c b/swad_announcement.c index 04a78e59..981303a2 100644 --- a/swad_announcement.c +++ b/swad_announcement.c @@ -155,7 +155,7 @@ void Ann_ShowAllAnnouncements (void) /* Get announcement code (row[0]) */ if (sscanf (row[0],"%ld",&AnnCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of announcement."); + Lay_WrongAnnouncementExit (); /* Get status of the announcement (row[1]) */ Status = Ann_OBSOLETE_ANNOUNCEMENT; @@ -260,7 +260,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void) /* Get announcement code (row[0]) */ if (sscanf (row[0],"%ld",&AnnCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of announcement."); + Lay_WrongAnnouncementExit (); /* Get the subject (row[1]), the content (row[2]), and insert links */ Str_Copy (Subject,row[1],sizeof (Subject) - 1); @@ -395,7 +395,7 @@ static long Ann_GetParamAnnCod (void) /***** Get announcement code *****/ if ((AnnCod = Par_GetParToLong ("AnnCod")) <= 0) - Lay_ShowErrorAndExit ("Wrong code of announcement."); + Lay_WrongAnnouncementExit (); return AnnCod; } diff --git a/swad_assignment.c b/swad_assignment.c index a1a5f387..f9d248ad 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -549,7 +549,7 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView Frm_BeginForm (ActFrmCreAsgCrs); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS, @@ -1233,7 +1233,7 @@ void Asg_RequestCreatOrEditAsg (void) Assignments.CurrentPage = Pag_GetParamPagNum (Pag_ASSIGNMENTS); /***** Get the code of the assignment *****/ - ItsANewAssignment = ((Asg.AsgCod = Asg_GetParamAsgCod ()) == -1L); + ItsANewAssignment = ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0); /***** Get from the database the data of the assignment *****/ if (ItsANewAssignment) diff --git a/swad_attendance.c b/swad_attendance.c index 07b3d29b..e62caa84 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1303,7 +1303,7 @@ void Att_ReceiveFormAttEvent (void) char Description[Cns_MAX_BYTES_TEXT + 1]; /***** Get the code of the attendance event *****/ - ItsANewAttEvent = ((ReceivedAtt.AttCod = Att_GetParamAttCod ()) == -1L); + ItsANewAttEvent = ((ReceivedAtt.AttCod = Att_GetParamAttCod ()) <= 0); if (!ItsANewAttEvent) { diff --git a/swad_center.c b/swad_center.c index 6d860634..69f0e1f2 100644 --- a/swad_center.c +++ b/swad_center.c @@ -760,7 +760,7 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row) /***** Get center status (row[3]) *****/ if (sscanf (row[3],"%u",&(Ctr->Status)) != 1) - Lay_ShowErrorAndExit ("Wrong center status."); + Lay_WrongStatusExit (); /***** Get requester user's code (row[4]) *****/ Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); @@ -1518,7 +1518,7 @@ void Ctr_ChangeCtrStatus (void) (unsigned long) Ctr_MAX_STATUS, (unsigned long) Ctr_WRONG_STATUS); if (Status == Ctr_WRONG_STATUS) - Lay_ShowErrorAndExit ("Wrong status."); + Lay_WrongStatusExit (); StatusTxt = Ctr_GetStatusTxtFromStatusBits (Status); Status = Ctr_GetStatusBitsFromStatusTxt (StatusTxt); // New status diff --git a/swad_changelog.h b/swad_changelog.h index 2d19c007..68a1f828 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -600,13 +600,20 @@ TODO: Salvador Romero Cort TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. */ -#define Log_PLATFORM_VERSION "SWAD 20.67.2 (2021-04-25)" +#define Log_PLATFORM_VERSION "SWAD 20.67.4 (2021-04-25)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.6.2.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.67.4: Apr 25, 2021 New file extensions for LogicWorks, reported by Eva Martínez Ortigosa. (309670 lines) +Copy the following icons to icon public directory: +sudo cp icon/filext32x32/cct32x32.gif /var/www/html/swad/icon/filext32x32/ +sudo cp icon/filext32x32/clf32x32.gif /var/www/html/swad/icon/filext32x32/ +sudo cp icon/filext32x32/tim32x32.gif /var/www/html/swad/icon/filext32x32/ + + Version 20.67.3: Apr 25, 2021 Code refactoring in error messages. (309662 lines) Version 20.67.2: Apr 25, 2021 Code refactoring in error messages. (309482 lines) Version 20.67.1: Apr 24, 2021 Code refactoring in error messages. (309415 lines) Version 20.67: Apr 24, 2021 Bug fixing and code optimizations related to user's roles. (309356 lines) diff --git a/swad_connected.c b/swad_connected.c index 14a27350..cd0684e6 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -746,7 +746,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -910,7 +910,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role) Frm_BeginFormUnique (ActSeeRecOneTch); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); @@ -1116,7 +1116,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } if (NumUsrs) @@ -1176,7 +1176,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R Frm_BeginForm (ActSeeRecOneTch); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod); } diff --git a/swad_course.c b/swad_course.c index e5254736..1eefff26 100644 --- a/swad_course.c +++ b/swad_course.c @@ -1846,7 +1846,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row) /***** Get course status (row[4]) *****/ if (sscanf (row[4],"%u",&(Crs->Status)) != 1) - Lay_ShowErrorAndExit ("Wrong course status."); + Lay_WrongStatusExit (); /***** Get requester user'code (row[5]) *****/ Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]); @@ -2397,7 +2397,7 @@ void Crs_ChangeCrsStatus (void) (unsigned long) Crs_MAX_STATUS, (unsigned long) Crs_WRONG_STATUS); if (Status == Crs_WRONG_STATUS) - Lay_ShowErrorAndExit ("Wrong status."); + Lay_WrongStatusExit (); StatusTxt = Crs_GetStatusTxtFromStatusBits (Status); Status = Crs_GetStatusBitsFromStatusTxt (StatusTxt); // New status diff --git a/swad_degree.c b/swad_degree.c index 8dc5662d..a080a96a 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1414,7 +1414,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row) /* Get course status (row[3]) */ if (sscanf (row[3],"%u",&(Deg->Status)) != 1) - Lay_ShowErrorAndExit ("Wrong degree status."); + Lay_WrongStatusExit (); /* Get requester user's code (row[4]) */ Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]); @@ -1807,7 +1807,7 @@ void Deg_ChangeDegStatus (void) (unsigned long) Deg_MAX_STATUS, (unsigned long) Deg_WRONG_STATUS); if (Status == Deg_WRONG_STATUS) - Lay_ShowErrorAndExit ("Wrong status."); + Lay_WrongStatusExit (); StatusTxt = Deg_GetStatusTxtFromStatusBits (Status); Status = Deg_GetStatusBitsFromStatusTxt (StatusTxt); // New status diff --git a/swad_department.c b/swad_department.c index d4419c44..1412317b 100644 --- a/swad_department.c +++ b/swad_department.c @@ -390,11 +390,11 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins row = mysql_fetch_row (mysql_res); /* Get department code (row[0]) */ - if ((Dpt->DptCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of department."); + if ((Dpt->DptCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongDepartmentExit (); /* Get institution code (row[1]) */ - if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) < 0) + if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0) Lay_WrongInstitExit (); /* Get short name (row[2]), full name (row[3]) @@ -644,7 +644,7 @@ long Dpt_GetAndCheckParamDptCod (long MinCodAllowed) /***** Get and check parameter with code of department *****/ if ((DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME)) < MinCodAllowed) - Lay_ShowErrorAndExit ("Code of department is missing or invalid."); + Lay_WrongDepartmentExit (); return DptCod; } @@ -1206,7 +1206,7 @@ static void Dpt_EditingDepartmentConstructor (void) { /***** Pointer must be NULL *****/ if (Dpt_EditingDpt != NULL) - Lay_ShowErrorAndExit ("Error initializing department."); + Lay_WrongDepartmentExit (); /***** Allocate memory for department *****/ if ((Dpt_EditingDpt = malloc (sizeof (*Dpt_EditingDpt))) == NULL) diff --git a/swad_enrolment.c b/swad_enrolment.c index 9df1192b..657c2fcd 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -243,7 +243,7 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole) case Rol_TCH: break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } /***** Update the role of a user in a course *****/ @@ -289,7 +289,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, case Rol_TCH: break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } /***** Register user in current course in database *****/ @@ -363,7 +363,7 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole) break; default: NotifyEvent = Ntf_EVENT_UNKNOWN; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } /***** Remove possible enrolment request ******/ @@ -453,7 +453,7 @@ void Enr_ReqAcceptRegisterInCrs (void) Frm_BeginForm (ActAccEnrTch); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } Btn_PutCreateButtonInline (Txt_Confirm_my_enrolment); Frm_EndForm (); @@ -471,7 +471,7 @@ void Enr_ReqAcceptRegisterInCrs (void) Frm_BeginForm (ActRemMe_Tch); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } Btn_PutRemoveButtonInline (Txt_Remove_me_from_this_course); Frm_EndForm (); @@ -493,7 +493,7 @@ void Enr_ReqAcceptRegisterInCrs (void) break; default: NotifyEvent = Ntf_EVENT_UNKNOWN; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Ntf_MarkNotifAsSeen (NotifyEvent,-1L,Gbl.Hierarchy.Crs.CrsCod, @@ -726,7 +726,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) default: NextAction = ActUnk; Title = NULL; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -751,7 +751,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role) default: NextAction = ActUnk; Title = NULL; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Frm_BeginForm (NextAction); @@ -1115,7 +1115,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role) Lay_NoPermissionExit (); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -2016,7 +2016,7 @@ void Enr_SignUpInCrs (void) if (!(RoleFromForm == Rol_STD || RoleFromForm == Rol_NET || RoleFromForm == Rol_TCH)) - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); /***** Try to get and old request of the same user in the same course from database *****/ ReqCod = DB_QuerySELECTCode ("can not get enrolment request", @@ -2179,7 +2179,7 @@ void Enr_AskIfRejectSignUp (void) Btn_REMOVE_BUTTON,Txt_Reject); } else - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } } else @@ -3026,7 +3026,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) break; default: NextAction = ActUnk; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Frm_BeginForm (NextAction); @@ -3172,7 +3172,7 @@ void Enr_PutLinkToAdminSeveralUsrs (Rol_Role_t Role) default: NextAction = ActUnk; TitleText = NULL; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } Lay_PutContextualLinkIconText (NextAction,NULL, NULL,NULL, @@ -3252,7 +3252,7 @@ static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role) break; default: NextAction = ActUnk; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Enr_WriteFormToReqAnotherUsrID (NextAction,NULL); @@ -3890,7 +3890,7 @@ void Enr_CreateNewUsr1 (void) Gbl.Action.Act = ActCreTch; break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Tab_SetCurrentTab (); @@ -4021,7 +4021,7 @@ void Enr_ModifyUsr1 (void) Gbl.Action.Act = ActUpdTch; break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Tab_SetCurrentTab (); @@ -4186,7 +4186,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat) break; default: NextAction = ActUnk; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Frm_BeginForm (NextAction); diff --git a/swad_exam.c b/swad_exam.c index fe4a1885..90242ef0 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -824,7 +824,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder) Lay_NotEnoughMemoryExit (); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } diff --git a/swad_exam_print.c b/swad_exam_print.c index 878bd751..4dc49d41 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -1289,7 +1289,7 @@ static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) /***** Get correct answer *****/ row = mysql_fetch_row (mysql_res); if (sscanf (row[0],"%ld",&Question->Answer.Integer) != 1) - Lay_ShowErrorAndExit ("Wrong integer answer."); + Lay_WrongAnswerExit (); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -1312,7 +1312,7 @@ static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) /***** Check if number of rows is correct *****/ if (Question->Answer.NumOptions != 2) - Lay_ShowErrorAndExit ("Wrong float range."); + Lay_WrongAnswerExit (); /***** Get float range *****/ for (NumOpt = 0; diff --git a/swad_exam_result.c b/swad_exam_result.c index ee640160..333bda8c 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -950,8 +950,8 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams, NumResult++) { /* Get print code (row[0]) */ - if ((Print.PrnCod = DB_GetNextCode (mysql_res)) < 0) - Lay_ShowErrorAndExit ("Wrong code of exam print."); + if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0) + Lay_WrongExamExit (); /* Get print data */ ExaPrn_GetDataOfPrintByPrnCod (&Print); diff --git a/swad_exam_session.c b/swad_exam_session.c index c16bee1e..9cbb49a5 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -175,7 +175,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, Lay_NotEnoughMemoryExit (); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -737,7 +737,7 @@ static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams, ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } diff --git a/swad_exam_set.c b/swad_exam_set.c index dc67bb2c..00e89244 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -1866,7 +1866,7 @@ void ExaSet_MoveUpSet (void) /* Indexes of sets to be exchanged */ SetIndTop = ExaSet_GetPrevSetIndexInExam (Exam.ExaCod,SetIndBottom); if (!SetIndTop) - Lay_ShowErrorAndExit ("Wrong index of set."); + Lay_ShowErrorAndExit ("Wrong set index."); /* Exchange sets */ ExaSet_ExchangeSets (Exam.ExaCod,SetIndTop,SetIndBottom); @@ -1917,7 +1917,7 @@ void ExaSet_MoveDownSet (void) /* Indexes of sets to be exchanged */ SetIndBottom = ExaSet_GetNextSetIndexInExam (Exam.ExaCod,SetIndTop); if (!SetIndBottom) - Lay_ShowErrorAndExit ("Wrong index of set."); + Lay_ShowErrorAndExit ("Wrong set index."); /* Exchange sets */ ExaSet_ExchangeSets (Exam.ExaCod,SetIndTop,SetIndBottom); diff --git a/swad_figure.c b/swad_figure.c index 69a4a820..42447953 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -1800,7 +1800,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; @@ -1978,7 +1978,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; @@ -2144,7 +2144,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; @@ -2298,7 +2298,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; @@ -2440,7 +2440,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; @@ -2570,7 +2570,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope, (unsigned) FileBrowser); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } break; diff --git a/swad_file_browser.c b/swad_file_browser.c index 3f6b0ff6..916dbf95 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -1977,7 +1977,7 @@ void Brw_GetParAndInitFileBrowser (void) Brw_ADMI_MRK_CRS; break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } break; @@ -3403,7 +3403,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) break; default: NextAction = ActUnk; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } Frm_BeginForm (NextAction); @@ -4035,7 +4035,7 @@ static void Brw_WriteSubtitleOfFileBrowser (void) break; default: Subtitle[0] = '\0'; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } break; @@ -7160,7 +7160,7 @@ static bool Brw_GetMyClipboard (void) DB_FreeMySQLResult (&mysql_res); if (NumRows > 1) - Lay_ShowErrorAndExit ("Error when getting source of copy."); + Lay_WrongCopySrcExit (); return (bool) (NumRows == 1); } @@ -7953,7 +7953,7 @@ static void Brw_PasteClipboard (void) (unsigned) Hie.Ins.InsCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_DOC_CTR: case Brw_ADMI_SHR_CTR: @@ -7965,7 +7965,7 @@ static void Brw_PasteClipboard (void) (unsigned) Hie.Ctr.CtrCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_DOC_DEG: case Brw_ADMI_SHR_DEG: @@ -7977,7 +7977,7 @@ static void Brw_PasteClipboard (void) (unsigned) Hie.Deg.DegCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_DOC_CRS: case Brw_ADMI_TCH_CRS: @@ -7989,7 +7989,7 @@ static void Brw_PasteClipboard (void) Cfg_PATH_CRS_PRIVATE,Hie.Crs.CrsCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_DOC_GRP: case Brw_ADMI_TCH_GRP: @@ -8004,7 +8004,7 @@ static void Brw_PasteClipboard (void) GrpDat.GrpCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_ASG_CRS: case Brw_ADMI_WRK_CRS: @@ -8026,7 +8026,7 @@ static void Brw_PasteClipboard (void) Usr_UsrDataDestructor (&UsrDat); } else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_ASG_USR: case Brw_ADMI_WRK_USR: @@ -8038,7 +8038,7 @@ static void Brw_PasteClipboard (void) Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_DOC_PRJ: case Brw_ADMI_ASS_PRJ: @@ -8051,7 +8051,7 @@ static void Brw_PasteClipboard (void) PrjCod, Gbl.FileBrowser.Clipboard.FilFolLnk.Full); else - Lay_ShowErrorAndExit ("The copy source does not exist."); + Lay_WrongCopySrcExit (); break; case Brw_ADMI_BRF_USR: snprintf (PathOrg,sizeof (PathOrg),"%s/%s", @@ -8059,7 +8059,7 @@ static void Brw_PasteClipboard (void) Gbl.FileBrowser.Clipboard.FilFolLnk.Full); break; default: - Lay_ShowErrorAndExit ("Wrong file browser."); + Lay_WrongFileBrowserExit (); break; } @@ -10749,7 +10749,7 @@ void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata) else FileMetadata->NumMyViews = FileMetadata->NumPublicViews; - /***** Update number of my views (if I am not logged, UsrCod == -1L) *****/ + /***** Update number of my views *****/ Brw_UpdateFileViews (FileMetadata->NumMyViews,FileMetadata->FilCod); /***** Increment number of file views in my user's figures *****/ diff --git a/swad_file_extension.c b/swad_file_extension.c index ced63b1a..b866adac 100644 --- a/swad_file_extension.c +++ b/swad_file_extension.c @@ -48,7 +48,9 @@ const char *Ext_FileExtensionsAllowed[] = "bz2" , "c" , "cc" , + "cct" , // LogicWorks "cdr" , + "clf" , // LogicWorks "cpp" , "css" , "csv" , @@ -135,6 +137,7 @@ const char *Ext_FileExtensionsAllowed[] = "tex" , "tgz" , "tif" , + "tim" , // LogicWorks "txt" , "voc" , "vp" , // Justinmind, http://www.justinmind.com/ diff --git a/swad_forum.c b/swad_forum.c index 5a3aba9e..a5bbd62d 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -490,7 +490,7 @@ void For_DisablePost (void) For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_banned); } else - Lay_ShowErrorAndExit ("The post to be banned no longer exists."); + Lay_WrongPostExit (); } /*****************************************************************************/ @@ -1123,7 +1123,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums, row = mysql_fetch_row (mysql_res); if (sscanf (row[0],"%ld",&Forums->PstCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of post."); + Lay_WrongPostExit (); CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]); @@ -1385,7 +1385,7 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, " FROM for_posts" " WHERE PstCod=%ld", PstCod) != 1) - Lay_ShowErrorAndExit ("Internal error in database when getting data of a post."); + Lay_WrongPostExit (); /***** Get number of rows *****/ row = mysql_fetch_row (mysql_res); @@ -3686,13 +3686,12 @@ static void For_GetThreadData (struct For_Thread *Thr) /***** Get the code of the last post in this thread (row[1]) *****/ Thr->PstCod[Dat_END_TIME ] = Str_ConvertStrCodToLongCod (row[1]); - /***** Get the code of the first message in this thread (row[0]) *****/ + /***** Get the code of the first message (row[0]) + and the last message (row[1]) in this thread *****/ if (sscanf (row[0],"%ld",&(Thr->PstCod[Dat_START_TIME])) != 1) - Lay_ShowErrorAndExit ("Wrong code of post."); - - /***** Get the code of the last message in this thread (row[1]) *****/ + Lay_WrongPostExit (); if (sscanf (row[1],"%ld",&(Thr->PstCod[Dat_END_TIME])) != 1) - Lay_ShowErrorAndExit ("Wrong code of post."); + Lay_WrongPostExit (); /***** Get the author of the first post in this thread (row[2]) *****/ Thr->UsrCod[Dat_START_TIME] = Str_ConvertStrCodToLongCod (row[2]); @@ -4267,7 +4266,7 @@ void For_RemovePost (void) /***** Check if I can remove the post *****/ /* Check if the message really exists, if it has not been removed */ if (!For_GetIfForumPstExists (Forums.PstCod)) - Lay_ShowErrorAndExit ("The post to remove no longer exists."); + Lay_WrongPostExit (); /* Check if I am the author of the message */ ItsMe = Usr_ItsMe (UsrDat.UsrCod); @@ -4627,7 +4626,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums) Forums->Thread.Current); break; default: - Lay_ShowErrorAndExit ("Wrong forum."); + Lay_WrongForumExit (); break; } } diff --git a/swad_game.c b/swad_game.c index b4d82f63..4d680c82 100644 --- a/swad_game.c +++ b/swad_game.c @@ -890,7 +890,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder) Lay_NotEnoughMemoryExit (); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -2885,7 +2885,7 @@ void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore) { unsigned NumAnswers; - /***** Get maximum score of a game from database *****/ + /***** Get number of answers of a game from database *****/ NumAnswers = (unsigned) DB_QueryCOUNT ("can not number of answers of a question", "SELECT COUNT(tst_answers.AnsInd)" @@ -2896,7 +2896,7 @@ void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore) " GROUP BY tst_answers.QstCod", GamCod); if (NumAnswers < 2) - Lay_ShowErrorAndExit ("Wrong number of answers."); + Lay_WrongAnswerExit (); /***** Set minimum and maximum scores *****/ *MinScore = *MaxScore = 0.0; diff --git a/swad_holiday.c b/swad_holiday.c index c89dd457..1025752a 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -383,8 +383,8 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays) row = mysql_fetch_row (mysql_res); /* Get holiday code (row[0]) */ - if ((Hld->HldCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong holiday code."); + if ((Hld->HldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongHolidayExit (); /* Get place code (row[1]) */ Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]); @@ -398,7 +398,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays) /* Get start date (row[4] holds the start date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&(Hld->StartDate),row[4]))) - Lay_ShowErrorAndExit ("Wrong start date."); + Lay_WrongDateExit (); /* Set / get end date */ switch (Hld->HldTyp) @@ -410,7 +410,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays) case Hld_NON_SCHOOL_PERIOD: // One or more days /* Get end date (row[5] holds the end date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&(Hld->EndDate),row[5]))) - Lay_ShowErrorAndExit ("Wrong end date."); + Lay_WrongDateExit (); break; } @@ -445,7 +445,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld) /***** Check if holiday code is correct *****/ if (Hld->HldCod <= 0) - Lay_ShowErrorAndExit ("Wrong code of holiday."); + Lay_WrongHolidayExit (); /***** Get data of holiday from database *****/ if (DB_QuerySELECT (&mysql_res,"can not get data of a holiday", @@ -496,7 +496,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld) /* Get start date (row[3] holds the start date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&(Hld->StartDate),row[3]))) - Lay_ShowErrorAndExit ("Wrong start date."); + Lay_WrongDateExit (); /* Set / get end date */ switch (Hld->HldTyp) @@ -508,7 +508,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld) case Hld_NON_SCHOOL_PERIOD: // One or more days /* Get end date (row[4] holds the end date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&(Hld->EndDate),row[4]))) - Lay_ShowErrorAndExit ("Wrong end date."); + Lay_WrongDateExit (); break; } @@ -542,10 +542,10 @@ static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr) unsigned UnsignedNum; if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1) - Lay_ShowErrorAndExit ("Wrong type of holiday."); + Lay_WrongHolidayExit (); if (UnsignedNum >= Hld_NUM_TYPES_HOLIDAY) - Lay_ShowErrorAndExit ("Wrong type of holiday."); + Lay_WrongHolidayExit (); return (Hld_HolidayType_t) UnsignedNum; } @@ -720,8 +720,8 @@ void Hld_RemoveHoliday (void) Hld_EditingHolidayConstructor (); /***** Get holiday code *****/ - if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of holiday is missing."); + if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0) + Lay_WrongHolidayExit (); /***** Get data of the holiday from database *****/ Hld_GetDataOfHolidayByCod (Hld_EditingHld); @@ -752,8 +752,8 @@ void Hld_ChangeHolidayPlace (void) /***** Get parameters from form *****/ /* Get the code of the holiday */ - if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of holiday is missing."); + if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0) + Lay_WrongHolidayExit (); /* Get the new place for the holiday */ NewPlace.PlcCod = Plc_GetParamPlcCod (); @@ -793,8 +793,8 @@ void Hld_ChangeHolidayType (void) Hld_EditingHolidayConstructor (); /***** Get the code of the holiday *****/ - if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of holiday is missing."); + if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0) + Lay_WrongHolidayExit (); /***** Get from the database the data of the holiday *****/ Hld_GetDataOfHolidayByCod (Hld_EditingHld); @@ -852,8 +852,8 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) Hld_EditingHolidayConstructor (); /***** Get the code of the holiday *****/ - if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of holiday is missing."); + if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0) + Lay_WrongHolidayExit (); /***** Get from the database the data of the holiday *****/ Hld_GetDataOfHolidayByCod (Hld_EditingHld); @@ -925,8 +925,8 @@ void Hld_RenameHoliday (void) /***** Get parameters from form *****/ /* Get the code of the holiday */ - if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of holiday is missing."); + if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0) + Lay_WrongHolidayExit (); /* Get the new name for the holiday */ Par_GetParToText ("Name",NewHldName,Hld_MAX_BYTES_HOLIDAY_NAME); @@ -1214,7 +1214,7 @@ static void Hld_EditingHolidayConstructor (void) { /***** Pointer must be NULL *****/ if (Hld_EditingHld != NULL) - Lay_ShowErrorAndExit ("Error initializing holiday."); + Lay_WrongHolidayExit (); /***** Allocate memory for holiday *****/ if ((Hld_EditingHld = malloc (sizeof (*Hld_EditingHld))) == NULL) diff --git a/swad_institution.c b/swad_institution.c index 7c8e9760..6e53b255 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -842,7 +842,7 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row) /***** Get institution status (row[2]) *****/ if (sscanf (row[2],"%u",&(Ins->Status)) != 1) - Lay_ShowErrorAndExit ("Wrong institution status."); + Lay_WrongStatusExit (); /***** Get requester user's code (row[3]) *****/ Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]); @@ -1618,7 +1618,7 @@ void Ins_ChangeInsStatus (void) (unsigned long) Ins_MAX_STATUS, (unsigned long) Ins_WRONG_STATUS); if (Status == Ins_WRONG_STATUS) - Lay_ShowErrorAndExit ("Wrong status."); + Lay_WrongStatusExit (); StatusTxt = Ins_GetStatusTxtFromStatusBits (Status); Status = Ins_GetStatusBitsFromStatusTxt (StatusTxt); // New status diff --git a/swad_layout.c b/swad_layout.c index f56d4f73..5b7bd5cc 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1378,6 +1378,15 @@ void Lay_NotEnoughMemoryExit (void) Lay_ShowErrorAndExit ("Not enough memory."); } +/*****************************************************************************/ +/************* Write error message and exit when wrong action ****************/ +/*****************************************************************************/ + +void Lay_WrongActionExit (void) + { + Lay_ShowErrorAndExit ("Wrong action."); + } + /*****************************************************************************/ /************* Write error message and exit when wrong scope *****************/ /*****************************************************************************/ @@ -1422,6 +1431,24 @@ void Lay_WrongCourseExit (void) Lay_ShowErrorAndExit ("Wrong course."); } +/*****************************************************************************/ +/*********** Write error message and exit when wrong department **************/ +/*****************************************************************************/ + +void Lay_WrongDepartmentExit (void) + { + Lay_ShowErrorAndExit ("Wrong department."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong place ****************/ +/*****************************************************************************/ + +void Lay_WrongPlaceExit (void) + { + Lay_ShowErrorAndExit ("Wrong department."); + } + /*****************************************************************************/ /************* Write error message and exit when wrong order *****************/ /*****************************************************************************/ @@ -1431,6 +1458,83 @@ void Lay_WrongOrderExit (void) Lay_ShowErrorAndExit ("Wrong order."); } +/*****************************************************************************/ +/************* Write error message and exit when wrong status ****************/ +/*****************************************************************************/ + +void Lay_WrongStatusExit (void) + { + Lay_ShowErrorAndExit ("Wrong status."); + } + +/*****************************************************************************/ +/************* Write error message and exit when wrong date ****************/ +/*****************************************************************************/ + +void Lay_WrongDateExit (void) + { + Lay_ShowErrorAndExit ("Wrong date."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong plugin ***************/ +/*****************************************************************************/ + +void Lay_WrongPluginExit (void) + { + Lay_ShowErrorAndExit ("Wrong plugin."); + } + +/*****************************************************************************/ +/********** Write error message and exit when wrong items list/item **********/ +/*****************************************************************************/ + +void Lay_WrongItemsListExit (void) + { + Lay_ShowErrorAndExit ("Wrong items list."); + } + +void Lay_WrongItemExit (void) + { + Lay_ShowErrorAndExit ("Wrong item."); + } + +/*****************************************************************************/ +/********** Write error message and exit when wrong syllabus format **********/ +/*****************************************************************************/ + +void Lay_WrongSyllabusFormatExit (void) + { + Lay_ShowErrorAndExit ("Wrong syllabus format."); + } + +/*****************************************************************************/ +/*********** Write error message and exit when wrong file browser ************/ +/*****************************************************************************/ + +void Lay_WrongFileBrowserExit (void) + { + Lay_ShowErrorAndExit ("Wrong file browser."); + } + +/*****************************************************************************/ +/*********** Write error message and exit when wrong copy source *************/ +/*****************************************************************************/ + +void Lay_WrongCopySrcExit (void) + { + Lay_ShowErrorAndExit ("The copy source does not exist."); + } + +/*****************************************************************************/ +/********** Write error message and exit when wrong number of rows ***********/ +/*****************************************************************************/ + +void Lay_WrongNumberOfRowsExit (void) + { + Lay_ShowErrorAndExit ("Wrong number of rows."); + } + /*****************************************************************************/ /********* Write error message and exit when wrong group type/group **********/ /*****************************************************************************/ @@ -1455,7 +1559,7 @@ void Lay_WrongTypeOfViewExit (void) } /*****************************************************************************/ -/************* Write error message and exit when wrong banner ****************/ +/*********** Write error message and exit when wrong banner/link *************/ /*****************************************************************************/ void Lay_WrongBannerExit (void) @@ -1463,8 +1567,22 @@ void Lay_WrongBannerExit (void) Lay_ShowErrorAndExit ("Wrong banner."); } +void Lay_WrongLinkExit (void) + { + Lay_ShowErrorAndExit ("Wrong link."); + } + /*****************************************************************************/ -/************ Write error message and exit when wrong building ***************/ +/************* Write error message and exit when wrong holiday ***************/ +/*****************************************************************************/ + +void Lay_WrongHolidayExit (void) + { + Lay_ShowErrorAndExit ("Wrong holiday."); + } + +/*****************************************************************************/ +/********** Write error message and exit when wrong building/room ************/ /*****************************************************************************/ void Lay_WrongBuildingExit (void) @@ -1472,6 +1590,20 @@ void Lay_WrongBuildingExit (void) Lay_ShowErrorAndExit ("Wrong building."); } +void Lay_WrongRoomExit (void) + { + Lay_ShowErrorAndExit ("Wrong room."); + } + +/*****************************************************************************/ +/*********** Write error message and exit when wrong record field ************/ +/*****************************************************************************/ + +void Lay_WrongRecordFieldExit (void) + { + Lay_ShowErrorAndExit ("Wrong record field."); + } + /*****************************************************************************/ /*********** Write error message and exit when wrong assignment **************/ /*****************************************************************************/ @@ -1499,6 +1631,24 @@ void Lay_WrongCallForExamExit (void) Lay_ShowErrorAndExit ("Wrong call for exam."); } +/*****************************************************************************/ +/************** Write error message and exit when wrong tag *****************/ +/*****************************************************************************/ + +void Lay_WrongTagExit (void) + { + Lay_ShowErrorAndExit ("Wrong tag."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong test *****************/ +/*****************************************************************************/ + +void Lay_WrongTestExit (void) + { + Lay_ShowErrorAndExit ("Wrong test."); + } + /*****************************************************************************/ /************** Write error message and exit when wrong exam *****************/ /*****************************************************************************/ @@ -1595,6 +1745,65 @@ void Lay_WrongEventExit (void) Lay_ShowErrorAndExit ("Wrong event."); } +/*****************************************************************************/ +/*********** Write error message and exit when wrong announcement ************/ +/*****************************************************************************/ + +void Lay_WrongAnnouncementExit (void) + { + Lay_ShowErrorAndExit ("Wrong announcement."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong notice ***************/ +/*****************************************************************************/ + +void Lay_WrongNoticeExit (void) + { + Lay_ShowErrorAndExit ("Wrong notice."); + } + +/*****************************************************************************/ +/************ Write error message and exit when wrong forum/post *************/ +/*****************************************************************************/ + +void Lay_WrongForumExit (void) + { + Lay_ShowErrorAndExit ("Wrong forum."); + } + +void Lay_WrongPostExit (void) + { + Lay_ShowErrorAndExit ("Wrong post."); + } + +/*****************************************************************************/ +/************** Write error message and exit when wrong message **************/ +/*****************************************************************************/ + +void Lay_WrongMessageExit (void) + { + Lay_ShowErrorAndExit ("Wrong message."); + } + +/*****************************************************************************/ +/************ Write error message and exit when wrong mail domain ************/ +/*****************************************************************************/ + +void Lay_WrongMailDomainExit (void) + { + Lay_ShowErrorAndExit ("Wrong mail domain."); + } + +/*****************************************************************************/ +/************* Show error message about wrong role and exit ******************/ +/*****************************************************************************/ + +void Lay_WrongRoleExit (void) + { + Lay_ShowErrorAndExit ("Wrong role."); + } + /*****************************************************************************/ /************ Write error message and exit when user does not exists *********/ /*****************************************************************************/ diff --git a/swad_layout.h b/swad_layout.h index 6f554067..2435d322 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -70,6 +70,7 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction, const char *Title,const char *Text); void Lay_NotEnoughMemoryExit (void); +void Lay_WrongActionExit (void); void Lay_WrongScopeExit (void); void Lay_WrongCountrExit (void); void Lay_WrongInstitExit (void); @@ -77,15 +78,32 @@ void Lay_WrongCenterExit (void); void Lay_WrongDegTypExit (void); void Lay_WrongDegreeExit (void); void Lay_WrongCourseExit (void); +void Lay_WrongDepartmentExit (void); +void Lay_WrongPlaceExit (void); void Lay_WrongOrderExit (void); +void Lay_WrongStatusExit (void); +void Lay_WrongDateExit (void); +void Lay_WrongPluginExit (void); +void Lay_WrongItemsListExit (void); +void Lay_WrongItemExit (void); +void Lay_WrongSyllabusFormatExit (void); +void Lay_WrongFileBrowserExit (void); +void Lay_WrongCopySrcExit (void); +void Lay_WrongNumberOfRowsExit (void); void Lay_WrongGrpTypExit (void); void Lay_WrongGroupExit (void); void Lay_WrongTypeOfViewExit (void); void Lay_WrongBannerExit (void); +void Lay_WrongLinkExit (void); +void Lay_WrongHolidayExit (void); void Lay_WrongBuildingExit (void); +void Lay_WrongRoomExit (void); +void Lay_WrongRecordFieldExit (void); void Lay_WrongAssignmentExit (void); void Lay_WrongProjectExit (void); void Lay_WrongCallForExamExit (void); +void Lay_WrongTagExit (void); +void Lay_WrongTestExit (void); void Lay_WrongExamExit (void); void Lay_WrongSetExit (void); void Lay_WrongQuestionExit (void); @@ -98,6 +116,13 @@ void Lay_WrongMatchExit (void); void Lay_WrongSurveyExit (void); void Lay_WrongWhoExit (void); void Lay_WrongEventExit (void); +void Lay_WrongAnnouncementExit (void); +void Lay_WrongNoticeExit (void); +void Lay_WrongForumExit (void); +void Lay_WrongPostExit (void); +void Lay_WrongMessageExit (void); +void Lay_WrongMailDomainExit (void); +void Lay_WrongRoleExit (void); void Lay_WrongUserExit (void); void Lay_NoPermissionExit (void); void Lay_ShowErrorAndExit (const char *Txt); diff --git a/swad_link.c b/swad_link.c index bb0d8503..463411cf 100644 --- a/swad_link.c +++ b/swad_link.c @@ -320,8 +320,8 @@ void Lnk_GetListLinks (void) row = mysql_fetch_row (mysql_res); /* Get link code (row[0]) */ - if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of institutional link."); + if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongLinkExit (); /* Get the short name (row[0]), the full name (row[1]) and de URL (row[2]) of the link */ @@ -493,8 +493,8 @@ void Lnk_RemoveLink (void) Lnk_EditingLinkConstructor (); /***** Get link code *****/ - if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of institutional link is missing."); + if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0) + Lay_WrongLinkExit (); /***** Get data of the link from database *****/ Lnk_GetDataOfLinkByCod (Lnk_EditingLnk); @@ -570,8 +570,8 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the link */ - if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of institutional link is missing."); + if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0) + Lay_WrongLinkExit (); /* Get the new name for the link */ Par_GetParToText (ParamName,NewLnkName,MaxBytes); @@ -659,8 +659,8 @@ void Lnk_ChangeLinkWWW (void) /***** Get parameters from form *****/ /* Get the code of the link */ - if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of institutional link is missing."); + if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0) + Lay_WrongLinkExit (); /* Get the new WWW for the link */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); @@ -864,7 +864,7 @@ static void Lnk_EditingLinkConstructor (void) { /***** Pointer must be NULL *****/ if (Lnk_EditingLnk != NULL) - Lay_ShowErrorAndExit ("Error initializing link."); + Lay_WrongLinkExit (); /***** Allocate memory for link *****/ if ((Lnk_EditingLnk = malloc (sizeof (*Lnk_EditingLnk))) == NULL) diff --git a/swad_mail.c b/swad_mail.c index 7c12159e..b109d884 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -325,8 +325,8 @@ static void Mai_GetListMailDomainsAllowedForNotif (void) row = mysql_fetch_row (mysql_res); /* Get mail code (row[0]) */ - if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of mail domain."); + if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongMailDomainExit (); /* Get the mail domain (row[1]) and the mail domain info (row[2]) */ Str_Copy (Mai->Domain,row[1],sizeof (Mai->Domain) - 1); @@ -574,8 +574,8 @@ void Mai_RemoveMailDomain (void) Mai_EditingMailDomainConstructor (); /***** Get mail code *****/ - if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of mail domain is missing."); + if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) <= 0) + Lay_WrongMailDomainExit (); /***** Get data of the mail from database *****/ Mai_GetDataOfMailDomainByCod (Mai_EditingMai); @@ -651,8 +651,8 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the mail */ - if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of mail domain is missing."); + if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) <= 0) + Lay_WrongMailDomainExit (); /* Get the new name for the mail */ Par_GetParToText (ParamName,NewMaiName,MaxBytes); @@ -1941,7 +1941,7 @@ static void Mai_EditingMailDomainConstructor (void) { /***** Pointer must be NULL *****/ if (Mai_EditingMai != NULL) - Lay_ShowErrorAndExit ("Error initializing mail domain."); + Lay_WrongMailDomainExit (); /***** Allocate memory for mail domain *****/ if ((Mai_EditingMai = malloc (sizeof (*Mai_EditingMai))) == NULL) diff --git a/swad_mark.c b/swad_mark.c index 0fe3a96f..50b174c2 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -197,11 +197,11 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks) /* Header (row[0]) */ if (sscanf (row[0],"%u",&(Marks->Header)) != 1) - Lay_ShowErrorAndExit ("Wrong number of header rows."); + Lay_WrongNumberOfRowsExit (); /* Footer (row[1]) */ if (sscanf (row[1],"%u",&(Marks->Footer)) != 1) - Lay_ShowErrorAndExit ("Wrong number of footer rows."); + Lay_WrongNumberOfRowsExit (); } else // Unknown numbers of header and footer rows Marks->Header = @@ -268,7 +268,7 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter) NumRows); } else - Lay_ShowErrorAndExit ("Wrong number of rows."); + Lay_WrongNumberOfRowsExit (); /***** Show again the file browser *****/ Brw_ShowAgainFileBrowserOrWorks (); @@ -764,11 +764,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], { /* Header (row[3]) */ if (sscanf (row[3],"%u",&(Marks.Header)) != 1) - Lay_ShowErrorAndExit ("Wrong number of header rows."); + Lay_WrongNumberOfRowsExit (); /* Footer (row[4]) */ if (sscanf (row[4],"%u",&(Marks.Footer)) != 1) - Lay_ShowErrorAndExit ("Wrong number of footer rows."); + Lay_WrongNumberOfRowsExit (); if (UsrDat.IDs.Num) { diff --git a/swad_match.c b/swad_match.c index 49d68ee7..cece9263 100644 --- a/swad_match.c +++ b/swad_match.c @@ -886,7 +886,7 @@ static void Mch_ListOneOrMoreMatchesResult (struct Gam_Games *Games, Mch_ListOneOrMoreMatchesResultTch (Games,Match); break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -1829,18 +1829,18 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) */ /* Get question code (row[0]) */ - if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) + if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) Lay_WrongQuestionExit (); /* Get question index (row[1]) */ - if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0) - Lay_ShowErrorAndExit ("Wrong question index."); + if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) <= 0) + Lay_WrongQuestionIndexExit (); QstInd = (unsigned) LongNum; /* Get answer type (row[2]) */ Question.Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[2]); if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE) - Lay_ShowErrorAndExit ("Wrong answer type."); + Lay_WrongAnswerExit (); /* Get shuffle (row[3]) */ Question.Answer.Shuffle = (row[3][0] == 'Y'); @@ -1894,8 +1894,8 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd, row = mysql_fetch_row (mysql_res); /* Get answer index (row[0]) */ - if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong answer index."); + if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongAnswerIndexExit (); AnsInd = (unsigned) LongNum; snprintf (StrOneAnswer,sizeof (StrOneAnswer),"%u",AnsInd); @@ -3274,7 +3274,7 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match) /***** Show question *****/ /* Check answer type */ if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE) - Lay_ShowErrorAndExit ("Wrong answer type."); + Lay_WrongAnswerExit (); /* Begin container */ HTM_DIV_Begin ("class=\"MCH_BOTTOM\""); // Bottom diff --git a/swad_message.c b/swad_message.c index a215c5ec..cb70a9da 100644 --- a/swad_message.c +++ b/swad_message.c @@ -257,7 +257,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages, if ((Messages->Reply.IsReply = Par_GetParToBool ("IsReply"))) /* Get original message code */ if ((Messages->Reply.OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Get user's code of possible preselected recipient *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) // There is a preselected recipient @@ -620,7 +620,7 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag " FROM msg_content" " WHERE MsgCod=%ld", MsgCod) != 1) - Lay_ShowErrorAndExit ("Error when getting message."); + Lay_WrongMessageExit (); row = mysql_fetch_row (mysql_res); @@ -770,7 +770,7 @@ void Msg_RecMsgFromUsr (void) if ((IsReply = Par_GetParToBool ("IsReply"))) /* Get original message code */ if ((OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /* Get user's code of possible preselected recipient */ Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); @@ -1197,7 +1197,7 @@ void Msg_DelSntMsg (void) /***** Get the code of the message to delete *****/ if ((MsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Delete the message *****/ /* Delete the sent message */ @@ -1219,7 +1219,7 @@ void Msg_DelRecMsg (void) /***** Get the code of the message to delete *****/ if ((MsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Delete the message *****/ /* Delete the received message */ @@ -1243,7 +1243,7 @@ void Msg_ExpSntMsg (void) /***** Get the code of the message to expand *****/ if ((Messages.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Expand the message *****/ Msg_ExpandSentMsg (Messages.ExpandedMsgCod); @@ -1265,7 +1265,7 @@ void Msg_ExpRecMsg (void) /***** Get the code of the message to expand *****/ if ((Messages.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Expand the message *****/ Msg_ExpandReceivedMsg (Messages.ExpandedMsgCod); @@ -1289,7 +1289,7 @@ void Msg_ConSntMsg (void) /***** Get the code of the message to contract *****/ if ((MsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Contract the message *****/ Msg_ContractSentMsg (MsgCod); @@ -1308,7 +1308,7 @@ void Msg_ConRecMsg (void) /***** Get the code of the message to contract *****/ if ((MsgCod = Msg_GetParamMsgCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + Lay_WrongMessageExit (); /***** Contract the message *****/ Msg_ContractReceivedMsg (MsgCod); @@ -1480,9 +1480,8 @@ static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Mess NumMsg < NumMsgs; NumMsg++) { - MsgCod = DB_GetNextCode (mysql_res); - if (MsgCod <= 0) - Lay_ShowErrorAndExit ("Wrong code of message."); + if ((MsgCod = DB_GetNextCode (mysql_res)) <= 0) + Lay_WrongMessageExit (); switch (Messages->TypeOfMessages) { @@ -2011,7 +2010,7 @@ static void Msg_ShowSentOrReceivedMessages (struct Msg_Messages *Messages) { row = mysql_fetch_row (mysql_res); if (sscanf (row[0],"%ld",&MsgCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of message when searching for a page."); + Lay_WrongMessageExit (); if (MsgCod == Messages->ExpandedMsgCod) // Expanded message found { @@ -2046,7 +2045,7 @@ static void Msg_ShowSentOrReceivedMessages (struct Msg_Messages *Messages) row = mysql_fetch_row (mysql_res); if (sscanf (row[0],"%ld",&MsgCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of message when listing the messages in a page."); + Lay_WrongMessageExit (); NumMsg = NumRows - NumRow + 1; Msg_ShowASentOrReceivedMessage (Messages,NumMsg,MsgCod); } @@ -3106,7 +3105,7 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod, /* Result should have a unique row */ if (NumRows != 1) - Lay_ShowErrorAndExit ("Error when getting data of a message."); + Lay_WrongMessageExit (); /* Get number of rows */ row = mysql_fetch_row (mysql_res); @@ -3159,7 +3158,7 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT " FROM msg_content" " WHERE MsgCod=%ld", MsgCod) != 1) - Lay_ShowErrorAndExit ("Error when getting content of a message."); + Lay_WrongMessageExit (); /***** Get number of rows *****/ row = mysql_fetch_row (mysql_res); @@ -4054,7 +4053,7 @@ void Msg_BanSenderWhenShowingMsgs (void) if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat, Usr_DONT_GET_PREFS, Usr_DONT_GET_ROLE_IN_CURRENT_CRS)) - Lay_ShowErrorAndExit ("Sender does not exist."); + Lay_WrongUserExit (); /***** Insert pair (sender's code - my code) in table of banned senders if not inserted *****/ DB_QueryREPLACE ("can not ban sender", @@ -4114,7 +4113,7 @@ static void Msg_UnbanSender (void) if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat, Usr_DONT_GET_PREFS, Usr_DONT_GET_ROLE_IN_CURRENT_CRS)) - Lay_ShowErrorAndExit ("Sender does not exist."); + Lay_WrongUserExit (); /***** Remove pair (sender's code - my code) from table of banned senders *****/ DB_QueryDELETE ("can not ban sender", diff --git a/swad_notice.c b/swad_notice.c index 4cbe4a56..caf28de3 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -447,7 +447,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod) /* Get notice code (row[0]) */ if (sscanf (row[0],"%ld",&NotCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of notice."); + Lay_WrongNoticeExit (); /* Get creation time (row[1] holds the UTC date-time) */ TimeUTC = Dat_GetUNIXTimeFromStr (row[1]); diff --git a/swad_notification.c b/swad_notification.c index 1df536ae..fe9886bc 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -455,7 +455,7 @@ void Ntf_ShowMyNotifications (void) /* Get status (row[8]) */ if (sscanf (row[8],"%u",&Status) != 1) - Lay_ShowErrorAndExit ("Wrong notification status."); + Lay_WrongStatusExit (); StatusTxt = Ntf_GetStatusTxtFromStatusBits (Status); if (Status & Ntf_STATUS_BIT_REMOVED) // The source of the notification was removed diff --git a/swad_place.c b/swad_place.c index b4296c2b..c722b4ea 100644 --- a/swad_place.c +++ b/swad_place.c @@ -412,8 +412,8 @@ void Plc_GetListPlaces (struct Plc_Places *Places) row = mysql_fetch_row (mysql_res); /* Get place code (row[0]) */ - if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of place."); + if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongPlaceExit (); /* Get the short (row[1]) and full (row[2]) names of the place */ Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1); @@ -615,8 +615,8 @@ void Plc_RemovePlace (void) Plc_EditingPlaceConstructor (); /***** Get place code *****/ - if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of place is missing."); + if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0) + Lay_WrongPlaceExit (); /***** Get data of the place from database *****/ Plc_GetDataOfPlaceByCod (Plc_EditingPlc); @@ -699,8 +699,8 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get the code of the place */ - if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of place is missing."); + if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0) + Lay_WrongPlaceExit (); /* Get the new name for the place */ Par_GetParToText (ParamName,NewPlcName,MaxBytes); @@ -941,7 +941,7 @@ static void Plc_EditingPlaceConstructor (void) { /***** Pointer must be NULL *****/ if (Plc_EditingPlc != NULL) - Lay_ShowErrorAndExit ("Error initializing place."); + Lay_WrongPlaceExit (); /***** Allocate memory for place *****/ if ((Plc_EditingPlc = malloc (sizeof (*Plc_EditingPlc))) == NULL) diff --git a/swad_plugin.c b/swad_plugin.c index d069fa67..b81476cc 100644 --- a/swad_plugin.c +++ b/swad_plugin.c @@ -260,8 +260,8 @@ static void Plg_GetListPlugins (void) row = mysql_fetch_row (mysql_res); /* Get plugin code (row[0]) */ - if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of plugin."); + if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongPluginExit (); /* Get name (row[1]), description (row[2), logo (row[3]), * application key (row[4]), URL (row[5]) and IP (row[6]) of the plugin */ @@ -492,8 +492,8 @@ void Plg_RemovePlugin (void) Plg_EditingPluginConstructor (); /***** Get plugin code *****/ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /***** Get data of the plugin from database *****/ Plg_GetDataOfPluginByCod (Plg_EditingPlg); @@ -526,8 +526,8 @@ void Plg_RenamePlugin (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new name for the plugin */ Par_GetParToText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME); @@ -605,8 +605,8 @@ void Plg_ChangePlgDescription (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new description for the plugin */ Par_GetParToText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION); @@ -652,8 +652,8 @@ void Plg_ChangePlgLogo (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new logo for the plugin */ Par_GetParToText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO); @@ -698,8 +698,8 @@ void Plg_ChangePlgAppKey (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new logo for the plugin */ Par_GetParToText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY); @@ -744,8 +744,8 @@ void Plg_ChangePlgURL (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new URL for the plugin */ Par_GetParToText ("URL",NewURL,Cns_MAX_BYTES_WWW); @@ -790,8 +790,8 @@ void Plg_ChangePlgIP (void) /***** Get parameters from form *****/ /* Get the code of the plugin */ - if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of plugin is missing."); + if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0) + Lay_WrongPluginExit (); /* Get the new IP for the plugin */ Par_GetParToText ("IP",NewIP,Cns_MAX_BYTES_IP); @@ -1047,7 +1047,7 @@ static void Plg_EditingPluginConstructor (void) { /***** Pointer must be NULL *****/ if (Plg_EditingPlg != NULL) - Lay_ShowErrorAndExit ("Error initializing plugin."); + Lay_WrongPluginExit (); /***** Allocate memory for plugin *****/ if ((Plg_EditingPlg = malloc (sizeof (*Plg_EditingPlg))) == NULL) diff --git a/swad_program.c b/swad_program.c index 9af95941..e6296e42 100644 --- a/swad_program.c +++ b/swad_program.c @@ -1004,8 +1004,8 @@ static void Prg_GetListItems (void) row = mysql_fetch_row (mysql_res); /* Get code of the program item (row[0]) */ - if ((Prg_Gbl.List.Items[NumItem].ItmCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Error: wrong program item code."); + if ((Prg_Gbl.List.Items[NumItem].ItmCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongItemExit (); /* Get index of the program item (row[1]) */ Prg_Gbl.List.Items[NumItem].Index = Str_ConvertStrToUnsigned (row[1]); @@ -1201,7 +1201,7 @@ static unsigned Prg_GetNumItemFromItmCod (long ItmCod) /***** List of items must be filled *****/ if (!Prg_Gbl.List.IsRead || Prg_Gbl.List.Items == NULL) - Lay_ShowErrorAndExit ("Wrong list of items."); + Lay_WrongItemsListExit (); /***** Find item code in list *****/ for (NumItem = 0; @@ -1211,7 +1211,7 @@ static unsigned Prg_GetNumItemFromItmCod (long ItmCod) return NumItem; /***** Not found *****/ - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); return 0; // Not reached } @@ -1233,7 +1233,7 @@ void Prg_ReqRemItem (void) Item.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&Item); if (Item.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Show question and button to remove the program item *****/ Ale_ShowAlertAndButton (ActRemPrgItm,NULL,NULL, @@ -1269,7 +1269,7 @@ void Prg_RemoveItem (void) Item.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&Item); if (Item.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Indexes of items *****/ Prg_SetItemRangeWithAllChildren (Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod), @@ -1326,7 +1326,7 @@ static void Prg_HideUnhideItem (char YN) Item.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&Item); if (Item.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Hide/unhide program item *****/ DB_QueryUPDATE ("can not change program item", @@ -1381,7 +1381,7 @@ static void Prg_MoveUpDownItem (Prg_MoveUpDown_t UpDown) Item.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&Item); if (Item.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Move up/down item *****/ NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod); @@ -1615,7 +1615,7 @@ static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight) Item.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&Item); if (Item.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Move up/down item *****/ NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod); @@ -1663,7 +1663,7 @@ static void Prg_SetItemRangeEmpty (struct ItemRange *ItemRange) { /***** List of items must be filled *****/ if (!Prg_Gbl.List.IsRead) - Lay_ShowErrorAndExit ("Wrong list of items."); + Lay_WrongItemsListExit (); /***** Range is empty *****/ if (Prg_Gbl.List.NumItems) @@ -1678,7 +1678,7 @@ static void Prg_SetItemRangeOnlyItem (unsigned Index,struct ItemRange *ItemRange { /***** List of items must be filled *****/ if (!Prg_Gbl.List.IsRead) - Lay_ShowErrorAndExit ("Wrong list of items."); + Lay_WrongItemsListExit (); /***** Range includes only this item *****/ ItemRange->Begin = @@ -1689,11 +1689,11 @@ static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct ItemRange * { /***** List of items must be filled *****/ if (!Prg_Gbl.List.IsRead) - Lay_ShowErrorAndExit ("Wrong list of items."); + Lay_WrongItemsListExit (); /***** Number of item must be in the correct range *****/ if (NumItem >= Prg_Gbl.List.NumItems) - Lay_ShowErrorAndExit ("Wrong item number."); + Lay_WrongItemExit (); /***** Range includes this item and all its children *****/ ItemRange->Begin = Prg_Gbl.List.Items[NumItem ].Index; @@ -1712,7 +1712,7 @@ static unsigned Prg_GetLastChild (int NumItem) /***** Trivial check: if item is wrong, there are no children *****/ if (NumItem < 0 || NumItem >= (int) Prg_Gbl.List.NumItems) - Lay_ShowErrorAndExit ("Wrong number of item."); + Lay_WrongItemExit (); /***** Get next brother after item *****/ // 0 <= NumItem < Prg_Gbl.List.NumItems @@ -2013,7 +2013,7 @@ void Prg_ReceiveFormChgItem (void) NewItem.Hierarchy.ItmCod = Prg_GetParamItmCod (); Prg_GetDataOfItemByCod (&NewItem); if (NewItem.Hierarchy.ItmCod <= 0) - Lay_ShowErrorAndExit ("Wrong item code."); + Lay_WrongItemExit (); /***** Get data of the old (current) program item from database *****/ OldItem.Hierarchy.ItmCod = NewItem.Hierarchy.ItmCod; diff --git a/swad_project.c b/swad_project.c index 6a9a5d9d..e8a7ce02 100644 --- a/swad_project.c +++ b/swad_project.c @@ -876,7 +876,7 @@ static Prj_HiddenVisibl_t Prj_GetHiddenParamHidVis (void) (unsigned) Prj_FILTER_HIDDEN_DEFAULT | (unsigned) Prj_FILTER_VISIBL_DEFAULT); default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); return Prj_NEW_PRJ_HIDDEN_VISIBL_DEFAULT; // Not reached } } @@ -2430,7 +2430,7 @@ static void Prj_FormToSelectUsrs (struct Prj_Projects *Projects, /***** Get parameters *****/ Prj_GetParams (Projects); - if ((Projects->PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) == -1L) + if ((Projects->PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) <= 0) Lay_WrongProjectExit (); /***** Put form to select users *****/ @@ -2508,7 +2508,7 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject) /***** Get parameters *****/ Prj_GetParams (&Projects); - if ((Projects.PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) == -1L) + if ((Projects.PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) <= 0) Lay_WrongProjectExit (); /***** Add the selected users to project *****/ @@ -2918,7 +2918,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects) } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } diff --git a/swad_record.c b/swad_record.c index bac0fcd1..ede67cef 100644 --- a/swad_record.c +++ b/swad_record.c @@ -230,8 +230,8 @@ void Rec_GetListRecordFieldsInCurrentCrs (void) row = mysql_fetch_row (mysql_res); /* Get the code of field (row[0]) */ - if ((Gbl.Crs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of field."); + if ((Gbl.Crs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongRecordFieldExit (); /* Name of the field (row[1]) */ Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1], @@ -242,7 +242,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void) /* Visible or editable by students? (row[3]) */ if (sscanf (row[3],"%u",&Vis) != 1) - Lay_ShowErrorAndExit ("Error when getting field of record in current course."); + Lay_WrongRecordFieldExit (); if (Vis < Rec_NUM_TYPES_VISIBILITY) Gbl.Crs.Records.LstFields.Lst[NumRow].Visibility = (Rec_VisibilityRecordFields_t) Vis; else @@ -567,8 +567,8 @@ void Rec_ReqRemField (void) unsigned NumRecords; /***** Get the code of field *****/ - if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1) - Lay_ShowErrorAndExit ("Code of field is missing."); + if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0) + Lay_WrongRecordFieldExit (); /***** Check if exists any record with that field filled *****/ if ((NumRecords = Rec_CountNumRecordsInCurrCrsWithField (Gbl.Crs.Records.Field.FieldCod))) // There are records with that field filled @@ -688,13 +688,13 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD /***** Get a field of a record in a course from database *****/ if (DB_QuerySELECT (&mysql_res,"can not get a field of a record in a course", "SELECT FieldName," // row[0] - "NumLines," // row[1] + "NumLines," // row[1] "Visibility" // row[2] " FROM crs_record_fields" " WHERE CrsCod=%ld" " AND FieldCod=%ld", Gbl.Hierarchy.Crs.CrsCod,FieldCod) != 1) - Lay_ShowErrorAndExit ("Error when getting a field of a record in a course."); + Lay_WrongRecordFieldExit (); /***** Get the field *****/ row = mysql_fetch_row (mysql_res); @@ -707,7 +707,7 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD /* Visible or editable by students? (row[2]) */ if (sscanf (row[2],"%u",&Vis) != 1) - Lay_ShowErrorAndExit ("Error when getting a field of a record in a course."); + Lay_WrongRecordFieldExit (); if (Vis < Rec_NUM_TYPES_VISIBILITY) *Visibility = (Rec_VisibilityRecordFields_t) Vis; else @@ -724,8 +724,8 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD void Rec_RemoveField (void) { /***** Get the code of the field *****/ - if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1) - Lay_ShowErrorAndExit ("Code of field is missing."); + if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0) + Lay_WrongRecordFieldExit (); /***** Borrarlo from the database *****/ Rec_RemoveFieldFromDB (); @@ -744,8 +744,8 @@ void Rec_RenameField (void) /***** Get parameters of the form *****/ /* Get the code of the field */ - if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1) - Lay_ShowErrorAndExit ("Code of field is missing."); + if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0) + Lay_WrongRecordFieldExit (); /* Get the new group name */ Par_GetParToText ("FieldName",NewFieldName,Rec_MAX_BYTES_NAME_FIELD); @@ -807,8 +807,8 @@ void Rec_ChangeLinesField (void) /***** Get parameters of the form *****/ /* Get the code of field */ - if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1) - Lay_ShowErrorAndExit ("Code of field is missing."); + if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0) + Lay_WrongRecordFieldExit (); /* Get the new number of lines */ NewNumLines = (unsigned) @@ -857,8 +857,8 @@ void Rec_ChangeVisibilityField (void) /***** Get parameters of the form *****/ /* Get the code of field */ - if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) == -1) - Lay_ShowErrorAndExit ("Code of field is missing."); + if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0) + Lay_WrongRecordFieldExit (); /* Get the new visibility of the field */ NewVisibility = (Rec_VisibilityRecordFields_t) @@ -1727,7 +1727,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView, } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } /***** Begin box and table *****/ @@ -3697,7 +3697,7 @@ Rol_Role_t Rec_GetRoleFromRecordForm (void) break; } if (!RoleOK) - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); return Role; } diff --git a/swad_report.c b/swad_report.c index ac66a9c8..3c6eb1b1 100644 --- a/swad_report.c +++ b/swad_report.c @@ -1285,7 +1285,7 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role, /* Get the year (in row[0] is the date in YYYY format) */ if (sscanf (row[0],"%04u",&ReadYear) != 1) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get number hits (in row[1]) */ if (sscanf (row[1],"%lu",&Report->Hits.Num) != 1) diff --git a/swad_role.c b/swad_role.c index 00d17071..fa88c2ad 100644 --- a/swad_role.c +++ b/swad_role.c @@ -646,12 +646,3 @@ Rol_Role_t Rol_GetRequestedRole (long UsrCod) Gbl.Hierarchy.Crs.CrsCod, UsrCod); } - -/*****************************************************************************/ -/************* Show error message about wrong role and exit ******************/ -/*****************************************************************************/ - -void Rol_WrongRoleExit (void) - { - Lay_ShowErrorAndExit ("Wrong role."); - } diff --git a/swad_role.h b/swad_role.h index c3da4f65..bf788e7a 100644 --- a/swad_role.h +++ b/swad_role.h @@ -64,6 +64,4 @@ unsigned Rol_GetSelectedRoles (void); Rol_Role_t Rol_GetRequestedRole (long UsrCod); -void Rol_WrongRoleExit (void); - #endif diff --git a/swad_room.c b/swad_room.c index 128cfbb2..bb4c9539 100644 --- a/swad_room.c +++ b/swad_room.c @@ -380,8 +380,8 @@ void Roo_ChangeMAC (void) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Par_GetParToLong ("Cod")) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Par_GetParToLong ("Cod")) <= 0) + Lay_WrongRoomExit (); /* Get the old MAC address of the room */ OldMACnum = MAC_GetMACnumFromForm ("MAC"); @@ -619,8 +619,8 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms, row = mysql_fetch_row (mysql_res); /* Get room code (row[0]) */ - if ((Room->RooCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of room."); + if ((Room->RooCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongRoomExit (); switch (WhichData) { @@ -1005,8 +1005,8 @@ void Roo_RemoveRoom (void) Roo_EditingRoomConstructor (); /***** Get room code *****/ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /***** Get data of the room from database *****/ Roo_GetDataOfRoomByCod (Roo_EditingRoom); @@ -1058,8 +1058,8 @@ void Roo_ChangeBuilding (void) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /* Get room building */ NewBldCod = Bld_GetParamBldCod (); @@ -1111,8 +1111,8 @@ void Roo_ChangeFloor (void) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /* Get room floor */ NewFloor = Roo_GetParamFloor (); @@ -1163,8 +1163,8 @@ void Roo_ChangeType (void) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /* Get room type */ NewType = Roo_GetParamType (); @@ -1260,8 +1260,8 @@ static void Roo_RenameRoom (Cns_ShrtOrFullName_t ShrtOrFullName) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /* Get the new name for the room */ Par_GetParToText (ParamName,NewClaName,MaxBytes); @@ -1354,8 +1354,8 @@ void Roo_ChangeCapacity (void) /***** Get parameters from form *****/ /* Get room code */ - if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of room is missing."); + if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0) + Lay_WrongRoomExit (); /* Get the seating capacity of the room */ NewCapacity = (unsigned) @@ -1656,7 +1656,7 @@ static void Roo_EditingRoomConstructor (void) { /***** Pointer must be NULL *****/ if (Roo_EditingRoom != NULL) - Lay_ShowErrorAndExit ("Error initializing room."); + Lay_WrongRoomExit (); /***** Allocate memory for room *****/ if ((Roo_EditingRoom = malloc (sizeof (*Roo_EditingRoom))) == NULL) diff --git a/swad_statistic.c b/swad_statistic.c index afecdd6c..c1d094dd 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1726,7 +1726,7 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats, /* Get logged role */ if (sscanf (row[2],"%u",&RoleFromLog) != 1) - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); HTM_TR_Begin (NULL); @@ -1764,7 +1764,7 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats, /* Write the action */ if (sscanf (row[4],"%ld",&ActCod) != 1) - Lay_ShowErrorAndExit ("Wrong action code."); + Lay_WrongActionExit (); HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd); if (ActCod >= 0) HTM_TxtF ("%s ",Act_GetActionText (Act_FromActCodToAction[ActCod])); @@ -1964,7 +1964,7 @@ static void Sta_ShowNumHitsPerDay (Sta_CountType_t CountType, /* Get year, month and day (row[0] holds the date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&ReadDate,row[0]))) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get number of pages generated (in row[1]) */ Hits.Num = Str_GetDoubleFromStr (row[1]); @@ -2172,11 +2172,11 @@ static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats, /* Get year, month and day (row[0] holds the date in YYYYMMDD format) */ if (!(Dat_GetDateFromYYYYMMDD (&CurrentReadDate,row[0]))) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get the hour (in row[1] is the hour in formato HH) */ if (sscanf (row[1],"%02u",&ReadHour) != 1) - Lay_ShowErrorAndExit ("Wrong hour."); + Lay_WrongDateExit (); /* Get number of pages generated (in row[2]) */ Hits.Num = Str_GetDoubleFromStr (row[2]); @@ -2542,7 +2542,7 @@ static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType, /* Get year and week (row[0] holds date in YYYYWW format) */ if (sscanf (row[0],"%04u%02u",&ReadDate.Year,&ReadDate.Week) != 2) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get number of pages generated (in row[1]) */ Hits.Num = Str_GetDoubleFromStr (row[1]); @@ -2643,7 +2643,7 @@ static void Sta_ShowNumHitsPerMonth (Sta_CountType_t CountType, /* Get the year and the month (in row[0] is the date in YYYYMM format) */ if (sscanf (row[0],"%04u%02u",&ReadDate.Year,&ReadDate.Month) != 2) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get number of pages generated (in row[1]) */ Hits.Num = Str_GetDoubleFromStr (row[1]); @@ -2744,7 +2744,7 @@ static void Sta_ShowNumHitsPerYear (Sta_CountType_t CountType, /* Get the year (in row[0] is the date in YYYY format) */ if (sscanf (row[0],"%04u",&ReadDate.Year) != 1) - Lay_ShowErrorAndExit ("Wrong date."); + Lay_WrongDateExit (); /* Get number of pages generated (in row[1]) */ Hits.Num = Str_GetDoubleFromStr (row[1]); @@ -2844,7 +2844,7 @@ static void Sta_ShowNumHitsPerHour (unsigned NumHits, row = mysql_fetch_row (mysql_res); // Get next result NumHit++; if (sscanf (row[0],"%02u",&ReadHour) != 1) // In row[0] is the date in HH format - Lay_ShowErrorAndExit ("Wrong hour."); + Lay_WrongDateExit (); for (H = Hour; H < ReadHour; @@ -2939,7 +2939,7 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned NumHits,MYSQL_RES *mysql_ row = mysql_fetch_row (mysql_res); // Get next result NumHit++; if (sscanf (row[0],"%02u%02u",&ReadHour,&MinuteRead) != 2) // In row[0] is the date in formato HHMM - Lay_ShowErrorAndExit ("Wrong hour-minute."); + Lay_WrongDateExit (); /* Get number of pages generated */ Hits.Num = Str_GetDoubleFromStr (row[1]); MinuteDayRead = ReadHour * 60 + MinuteRead; @@ -3221,7 +3221,7 @@ static void Sta_ShowNumHitsPerPlugin (Sta_CountType_t CountType, /* Write the plugin */ if (sscanf (row[0],"%ld",&Plg.PlgCod) != 1) - Lay_ShowErrorAndExit ("Wrong plugin code."); + Lay_WrongPluginExit (); HTM_TD_Begin ("class=\"LOG RT\""); if (Plg_GetDataOfPluginByCod (&Plg)) HTM_Txt (Plg.Name); @@ -3343,7 +3343,7 @@ static void Sta_ShowNumHitsPerBanner (Sta_CountType_t CountType, /* Write the banner */ if (sscanf (row[0],"%ld",&(Ban.BanCod)) != 1) - Lay_ShowErrorAndExit ("Wrong banner code."); + Lay_WrongBannerExit (); Ban_GetDataOfBannerByCod (&Ban); HTM_TD_Begin ("class=\"LOG LT\""); HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"DAT\" target=\"_blank\"", diff --git a/swad_survey.c b/swad_survey.c index 3285d5fc..edbd9782 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1894,7 +1894,7 @@ void Svy_RequestCreatOrEditSvy (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get the code of the survey *****/ - ItsANewSurvey = ((Svy.SvyCod = Svy_GetParamSvyCod ()) == -1L); + ItsANewSurvey = ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0); /***** Get from the database the data of the survey *****/ if (ItsANewSurvey) @@ -2205,7 +2205,7 @@ void Svy_ReceiveFormSurvey (void) Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS); /***** Get the code of the survey *****/ - ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) == -1L); + ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) <= 0); if (ItsANewSurvey) NewSvy.Scope = Hie_Lvl_UNK; @@ -2767,7 +2767,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys, row = mysql_fetch_row (mysql_res); if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns)) /* Abort on error */ Ale_ShowAlertsAndExit (); diff --git a/swad_syllabus.c b/swad_syllabus.c index 46a136b8..0cc13810 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -350,7 +350,7 @@ static void Syl_SetSyllabusTypeFromAction (struct Syl_Syllabus *Syllabus) Gbl.Crs.Info.Type = Inf_PRACTICALS; break; default: - Lay_ShowErrorAndExit ("Wrong action."); + Lay_WrongActionExit (); break; } } @@ -381,7 +381,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus, /***** Go to the start of the list of items *****/ if (!Str_FindStrInFile (Gbl.F.XML,"",Str_NO_SKIP_HTML_COMMENTS)) - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); /***** Save the position of the start of the list *****/ PostBeginList = ftell (Gbl.F.XML); @@ -429,7 +429,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus, { /* Go to the start of the item */ if (!Str_FindStrInFile (Gbl.F.XML,"",Str_NO_SKIP_HTML_COMMENTS)) // End the search - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); } else if (Result == -1) - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); } /***** Close the file with the syllabus *****/ @@ -507,12 +507,12 @@ int Syl_ReadLevelItemSyllabus (void) char StrlLevel[11 + 1]; if (!Str_FindStrInFile (Gbl.F.XML,"nivel=\"",Str_NO_SKIP_HTML_COMMENTS)) - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); if (Str_ReadFileUntilBoundaryStr (Gbl.F.XML,StrlLevel,"\"",1, (unsigned long long) (11 + 1)) != 1) - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); if (sscanf (StrlLevel,"%d",&Level) != 1) - Lay_ShowErrorAndExit ("Wrong syllabus format."); + Lay_WrongSyllabusFormatExit (); Str_FindStrInFile (Gbl.F.XML,">",Str_NO_SKIP_HTML_COMMENTS); if (Level < 1) Level = 1; diff --git a/swad_tag.c b/swad_tag.c index ac111f9d..aeb8d545 100644 --- a/swad_tag.c +++ b/swad_tag.c @@ -230,7 +230,7 @@ static long Tag_GetParamTagCode (void) /***** Get tag code *****/ if ((TagCod = Par_GetParToLong ("TagCod")) <= 0) - Lay_ShowErrorAndExit ("Code of tag is missing."); + Lay_WrongTagExit (); return TagCod; } @@ -285,8 +285,8 @@ void Tag_RenameTag (void) - If the new tag did not exist for a question ==> change old tag to new tag in tst_question_tags *****/ /* Get tag code of the old tag */ - if ((OldTagCod = Tag_GetTagCodFromTagTxt (OldTagTxt)) < 0) - Lay_ShowErrorAndExit ("Tag does not exists."); + if ((OldTagCod = Tag_GetTagCodFromTagTxt (OldTagTxt)) <= 0) + Lay_WrongTagExit (); /* Create a temporary table with all the question codes that had the new tag as one of their tags */ @@ -577,8 +577,8 @@ void Tag_ShowFormEditTags (void) row[1] TagTxt row[2] TagHidden */ - if ((TagCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of tag."); + if ((TagCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongTagExit (); HTM_TR_Begin (NULL); diff --git a/swad_test.c b/swad_test.c index 69f7fc3e..8eb72187 100644 --- a/swad_test.c +++ b/swad_test.c @@ -435,7 +435,7 @@ void Tst_ReceiveTestDraft (void) /* Get test exam code from form */ TstPrn_ResetPrint (&Print); if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong test exam."); + Lay_WrongTestExit (); /* Get number of this test from form */ NumTst = Tst_GetParamNumTst (); @@ -491,7 +491,7 @@ void Tst_AssessTest (void) /* Get test exam code from form */ TstPrn_ResetPrint (&Print); if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0) - Lay_ShowErrorAndExit ("Wrong test exam."); + Lay_WrongTestExit (); /* Get number of this test from form */ NumTst = Tst_GetParamNumTst (); @@ -2903,7 +2903,7 @@ void Tst_WriteParamQstCod (unsigned NumQst,long QstCod) void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question) { if (Question->Answer.NumOptions != 1) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); } /*****************************************************************************/ @@ -3944,7 +3944,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) break; case Tst_ANS_FLOAT: if (Question->Answer.NumOptions != 2) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]); break; case Tst_ANS_TRUE_FALSE: @@ -3956,7 +3956,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) case Tst_ANS_TEXT: /* Check number of options */ if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION) - Lay_ShowErrorAndExit ("Wrong answer."); + Lay_WrongAnswerExit (); /* Allocate space for text and feedback */ if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) @@ -4142,7 +4142,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) Tst_NUM_ANS_TYPES - 1, (unsigned long) Tst_ANS_UNKNOWN); if (Question->Answer.Type == Tst_ANS_UNKNOWN) - Lay_ShowErrorAndExit ("Wrong type of answer."); + Lay_WrongAnswerExit (); /***** Get question tags *****/ for (NumTag = 0; @@ -4279,9 +4279,9 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) { Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); if (sscanf (UnsignedStr,"%u",&NumCorrectAns) != 1) - Lay_ShowErrorAndExit ("Wrong selected answer."); + Lay_WrongAnswerExit (); if (NumCorrectAns >= Tst_MAX_OPTIONS_PER_QUESTION) - Lay_ShowErrorAndExit ("Wrong selected answer."); + Lay_WrongAnswerExit (); Question->Answer.Options[NumCorrectAns].Correct = true; } } diff --git a/swad_test_import.c b/swad_test_import.c index a5f214a8..3e40efa6 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -218,8 +218,8 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res) /* Get question code (row[0]) */ row = mysql_fetch_row (mysql_res); - if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_WrongQuestionExit (); TsI_ExportQuestion (&Question,FileXML); @@ -651,7 +651,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) } } else // Answer type not found - Lay_ShowErrorAndExit ("Wrong type of answer."); + Lay_WrongAnswerExit (); /***** Destroy test question *****/ Tst_QstDestructor (&Question); @@ -687,7 +687,7 @@ static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsT if (!strcasecmp (StrAnsTypeXML,Tst_StrAnswerTypesXML[AnsType])) return AnsType; - Lay_ShowErrorAndExit ("Wrong type of answer."); + Lay_WrongAnswerExit (); return (Tst_AnswerType_t) 0; // Not reached } diff --git a/swad_test_print.c b/swad_test_print.c index a7d1db6a..b3868981 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -890,7 +890,7 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) /***** Get correct answer *****/ row = mysql_fetch_row (mysql_res); if (sscanf (row[0],"%ld",&Question->Answer.Integer) != 1) - Lay_ShowErrorAndExit ("Wrong integer answer."); + Lay_WrongAnswerExit (); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -913,7 +913,7 @@ static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) /***** Check if number of rows is correct *****/ if (Question->Answer.NumOptions != 2) - Lay_ShowErrorAndExit ("Wrong float range."); + Lay_WrongAnswerExit (); /***** Get float range *****/ for (NumOpt = 0; @@ -1257,10 +1257,10 @@ void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES Par_GetNextStrUntilComma (&Ptr,StrOneIndex,Cns_MAX_DECIMAL_DIGITS_UINT); if (sscanf (StrOneIndex,"%u",&(Indexes[NumOpt])) != 1) - Lay_ShowErrorAndExit ("Wrong index of answer."); + Lay_WrongAnswerIndexExit (); if (Indexes[NumOpt] >= Tst_MAX_OPTIONS_PER_QUESTION) - Lay_ShowErrorAndExit ("Wrong index of answer."); + Lay_WrongAnswerIndexExit (); } /***** Initialize remaining to 0 *****/ @@ -1296,10 +1296,10 @@ void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS Par_GetNextStrUntilComma (&Ptr,StrOneAnswer,Cns_MAX_DECIMAL_DIGITS_UINT); if (sscanf (StrOneAnswer,"%u",&AnsUsr) != 1) - Lay_ShowErrorAndExit ("Bad user's answer."); + Lay_WrongAnswerExit (); if (AnsUsr >= Tst_MAX_OPTIONS_PER_QUESTION) - Lay_ShowErrorAndExit ("Bad user's answer."); + Lay_WrongAnswerExit (); UsrAnswers[AnsUsr] = true; } @@ -1454,7 +1454,7 @@ static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat, /***** Check if number of rows is correct *****/ if (Question->Answer.NumOptions != 2) - Lay_ShowErrorAndExit ("Wrong float range."); + Lay_WrongAnswerExit (); /***** Header with the title of each column *****/ HTM_TABLE_BeginPadding (2); @@ -2104,7 +2104,7 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat) /* Get print code (row[0]) */ if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of test exam."); + Lay_WrongTestExit (); /* Get print data */ TstPrn_GetPrintDataByPrnCod (&Print); @@ -2398,8 +2398,8 @@ void TstPrn_ShowOnePrint (void) /***** Get the code of the test *****/ TstPrn_ResetPrint (&Print); - if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of test is missing."); + if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0) + Lay_WrongTestExit (); /***** Get test exam data *****/ TstPrn_GetPrintDataByPrnCod (&Print); diff --git a/swad_timetable.c b/swad_timetable.c index 4b61a3b3..0d613e13 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -344,7 +344,7 @@ void Tmt_ShowClassTimeTable (void) Timetable.Type = Tmt_MY_TIMETABLE; break; default: - Lay_ShowErrorAndExit ("Wrong action."); + Lay_WrongActionExit (); } Timetable.ContextualIcons.PutIconEditCrsTT = (Timetable.Type == Tmt_COURSE_TIMETABLE && diff --git a/swad_user.c b/swad_user.c index c5066440..f563c0f9 100644 --- a/swad_user.c +++ b/swad_user.c @@ -1145,7 +1145,7 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole, break; default: SubQueryRole[0] = '\0'; - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } DB_Query ("can not create temporary table", @@ -2977,11 +2977,11 @@ void Usr_GetParamOtherUsrCodEncrypted (struct UsrData *UsrDat) { Par_GetParToText ("OtherUsrCod",UsrDat->EnUsrCod, Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); - if (UsrDat->EnUsrCod[0]) // If parameter exists... + if (UsrDat->EnUsrCod[0]) // If parameter exists... { Usr_GetUsrCodFromEncryptedUsrCod (UsrDat); - if (UsrDat->UsrCod < 0) // Check is user's code is valid - Lay_ShowErrorAndExit ("Wrong user's code."); + if (UsrDat->UsrCod <= 0) // Check is user's code is valid + Lay_WrongUserExit (); } else UsrDat->UsrCod = -1L; @@ -5087,7 +5087,7 @@ void Usr_SearchListUsrs (Rol_Role_t Role) } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -5656,7 +5656,7 @@ static void Usr_GetListUsrsFromQuery (char *Query,Rol_Role_t Role,Hie_Lvl_Level_ } break; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); break; } @@ -6621,7 +6621,7 @@ static void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role, free (ParamName); } else - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); Sex = Usr_GetSexOfUsrsLst (Role); HTM_TxtColon (Gbl.Usrs.LstUsrs[Role].NumUsrs == 1 ? Txt_ROLES_SINGUL_Abc[Role][Sex] : Txt_ROLES_PLURAL_Abc[Role][Sex]); @@ -6701,7 +6701,7 @@ static void Usr_PutCheckboxToSelectUser (Rol_Role_t Role, free (ParamName); } else - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); } /*****************************************************************************/ @@ -9712,7 +9712,7 @@ static FigCch_FigureCached_t Usr_GetFigureNumUsrsInCrss (unsigned Roles) 1 << Rol_TCH: // Any user in courses return FigCch_NUM_USRS_IN_CRSS; default: - Rol_WrongRoleExit (); + Lay_WrongRoleExit (); return FigCch_UNKNOWN; // Not reached } }