Version 15.96

This commit is contained in:
Antonio Cañas Vargas 2016-01-04 11:58:36 +01:00
parent 744e9525a0
commit 2c4d437fd1
3 changed files with 107 additions and 37 deletions

View File

@ -1705,10 +1705,26 @@ a:hover img.CENTRE_PHOTO_SHOW
text-align:right;
vertical-align:top;
}
.SOCIAL_ICON
.SOCIAL_NUM_SHARES {color:#A0A0A0; font-size:12pt; font-weight:bold;}
.SOCIAL_ICON_SHARE
{
display:inline-block;
padding-top:10px;
vertical-align:bottom;
}
.SOCIAL_ICON_SHARE_DISABLED
{
display:inline-block;
padding-top:10px;
opacity:0.2;
vertical-align:bottom;
}
.SOCIAL_ICON_REMOVE
{
display:inline-block;
padding-top:10px;
vertical-align:bottom;
float:right;
}
/*********************************** Messages ********************************/

View File

@ -117,13 +117,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.95.2 (2016-01-04)"
#define CSS_FILE "swad15.88.1.css"
#define Log_PLATFORM_VERSION "SWAD 15.96 (2016-01-04)"
#define CSS_FILE "swad15.96.css"
#define JS_FILE "swad15.77.7.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 15.96: Jan 04, 2016 Display number of times a social note is shared. (190616 lines)
Version 15.95.2: Jan 04, 2016 Unavailable social notes can not be shared. (190556 lines)
Version 15.95.1: Jan 04, 2016 Optimization in writing social note. (190555 lines)
Version 15.95: Jan 04, 2016 Fixed bug in social timeline: social notes can be shared, not social publishings. (190583 lines)

View File

@ -113,6 +113,7 @@ struct SocialNote
long Cod; // Code of file, forum post, notice,...
bool Unavailable; // File, forum post, notice,... unavailable (removed)
time_t DateTimeUTC;
unsigned NumTimesShared; // Number of times this note has been shared
};
/*****************************************************************************/
@ -145,6 +146,7 @@ static void Soc_PutLinkToWriteANewPost (Act_Action_t Action,void (*FuncParams) (
static void Soc_FormSocialPost (void);
static void Soc_ReceiveSocialPost (void);
static void Soc_PutIconShared (void);
static void Soc_PutFormToShareSocialNote (long NotCod);
static void Soc_PutFormToUnshareSocialPublishing (long PubCod);
static void Soc_PutFormToRemoveSocialPublishing (long PubCod);
@ -165,10 +167,11 @@ static void Soc_CheckAndDeleteASocialNoteFromDB (const struct SocialNote *SocNot
static bool Soc_CheckIfNoteIsYetPublishedByMe (long NotCod);
static unsigned long Soc_GetNumPubsOfANote (long NotCod);
static void Soc_GetNumTimesANoteHasBeenShared (struct SocialNote *SocNot);
static void Soc_GetDataOfSocialPublishingByCod (struct SocialPublishing *SocPub);
static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot);
static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *SocNot);
static Soc_NoteType_t Soc_GetSocialNoteFromDB (const char *Str);
static Soc_NoteType_t Soc_GetNoteTypeFromStr (const char *Str);
/*****************************************************************************/
/*********** Show social activity (timeline) of a selected user **************/
@ -514,28 +517,29 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
}
/* Put icons to share/unshare/remove */
if (Gbl.Usrs.Me.Logged)
/* Put icons to share/unshare */
if (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod || // I am the author
SocNot->Unavailable) // Unavailable social notes can not be shared
Soc_PutIconShared ();
else // I am not the author && not unavailable
{
if (UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author
{
if (WritingTimeline)
/* Put icon to remove this publishing */
Soc_PutFormToRemoveSocialPublishing (SocPub->PubCod);
}
else // I am not the author
{
if (Soc_CheckIfNoteIsYetPublishedByMe (SocNot->NotCod))
// I have yet published this social note
/* Put icon to unshare this publishing */
Soc_PutFormToUnshareSocialPublishing (SocPub->PubCod);
else
// I have not yet published this social note
/* Put icon to share this publishing */
if (!SocNot->Unavailable) // Unavailable social notes can not be shared
Soc_PutFormToShareSocialNote (SocNot->NotCod);
}
if (Soc_CheckIfNoteIsYetPublishedByMe (SocNot->NotCod))
// I have yet published this social note
/* Put icon to unshare this publishing */
Soc_PutFormToUnshareSocialPublishing (SocPub->PubCod);
else
// I have not yet published this social note
/* Put icon to share this publishing */
Soc_PutFormToShareSocialNote (SocNot->NotCod);
}
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES\"> %u</span>",SocNot->NumTimesShared);
/* Put icon to remove */
if (WritingTimeline &&
Gbl.Usrs.Me.Logged &&
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author
/* Put icon to remove this publishing */
Soc_PutFormToRemoveSocialPublishing (SocPub->PubCod);
/* End of right part */
fprintf (Gbl.F.Out,"</div>");
@ -1086,6 +1090,25 @@ static void Soc_ReceiveSocialPost (void)
Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod);
}
/*****************************************************************************/
/************************* Put inactive icon shared **************************/
/*****************************************************************************/
static void Soc_PutIconShared (void)
{
extern const char *Txt_SOCIAL_PUBLISHING_Shared;
/***** Inactive icon shared *****/
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE_DISABLED\">"
"<img src=\"%s/share64x64.png\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</div>",
Gbl.Prefs.IconsURL,
Txt_SOCIAL_PUBLISHING_Shared,
Txt_SOCIAL_PUBLISHING_Shared);
}
/*****************************************************************************/
/************************* Form to share social note *************************/
/*****************************************************************************/
@ -1104,7 +1127,7 @@ static void Soc_PutFormToShareSocialNote (long NotCod)
else
Act_FormStart (ActShaSocNotGbl);
Soc_PutHiddenParamNotCod (NotCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON ICON_HIGHLIGHT\">"
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
"<input type=\"image\""
" src=\"%s/share64x64.png\""
" alt=\"%s\" title=\"%s\""
@ -1133,7 +1156,7 @@ static void Soc_PutFormToUnshareSocialPublishing (long PubCod)
else
Act_FormStart (ActUnsSocPubGbl);
Soc_PutHiddenParamPubCod (PubCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON ICON_HIGHLIGHT\">"
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
"<input type=\"image\""
" src=\"%s/shared64x64.png\""
" alt=\"%s\" title=\"%s\""
@ -1162,7 +1185,7 @@ static void Soc_PutFormToRemoveSocialPublishing (long PubCod)
else
Act_FormStart (ActReqRemSocPubGbl);
Soc_PutHiddenParamPubCod (PubCod);
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON ICON_HIGHLIGHT\">"
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">"
"<input type=\"image\""
" src=\"%s/remove-on64x64.png\""
" alt=\"%s\" title=\"%s\""
@ -1292,6 +1315,9 @@ static void Soc_ShareSocialNote (void)
/***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Shared);
/***** Update number of times this note is shared *****/
Soc_GetNumTimesANoteHasBeenShared (&SocNot);
/***** Show the social note just shared *****/
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL);
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
@ -1363,6 +1389,9 @@ static void Soc_UnshareSocialPublishing (void)
/***** Message of success *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_SOCIAL_PUBLISHING_Unshared);
/***** Update number of times this note is shared *****/
Soc_GetNumTimesANoteHasBeenShared (&SocNot);
/***** Show the social note just unshared *****/
Lay_StartRoundFrame (Soc_WIDTH_TIMELINE,NULL);
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
@ -1624,11 +1653,31 @@ static unsigned long Soc_GetNumPubsOfANote (long NotCod)
{
char Query[128];
sprintf (Query,"SELECT COUNT(*) FROM social_timeline WHERE NotCod='%ld'",
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld'",
NotCod);
return DB_QueryCOUNT (Query,"can not get number of publishing of a note");
}
/*****************************************************************************/
/******** Get number of times a note code has been shared in timeline ********/
/*****************************************************************************/
static void Soc_GetNumTimesANoteHasBeenShared (struct SocialNote *SocNot)
{
char Query[128];
/* TODO: Check if this check is faster
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld' AND AuthorCod<>PublisherCod",
SocNot->NotCod);
*/
sprintf (Query,"SELECT COUNT(*) FROM social_timeline"
" WHERE NotCod='%ld' AND PublisherCod<>'%ld'",
SocNot->NotCod,SocNot->UsrCod);
SocNot->NumTimesShared = (unsigned) DB_QueryCOUNT (Query,"can not get number of times a note has been shared");
}
/*****************************************************************************/
/********* Get data of social publishing in timeline using its code **********/
/*****************************************************************************/
@ -1677,19 +1726,23 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot)
SocNot->NotCod);
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social note"))
{
/***** Get social note *****/
/***** Get data of social note *****/
row = mysql_fetch_row (mysql_res);
Soc_GetDataOfSocialNoteFromRow (row,SocNot);
/***** Get number of times this social note has been shared *****/
Soc_GetNumTimesANoteHasBeenShared (SocNot);
}
else
{
/***** Reset fields of social note *****/
SocNot->NoteType = Soc_NOTE_UNKNOWN;
SocNot->UsrCod = -1L;
SocNot->HieCod = -1L;
SocNot->Cod = -1L;
SocNot->Unavailable = false;
SocNot->DateTimeUTC = (time_t) 0;
SocNot->NoteType = Soc_NOTE_UNKNOWN;
SocNot->UsrCod = -1L;
SocNot->HieCod = -1L;
SocNot->Cod = -1L;
SocNot->Unavailable = false;
SocNot->DateTimeUTC = (time_t) 0;
SocNot->NumTimesShared = 0;
}
}
@ -1703,7 +1756,7 @@ static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc
SocNot->NotCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get note type (row[1]) */
SocNot->NoteType = Soc_GetSocialNoteFromDB ((const char *) row[1]);
SocNot->NoteType = Soc_GetNoteTypeFromStr ((const char *) row[1]);
/* Get (from) user code (row[2]) */
SocNot->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
@ -1725,7 +1778,7 @@ static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc
/****** Get social note type from string number coming from database *********/
/*****************************************************************************/
static Soc_NoteType_t Soc_GetSocialNoteFromDB (const char *Str)
static Soc_NoteType_t Soc_GetNoteTypeFromStr (const char *Str)
{
unsigned UnsignedNum;