Version 18.58.1

This commit is contained in:
Antonio Cañas Vargas 2019-02-24 21:45:46 +01:00
parent a42771b7c4
commit 59f0747de3
9 changed files with 157 additions and 209 deletions

View File

@ -710,15 +710,14 @@ function refreshFav (elem,Params) {
} }
} }
// Receives and shows fav note area: icon and users who have faved a social note or comment in timeline // Receives and shows fav area: icon and users who have faved a social note or comment in timeline
function readAndUpdateFav () { function readAndUpdateFav () {
if (objXMLHttpReqFavSoc.readyState == 4) { // Check if data have been received if (objXMLHttpReqFavSoc.readyState == 4) { // Check if data have been received
if (objXMLHttpReqFavSoc.status == 200) if (objXMLHttpReqFavSoc.status == 200)
if (idDivFav) { if (idDivFav) {
var htmlFav = objXMLHttpReqFavSoc.responseText;
var divFav = document.getElementById(idDivFav); // Access to last click DIV var divFav = document.getElementById(idDivFav); // Access to last click DIV
if (divFav) if (divFav)
divFav.innerHTML = htmlFav; // Update fav area DIV divFav.innerHTML = objXMLHttpReqFavSoc.responseText; // Update fav area DIV
} }
} }
} }

View File

@ -12611,3 +12611,8 @@ ORDER BY FavCod LIMIT 7
SELECT UsrCod FROM social_notes_fav WHERE NotCod=278 AND UsrCod<>7 AND UsrCod<>1 ORDER BY FavCod LIMIT 7; SELECT UsrCod FROM social_notes_fav WHERE NotCod=278 AND UsrCod<>7 AND UsrCod<>1 ORDER BY FavCod LIMIT 7;
SELECT CAST(~0 AS UNSIGNED); SELECT CAST(~0 AS UNSIGNED);
SELECT last_logs.LogCod,last_logs.ActCod,last_logs.Dif,last_logs.Role,last_logs.CtyCod,last_logs.InsCod,last_logs.CtrCod,last_logs.DegCod,actions.Txt FROM (SELECT LogCod,ActCod,UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ClickTime) AS Dif,Role,CtyCod,InsCod,CtrCod,DegCod FROM log_recent ORDER BY LogCod DESC LIMIT 20) AS last_logs LEFT JOIN actions ON last_logs.ActCod=actions.ActCod WHERE actions.Language='es';

View File

