diff --git a/css/swad18.57.css b/css/swad18.57.css
index f95de4fc5..ad8f7292e 100644
--- a/css/swad18.57.css
+++ b/css/swad18.57.css
@@ -1577,7 +1577,7 @@ a:hover /* Default ==> underlined */
/* background-color:#fff3d4; */
background-color:#fff8e5;
border-radius:2px;
- box-shadow: 0 2px 2px 0 rgba(124,121,109,0.14), 0 2px 1px -2px rgba(124,121,109,0.2), 0 1px 5px 0 rgba(124,121,109,0.12);
+ box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 2px 1px -2px rgba(0,0,0,0.2), 0 1px 5px 0 rgba(0,0,0,0.12);
}
.ALERT_CLOSE
{
diff --git a/js/swad18.58.js b/js/swad18.59.js
similarity index 97%
rename from js/swad18.58.js
rename to js/swad18.59.js
index 4e15d9db5..03cd5bc1a 100644
--- a/js/swad18.58.js
+++ b/js/swad18.59.js
@@ -715,13 +715,46 @@ function readAndUpdateFav () {
if (objXMLHttpReqFavSoc.readyState == 4) { // Check if data have been received
if (objXMLHttpReqFavSoc.status == 200)
if (idDivFav) {
- var divFav = document.getElementById(idDivFav); // Access to last click DIV
+ var divFav = document.getElementById(idDivFav); // Access to DIV
if (divFav)
divFav.innerHTML = objXMLHttpReqFavSoc.responseText; // Update fav area DIV
}
}
}
+/*****************************************************************************/
+/************* Update share area in social timeline using AJAX ***************/
+/*****************************************************************************/
+
+var objXMLHttpReqShaSoc = false;
+var idDivSha = null;
+
+// This function is called when user clicks in icon to share/unshare in timeline
+function refreshSha (elem,Params) {
+ idDivSha = elem.parentNode.id;
+
+ objXMLHttpReqShaSoc = AJAXCreateObject ();
+ if (objXMLHttpReqShaSoc) {
+ /* Send request to server */
+ objXMLHttpReqShaSoc.onreadystatechange = readAndUpdateSha; // onreadystatechange must be lowercase
+ objXMLHttpReqShaSoc.open('POST',ActionAJAX,true);
+ objXMLHttpReqShaSoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ objXMLHttpReqShaSoc.send(Params);
+ }
+}
+
+// Receives and shows share area: icon and users who have shared a social note or comment in timeline
+function readAndUpdateSha () {
+ if (objXMLHttpReqShaSoc.readyState == 4) { // Check if data have been received
+ if (objXMLHttpReqShaSoc.status == 200)
+ if (idDivSha) {
+ var divSha = document.getElementById(idDivSha); // Access to DIV
+ if (divSha)
+ divSha.innerHTML = objXMLHttpReqShaSoc.responseText; // Update share area DIV
+ }
+ }
+}
+
function readLastClicksData () {
if (objXMLHttpReqLog.readyState == 4) { // Check if data have been received
if (objXMLHttpReqLog.status == 200) {
@@ -1462,31 +1495,3 @@ function ContractChildren (idParent) {
row.style.display = 'none'; // hide
}
}
-
-/*****************************************************************************/
-/**************** Animate icon "recycle" when click on a link ****************/
-/*****************************************************************************/
-
-function FavSocial (idParent) {
- var parent = document.getElementById(idParent);
- var iconToFav = document.getElementById('fav_' + idParent);
- var iconToUnfav = document.getElementById('unfav_' + idParent);
-
- if (parent.dataset.status == 'unfaved') {
- parent.dataset.status = 'faved';
- iconToFav.style.display = 'none';
- iconToUnfav.style.display = '';
- }
-}
-
-function UnfavSocial (idParent) {
- var parent = document.getElementById(idParent);
- var iconToFav = document.getElementById('fav_' + idParent);
- var iconToUnfav = document.getElementById('unfav_' + idParent);
-
- if (parent.dataset.status == 'faved') {
- parent.dataset.status = 'unfaved';
- iconToUnfav.style.display = 'none';
- iconToFav.style.display = '';
- }
-}
diff --git a/swad_action.c b/swad_action.c
index 324fdc8d0..afec41693 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -1613,8 +1613,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActRcvSocPstGbl */{1492,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,Soc_ShowTimelineGbl1 ,Soc_ReceiveSocialPostGbl ,NULL},
/* ActRcvSocComGbl */{1503,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,Soc_ShowTimelineGbl1 ,Soc_ReceiveCommentGbl ,NULL},
- /* ActShaSocNotGbl */{1495,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Soc_ShowTimelineGbl1 ,Soc_ShareSocialNoteGbl ,NULL},
- /* ActUnsSocNotGbl */{1496,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Soc_ShowTimelineGbl1 ,Soc_UnshareSocialNoteGbl ,NULL},
+ /* ActShaSocNotGbl */{1495,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Soc_ShareSocialNoteGbl ,NULL},
+ /* ActUnsSocNotGbl */{1496,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Soc_UnshareSocialNoteGbl ,NULL},
/* ActFavSocNotGbl */{1512,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Soc_FavSocialNoteGbl ,NULL},
/* ActUnfSocNotGbl */{1513,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Soc_UnfavSocialNoteGbl ,NULL},
/* ActFavSocComGbl */{1516,-1,TabUnk,ActSeeSocTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Soc_FavSocialCommentGbl ,NULL},
diff --git a/swad_changelog.h b/swad_changelog.h
index bb0c83bad..aeb551200 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -429,10 +429,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 18.58.1 (2019-02-24)"
+#define Log_PLATFORM_VERSION "SWAD 18.59 (2019-02-25)"
#define CSS_FILE "swad18.57.css"
-#define JS_FILE "swad18.58.js"
+#define JS_FILE "swad18.59.js"
/*
+ Version 18.59: Feb 25, 2019 Shared in social notes are made in AJAX without reloading page. (237809 lines)
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:
diff --git a/swad_layout.c b/swad_layout.c
index 52fd8e3a8..16231f7f3 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -726,8 +726,6 @@ static void Lay_WriteScriptParamsAJAX (void)
case ActSeeSocTmlGbl:
case ActRcvSocPstGbl:
case ActRcvSocComGbl:
- case ActShaSocNotGbl:
- case ActUnsSocNotGbl:
case ActReqRemSocPubGbl:
case ActRemSocPubGbl:
case ActReqRemSocComGbl:
@@ -746,8 +744,6 @@ static void Lay_WriteScriptParamsAJAX (void)
case ActSeeOthPubPrf:
case ActRcvSocPstUsr:
case ActRcvSocComUsr:
- case ActShaSocNotUsr:
- case ActUnsSocNotUsr:
case ActReqRemSocPubUsr:
case ActRemSocPubUsr:
case ActReqRemSocComUsr:
diff --git a/swad_parameter.c b/swad_parameter.c
index ae2af19fc..769539fa5 100644
--- a/swad_parameter.c
+++ b/swad_parameter.c
@@ -735,6 +735,8 @@ void Par_GetMainParameters (void)
Gbl.Action.IsAJAXAutoRefresh = true;
}
else if (Gbl.Action.Act == ActRefOldSocPubGbl || Gbl.Action.Act == ActRefOldSocPubUsr ||
+ Gbl.Action.Act == ActShaSocNotGbl || Gbl.Action.Act == ActShaSocNotUsr ||
+ Gbl.Action.Act == ActUnsSocNotGbl || Gbl.Action.Act == ActUnsSocNotUsr ||
Gbl.Action.Act == ActFavSocNotGbl || Gbl.Action.Act == ActFavSocNotUsr ||
Gbl.Action.Act == ActUnfSocNotGbl || Gbl.Action.Act == ActUnfSocNotUsr ||
Gbl.Action.Act == ActFavSocComGbl || Gbl.Action.Act == ActFavSocComUsr ||
diff --git a/swad_social.c b/swad_social.c
index 69941e6a0..6906b0f2d 100644
--- a/swad_social.c
+++ b/swad_social.c
@@ -198,8 +198,8 @@ static void Soc_PutFormToRemoveComment (long PubCod);
static void Soc_PutDisabledIconShare (unsigned NumShared);
static void Soc_PutDisabledIconFav (unsigned NumFavs);
-static void Soc_PutFormToShareSocialNote (long NotCod);
-static void Soc_PutFormToUnshareSocialNote (long NotCod);
+static void Soc_PutFormToShareSocialNote (const struct SocialNote *SocNot);
+static void Soc_PutFormToUnshareSocialNote (const struct SocialNote *SocNot);
static void Soc_PutFormToFavSocialNote (const struct SocialNote *SocNot);
static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot);
static void Soc_PutFormToFavSocialComment (struct SocialComment *SocCom);
@@ -213,13 +213,13 @@ static long Soc_GetParamPubCod (void);
static long Soc_ReceiveComment (void);
-static long Soc_ShareSocialNote (void);
+static void Soc_ShareSocialNote (struct SocialNote *SocNot);
static void Soc_FavSocialNote (struct SocialNote *SocNot);
static void Soc_FavSocialComment (struct SocialComment *SocCom);
static void Soc_CreateNotifToAuthor (long AuthorCod,long PubCod,
Ntf_NotifyEvent_t NotifyEvent);
-static long Soc_UnshareSocialNote (void);
+static void Soc_UnshareSocialNote (struct SocialNote *SocNot);
static void Soc_UnfavSocialNote (struct SocialNote *SocNot);
static void Soc_UnfavSocialComment (struct SocialComment *SocCom);
@@ -242,7 +242,7 @@ static bool Soc_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod);
static bool Soc_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod);
static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod);
-static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
+static void Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
static void Soc_GetNumTimesANoteHasBeenFav (struct SocialNote *SocNot);
static void Soc_GetNumTimesACommHasBeenFav (struct SocialComment *SocCom);
@@ -1374,7 +1374,9 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1];
unsigned NumComments;
char IdNewComment[Frm_MAX_BYTES_ID + 1];
- static unsigned Num = 0;
+ static unsigned NumDiv = 0; // Used to create unique div id for fav and shared
+
+ NumDiv++;
/***** Start box ****/
if (ShowNoteAlone)
@@ -1565,51 +1567,50 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot,
"
");
/* Put icon to mark this social note as favourite */
- if (SocNot->Unavailable) // Unavailable social notes can not be favourited
- {
- /* Put disabled icon */
- Soc_PutDisabledIconFav (SocNot->NumFavs);
- // Don't show who have marked this social note as favourite
- }
- else if (IAmTheAuthor) // I am the author
+ if (SocNot->Unavailable || // Unavailable social notes can not be favourited
+ IAmTheAuthor) // I am the author
{
/* Put disabled icon and list of users
- who have marked this social note as favourite*/
+ who have marked this social note as favourite */
Soc_PutDisabledIconFav (SocNot->NumFavs);
Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (SocNot);
}
- else // I am not the author
+ else // Available and I am not the author
{
fprintf (Gbl.F.Out,"
",
- Gbl.UniqueNameEncrypted,++Num);
+ Gbl.UniqueNameEncrypted,NumDiv);
if (IAmAFaverOfThisSocNot) // I have favourited this social note
/* Put icon to unfav this publishing and list of users */
Soc_PutFormToUnfavSocialNote (SocNot);
- else // I am not a faver
+ else // I am not a faver of this social note
/* Put icon to fav this publishing and list of users */
Soc_PutFormToFavSocialNote (SocNot);
fprintf (Gbl.F.Out,"
");
}
- /* Put icons to share/unshare */
- if (IAmTheAuthor) // I am the author
+ /* Put icon to share/unshare */
+ if (SocNot->Unavailable || // Unavailable social notes can not be shared
+ IAmTheAuthor) // I am the author
+ {
+ /* Put disabled icon and list of users
+ who have shared this social note */
Soc_PutDisabledIconShare (SocNot->NumShared);
- else if (IAmASharerOfThisSocNot) // I am a sharer of this social note,
- // but not the author ==> I have shared this social note
- /* Put icon to unshare this publishing */
- Soc_PutFormToUnshareSocialNote (SocNot->NotCod);
- else // I am not the author and I am not a sharer
- {
- if (SocNot->Unavailable) // Unavailable social notes can not be shared
- Soc_PutDisabledIconShare (SocNot->NumShared);
- else
- /* Put icon to share this publishing */
- Soc_PutFormToShareSocialNote (SocNot->NotCod);
- }
-
- /* Show who have shared this social note */
- Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
+ Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
+ }
+ else // Available and I am not the author
+ {
+ fprintf (Gbl.F.Out,"
",
+ Gbl.UniqueNameEncrypted,NumDiv);
+ if (IAmASharerOfThisSocNot) // I am a sharer of this social note
+ /* Put icon to unshare this publishing and list of users */
+ Soc_PutFormToUnshareSocialNote (SocNot);
+ else // I am not a sharer of this social note
+ /* Put icon to share this publishing and list of users */
+ Soc_PutFormToShareSocialNote (SocNot);
+ fprintf (Gbl.F.Out,"
");
+ }
/* Put icon to remove this social note */
if (IAmTheAuthor)
@@ -2626,7 +2627,9 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
bool IAmAFaverOfThisSocCom = false;
bool ShowPhoto = false;
char PhotoURL[PATH_MAX + 1];
- static unsigned Num = 0;
+ static unsigned NumDiv = 0; // Used to create unique div id for fav
+
+ NumDiv++;
if (ShowCommentAlone)
{
@@ -2701,7 +2704,7 @@ static void Soc_WriteSocialComment (struct SocialComment *SocCom,
{
fprintf (Gbl.F.Out,"
",
- Gbl.UniqueNameEncrypted,++Num);
+ Gbl.UniqueNameEncrypted,NumDiv);
if (IAmAFaverOfThisSocCom) // I have favourited this social comment
/* Put icon to unfav this publishing and list of users */
Soc_PutFormToUnfavSocialComment (SocCom);
@@ -2830,16 +2833,44 @@ static void Soc_PutDisabledIconFav (unsigned NumFavs)
/*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers
-static void Soc_PutFormToShareSocialNote (long NotCod)
+static void Soc_PutFormToShareSocialNote (const struct SocialNote *SocNot)
{
extern const char *Txt_Share;
+ char *OnSubmit;
- /***** Form to share social note *****/
- Soc_FormStart (ActShaSocNotGbl,ActShaSocNotUsr);
- Soc_PutHiddenParamNotCod (NotCod);
- Ico_PutDivIconLink ("SOCIAL_ICO_SHARE",
- "share-alt.svg",Txt_Share);
+ /***** Form and icon to mark social note as favourite *****/
+ /* Form with icon */
+ if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
+ {
+ if (asprintf (&OnSubmit,"refreshSha(this,"
+ "'act=%ld&ses=%s&NotCod=%ld&OtherUsrCod=%s');"
+ " return false;", // return false is necessary to not submit form
+ Act_GetActCod (ActShaSocNotUsr),
+ Gbl.Session.Id,
+ SocNot->NotCod,
+ Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
+ }
+ else
+ {
+ if (asprintf (&OnSubmit,"refreshSha(this,"
+ "'act=%ld&ses=%s&NotCod=%ld');"
+ " return false;", // return false is necessary to not submit form
+ Act_GetActCod (ActShaSocNotGbl),
+ Gbl.Session.Id,
+ SocNot->NotCod) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
+ }
+ Ico_PutIconLink ("share-alt.svg",Txt_Share);
Frm_EndForm ();
+
+ /* Free allocated memory for subquery */
+ free ((void *) OnSubmit);
+
+ /***** Who have shared this social note *****/
+ Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
}
/*****************************************************************************/
@@ -2847,16 +2878,44 @@ static void Soc_PutFormToShareSocialNote (long NotCod)
/*****************************************************************************/
// All forms in this function and nested functions must have unique identifiers
-static void Soc_PutFormToUnshareSocialNote (long NotCod)
+static void Soc_PutFormToUnshareSocialNote (const struct SocialNote *SocNot)
{
extern const char *Txt_SOCIAL_NOTE_Shared;
+ char *OnSubmit;
- /***** 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);
+ /***** Form and icon to mark social note as favourite *****/
+ /* Form with icon */
+ if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
+ {
+ if (asprintf (&OnSubmit,"refreshSha(this,"
+ "'act=%ld&ses=%s&NotCod=%ld&OtherUsrCod=%s');"
+ " return false;", // return false is necessary to not submit form
+ Act_GetActCod (ActUnsSocNotUsr),
+ Gbl.Session.Id,
+ SocNot->NotCod,
+ Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit);
+ }
+ else
+ {
+ if (asprintf (&OnSubmit,"refreshSha(this,"
+ "'act=%ld&ses=%s&NotCod=%ld');"
+ " return false;", // return false is necessary to not submit form
+ Act_GetActCod (ActUnsSocNotGbl),
+ Gbl.Session.Id,
+ SocNot->NotCod) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
+ }
+ Ico_PutIconLink ("share-alt-green.svg",Txt_SOCIAL_NOTE_Shared);
Frm_EndForm ();
+
+ /* Free allocated memory for subquery */
+ free ((void *) OnSubmit);
+
+ /***** Who have shared this social note *****/
+ Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
}
/*****************************************************************************/
@@ -2949,7 +3008,6 @@ static void Soc_PutFormToUnfavSocialNote (const struct SocialNote *SocNot)
Soc_ShowUsrsWhoHaveMarkedSocialNoteAsFav (SocNot);
}
-
/*****************************************************************************/
/***************** Form to mark a social comment as favourite ****************/
/*****************************************************************************/
@@ -3217,77 +3275,69 @@ static long Soc_ReceiveComment (void)
void Soc_ShareSocialNoteGbl (void)
{
- long NotCod;
+ struct SocialNote SocNot;
- /***** Share social note *****/
- NotCod = Soc_ShareSocialNote ();
+ /***** Mark social note as favourite *****/
+ Soc_ShareSocialNote (&SocNot);
- /***** Write updated timeline after sharing (global) *****/
- Soc_ShowTimelineGblHighlightingNot (NotCod);
+ /***** Write HTML inside DIV with form to unshare *****/
+ Soc_PutFormToUnshareSocialNote (&SocNot);
+
+ /***** All the output is made, so don't write anymore *****/
+ Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
}
void Soc_ShareSocialNoteUsr (void)
{
- long NotCod;
+ struct SocialNote SocNot;
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
- /***** Show user's profile *****/
- Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
-
- /***** Start section *****/
- Lay_StartSection (Soc_TIMELINE_SECTION_ID);
-
/***** Share social note *****/
- NotCod = Soc_ShareSocialNote ();
+ Soc_ShareSocialNote (&SocNot);
- /***** Write updated timeline after sharing (user) *****/
- Soc_ShowTimelineUsrHighlightingNot (NotCod);
+ /***** Write HTML inside DIV with form to unshare *****/
+ Soc_PutFormToUnshareSocialNote (&SocNot);
- /***** End section *****/
- Lay_EndSection ();
+ /***** All the output is made, so don't write anymore *****/
+ Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
}
-static long Soc_ShareSocialNote (void)
+static void Soc_ShareSocialNote (struct SocialNote *SocNot)
{
extern const char *Txt_The_original_post_no_longer_exists;
- struct SocialNote SocNot;
struct SocialPublishing SocPub;
bool ItsMe;
long OriginalPubCod;
/***** Get data of social note *****/
- SocNot.NotCod = Soc_GetParamNotCod ();
- Soc_GetDataOfSocialNotByCod (&SocNot);
+ SocNot->NotCod = Soc_GetParamNotCod ();
+ Soc_GetDataOfSocialNotByCod (SocNot);
- if (SocNot.NotCod > 0)
+ if (SocNot->NotCod > 0)
{
- ItsMe = Usr_ItsMe (SocNot.UsrCod);
+ ItsMe = Usr_ItsMe (SocNot->UsrCod);
if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
- if (!Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
+ if (!Soc_CheckIfNoteIsSharedByUsr (SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me
{
/***** Share (publish social note in timeline) *****/
- SocPub.NotCod = SocNot.NotCod;
+ SocPub.NotCod = SocNot->NotCod;
SocPub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
SocPub.PubType = Soc_PUB_SHARED_NOTE;
Soc_PublishSocialNoteInTimeline (&SocPub); // Set SocPub.PubCod
/* Update number of times this social note is shared */
- SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
+ Soc_UpdateNumTimesANoteHasBeenShared (SocNot);
/**** Create notification about shared post
for the author of the post ***/
- OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
+ OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot->NotCod);
if (OriginalPubCod > 0)
- Soc_CreateNotifToAuthor (SocNot.UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE);
+ Soc_CreateNotifToAuthor (SocNot->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE);
}
}
- else
- Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists);
-
- return SocNot.NotCod;
}
/*****************************************************************************/
@@ -3478,55 +3528,51 @@ static void Soc_CreateNotifToAuthor (long AuthorCod,long PubCod,
void Soc_UnshareSocialNoteGbl (void)
{
- long NotCod;
+ struct SocialNote SocNot;
- /***** Unshare a previously shared social note *****/
- NotCod = Soc_UnshareSocialNote ();
+ /***** Unshare social note *****/
+ Soc_UnshareSocialNote (&SocNot);
- /***** Write updated timeline after unsharing (global) *****/
- Soc_ShowTimelineGblHighlightingNot (NotCod);
+ /***** Write HTML inside DIV with form to share *****/
+ Soc_PutFormToShareSocialNote (&SocNot);
+
+ /***** All the output is made, so don't write anymore *****/
+ Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
}
void Soc_UnshareSocialNoteUsr (void)
{
- long NotCod;
+ struct SocialNote SocNot;
/***** Get user whom profile is displayed *****/
Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ();
- /***** Show user's profile *****/
- Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat);
+ /***** Share social note *****/
+ Soc_UnshareSocialNote (&SocNot);
- /***** Start section *****/
- Lay_StartSection (Soc_TIMELINE_SECTION_ID);
+ /***** Write HTML inside DIV with form to share *****/
+ Soc_PutFormToShareSocialNote (&SocNot);
- /***** Unshare a previously shared social note *****/
- NotCod = Soc_UnshareSocialNote ();
-
- /***** Write updated timeline after unsharing (user) *****/
- Soc_ShowTimelineUsrHighlightingNot (NotCod);
-
- /***** End section *****/
- Lay_EndSection ();
+ /***** All the output is made, so don't write anymore *****/
+ Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
}
-static long Soc_UnshareSocialNote (void)
+static void Soc_UnshareSocialNote (struct SocialNote *SocNot)
{
extern const char *Txt_The_original_post_no_longer_exists;
- struct SocialNote SocNot;
long OriginalPubCod;
bool ItsMe;
/***** Get data of social note *****/
- SocNot.NotCod = Soc_GetParamNotCod ();
- Soc_GetDataOfSocialNotByCod (&SocNot);
+ SocNot->NotCod = Soc_GetParamNotCod ();
+ Soc_GetDataOfSocialNotByCod (SocNot);
- if (SocNot.NotCod > 0)
+ if (SocNot->NotCod > 0)
{
- ItsMe = Usr_ItsMe (SocNot.UsrCod);
- if (SocNot.NumShared &&
+ ItsMe = Usr_ItsMe (SocNot->UsrCod);
+ if (SocNot->NumShared &&
Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author
- if (Soc_CheckIfNoteIsSharedByUsr (SocNot.NotCod,
+ if (Soc_CheckIfNoteIsSharedByUsr (SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod)) // I am a sharer
{
/***** Delete social publishing from database *****/
@@ -3535,29 +3581,19 @@ static long Soc_UnshareSocialNote (void)
" WHERE NotCod=%ld"
" AND PublisherCod=%ld"
" AND PubType=%u",
- SocNot.NotCod,
+ SocNot->NotCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) Soc_PUB_SHARED_NOTE);
/***** Update number of times this social note is shared *****/
- SocNot.NumShared = Soc_UpdateNumTimesANoteHasBeenShared (&SocNot);
+ Soc_UpdateNumTimesANoteHasBeenShared (SocNot);
/***** Mark possible notifications on this social note as removed *****/
- OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot.NotCod);
+ OriginalPubCod = Soc_GetPubCodOfOriginalSocialNote (SocNot->NotCod);
if (OriginalPubCod > 0)
Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod);
-
- /***** Show the social note corresponding
- to the publishing just unshared *****/
- Soc_WriteSocialNote (&SocNot,
- Soc_TOP_MESSAGE_UNSHARED,Gbl.Usrs.Me.UsrDat.UsrCod,
- true,true);
}
}
- else
- Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists);
-
- return SocNot.NotCod;
}
/*****************************************************************************/
@@ -4407,10 +4443,10 @@ static bool Soc_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod)
/******* Get number of times a social note has been shared in timeline *******/
/*****************************************************************************/
-static unsigned Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
+static void Soc_UpdateNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
{
/***** Get number of times (users) this note has been shared *****/
- return
+ SocNot->NumShared =
(unsigned) DB_QueryCOUNT ("can not get number of times"
" a note has been shared",
"SELECT COUNT(*) FROM social_pubs"
@@ -4759,7 +4795,7 @@ static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc
SocNot->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]);
/***** Get number of times this social note has been shared *****/
- SocNot->NumShared = Soc_UpdateNumTimesANoteHasBeenShared (SocNot);
+ Soc_UpdateNumTimesANoteHasBeenShared (SocNot);
/***** Get number of times this social note has been favourited *****/
Soc_GetNumTimesANoteHasBeenFav (SocNot);