mirror of https://github.com/acanas/swad-core.git
Version 22.47: Oct 15, 2022 Code optimization related to forms.
This commit is contained in:
parent
80a32b1f05
commit
5b4a928226
|
@ -539,25 +539,14 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh,
|
|||
(*Link)->NickAnchor[1].Str =
|
||||
(*Link)->NickAnchor[2].Str = NULL;
|
||||
|
||||
/***** Create id for this form *****/
|
||||
Gbl.Form.Num++;
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
snprintf (Gbl.Form.UniqueId,sizeof (Gbl.Form.UniqueId),
|
||||
"form_%s_%d",Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
||||
else
|
||||
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),
|
||||
"form_%d",Gbl.Form.Num);
|
||||
|
||||
/***** Store first part of anchor *****/
|
||||
Frm_SetParamsForm (ParamsStr,ActSeeOthPubPrf,true);
|
||||
if (asprintf (&(*Link)->NickAnchor[0].Str,
|
||||
"<form method=\"post\" action=\"%s/%s\" id=\"%s\">"
|
||||
"<form method=\"post\" action=\"%s/%s\">"
|
||||
"%s" // Parameters
|
||||
"<input type=\"hidden\" name=\"usr\" value=\"",
|
||||
Cfg_URL_SWAD_CGI,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
|
||||
Gbl.Form.Id,
|
||||
ParamsStr) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
(*Link)->NickAnchor[0].Len = strlen ((*Link)->NickAnchor[0].Str);
|
||||
|
@ -566,9 +555,7 @@ static ALn_LinkType_t ALn_CheckNickname (char **PtrSrc,char PrevCh,
|
|||
if (asprintf (&(*Link)->NickAnchor[1].Str,
|
||||
"\">"
|
||||
"<a href=\"\""
|
||||
" onclick=\"document.getElementById('%s').submit();return false;\">",
|
||||
Gbl.Usrs.Me.Logged ? Gbl.Form.UniqueId :
|
||||
Gbl.Form.Id) < 0)
|
||||
" onclick=\"this.closest('form').submit();return false;\">") < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
(*Link)->NickAnchor[1].Len = strlen ((*Link)->NickAnchor[1].Str);
|
||||
|
||||
|
|
|
@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
|
|||
|
||||
TODO: Attach pdf files in multimedia.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 22.46.3 (2022-10-15)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 22.47 (2022-10-15)"
|
||||
#define CSS_FILE "swad22.46.css"
|
||||
#define JS_FILE "swad21.100.js"
|
||||
/*
|
||||
Version 22.47: Oct 15, 2022 Code optimization related to forms. (333227 lines)
|
||||
Version 22.46.3: Oct 15, 2022 Code refactoring submiting forms. (333211 lines)
|
||||
Version 22.46.2: Oct 14, 2022 Changes in anchors behavior in project listing. (333228 lines)
|
||||
Version 22.46.1: Oct 14, 2022 Fixed bug filtering projects by department. (333227 lines)
|
||||
|
|
|
@ -174,10 +174,13 @@ void Con_ShowGlobalConnectedUsrs (void)
|
|||
|
||||
/***** Number of sessions *****/
|
||||
/* Link to view more details about connected users */
|
||||
/*
|
||||
Frm_BeginFormUnique (ActLstCon); // Must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
HTM_BUTTON_Submit_Begin (Txt_Connected_users,"class=\"BT_LINK\"");
|
||||
*/
|
||||
Frm_BeginForm (ActLstCon);
|
||||
HTM_BUTTON_Submit_Begin (Txt_Connected_users,"class=\"BT_LINK\"");
|
||||
|
||||
/* Write total number of sessions */
|
||||
HTM_TxtF ("%u %s",Gbl.Session.NumSessions,
|
||||
|
@ -326,9 +329,12 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
|
|||
|
||||
/***** Number of connected users who belong to course *****/
|
||||
/* Link to view more details about connected users */
|
||||
/*
|
||||
Frm_BeginFormUnique (ActLstCon); // Must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
*/
|
||||
Frm_BeginForm (ActLstCon);
|
||||
HTM_BUTTON_Submit_Begin (Txt_Connected_users,"class=\"BT_LINK\"");
|
||||
Str_Copy (CourseName,Gbl.Hierarchy.Crs.ShrtName,sizeof (CourseName) - 1);
|
||||
Con_GetNumConnectedWithARoleBelongingToCurrentScope (Rol_UNK,&Usrs);
|
||||
|
@ -414,9 +420,12 @@ static void Con_ShowConnectedUsrsWithARoleBelongingToCurrentCrsOnRightColumn (Ro
|
|||
{
|
||||
HTM_TR_Begin (NULL);
|
||||
HTM_TD_Begin ("colspan=\"3\" class=\"CM\"");
|
||||
/*
|
||||
Frm_BeginFormUnique (ActLstCon); // Must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
*/
|
||||
Frm_BeginForm (ActLstCon);
|
||||
Sco_PutParamScope ("ScopeCon",HieLvl_CRS);
|
||||
HTM_INPUT_IMAGE (Cfg_URL_ICON_PUBLIC,"ellipsis-h.svg",
|
||||
Txt_Connected_users,
|
||||
|
@ -604,12 +613,14 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
|
|||
ClassTxt = (Gbl.Usrs.Connected.Lst[Gbl.Usrs.Connected.NumUsr].ThisCrs) ? "CON_NAME_NARROW CON_CRS" :
|
||||
"CON_NAME_NARROW CON_NO_CRS";
|
||||
HTM_TD_Begin ("class=\"%s %s\"",ClassTxt,The_GetColorRows ());
|
||||
// The form must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
if (!NextAction[Role])
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginFormUnique (NextAction[Role]);
|
||||
/*
|
||||
Frm_BeginFormUnique (NextAction[Role]); // The form must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
*/
|
||||
Frm_BeginForm (NextAction[Role]);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
||||
HTM_DIV_Begin ("class=\"CON_NAME_NARROW\""); // Limited width
|
||||
|
|
|
@ -80,7 +80,7 @@ void Frm_BeginFormAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,con
|
|||
snprintf (Gbl.Form.Id,sizeof (Gbl.Form.Id),"form_%d",Gbl.Form.Num);
|
||||
Frm_BeginFormInternal (NextAction,true,Gbl.Form.Id,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
||||
}
|
||||
|
||||
/*
|
||||
void Frm_BeginFormUnique (Act_Action_t NextAction)
|
||||
{
|
||||
Frm_BeginFormUniqueAnchor (NextAction,NULL);
|
||||
|
@ -101,7 +101,7 @@ void Frm_BeginFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anch
|
|||
Gbl.UniqueNameEncrypted,Gbl.Form.Num);
|
||||
Frm_BeginFormInternal (NextAction,true,Gbl.Form.UniqueId,Anchor,OnSubmit); // Do put now parameter location (if no open session)
|
||||
}
|
||||
|
||||
*/
|
||||
void Frm_BeginFormId (Act_Action_t NextAction,const char *Id)
|
||||
{
|
||||
Gbl.Form.Num++; // Initialized to -1. The first time it is incremented, it will be equal to 0
|
||||
|
|
|
@ -50,10 +50,10 @@ void Frm_BeginFormGoTo (Act_Action_t NextAction);
|
|||
void Frm_BeginForm (Act_Action_t NextAction);
|
||||
void Frm_BeginFormOnSubmit (Act_Action_t NextAction,const char *OnSubmit);
|
||||
void Frm_BeginFormAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit);
|
||||
void Frm_BeginFormUnique (Act_Action_t NextAction);
|
||||
// void Frm_BeginFormUnique (Act_Action_t NextAction);
|
||||
void Frm_BeginFormAnchor (Act_Action_t NextAction,const char *Anchor);
|
||||
void Frm_BeginFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor);
|
||||
void Frm_BeginFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit);
|
||||
// void Frm_BeginFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor);
|
||||
// void Frm_BeginFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit);
|
||||
void Frm_BeginFormId (Act_Action_t NextAction,const char *Id);
|
||||
void Frm_BeginFormNoAction (void);
|
||||
void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR],Act_Action_t NextAction,
|
||||
|
|
|
@ -79,7 +79,7 @@ struct Globals
|
|||
{
|
||||
int Num; // Number of form, used in form submit links
|
||||
char Id[32]; // Identifier string used in forms
|
||||
char UniqueId[32 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 10 + 1]; // Unique identifier string used in forms
|
||||
// char UniqueId[32 + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 10 + 1]; // Unique identifier string used in forms
|
||||
bool Inside; // Set to true inside a form to avoid nested forms
|
||||
} Form;
|
||||
struct
|
||||
|
|
|
@ -1263,8 +1263,9 @@ void Pho_ShowUsrPhoto (const struct Usr_Data *UsrDat,const char *PhotoURL,
|
|||
if (PutLinkToPublicProfile)
|
||||
{
|
||||
if (FormUnique)
|
||||
Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
else
|
||||
// Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
Frm_BeginForm (ActSeeOthPubPrf);
|
||||
else
|
||||
Frm_BeginForm (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
HTM_BUTTON_Submit_Begin (NULL,"class=\"BT_LINK\"");
|
||||
|
|
|
@ -617,7 +617,8 @@ static void TmlCom_WriteAuthorName (const struct Usr_Data *UsrDat) // Author
|
|||
|
||||
/***** Show user's name inside form to go to user's public profile *****/
|
||||
/* Begin form */
|
||||
Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
// Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
Frm_BeginForm (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
||||
/* Author's name */
|
||||
|
|
|
@ -224,7 +224,8 @@ void TmlFrm_FormFavSha (const struct Tml_Form *Form)
|
|||
ParamStr,
|
||||
Gbl.Usrs.Other.UsrDat.EnUsrCod) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
|
||||
// Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
|
||||
Frm_BeginFormAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
|
||||
free (OnSubmit);
|
||||
Ico_PutIconLink (Form->Icon,Form->Color,
|
||||
TmlFrm_ActionUsr[Form->Action]);
|
||||
|
@ -238,7 +239,8 @@ void TmlFrm_FormFavSha (const struct Tml_Form *Form)
|
|||
Gbl.Session.Id,
|
||||
ParamStr) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
|
||||
// Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
|
||||
Frm_BeginFormAnchorOnSubmit (ActUnk,NULL,OnSubmit);
|
||||
free (OnSubmit);
|
||||
Ico_PutIconLink (Form->Icon,Form->Color,
|
||||
TmlFrm_ActionGbl[Form->Action]);
|
||||
|
@ -299,7 +301,8 @@ void TmlFrm_FormToShowHiddenComms (long NotCod,
|
|||
Err_NotEnoughMemoryExit ();
|
||||
Anchor = NULL;
|
||||
}
|
||||
Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,Anchor,OnSubmit);
|
||||
// Frm_BeginFormUniqueAnchorOnSubmit (ActUnk,Anchor,OnSubmit);
|
||||
Frm_BeginFormAnchorOnSubmit (ActUnk,Anchor,OnSubmit);
|
||||
free (OnSubmit);
|
||||
|
||||
/* Put icon and text with link to show the first hidden comments */
|
||||
|
|
|
@ -352,7 +352,8 @@ void TmlNot_WriteAuthorName (const struct Usr_Data *UsrDat,
|
|||
|
||||
/***** Show user's name inside form to go to user's public profile *****/
|
||||
/* Begin form */
|
||||
Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
// Frm_BeginFormUnique (ActSeeOthPubPrf);
|
||||
Frm_BeginForm (ActSeeOthPubPrf);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
||||
/* Author's name */
|
||||
|
@ -623,36 +624,42 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
|
|||
{
|
||||
case TmlNot_INS_DOC_PUB_FILE:
|
||||
case TmlNot_INS_SHA_PUB_FILE:
|
||||
Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
// Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
||||
Brw_PutHiddenParamFilCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution
|
||||
Ins_PutParamInsCod (Not->HieCod); // Go to another institution
|
||||
break;
|
||||
case TmlNot_CTR_DOC_PUB_FILE:
|
||||
case TmlNot_CTR_SHA_PUB_FILE:
|
||||
Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
// Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
||||
Brw_PutHiddenParamFilCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current center
|
||||
Ctr_PutParamCtrCod (Not->HieCod); // Go to another center
|
||||
break;
|
||||
case TmlNot_DEG_DOC_PUB_FILE:
|
||||
case TmlNot_DEG_SHA_PUB_FILE:
|
||||
Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
// Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
||||
Brw_PutHiddenParamFilCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree
|
||||
Deg_PutParamDegCod (Not->HieCod); // Go to another degree
|
||||
break;
|
||||
case TmlNot_CRS_DOC_PUB_FILE:
|
||||
case TmlNot_CRS_SHA_PUB_FILE:
|
||||
Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
// Frm_BeginFormUnique (Tml_DefaultActions[Not->Type]);
|
||||
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
|
||||
Brw_PutHiddenParamFilCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
|
||||
Crs_PutParamCrsCod (Not->HieCod); // Go to another course
|
||||
break;
|
||||
case TmlNot_CALL_FOR_EXAM:
|
||||
Frm_SetAnchorStr (Not->Cod,&Anchor);
|
||||
Frm_BeginFormUniqueAnchor (Tml_DefaultActions[Not->Type],
|
||||
Anchor); // Locate on this specific exam
|
||||
// Frm_BeginFormUniqueAnchor (Tml_DefaultActions[Not->Type],
|
||||
// Anchor); // Locate on this specific exam
|
||||
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],
|
||||
Anchor); // Locate on this specific exam
|
||||
Frm_FreeAnchorStr (Anchor);
|
||||
Cfe_PutHiddenParamExaCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
|
||||
|
@ -661,7 +668,8 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
|
|||
case TmlNot_POST: // Not applicable
|
||||
return;
|
||||
case TmlNot_FORUM_POST:
|
||||
Frm_BeginFormUnique (For_ActionsSeeFor[Forums->Forum.Type]);
|
||||
// Frm_BeginFormUnique (For_ActionsSeeFor[Forums->Forum.Type]);
|
||||
Frm_BeginForm (For_ActionsSeeFor[Forums->Forum.Type]);
|
||||
For_PutAllHiddenParamsForum (1, // Page of threads = first
|
||||
1, // Page of posts = first
|
||||
Forums->ForumSet,
|
||||
|
@ -674,8 +682,9 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
|
|||
break;
|
||||
case TmlNot_NOTICE:
|
||||
Frm_SetAnchorStr (Not->Cod,&Anchor);
|
||||
Frm_BeginFormUniqueAnchor (Tml_DefaultActions[Not->Type],
|
||||
Anchor);
|
||||
// Frm_BeginFormUniqueAnchor (Tml_DefaultActions[Not->Type],
|
||||
// Anchor);
|
||||
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],Anchor);
|
||||
Frm_FreeAnchorStr (Anchor);
|
||||
Not_PutHiddenParamNotCod (Not->Cod);
|
||||
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
|
||||
|
|
Loading…
Reference in New Issue