@ -429,10 +429,23 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 18.58 (2019-02-24)" #define Log_PLATFORM_VERSION "SWAD 18.58.1 (2019-02-24)"
#define CSS_FILE "swad18.57.css" #define CSS_FILE "swad18.57.css"
#define JS_FILE "swad18.58.js" #define JS_FILE "swad18.58.js"
/* /*
Version 18.58.1: Feb 24, 2019 Code cleaning related to AJAX and timeline.
Fixed bug in recent clicks. (237768 lines)
9 changes necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1512','es','N','Favorito public. social (global)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1513','es','N','Deshacer fav. public. social (global)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1514','es','N','Favorito public. social (usuario)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1515','es','N','Deshacer fav. public. social (usuario)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1516','es','N','Favorito coment. social (global)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1517','es','N','Deshacer fav. coment. social (global)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1518','es','N','Favorito coment. social (usuario)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1519','es','N','Deshacer fav. coment. social (usuario)');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1520','es','N','Sugerir lista de usuarios a seguir');
Version 18.58: Feb 24, 2019 Favourites in social comments are made in AJAX without reloading page. (237816 lines) Version 18.58: Feb 24, 2019 Favourites in social comments are made in AJAX without reloading page. (237816 lines)
Version 18.57.3: Feb 24, 2019 Changes in social timeline related to AJAX and favourites. (237804 lines) Version 18.57.3: Feb 24, 2019 Changes in social timeline related to AJAX and favourites. (237804 lines)
Version 18.57.2: Feb 24, 2019 Changes in social timeline related to AJAX and favourites. (237827 lines) Version 18.57.2: Feb 24, 2019 Changes in social timeline related to AJAX and favourites. (237827 lines)

View File

@ -165,45 +165,47 @@ void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR + 1],Act_Action_
ParamLocation[0] = '\0'; ParamLocation[0] = '\0';
if (NextAction != ActUnk) if (NextAction != ActUnk)
{
snprintf (ParamAction,sizeof (ParamAction), snprintf (ParamAction,sizeof (ParamAction),
"<input type=\"hidden\" name=\"act\" value=\"%ld\" />", "<input type=\"hidden\" name=\"act\" value=\"%ld\" />",
Act_GetActCod (NextAction)); Act_GetActCod (NextAction));
if (Gbl.Session.Id[0]) if (Gbl.Session.Id[0])
snprintf (ParamSession,sizeof (ParamSession), snprintf (ParamSession,sizeof (ParamSession),
"<input type=\"hidden\" name=\"ses\" value=\"%s\" />", "<input type=\"hidden\" name=\"ses\" value=\"%s\" />",
Gbl.Session.Id); Gbl.Session.Id);
else if (PutParameterLocationIfNoSesion) else if (PutParameterLocationIfNoSesion)
// Extra parameters necessary when there's no open session // Extra parameters necessary when there's no open session
{ {
/* If session is open, course code will be get from session data, /* If session is open, course code will be get from session data,
but if there is not an open session, and next action is known, but if there is not an open session, and next action is known,
it is necessary to send a parameter with course code */ it is necessary to send a parameter with course code */
if (Gbl.CurrentCrs.Crs.CrsCod > 0) if (Gbl.CurrentCrs.Crs.CrsCod > 0)
// If course selected... // If course selected...
snprintf (ParamLocation,sizeof (ParamLocation), snprintf (ParamLocation,sizeof (ParamLocation),
"<input type=\"hidden\" name=\"crs\" value=\"%ld\" />", "<input type=\"hidden\" name=\"crs\" value=\"%ld\" />",
Gbl.CurrentCrs.Crs.CrsCod); Gbl.CurrentCrs.Crs.CrsCod);
else if (Gbl.CurrentDeg.Deg.DegCod > 0) else if (Gbl.CurrentDeg.Deg.DegCod > 0)
// If no course selected, but degree selected... // If no course selected, but degree selected...
snprintf (ParamLocation,sizeof (ParamLocation), snprintf (ParamLocation,sizeof (ParamLocation),
"<input type=\"hidden\" name=\"deg\" value=\"%ld\" />", "<input type=\"hidden\" name=\"deg\" value=\"%ld\" />",
Gbl.CurrentDeg.Deg.DegCod); Gbl.CurrentDeg.Deg.DegCod);
else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) else if (Gbl.CurrentCtr.Ctr.CtrCod > 0)
// If no degree selected, but centre selected... // If no degree selected, but centre selected...
snprintf (ParamLocation,sizeof (ParamLocation), snprintf (ParamLocation,sizeof (ParamLocation),
"<input type=\"hidden\" name=\"ctr\" value=\"%ld\" />", "<input type=\"hidden\" name=\"ctr\" value=\"%ld\" />",
Gbl.CurrentCtr.Ctr.CtrCod); Gbl.CurrentCtr.Ctr.CtrCod);
else if (Gbl.CurrentIns.Ins.InsCod > 0) else if (Gbl.CurrentIns.Ins.InsCod > 0)
// If no centre selected, but institution selected... // If no centre selected, but institution selected...
snprintf (ParamLocation,sizeof (ParamLocation), snprintf (ParamLocation,sizeof (ParamLocation),
"<input type=\"hidden\" name=\"ins\" value=\"%ld\" />", "<input type=\"hidden\" name=\"ins\" value=\"%ld\" />",
Gbl.CurrentIns.Ins.InsCod); Gbl.CurrentIns.Ins.InsCod);
else if (Gbl.CurrentCty.Cty.CtyCod > 0) else if (Gbl.CurrentCty.Cty.CtyCod > 0)
// If no institution selected, but country selected... // If no institution selected, but country selected...
snprintf (ParamLocation,sizeof (ParamLocation), snprintf (ParamLocation,sizeof (ParamLocation),
"<input type=\"hidden\" name=\"cty\" value=\"%ld\" />", "<input type=\"hidden\" name=\"cty\" value=\"%ld\" />",
Gbl.CurrentCty.Cty.CtyCod); Gbl.CurrentCty.Cty.CtyCod);
}
} }
snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1, snprintf (ParamsStr,Frm_MAX_BYTES_PARAMS_STR + 1,

View File

@ -679,10 +679,6 @@ static void Lay_WriteScriptInit (void)
case ActRcvSocComGbl: case ActRcvSocComGbl:
case ActShaSocNotGbl: case ActShaSocNotGbl:
case ActUnsSocNotGbl: case ActUnsSocNotGbl:
case ActFavSocNotGbl:
case ActUnfSocNotGbl:
case ActFavSocComGbl:
case ActUnfSocComGbl:
case ActReqRemSocPubGbl: case ActReqRemSocPubGbl:
case ActRemSocPubGbl: case ActRemSocPubGbl:
case ActReqRemSocComGbl: case ActReqRemSocComGbl:
@ -694,7 +690,6 @@ static void Lay_WriteScriptInit (void)
default: default:
break; break;
} }
// fprintf (Gbl.F.Out," document.getElementById('whole_page').style.opacity='1';\n");
fprintf (Gbl.F.Out,"}\n" fprintf (Gbl.F.Out,"}\n"
"</script>\n"); "</script>\n");
} }
@ -733,10 +728,6 @@ static void Lay_WriteScriptParamsAJAX (void)
case ActRcvSocComGbl: case ActRcvSocComGbl:
case ActShaSocNotGbl: case ActShaSocNotGbl:
case ActUnsSocNotGbl: case ActUnsSocNotGbl:
case ActFavSocNotGbl:
case ActUnfSocNotGbl:
case ActFavSocComGbl:
case ActUnfSocComGbl:
case ActReqRemSocPubGbl: case ActReqRemSocPubGbl:
case ActRemSocPubGbl: case ActRemSocPubGbl:
case ActReqRemSocComGbl: case ActReqRemSocComGbl:
@ -757,10 +748,6 @@ static void Lay_WriteScriptParamsAJAX (void)
case ActRcvSocComUsr: case ActRcvSocComUsr:
case ActShaSocNotUsr: case ActShaSocNotUsr:
case ActUnsSocNotUsr: case ActUnsSocNotUsr:
case ActFavSocNotUsr:
case ActUnfSocNotUsr:
case ActFavSocComUsr:
case ActUnfSocComUsr:
case ActReqRemSocPubUsr: case ActReqRemSocPubUsr:
case ActRemSocPubUsr: case ActRemSocPubUsr:
case ActReqRemSocComUsr: case ActReqRemSocComUsr:
@ -1293,25 +1280,9 @@ void Lay_ShowErrorAndExit (const char *Txt)
Lay_WriteEndOfPage (); Lay_WriteEndOfPage ();
} }
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'antes de Gbl_Cleanup')");
/***** Free memory and close all the open files *****/ /***** Free memory and close all the open files *****/
Gbl_Cleanup (); Gbl_Cleanup ();
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'tras Gbl_Cleanup')");
/***** Page is generated (except </body> and </html>). /***** Page is generated (except </body> and </html>).
Compute time to generate page *****/ Compute time to generate page *****/
if (!Gbl.Action.IsAJAXAutoRefresh) if (!Gbl.Action.IsAJAXAutoRefresh)
@ -1354,14 +1325,6 @@ void Lay_ShowErrorAndExit (const char *Txt)
} }
} }
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'antes de DB_CloseDBConnection')");
/***** Close database connection *****/ /***** Close database connection *****/
DB_CloseDBConnection (); DB_CloseDBConnection ();

