void Ban_RecFormNewBanner (void) { extern const char *Txt_The_banner_X_already_exists; extern const char *Txt_You_must_specify_the_image_of_the_new_banner; extern const char *Txt_You_must_specify_the_URL_of_the_new_banner; extern const char *Txt_Created_new_banner_X; extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_banner; /***** Banner constructor *****/ Ban_EditingBannerConstructor (); /***** Get parameters from form *****/ /* Get banner short name */ Par_GetParToText ("ShortName",Ban_EditingBan->ShrtName,Ban_MAX_BYTES_SHRT_NAME); /* Get banner full name */ Par_GetParToText ("FullName",Ban_EditingBan->FullName,Ban_MAX_BYTES_FULL_NAME); /* Get banner image */ Par_GetParToText ("Img",Ban_EditingBan->Img,Ban_MAX_BYTES_IMAGE); /* Get banner URL */ Par_GetParToText ("WWW",Ban_EditingBan->WWW,Cns_MAX_BYTES_WWW); if (Ban_EditingBan->ShrtName[0] && Ban_EditingBan->FullName[0]) // If there's a banner name { /***** If name of banner was in database... *****/ if (Ban_CheckIfBannerNameExists ("ShortName",Ban_EditingBan->ShrtName,-1L)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_banner_X_already_exists, Ban_EditingBan->ShrtName); else if (Ban_CheckIfBannerNameExists ("FullName",Ban_EditingBan->FullName,-1L)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_banner_X_already_exists, Ban_EditingBan->FullName); else if (!Ban_EditingBan->Img[0]) Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_must_specify_the_image_of_the_new_banner); else if (!Ban_EditingBan->WWW[0]) Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_must_specify_the_URL_of_the_new_banner); else // Add new banner to database { Ban_CreateBanner (Ban_EditingBan); Ale_CreateAlert (Ale_SUCCESS,Txt_Created_new_banner_X, Ban_EditingBan->ShrtName); } } else // If there is not a banner name Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_banner); }
static void Net_GetMyWebsAndSocialNetsFromForm (void) { Net_WebsAndSocialNetworks_t NumURL; char ParamName[3 + 10 + 1]; char URL[Cns_MAX_BYTES_WWW + 1]; /***** Get URLs *****/ for (NumURL = (Net_WebsAndSocialNetworks_t) 0; NumURL < Net_NUM_WEBS_AND_SOCIAL_NETWORKS; NumURL++) { /***** Get URL from the form *****/ snprintf (ParamName,sizeof (ParamName), "URL%u", (unsigned) NumURL); Par_GetParToText (ParamName,URL,Cns_MAX_BYTES_WWW); if (URL[0]) /***** Insert or replace web / social network *****/ DB_QueryREPLACE ("can not update user's web / social network", "REPLACE INTO usr_webs" " (UsrCod,Web,URL)" " VALUES" " (%ld,'%s','%s')", Gbl.Usrs.Me.UsrDat.UsrCod, Net_WebsAndSocialNetworksDB[NumURL], URL); else /***** Remove web / social network *****/ DB_QueryDELETE ("can not remove user's web / social network", "DELETE FROM usr_webs WHERE UsrCod=%ld AND Web='%s'", Gbl.Usrs.Me.UsrDat.UsrCod, Net_WebsAndSocialNetworksDB[NumURL]); } }
bool Par_GetParToBool (const char *ParamName) { char YN[1 + 1]; /***** Get parameter "Y"/"N" and convert to boolean *****/ Par_GetParToText (ParamName,YN,1); return (Str_ConvertToUpperLetter (YN[0]) == 'Y'); }
long Par_GetParToLong (const char *ParamName) { char LongStr[1 + 10 + 1]; /***** Get parameter with long number *****/ Par_GetParToText (ParamName,LongStr,1 + 10); return Str_ConvertStrCodToLongCod (LongStr); }
static long Not_GetParamNotCod (void) { char LongStr[1+10+1]; // String that holds the notice code long NotCod; /* Get notice code */ Par_GetParToText ("NotCod",LongStr,1+10); if (sscanf (LongStr,"%ld",&NotCod) != 1) Lay_ShowErrorAndExit ("Wrong code of notice."); return NotCod; }
unsigned long Par_GetParToUnsignedLong (const char *ParamName, unsigned long Min, unsigned long Max, unsigned long Default) { char UnsignedLongStr[20 + 1]; unsigned long UnsignedLongNum; /***** Get parameter with unsigned number *****/ Par_GetParToText (ParamName,UnsignedLongStr,10); if (sscanf (UnsignedLongStr,"%lu",&UnsignedLongNum) == 1) if (UnsignedLongNum >= Min && UnsignedLongNum <= Max) return UnsignedLongNum; return Default; }
void Ban_ChangeBannerWWW (void) { extern const char *Txt_The_new_web_address_is_X; extern const char *Txt_You_can_not_leave_the_web_address_empty; char NewWWW[Cns_MAX_BYTES_WWW + 1]; /***** Banner constructor *****/ Ban_EditingBannerConstructor (); /***** Get parameters from form *****/ /* Get the code of the banner */ if ((Ban_EditingBan->BanCod = Ban_GetParamBanCod ()) == -1L) Lay_ShowErrorAndExit ("Code of banner is missing."); /* Get the new WWW for the banner */ Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); /***** Get banner data from the database *****/ Ban_GetDataOfBannerByCod (Ban_EditingBan); /***** Check if new WWW is empty *****/ if (NewWWW[0]) { /* Update the table changing old WWW by new WWW */ DB_QueryUPDATE ("can not update the web of a banner", "UPDATE banners SET WWW='%s' WHERE BanCod=%ld", NewWWW,Ban_EditingBan->BanCod); /***** Write message to show the change made *****/ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_new_web_address_is_X, NewWWW); } else Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_can_not_leave_the_web_address_empty); /***** Update web *****/ Str_Copy (Ban_EditingBan->WWW,NewWWW, Cns_MAX_BYTES_WWW); }
void Ban_ChangeBannerImg (void) { extern const char *Txt_The_new_image_is_X; extern const char *Txt_You_can_not_leave_the_image_empty; char NewImg[Ban_MAX_BYTES_IMAGE + 1]; /***** Banner constructor *****/ Ban_EditingBannerConstructor (); /***** Get parameters from form *****/ /* Get the code of the banner */ if ((Ban_EditingBan->BanCod = Ban_GetParamBanCod ()) == -1L) Lay_ShowErrorAndExit ("Code of banner is missing."); /* Get the new WWW for the banner */ Par_GetParToText ("Img",NewImg,Ban_MAX_BYTES_IMAGE); /***** Get banner data from the database *****/ Ban_GetDataOfBannerByCod (Ban_EditingBan); /***** Check if new image is empty *****/ if (NewImg[0]) { /* Update the table changing old image by new image */ DB_QueryUPDATE ("can not update the image of a banner", "UPDATE banners SET Img='%s' WHERE BanCod=%ld", NewImg,Ban_EditingBan->BanCod); /***** Write message to show the change made *****/ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_new_image_is_X, NewImg); } else Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_can_not_leave_the_image_empty); /***** Update image *****/ Str_Copy (Ban_EditingBan->Img,NewImg, Ban_MAX_BYTES_IMAGE); }
void Par_GetMainParameters (void) { extern Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD]; extern const char *The_ThemeId[The_NUM_THEMES]; extern const char *Ico_IconSetId[Ico_NUM_ICON_SETS]; long ActCod; char Nickname[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1]; char URL[PATH_MAX + 1]; char LongStr[1 + 10 + 1]; /***** Reset codes of country, institution, centre, degree and course *****/ Gbl.Hierarchy.Cty.CtyCod = Gbl.Hierarchy.Ins.InsCod = Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.CrsCod = -1L; // First of all, get action, and session identifier. // So, if other parameters have been stored in the database, there will be no problems to get them. /***** Get action to perform *****/ if (Gbl.WebService.IsWebService) { Gbl.Action.Act = Gbl.Action.Original = ActWebSvc; Tab_SetCurrentTab (); return; } /***** Set default action *****/ Gbl.Action.Act = Gbl.Action.Original = ActUnk; /***** Get another user's nickname, if exists (this nickname is used to go to another user's profile, not to get the logged user) *****/ if (Par_GetParToText ("usr",Nickname,Nck_MAX_BYTES_NICKNAME_FROM_FORM)) { if (Nickname[0]) { /* Set another user's nickname */ Str_RemoveLeadingArrobas (Nickname); Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA); // This user's code is used to go to public profile // and to refresh old publishings in user's timeline // If user does not exist ==> UsrCod = -1 Gbl.Usrs.Other.UsrDat.UsrCod = Nck_GetUsrCodFromNickname (Gbl.Usrs.Other.UsrDat.Nickname); Gbl.Action.Act = Gbl.Action.Original = ActSeeOthPubPrf; // Set default action if no other is specified } } else if (Par_GetParToText ("agd",Nickname,Nck_MAX_BYTES_NICKNAME_FROM_FORM)) { if (Nickname[0]) { /* Set another user's nickname */ Str_RemoveLeadingArrobas (Nickname); Str_Copy (Gbl.Usrs.Other.UsrDat.Nickname,Nickname, // without arroba Nck_MAX_BYTES_NICKNAME_WITHOUT_ARROBA); // This user's code is used to go to public agenda // If user does not exist ==> UsrCod = -1 Gbl.Usrs.Other.UsrDat.UsrCod = Nck_GetUsrCodFromNickname (Gbl.Usrs.Other.UsrDat.Nickname); Gbl.Action.Act = Gbl.Action.Original = ActFrmLogInUsrAgd; // Set default action if no other is specified } } /***** Get action to perform *****/ ActCod = Par_GetParToLong ("act"); if (ActCod >= 0 && ActCod <= Act_MAX_ACTION_COD) Gbl.Action.Act = Gbl.Action.Original = Act_FromActCodToAction[ActCod]; /***** Some preliminary adjusts depending on action *****/ switch (Act_GetBrowserTab (Gbl.Action.Act)) { case Act_AJAX_NORMAL: Gbl.Action.UsesAJAX = true; Gbl.Action.IsAJAXAutoRefresh = false; break; case Act_AJAX_RFRESH: Gbl.Action.UsesAJAX = true; Gbl.Action.IsAJAXAutoRefresh = true; break; default: Gbl.Action.UsesAJAX = false; Gbl.Action.IsAJAXAutoRefresh = false; break; } /***** Get session identifier, if exists *****/ Par_GetParToText ("ses",Gbl.Session.Id,Cns_BYTES_SESSION_ID); if (Gbl.Session.Id[0]) { /***** Get user's code, password, current degree and current course from stored session *****/ if (Ses_GetSessionData ()) Gbl.Session.IsOpen = true; else { Gbl.Session.HasBeenDisconnected = true; Gbl.Session.Id[0] = '\0'; } } else { // Try old parameter "IdSes" (allowed for compatibility, to be removed soon) Par_GetParToText ("IdSes",Gbl.Session.Id,Cns_BYTES_SESSION_ID); if (Gbl.Session.Id[0]) { /***** Get user's code, password, current degree and current course from stored session *****/ if (Ses_GetSessionData ()) Gbl.Session.IsOpen = true; else { Gbl.Session.HasBeenDisconnected = true; Gbl.Session.Id[0] = '\0'; } } } /***** Get user password and login *****/ switch (Gbl.Action.Act) { case ActLogIn: case ActFrmLogInUsrAgd: case ActLogInUsrAgd: // This action is necessary here when log in fails Pwd_GetParamUsrPwdLogin (); /* falls through */ /* no break */ case ActReqSndNewPwd: case ActSndNewPwd: Usr_GetParamUsrIdLogin (); break; } /***** Try to get settings changed from current IP *****/ Set_GetSettingsFromIP (); if (!Gbl.Session.IsOpen) // When no session open (no logged user)... { /***** Try to get settings changed from current IP *****/ if (Gbl.Prefs.Theme == The_THEME_UNKNOWN) Gbl.Prefs.Theme = The_THEME_DEFAULT; /***** Set path of theme *****/ snprintf (URL,sizeof (URL), "%s/%s", Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Gbl.Prefs.Theme]); Str_Copy (Gbl.Prefs.URLTheme,URL, PATH_MAX); /***** Set path of icon set *****/ snprintf (URL,sizeof (URL), "%s/%s", Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[Gbl.Prefs.IconSet]); Str_Copy (Gbl.Prefs.URLIconSet,URL, PATH_MAX); } /***** Get country if exists (from menu) *****/ Par_GetParToText ("cty",LongStr,1 + 10); if (LongStr[0]) // Parameter "cty" available { Gbl.Hierarchy.Cty.CtyCod = Str_ConvertStrCodToLongCod (LongStr); Gbl.Hierarchy.Ins.InsCod = Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.CrsCod = -1L; } /***** Get institution if exists (from menu) *****/ Par_GetParToText ("ins",LongStr,1 + 10); if (LongStr[0]) // Parameter "ins" available { Gbl.Hierarchy.Ins.InsCod = Str_ConvertStrCodToLongCod (LongStr); Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.CrsCod = -1L; } /***** Get centre if exists (from menu) *****/ Par_GetParToText ("ctr",LongStr,1 + 10); if (LongStr[0]) // Parameter "ctr" available { Gbl.Hierarchy.Ctr.CtrCod = Str_ConvertStrCodToLongCod (LongStr); Gbl.Hierarchy.Deg.DegCod = Gbl.Hierarchy.Crs.CrsCod = -1L; } /***** Get numerical degree code if exists (from menu) *****/ Par_GetParToText ("deg",LongStr,1 + 10); if (LongStr[0]) // Parameter "deg" available { Gbl.Hierarchy.Deg.DegCod = Str_ConvertStrCodToLongCod (LongStr); Gbl.Hierarchy.Crs.CrsCod = -1L; // Reset possible course from session } /***** Get numerical course code if exists (from menu) *****/ Par_GetParToText ("crs",LongStr,1 + 10); if (LongStr[0]) // Parameter "crs" available Gbl.Hierarchy.Crs.CrsCod = Str_ConvertStrCodToLongCod (LongStr); // Overwrite CrsCod from session /***** Get tab to activate *****/ Gbl.Action.Tab = TabUnk; if (Gbl.Action.Act == ActMnu) { Gbl.Action.Tab = (Tab_Tab_t) Par_GetParToUnsignedLong ("NxtTab", (unsigned long) TabUnk, Tab_NUM_TABS - 1, (unsigned long) TabUnk); Tab_DisableIncompatibleTabs (); } else // Set tab depending on current action Tab_SetCurrentTab (); }
static void Sch_GetParamSearch (void) { /***** Get string to search *****/ Par_GetParToText ("Search",Gbl.Search.Str,Sch_MAX_BYTES_STRING_TO_FIND); }
static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_You_can_not_leave_the_name_of_the_banner_X_empty; extern const char *Txt_The_banner_X_already_exists; extern const char *Txt_The_banner_X_has_been_renamed_as_Y; extern const char *Txt_The_name_of_the_banner_X_has_not_changed; const char *ParamName = NULL; // Initialized to avoid warning const char *FieldName = NULL; // Initialized to avoid warning unsigned MaxBytes = 0; // Initialized to avoid warning char *CurrentBanName = NULL; // Initialized to avoid warning char NewBanName[Ban_MAX_BYTES_FULL_NAME + 1]; switch (ShrtOrFullName) { case Cns_SHRT_NAME: ParamName = "ShortName"; FieldName = "ShortName"; MaxBytes = Ban_MAX_BYTES_SHRT_NAME; CurrentBanName = Ban_EditingBan->ShrtName; break; case Cns_FULL_NAME: ParamName = "FullName"; FieldName = "FullName"; MaxBytes = Ban_MAX_BYTES_FULL_NAME; CurrentBanName = Ban_EditingBan->FullName; break; } /***** Get parameters from form *****/ /* Get the code of the banner */ if ((Ban_EditingBan->BanCod = Ban_GetParamBanCod ()) == -1L) Lay_ShowErrorAndExit ("Code of banner is missing."); /* Get the new name for the banner */ Par_GetParToText (ParamName,NewBanName,MaxBytes); /***** Get banner data from the database *****/ Ban_GetDataOfBannerByCod (Ban_EditingBan); /***** Check if new name is empty *****/ if (!NewBanName[0]) Ale_CreateAlert (Ale_WARNING,NULL, Txt_You_can_not_leave_the_name_of_the_banner_X_empty, CurrentBanName); else { /***** Check if old and new names are the same (this happens when return is pressed without changes) *****/ if (strcmp (CurrentBanName,NewBanName)) // Different names { /***** If banner was in database... *****/ if (Ban_CheckIfBannerNameExists (ParamName,NewBanName,Ban_EditingBan->BanCod)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_banner_X_already_exists, NewBanName); else { /* Update the table changing old name by new name */ Ban_UpdateBanNameDB (Ban_EditingBan->BanCod,FieldName,NewBanName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_The_banner_X_has_been_renamed_as_Y, CurrentBanName,NewBanName); } } else // The same name Ale_CreateAlert (Ale_INFO,NULL, Txt_The_name_of_the_banner_X_has_not_changed, CurrentBanName); } /***** Update name *****/ Str_Copy (CurrentBanName,NewBanName, MaxBytes); }