mirror of
https://github.com/acanas/swad-core.git
synced 2024-05-29 13:03:31 +02:00
Version 15.97
This commit is contained in:
parent
a365adb30e
commit
7f72b603b7
|
@ -1705,27 +1705,33 @@ a:hover img.CENTRE_PHOTO_SHOW
|
|||
text-align:right;
|
||||
vertical-align:top;
|
||||
}
|
||||
.SOCIAL_NUM_SHARES {color:#A0A0A0; font-size:12pt; font-weight:bold;}
|
||||
.SOCIAL_ICON_SHARE
|
||||
.SOCIAL_ICON
|
||||
{
|
||||
display:inline-block;
|
||||
padding-top:10px;
|
||||
vertical-align:bottom;
|
||||
}
|
||||
.SOCIAL_ICON_SHARE_DISABLED
|
||||
.SOCIAL_ICON_DISABLED
|
||||
{
|
||||
display:inline-block;
|
||||
padding-top:10px;
|
||||
opacity:0.2;
|
||||
vertical-align:bottom;
|
||||
}
|
||||
.SOCIAL_ICON_REMOVE
|
||||
.SOCIAL_ICON_RIGHT
|
||||
{
|
||||
display:inline-block;
|
||||
padding-top:10px;
|
||||
vertical-align:bottom;
|
||||
float:right;
|
||||
}
|
||||
.SOCIAL_NUM_SHARES {color:#A0A0A0; font-size:12pt; font-weight:bold;}
|
||||
.SOCIAL_SHARER
|
||||
{
|
||||
display:inline-block;
|
||||
padding-left:4px;
|
||||
vertical-align:bottom;
|
||||
}
|
||||
|
||||
/*********************************** Messages ********************************/
|
||||
.MSG_TO_ONE_RCP
|
|
@ -11212,4 +11212,7 @@ UPDATE social_notes SET HieCod=DegCod WHERE NoteType IN ('5','6');
|
|||
UPDATE social_notes SET HieCod=CrsCod WHERE NoteType IN ('7','8','9','12');
|
||||
ALTER TABLE social_notes DROP COLUMN CtyCod,DROP COLUMN InsCod,DROP COLUMN CtrCod,DROP COLUMN CrsCod;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS social_timeline_new (PubCod BIGINT NOT NULL AUTO_INCREMENT, NotCod BIGINT NOT NULL, PublisherCod INT NOT NULL, AuthorCod INT NOT NULL, TimePublish DATETIME NOT NULL, UNIQUE INDEX(PubCod), UNIQUE INDEX(NotCod,PublisherCod), INDEX(PublisherCod), INDEX(AuthorCod), INDEX(TimePublish)) SELECT PubCod,NotCod,PublisherCod,AuthorCod,TimePublish FROM social_timeline ORDER BY PubCod;
|
||||
|
|
|
@ -940,14 +940,14 @@ CREATE TABLE IF NOT EXISTS social_posts (
|
|||
--
|
||||
CREATE TABLE IF NOT EXISTS social_timeline (
|
||||
PubCod BIGINT NOT NULL AUTO_INCREMENT,
|
||||
AuthorCod INT NOT NULL,
|
||||
PublisherCod INT NOT NULL,
|
||||
NotCod BIGINT NOT NULL,
|
||||
PublisherCod INT NOT NULL,
|
||||
AuthorCod INT NOT NULL,
|
||||
TimePublish DATETIME NOT NULL,
|
||||
UNIQUE INDEX(PubCod),
|
||||
INDEX(AuthorCod),
|
||||
UNIQUE INDEX(NotCod,PublisherCod),
|
||||
INDEX(PublisherCod),
|
||||
INDEX(NotCod),
|
||||
INDEX(AuthorCod),
|
||||
INDEX(TimePublish));
|
||||
--
|
||||
-- Table sta_degrees: stores statistics about degrees
|
||||
|
|
|
@ -117,13 +117,19 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.96 (2016-01-04)"
|
||||
#define CSS_FILE "swad15.96.css"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.97 (2016-01-04)"
|
||||
#define CSS_FILE "swad15.97.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.97: Jan 04, 2016 Show list of some users who has shared a social note. (190718 lines)
|
||||
3 changes necessary in database:
|
||||
CREATE TABLE IF NOT EXISTS social_timeline_new (PubCod BIGINT NOT NULL AUTO_INCREMENT, NotCod BIGINT NOT NULL, PublisherCod INT NOT NULL, AuthorCod INT NOT NULL, TimePublish DATETIME NOT NULL, UNIQUE INDEX(PubCod), UNIQUE INDEX(NotCod,PublisherCod), INDEX(PublisherCod), INDEX(AuthorCod), INDEX(TimePublish)) SELECT PubCod,NotCod,PublisherCod,AuthorCod,TimePublish FROM social_timeline ORDER BY PubCod;
|
||||
DROP TABLE social_timeline;
|
||||
RENAME TABLE social_timeline_new TO social_timeline;
|
||||
|
||||
Version 15.96.1: Jan 04, 2016 Changes in title of user's timeline. (190641 lines)
|
||||
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)
|
||||
|
|
|
@ -1988,23 +1988,23 @@ mysql> DESCRIBE social_timeline;
|
|||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+------------+------+-----+---------+----------------+
|
||||
| PubCod | bigint(20) | NO | PRI | NULL | auto_increment |
|
||||
| AuthorCod | int(11) | NO | MUL | NULL | |
|
||||
| PublisherCod | int(11) | NO | MUL | NULL | |
|
||||
| NotCod | bigint(20) | NO | MUL | NULL | |
|
||||
| PublisherCod | int(11) | NO | MUL | NULL | |
|
||||
| AuthorCod | int(11) | NO | MUL | NULL | |
|
||||
| TimePublish | datetime | NO | MUL | NULL | |
|
||||
+--------------+------------+------+-----+---------+----------------+
|
||||
5 rows in set (0.00 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_timeline ("
|
||||
"PubCod BIGINT NOT NULL AUTO_INCREMENT,"
|
||||
"AuthorCod INT NOT NULL,"
|
||||
"PublisherCod INT NOT NULL,"
|
||||
"NotCod BIGINT NOT NULL,"
|
||||
"PublisherCod INT NOT NULL,"
|
||||
"AuthorCod INT NOT NULL,"
|
||||
"TimePublish DATETIME NOT NULL,"
|
||||
"UNIQUE INDEX(PubCod),"
|
||||
"INDEX(AuthorCod),"
|
||||
"UNIQUE INDEX(NotCod,PublisherCod),"
|
||||
"INDEX(PublisherCod),"
|
||||
"INDEX(NotCod),"
|
||||
"INDEX(AuthorCod),"
|
||||
"INDEX(TimePublish))");
|
||||
|
||||
/***** Table sta_degrees *****/
|
||||
|
|
131
swad_social.c
131
swad_social.c
|
@ -52,6 +52,7 @@
|
|||
#define Soc_MAX_BYTES_SUMMARY 100
|
||||
#define Soc_NUM_PUBS_IN_TIMELINE 100
|
||||
#define Soc_WIDTH_TIMELINE "560px"
|
||||
#define Soc_MAX_NUM_SHARERS_SHOWN 10 // Maximum number of users shown who have share a social note
|
||||
|
||||
static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_NOTES] =
|
||||
{
|
||||
|
@ -98,9 +99,9 @@ static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_NOTES] =
|
|||
struct SocialPublishing
|
||||
{
|
||||
long PubCod;
|
||||
long AuthorCod;
|
||||
long PublisherCod;
|
||||
long NotCod;
|
||||
long PublisherCod;
|
||||
long AuthorCod;
|
||||
time_t DateTimeUTC;
|
||||
};
|
||||
|
||||
|
@ -113,7 +114,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
|
||||
unsigned NumShared; // Number of times this note has been shared
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -169,6 +170,7 @@ 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_ShowUsrsWhoHaveSharedSocialNote (const 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);
|
||||
|
@ -189,7 +191,7 @@ void Soc_ShowTimelineUsr (void)
|
|||
Soc_PutLinkToWriteANewPost (ActReqSocPstUsr,Usr_PutParamOtherUsrCodEncrypted);
|
||||
|
||||
/***** Build query to show timeline with publishing of a unique user *****/
|
||||
sprintf (Query,"SELECT PubCod,AuthorCod,PublisherCod,NotCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
" FROM social_timeline"
|
||||
" WHERE PublisherCod='%ld'"
|
||||
" ORDER BY PubCod DESC LIMIT %u",
|
||||
|
@ -239,7 +241,7 @@ void Soc_ShowTimelineGbl (void)
|
|||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
|
||||
/***** Build query to show timeline including the users I am following *****/
|
||||
sprintf (Query,"SELECT PubCod,AuthorCod,PublisherCod,NotCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
" FROM social_timeline WHERE PubCod IN "
|
||||
"(SELECT PubCod FROM pub_cods)"
|
||||
" ORDER BY PubCod DESC");
|
||||
|
@ -337,14 +339,14 @@ static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPub
|
|||
/* Get social publishing code (row[0]) */
|
||||
SocPub->PubCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get author's code (row[1]) */
|
||||
SocPub->AuthorCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
/* Get social note code (row[1]) */
|
||||
SocPub->NotCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
||||
/* Get publisher's code (row[2]) */
|
||||
SocPub->PublisherCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
||||
/* Get social note code (row[3]) */
|
||||
SocPub->NotCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
/* Get author's code (row[3]) */
|
||||
SocPub->AuthorCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
||||
/* Get time of the note (row[4]) */
|
||||
SocPub->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[4]);
|
||||
|
@ -536,7 +538,9 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
|
|||
/* Put icon to share this publishing */
|
||||
Soc_PutFormToShareSocialNote (SocNot->NotCod);
|
||||
}
|
||||
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES\"> %u</span>",SocNot->NumTimesShared);
|
||||
|
||||
/* Show who have shared this social note */
|
||||
Soc_ShowUsrsWhoHaveSharedSocialNote (SocNot);
|
||||
|
||||
/* Put icon to remove */
|
||||
if (WritingTimeline &&
|
||||
|
@ -950,10 +954,10 @@ static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub)
|
|||
|
||||
/***** Publish social note in timeline *****/
|
||||
sprintf (Query,"INSERT INTO social_timeline"
|
||||
" (AuthorCod,PublisherCod,NotCod,TimePublish)"
|
||||
" (NotCod,PublisherCod,AuthorCod,TimePublish)"
|
||||
" VALUES"
|
||||
" ('%ld','%ld','%ld',NOW())",
|
||||
SocPub->AuthorCod,SocPub->PublisherCod,SocPub->NotCod);
|
||||
SocPub->NotCod,SocPub->PublisherCod,SocPub->AuthorCod);
|
||||
SocPub->PubCod = DB_QueryINSERTandReturnCode (Query,"can not publish social note");
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1107,7 @@ 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\">"
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_DISABLED\">"
|
||||
"<img src=\"%s/share64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"ICON20x20\" />"
|
||||
|
@ -1131,7 +1135,7 @@ static void Soc_PutFormToShareSocialNote (long NotCod)
|
|||
else
|
||||
Act_FormStart (ActShaSocNotGbl);
|
||||
Soc_PutHiddenParamNotCod (NotCod);
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON ICON_HIGHLIGHT\">"
|
||||
"<input type=\"image\""
|
||||
" src=\"%s/share64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
|
@ -1160,7 +1164,7 @@ static void Soc_PutFormToUnshareSocialPublishing (long PubCod)
|
|||
else
|
||||
Act_FormStart (ActUnsSocPubGbl);
|
||||
Soc_PutHiddenParamPubCod (PubCod);
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_SHARE ICON_HIGHLIGHT\">"
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON ICON_HIGHLIGHT\">"
|
||||
"<input type=\"image\""
|
||||
" src=\"%s/shared64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
|
@ -1189,7 +1193,7 @@ static void Soc_PutFormToRemoveSocialPublishing (long PubCod)
|
|||
else
|
||||
Act_FormStart (ActReqRemSocPubGbl);
|
||||
Soc_PutHiddenParamPubCod (PubCod);
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_REMOVE ICON_HIGHLIGHT\">"
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_ICON_RIGHT ICON_HIGHLIGHT\">"
|
||||
"<input type=\"image\""
|
||||
" src=\"%s/remove-on64x64.png\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
|
@ -1671,15 +1675,88 @@ 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);
|
||||
*/
|
||||
/***** Get number of times (users) this note has been shared *****/
|
||||
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");
|
||||
SocNot->NotCod,
|
||||
SocNot->UsrCod); // The author
|
||||
SocNot->NumShared = (unsigned) DB_QueryCOUNT (Query,"can not get number of times a note has been shared");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Show users who have shared this social note ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Soc_ShowUsrsWhoHaveSharedSocialNote (const struct SocialNote *SocNot)
|
||||
{
|
||||
char Query[256];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumUsrs;
|
||||
unsigned NumUsr;
|
||||
unsigned NumUsrsShown = 0;
|
||||
struct UsrData UsrDat;
|
||||
bool ShowPhoto;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
|
||||
/* Show number of users who have shared this social note */
|
||||
fprintf (Gbl.F.Out,"<span class=\"SOCIAL_NUM_SHARES\"> %u</span>",
|
||||
SocNot->NumShared);
|
||||
|
||||
if (SocNot->NumShared)
|
||||
{
|
||||
/***** Get list of publishers from database (only the first) *****/
|
||||
sprintf (Query,"SELECT PublisherCod"
|
||||
" FROM social_timeline"
|
||||
" WHERE NotCod='%ld' AND PublisherCod<>'%ld'"
|
||||
" ORDER BY PubCod LIMIT %u",
|
||||
SocNot->NotCod,SocNot->UsrCod,
|
||||
Soc_MAX_NUM_SHARERS_SHOWN);
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get data of social publishing");
|
||||
if (NumUsrs)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
|
||||
/***** List users *****/
|
||||
for (NumUsr = 0;
|
||||
NumUsr < NumUsrs;
|
||||
NumUsr++)
|
||||
{
|
||||
/***** Get user *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get user's code (row[0]) */
|
||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/***** Get user's data and show user's photo *****/
|
||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat))
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">");
|
||||
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
|
||||
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
|
||||
NULL,
|
||||
"PHOTO18x24",Pho_ZOOM);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
NumUsrsShown++;
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
}
|
||||
|
||||
if (SocNot->NumShared > NumUsrsShown)
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_SHARER\">"
|
||||
"<img src=\"%s/ellipsis32x32.gif\""
|
||||
" alt=\"%u\" title=\"%u\""
|
||||
" class=\"ICON20x20\" />"
|
||||
"</div>",
|
||||
Gbl.Prefs.IconsURL,
|
||||
SocNot->NumShared - NumUsrsShown,
|
||||
SocNot->NumShared - NumUsrsShown);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1693,7 +1770,7 @@ static void Soc_GetDataOfSocialPublishingByCod (struct SocialPublishing *SocPub)
|
|||
MYSQL_ROW row;
|
||||
|
||||
/***** Get data of social publishing from database *****/
|
||||
sprintf (Query,"SELECT PubCod,AuthorCod,PublisherCod,NotCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
sprintf (Query,"SELECT PubCod,NotCod,PublisherCod,AuthorCod,UNIX_TIMESTAMP(TimePublish)"
|
||||
" FROM social_timeline"
|
||||
" WHERE PubCod='%ld'",
|
||||
SocPub->PubCod);
|
||||
|
@ -1706,9 +1783,9 @@ static void Soc_GetDataOfSocialPublishingByCod (struct SocialPublishing *SocPub)
|
|||
else
|
||||
{
|
||||
/***** Reset fields of social publishing *****/
|
||||
SocPub->AuthorCod = -1L;
|
||||
SocPub->PublisherCod = -1L;
|
||||
SocPub->NotCod = -1L;
|
||||
SocPub->PublisherCod = -1L;
|
||||
SocPub->AuthorCod = -1L;
|
||||
SocPub->DateTimeUTC = (time_t) 0;
|
||||
}
|
||||
}
|
||||
|
@ -1746,7 +1823,7 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot)
|
|||
SocNot->Cod = -1L;
|
||||
SocNot->Unavailable = false;
|
||||
SocNot->DateTimeUTC = (time_t) 0;
|
||||
SocNot->NumTimesShared = 0;
|
||||
SocNot->NumShared = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user