View File

@ -152,39 +152,15 @@ int main (void)
/***** Write HTTP Status 204 No Content *****/ /***** Write HTTP Status 204 No Content *****/
Lay_WriteHTTPStatus204NoContent (); Lay_WriteHTTPStatus204NoContent ();
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'tras FunctionPriori')");
/***** Start writing HTML output *****/ /***** Start writing HTML output *****/
Lay_WriteStartOfPage (); Lay_WriteStartOfPage ();
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'antes de FunctionPosteriori')");
/***** Make a processing or other depending on the action *****/ /***** Make a processing or other depending on the action *****/
FunctionPosteriori = Act_GetFunctionPosteriori (Gbl.Action.Act); FunctionPosteriori = Act_GetFunctionPosteriori (Gbl.Action.Act);
if (FunctionPosteriori != NULL) if (FunctionPosteriori != NULL)
FunctionPosteriori (); FunctionPosteriori ();
} }
if (Gbl.Action.Act == ActFavSocNotGbl ||
Gbl.Action.Act == ActUnfSocNotGbl)
DB_QueryINSERT ("can not debug",
"INSERT INTO debug"
" (DebugTime,Txt)"
" VALUES"
" (NOW(),'antes de Lay_ShowErrorAndExit')");
/***** Cleanup and exit *****/ /***** Cleanup and exit *****/
Lay_ShowErrorAndExit (NULL); Lay_ShowErrorAndExit (NULL);

View File

@ -727,23 +727,26 @@ void Par_GetMainParameters (void)
Gbl.Action.Act = Gbl.Action.Original = Act_FromActCodToAction[ActCod]; Gbl.Action.Act = Gbl.Action.Original = Act_FromActCodToAction[ActCod];
/***** Some preliminary adjusts depending on action *****/ /***** Some preliminary adjusts depending on action *****/
Gbl.Action.UsesAJAX = false;
Gbl.Action.IsAJAXAutoRefresh = false;
if (Gbl.Action.Act == ActRefCon || if (Gbl.Action.Act == ActRefCon ||
Gbl.Action.Act == ActRefLstClk || Gbl.Action.Act == ActRefLstClk ||
Gbl.Action.Act == ActRefNewSocPubGbl || Gbl.Action.Act == ActRefNewSocPubGbl)
Gbl.Action.Act == ActRefOldSocPubGbl || {
Gbl.Action.Act == ActRefOldSocPubUsr || Gbl.Action.UsesAJAX = true;
Gbl.Action.Act == ActFavSocNotGbl || Gbl.Action.Act == ActFavSocNotUsr || Gbl.Action.IsAJAXAutoRefresh = true;
Gbl.Action.Act == ActUnfSocNotGbl || Gbl.Action.Act == ActUnfSocNotUsr || }
Gbl.Action.Act == ActFavSocComGbl || Gbl.Action.Act == ActFavSocComUsr || else if (Gbl.Action.Act == ActRefOldSocPubGbl || Gbl.Action.Act == ActRefOldSocPubUsr ||
Gbl.Action.Act == ActUnfSocComGbl || Gbl.Action.Act == ActUnfSocComUsr) Gbl.Action.Act == ActFavSocNotGbl || Gbl.Action.Act == ActFavSocNotUsr ||
Gbl.Action.Act == ActUnfSocNotGbl || Gbl.Action.Act == ActUnfSocNotUsr ||
Gbl.Action.Act == ActFavSocComGbl || Gbl.Action.Act == ActFavSocComUsr ||
Gbl.Action.Act == ActUnfSocComGbl || Gbl.Action.Act == ActUnfSocComUsr)
{ {
Gbl.Action.UsesAJAX = true; Gbl.Action.UsesAJAX = true;
if (Gbl.Action.Act == ActRefCon || Gbl.Action.IsAJAXAutoRefresh = false;
Gbl.Action.Act == ActRefLstClk || }
Gbl.Action.Act == ActRefNewSocPubGbl) else
Gbl.Action.IsAJAXAutoRefresh = true; {
Gbl.Action.UsesAJAX = false;
Gbl.Action.IsAJAXAutoRefresh = false;
} }
/***** Get session identifier, if exists *****/ /***** Get session identifier, if exists *****/

View File

@ -194,16 +194,15 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
static void Soc_WriteAuthorComment (struct UsrData *UsrDat); static void Soc_WriteAuthorComment (struct UsrData *UsrDat);
static void Soc_PutFormToRemoveComment (long PubCod); static void Soc_PutFormToRemoveComment (long PubCod);
static void Soc_PutFormToFavSocialComment (struct SocialComment *SocCom);
static void Soc_PutDisabledIconShare (unsigned NumShared); static void Soc_PutDisabledIconShare (unsigned NumShared);
static void Soc_PutDisabledIconFav (unsigned NumFavs); static void Soc_PutDisabledIconFav (unsigned NumFavs);
static void Soc_PutFormToShareSocialNote (long NotCod); static void Soc_PutFormToShareSocialNote (long NotCod);
static void Soc_PutFormToUnshareSocialNote (long NotCod);
static void Soc_PutFormToFavSocialNote (const struct SocialNote *SocNot); static void Soc_PutFormToFavSocialNote (const struct SocialNote *SocNot);
static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot); static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot);
static void Soc_PutFormToFavSocialComment (struct SocialComment *SocCom);
static void Soc_PutFormToUnshareSocialNote (long NotCod);
static void Soc_PutFormToUnfavSocialComment (struct SocialComment *SocCom); static void Soc_PutFormToUnfavSocialComment (struct SocialComment *SocCom);
static void Soc_PutFormToRemoveSocialPublishing (long NotCod); static void Soc_PutFormToRemoveSocialPublishing (long NotCod);
@ -2782,52 +2781,6 @@ static void Soc_PutFormToRemoveComment (long PubCod)
Frm_EndForm (); Frm_EndForm ();
} }
/*****************************************************************************/
/***************** Form to mark a social comment as favourite ****************/
/*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToFavSocialComment (struct SocialComment *SocCom)
{
extern const char *Txt_Mark_as_favourite;
char *OnSubmit;
/***** Form and icon to mark social note as favourite *****/
/* Form with icon */
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
{
if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&PubCod=%ld&OtherUsrCod=%s');"
" return false;", // return false is necessary to not submit form
Act_GetActCod (ActFavSocComUsr),
Gbl.Session.Id,
SocCom->PubCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActFavSocComUsr,"timeline",OnSubmit);
}
else
{
if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&PubCod=%ld&WhichUsrs=%u');"
" return false;", // return false is necessary to not submit form
Act_GetActCod (ActFavSocComGbl),
Gbl.Session.Id,
SocCom->PubCod,
(unsigned) Gbl.Social.WhichUsrs) < 0)
Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActFavSocComGbl,NULL,OnSubmit);
}
Ico_PutIconLink ("heart.svg",Txt_Mark_as_favourite);
Frm_EndForm ();
/* Free allocated memory for subquery */
free ((void *) OnSubmit);
/***** Show who have marked this social comment as favourite *****/
Soc_ShowUsrsWhoHaveMarkedSocialCommAsFav (SocCom);
}
/*****************************************************************************/ /*****************************************************************************/
/*********************** Put disabled icon to share **************************/ /*********************** Put disabled icon to share **************************/
/*****************************************************************************/ /*****************************************************************************/
@ -2889,6 +2842,23 @@ static void Soc_PutFormToShareSocialNote (long NotCod)
Frm_EndForm (); Frm_EndForm ();
} }
/*****************************************************************************/
/*************** Form to unshare (stop sharing) social note ******************/
/*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToUnshareSocialNote (long NotCod)
{
extern const char *Txt_SOCIAL_NOTE_Shared;
/***** Form to share social publishing *****/
Soc_FormStart (ActUnsSocNotGbl,ActUnsSocNotUsr);
Soc_PutHiddenParamNotCod (NotCod);
Ico_PutDivIconLink ("SOCIAL_ICO_SHARE",
"share-alt-green.svg",Txt_SOCIAL_NOTE_Shared);
Frm_EndForm ();
}
/*****************************************************************************/ /*****************************************************************************/
/*************** Form to fav (mark as favourite) social note *****************/ /*************** Form to fav (mark as favourite) social note *****************/
/*****************************************************************************/ /*****************************************************************************/
@ -2911,19 +2881,18 @@ static void Soc_PutFormToFavSocialNote (const struct SocialNote *SocNot)
SocNot->NotCod, SocNot->NotCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActFavSocNotUsr,"timeline",OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
} }
else else
{ {
if (asprintf (&OnSubmit,"refreshFav(this," if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&NotCod=%ld&WhichUsrs=%u');" "'act=%ld&ses=%s&NotCod=%ld');"
" return false;", // return false is necessary to not submit form " return false;", // return false is necessary to not submit form
Act_GetActCod (ActFavSocNotGbl), Act_GetActCod (ActFavSocNotGbl),
Gbl.Session.Id, Gbl.Session.Id,
SocNot->NotCod, SocNot->NotCod) < 0)
(unsigned) Gbl.Social.WhichUsrs) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActFavSocNotGbl,NULL,OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
} }
Ico_PutIconLink ("heart.svg",Txt_Mark_as_favourite); Ico_PutIconLink ("heart.svg",Txt_Mark_as_favourite);
Frm_EndForm (); Frm_EndForm ();
@ -2957,19 +2926,18 @@ static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot)
SocNot->NotCod, SocNot->NotCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnfSocNotUsr,"timeline",OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
} }
else else
{ {
if (asprintf (&OnSubmit,"refreshFav(this," if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&NotCod=%ld&WhichUsrs=%u');" "'act=%ld&ses=%s&NotCod=%ld');"
" return false;", // return false is necessary to not submit form " return false;", // return false is necessary to not submit form
Act_GetActCod (ActUnfSocNotGbl), Act_GetActCod (ActUnfSocNotGbl),
Gbl.Session.Id, Gbl.Session.Id,
SocNot->NotCod, SocNot->NotCod) < 0)
(unsigned) Gbl.Social.WhichUsrs) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnfSocNotGbl,NULL,OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
} }
Ico_PutIconLink ("heart-red.svg",Txt_SOCIAL_NOTE_Favourite); Ico_PutIconLink ("heart-red.svg",Txt_SOCIAL_NOTE_Favourite);
Frm_EndForm (); Frm_EndForm ();
@ -2981,21 +2949,50 @@ static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot)
Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (SocNot); Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (SocNot);
} }
/*****************************************************************************/ /*****************************************************************************/
/*************** Form to unshare (stop sharing) social note ******************/ /***************** Form to mark a social comment as favourite ****************/
/*****************************************************************************/ /*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers // All forms in this function and nested functions must have unique identifiers
static void Soc_PutFormToUnshareSocialNote (long NotCod) static void Soc_PutFormToFavSocialComment (struct SocialComment *SocCom)
{ {
extern const char *Txt_SOCIAL_NOTE_Shared; extern const char *Txt_Mark_as_favourite;
char *OnSubmit;
/***** Form to share social publishing *****/ /***** Form and icon to mark social note as favourite *****/
Soc_FormStart (ActUnsSocNotGbl,ActUnsSocNotUsr); /* Form with icon */
Soc_PutHiddenParamNotCod (NotCod); if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Ico_PutDivIconLink ("SOCIAL_ICO_SHARE", {
"share-alt-green.svg",Txt_SOCIAL_NOTE_Shared); if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&PubCod=%ld&OtherUsrCod=%s');"
" return false;", // return false is necessary to not submit form
Act_GetActCod (ActFavSocComUsr),
Gbl.Session.Id,
SocCom->PubCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
}
else
{
if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&PubCod=%ld');"
" return false;", // return false is necessary to not submit form
Act_GetActCod (ActFavSocComGbl),
Gbl.Session.Id,
SocCom->PubCod) < 0)
Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
}
Ico_PutIconLink ("heart.svg",Txt_Mark_as_favourite);
Frm_EndForm (); Frm_EndForm ();
/* Free allocated memory for subquery */
free ((void *) OnSubmit);
/***** Show who have marked this social comment as favourite *****/
Soc_ShowUsrsWhoHaveMarkedSocialCommAsFav (SocCom);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3020,19 +3017,18 @@ static void Soc_PutFormToUnfavSocialComment (struct SocialComment *SocCom)
SocCom->PubCod, SocCom->PubCod,
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnfSocComUsr,"timeline",OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
} }
else else
{ {
if (asprintf (&OnSubmit,"refreshFav(this," if (asprintf (&OnSubmit,"refreshFav(this,"
"'act=%ld&ses=%s&PubCod=%ld&WhichUsrs=%u');" "'act=%ld&ses=%s&PubCod=%ld');"
" return false;", // return false is necessary to not submit form " return false;", // return false is necessary to not submit form
Act_GetActCod (ActUnfSocComGbl), Act_GetActCod (ActUnfSocComGbl),
Gbl.Session.Id, Gbl.Session.Id,
SocCom->PubCod, SocCom->PubCod) < 0)
(unsigned) Gbl.Social.WhichUsrs) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Frm_StartFormUniqueAnchorOnSubmit (ActUnfSocComGbl,NULL,OnSubmit); Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
} }
Ico_PutIconLink ("heart-red.svg",Txt_SOCIAL_NOTE_Favourite); Ico_PutIconLink ("heart-red.svg",Txt_SOCIAL_NOTE_Favourite);
Frm_EndForm (); Frm_EndForm ();
@ -3302,9 +3298,6 @@ void Soc_FavSocialNoteGbl (void)
{ {
struct SocialNote SocNot; struct SocialNote SocNot;
/***** Get which users *****/
Soc_GetParamsWhichUsrs ();
/***** Mark social note as favourite *****/ /***** Mark social note as favourite *****/
Soc_FavSocialNote (&SocNot); Soc_FavSocialNote (&SocNot);
@ -3357,11 +3350,11 @@ static void Soc_FavSocialNote (struct SocialNote *SocNot)
SocNot->NotCod, SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod);
/* Update number of times this social note is favourited */ /***** Update number of times this social note is favourited**** */
Soc_GetNumTimesANoteHasBeenFav (SocNot); Soc_GetNumTimesANoteHasBeenFav (SocNot);
/**** Create notification about favourite post /***** Create notification about favourite post
for the author of the post ***/ for the author of the post *****/
OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot->NotCod); OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot->NotCod);
if (OriginalPubCod > 0) if (OriginalPubCod > 0)
Soc_CreateNotifToAuthor (SocNot->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV); Soc_CreateNotifToAuthor (SocNot->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV);
@ -3377,9 +3370,6 @@ void Soc_FavSocialCommentGbl (void)
{ {
struct SocialComment SocCom; struct SocialComment SocCom;
/***** Get which users *****/
Soc_GetParamsWhichUsrs ();
/***** Mark social comment as favourite *****/ /***** Mark social comment as favourite *****/
Soc_FavSocialComment (&SocCom); Soc_FavSocialComment (&SocCom);
@ -3578,9 +3568,6 @@ void Soc_UnfavSocialNoteGbl (void)
{ {
struct SocialNote SocNot; struct SocialNote SocNot;
/***** Get which users *****/
Soc_GetParamsWhichUsrs ();
/***** Stop marking as favourite a previously favourited social note *****/ /***** Stop marking as favourite a previously favourited social note *****/
Soc_UnfavSocialNote (&SocNot); Soc_UnfavSocialNote (&SocNot);
@ -3651,9 +3638,6 @@ void Soc_UnfavSocialCommentGbl (void)
{ {
struct SocialComment SocCom; struct SocialComment SocCom;
/***** Get which users *****/
Soc_GetParamsWhichUsrs ();
/***** Stop marking as favourite a previously favourited social comment *****/ /***** Stop marking as favourite a previously favourited social comment *****/
Soc_UnfavSocialComment (&SocCom); Soc_UnfavSocialComment (&SocCom);

View File

@ -4117,9 +4117,10 @@ void Sta_GetAndShowLastClicks (void)
"UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ClickTime) AS Dif," "UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ClickTime) AS Dif,"
"Role,CtyCod,InsCod,CtrCod,DegCod" "Role,CtyCod,InsCod,CtrCod,DegCod"
" FROM log_recent ORDER BY LogCod DESC LIMIT 20)" " FROM log_recent ORDER BY LogCod DESC LIMIT 20)"
" AS last_logs,actions" " AS last_logs LEFT JOIN actions" // LEFT JOIN because action may be not present in table of actions
" WHERE last_logs.ActCod=actions.ActCod" " ON last_logs.ActCod=actions.ActCod"
" AND actions.Language='es'"); " WHERE actions.Language='es'" // TODO: Change to user's language
" OR actions.Language IS NULL"); // When action is not present in table of actions
/***** Write list of connected users *****/ /***** Write list of connected users *****/
Tbl_StartTableCenter (1); Tbl_StartTableCenter (1);
@ -4229,16 +4230,18 @@ void Sta_GetAndShowLastClicks (void)
"<td class=\"%s LEFT_MIDDLE\">" "<td class=\"%s LEFT_MIDDLE\">"
"%s" // Degree "%s" // Degree
"</td>" "</td>"
"<td class=\"%s LEFT_MIDDLE\">" "<td class=\"%s LEFT_MIDDLE\">",
"%s" // Action
"</td>"
"</tr>",
ClassRow,Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN], ClassRow,Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN],
ClassRow,Cty.Name[Gbl.Prefs.Language], ClassRow,Cty.Name[Gbl.Prefs.Language],
ClassRow,Ins.ShrtName, ClassRow,Ins.ShrtName,
ClassRow,Ctr.ShrtName, ClassRow,Ctr.ShrtName,
ClassRow,Deg.ShrtName, ClassRow,Deg.ShrtName,
ClassRow,row[8]); ClassRow);
if (row[8])
if (row[8][0])
fprintf (Gbl.F.Out,"%s",row[8]); // Action
fprintf (Gbl.F.Out,"</td>"
"</tr>");
} }
Tbl_EndTable (); Tbl_EndTable ();