mirror of https://github.com/acanas/swad-core.git
Version 15.90
This commit is contained in:
parent
bef6956fdf
commit
a0c5cfdf57
|
@ -11202,7 +11202,14 @@ INSERT INTO social_timeline (AuthorCod,PublisherCod,NotCod,TimePublish) SELECT U
|
|||
|
||||
|
||||
SELECT MIN(PubCod) FROM social_timeline WHERE PublisherCod IN (SELECT '1' UNION SELECT FollowedCod FROM usr_follow WHERE FollowerCod='1') GROUP BY NotCod;
|
||||
|
||||
|
||||
|
||||
|
||||
----- SWAD 15.90 (2016/01/02) -----
|
||||
|
||||
ALTER TABLE social_notes ADD COLUMN HieCod INT NOT NULL DEFAULT -1 AFTER UsrCod;
|
||||
UPDATE social_notes SET HieCod=InsCod WHERE NoteType IN ('1','2');
|
||||
UPDATE social_notes SET HieCod=CtrCod WHERE NoteType IN ('3','4');
|
||||
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;
|
||||
|
||||
|
|
@ -919,11 +919,7 @@ CREATE TABLE IF NOT EXISTS social_notes (
|
|||
NotCod BIGINT NOT NULL AUTO_INCREMENT,
|
||||
NoteType TINYINT NOT NULL,
|
||||
UsrCod INT NOT NULL,
|
||||
CtyCod INT NOT NULL DEFAULT -1,
|
||||
InsCod INT NOT NULL DEFAULT -1,
|
||||
CtrCod INT NOT NULL DEFAULT -1,
|
||||
DegCod INT NOT NULL DEFAULT -1,
|
||||
CrsCod INT NOT NULL DEFAULT -1,
|
||||
HieCod INT NOT NULL DEFAULT -1,
|
||||
Cod INT NOT NULL DEFAULT -1,
|
||||
TimeNote DATETIME NOT NULL,
|
||||
UNIQUE INDEX(NotCod),
|
||||
|
|
|
@ -111,19 +111,28 @@
|
|||
// TODO: Reply to all
|
||||
// TODO: Hour in exam announcement should start at six a.m.
|
||||
// TODO: When a file, notice, etc. is removed, it should be removed from social events?
|
||||
// TODO: New database table used to store users who write or share social
|
||||
// TODO: Cange "Actividad pública" to "Actividad de Antonio" in user's profile
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.89.2 (2016-01-02)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.90 (2016-01-02)"
|
||||
#define CSS_FILE "swad15.88.1.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.90: Jan 02, 2016 Change in fields of database table that stores social notes. (190122 lines)
|
||||
6 changes necessary in database:
|
||||
ALTER TABLE social_notes ADD COLUMN HieCod INT NOT NULL DEFAULT -1 AFTER UsrCod;
|
||||
UPDATE social_notes SET HieCod=InsCod WHERE NoteType IN ('1','2');
|
||||
UPDATE social_notes SET HieCod=CtrCod WHERE NoteType IN ('3','4');
|
||||
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;
|
||||
|
||||
Version 15.89.2: Jan 02, 2016 Change in layout of user profile. (190141 lines)
|
||||
Version 15.89.1: Jan 02, 2016 Change in layout of user profile. (190137 lines)
|
||||
Version 15.89: Jan 02, 2016 Social timeline can be updated from user profile. (190084 lines)
|
||||
|
|
|
@ -1938,31 +1938,24 @@ mysql> DESCRIBE sessions;
|
|||
/***** Table social_notes *****/
|
||||
/*
|
||||
mysql> DESCRIBE social_notes;
|
||||
+------------+------------+------+-----+---------+----------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+------------+------------+------+-----+---------+----------------+
|
||||
| NotCod | bigint(20) | NO | PRI | NULL | auto_increment |
|
||||
+----------+------------+------+-----+---------+----------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+----------+------------+------+-----+---------+----------------+
|
||||
| NotCod | bigint(20) | NO | PRI | NULL | auto_increment |
|
||||
| NoteType | tinyint(4) | NO | MUL | NULL | |
|
||||
| UsrCod | int(11) | NO | MUL | NULL | |
|
||||
| CtyCod | int(11) | NO | | -1 | |
|
||||
| InsCod | int(11) | NO | | -1 | |
|
||||
| CtrCod | int(11) | NO | | -1 | |
|
||||
| DegCod | int(11) | NO | | -1 | |
|
||||
| CrsCod | int(11) | NO | | -1 | |
|
||||
| Cod | int(11) | NO | | -1 | |
|
||||
| TimeNote | datetime | NO | MUL | NULL | |
|
||||
+------------+------------+------+-----+---------+----------------+
|
||||
10 rows in set (0.00 sec)
|
||||
| UsrCod | int(11) | NO | MUL | NULL | |
|
||||
| HieCod | int(11) | NO | | -1 | |
|
||||
| DegCod | int(11) | NO | | -1 | |
|
||||
| Cod | int(11) | NO | | -1 | |
|
||||
| TimeNote | datetime | NO | MUL | NULL | |
|
||||
+----------+------------+------+-----+---------+----------------+
|
||||
7 rows in set (0.00 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_notes ("
|
||||
"NotCod BIGINT NOT NULL AUTO_INCREMENT,"
|
||||
"NoteType TINYINT NOT NULL,"
|
||||
"UsrCod INT NOT NULL,"
|
||||
"CtyCod INT NOT NULL DEFAULT -1,"
|
||||
"InsCod INT NOT NULL DEFAULT -1,"
|
||||
"CtrCod INT NOT NULL DEFAULT -1,"
|
||||
"DegCod INT NOT NULL DEFAULT -1,"
|
||||
"CrsCod INT NOT NULL DEFAULT -1,"
|
||||
"HieCod INT NOT NULL DEFAULT -1,"
|
||||
"Cod INT NOT NULL DEFAULT -1,"
|
||||
"TimeNote DATETIME NOT NULL,"
|
||||
"UNIQUE INDEX(NotCod),"
|
||||
|
|
193
swad_social.c
193
swad_social.c
|
@ -108,12 +108,8 @@ struct SocialNote
|
|||
long NotCod;
|
||||
Soc_NoteType_t NoteType;
|
||||
long UsrCod;
|
||||
long CtyCod;
|
||||
long InsCod;
|
||||
long CtrCod;
|
||||
long DegCod;
|
||||
long CrsCod;
|
||||
long Cod;
|
||||
long HieCod; // Hierarchy code (institution/centre/degree/course)
|
||||
long Cod; // Code of file, forum post, notice,...
|
||||
time_t DateTimeUTC;
|
||||
};
|
||||
|
||||
|
@ -367,8 +363,6 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
|
|||
extern const char *Txt_Degree;
|
||||
extern const char *Txt_Centre;
|
||||
extern const char *Txt_Institution;
|
||||
extern const char *Txt_Country;
|
||||
struct Country Cty;
|
||||
struct Institution Ins;
|
||||
struct Centre Ctr;
|
||||
struct Degree Deg;
|
||||
|
@ -383,26 +377,6 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
|
|||
UsrDat->UsrCod = SocNot->UsrCod;
|
||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat);
|
||||
|
||||
/* Get country data */
|
||||
Cty.CtyCod = SocNot->CtyCod;
|
||||
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_BASIC_DATA);
|
||||
|
||||
/* Get institution data */
|
||||
Ins.InsCod = SocNot->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
|
||||
|
||||
/* Get centre data */
|
||||
Ctr.CtrCod = SocNot->CtrCod;
|
||||
Ctr_GetDataOfCentreByCod (&Ctr);
|
||||
|
||||
/* Get degree data */
|
||||
Deg.DegCod = SocNot->DegCod;
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
||||
/* Get course data */
|
||||
Crs.CrsCod = SocNot->CrsCod;
|
||||
Crs_GetDataOfCourseByCod (&Crs);
|
||||
|
||||
/* Get forum type of the post */
|
||||
if (SocNot->NoteType == Soc_NOTE_FORUM_POST)
|
||||
{
|
||||
|
@ -473,7 +447,7 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Write note type and location */
|
||||
/* Write note type and location-hierarchy */
|
||||
fprintf (Gbl.F.Out,"<div>");
|
||||
Soc_StartFormGoToAction (SocNot->NoteType,Crs.CrsCod,SocNot->Cod);
|
||||
Act_LinkFormSubmit (Txt_SOCIAL_NOTE[SocNot->NoteType],
|
||||
|
@ -483,24 +457,53 @@ static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
|
|||
Act_FormEnd ();
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
if (SocNot->NoteType == Soc_NOTE_FORUM_POST)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Forum,ForumName);
|
||||
else if (Crs.CrsCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Course,Crs.ShortName);
|
||||
else if (Deg.DegCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Degree,Deg.ShortName);
|
||||
else if (Ctr.CtrCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Centre,Ctr.ShortName);
|
||||
else if (Ins.InsCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Institution,Ins.ShortName);
|
||||
else if (Cty.CtyCod > 0)
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Country,Cty.Name[Gbl.Prefs.Language]);
|
||||
switch (SocNot->NoteType)
|
||||
{
|
||||
case Soc_NOTE_INS_DOC_PUB_FILE:
|
||||
case Soc_NOTE_INS_SHA_PUB_FILE:
|
||||
/* Get institution data */
|
||||
Ins.InsCod = SocNot->HieCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
|
||||
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Institution,Ins.ShortName);
|
||||
break;
|
||||
case Soc_NOTE_CTR_DOC_PUB_FILE:
|
||||
case Soc_NOTE_CTR_SHA_PUB_FILE:
|
||||
/* Get centre data */
|
||||
Ctr.CtrCod = SocNot->HieCod;
|
||||
Ctr_GetDataOfCentreByCod (&Ctr);
|
||||
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Centre,Ctr.ShortName);
|
||||
break;
|
||||
case Soc_NOTE_DEG_DOC_PUB_FILE:
|
||||
case Soc_NOTE_DEG_SHA_PUB_FILE:
|
||||
/* Get degree data */
|
||||
Deg.DegCod = SocNot->HieCod;
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Degree,Deg.ShortName);
|
||||
break;
|
||||
case Soc_NOTE_CRS_DOC_PUB_FILE:
|
||||
case Soc_NOTE_CRS_SHA_PUB_FILE:
|
||||
case Soc_NOTE_EXAM_ANNOUNCEMENT:
|
||||
case Soc_NOTE_NOTICE:
|
||||
/* Get course data */
|
||||
Crs.CrsCod = SocNot->HieCod;
|
||||
Crs_GetDataOfCourseByCod (&Crs);
|
||||
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Course,Crs.ShortName);
|
||||
break;
|
||||
case Soc_NOTE_FORUM_POST:
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s: %s</div>",
|
||||
Txt_Forum,ForumName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write content of the note */
|
||||
Soc_GetNoteSummary (SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY);
|
||||
|
@ -709,46 +712,40 @@ static void Soc_GetNoteSummary (const struct SocialNote *SocNot,
|
|||
|
||||
void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod)
|
||||
{
|
||||
char Query[512];
|
||||
long CtyCod;
|
||||
long InsCod;
|
||||
long CtrCod;
|
||||
long DegCod;
|
||||
long CrsCod;
|
||||
char Query[256];
|
||||
long HieCod; // Hierarchy code (institution/centre/degree/course)
|
||||
struct SocialPublishing SocPub;
|
||||
|
||||
if (NoteType == Soc_NOTE_FORUM_POST)
|
||||
switch (NoteType)
|
||||
{
|
||||
// CtyCod = Gbl.Forum.Cty.CtyCod;
|
||||
// InsCod = Gbl.Forum.Ins.InsCod;
|
||||
// CtrCod = Gbl.Forum.Ctr.CtrCod;
|
||||
// DegCod = Gbl.Forum.Deg.DegCod;
|
||||
// CrsCod = Gbl.Forum.Crs.CrsCod;
|
||||
CtyCod = -1L;
|
||||
InsCod = -1L;
|
||||
CtrCod = -1L;
|
||||
DegCod = -1L;
|
||||
CrsCod = -1L;
|
||||
}
|
||||
else
|
||||
{
|
||||
CtyCod = Gbl.CurrentCty.Cty.CtyCod;
|
||||
InsCod = Gbl.CurrentIns.Ins.InsCod;
|
||||
CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
|
||||
DegCod = Gbl.CurrentDeg.Deg.DegCod;
|
||||
CrsCod = Gbl.CurrentCrs.Crs.CrsCod;
|
||||
case Soc_NOTE_INS_DOC_PUB_FILE:
|
||||
case Soc_NOTE_INS_SHA_PUB_FILE:
|
||||
HieCod = Gbl.CurrentIns.Ins.InsCod;
|
||||
break;
|
||||
case Soc_NOTE_CTR_DOC_PUB_FILE:
|
||||
case Soc_NOTE_CTR_SHA_PUB_FILE:
|
||||
HieCod = Gbl.CurrentCtr.Ctr.CtrCod;
|
||||
break;
|
||||
case Soc_NOTE_DEG_DOC_PUB_FILE:
|
||||
case Soc_NOTE_DEG_SHA_PUB_FILE:
|
||||
HieCod = Gbl.CurrentDeg.Deg.DegCod;
|
||||
break;
|
||||
case Soc_NOTE_CRS_DOC_PUB_FILE:
|
||||
case Soc_NOTE_CRS_SHA_PUB_FILE:
|
||||
case Soc_NOTE_EXAM_ANNOUNCEMENT:
|
||||
case Soc_NOTE_NOTICE:
|
||||
HieCod = Gbl.CurrentCrs.Crs.CrsCod;
|
||||
break;
|
||||
default:
|
||||
HieCod = -1L;
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Store social note *****/
|
||||
sprintf (Query,"INSERT INTO social_notes (NoteType,UsrCod,"
|
||||
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,"
|
||||
"Cod,TimeNote)"
|
||||
" VALUES ('%u','%ld',"
|
||||
"'%ld','%ld','%ld','%ld','%ld',"
|
||||
"'%ld',NOW())",
|
||||
(unsigned) NoteType,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
Cod);
|
||||
sprintf (Query,"INSERT INTO social_notes"
|
||||
" (NoteType,UsrCod,HieCod,Cod,TimeNote)"
|
||||
" VALUES ('%u','%ld','%ld','%ld',NOW())",
|
||||
(unsigned) NoteType,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod,Cod);
|
||||
SocPub.NotCod = DB_QueryINSERTandReturnCode (Query,"can not create new social note");
|
||||
|
||||
/***** Publish social note in timeline *****/
|
||||
|
@ -1416,9 +1413,7 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot)
|
|||
MYSQL_ROW row;
|
||||
|
||||
/***** Get data of social note from database *****/
|
||||
sprintf (Query,"SELECT NotCod,NoteType,UsrCod,"
|
||||
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,"
|
||||
"Cod,UNIX_TIMESTAMP(TimeNote)"
|
||||
sprintf (Query,"SELECT NotCod,NoteType,UsrCod,HieCod,Cod,UNIX_TIMESTAMP(TimeNote)"
|
||||
" FROM social_notes"
|
||||
" WHERE NotCod='%ld'",
|
||||
SocNot->NotCod);
|
||||
|
@ -1433,11 +1428,7 @@ static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *SocNot)
|
|||
/***** Reset fields of social note *****/
|
||||
SocNot->NoteType = Soc_NOTE_UNKNOWN;
|
||||
SocNot->UsrCod = -1L;
|
||||
SocNot->CtyCod = -1L;
|
||||
SocNot->InsCod = -1L;
|
||||
SocNot->CtrCod = -1L;
|
||||
SocNot->DegCod = -1L;
|
||||
SocNot->CrsCod = -1L;
|
||||
SocNot->HieCod = -1L;
|
||||
SocNot->Cod = -1L;
|
||||
SocNot->DateTimeUTC = (time_t) 0;
|
||||
}
|
||||
|
@ -1458,26 +1449,14 @@ static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc
|
|||
/* Get (from) user code (row[2]) */
|
||||
SocNot->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
||||
/* Get country code (row[3]) */
|
||||
SocNot->CtyCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
/* Get hierarchy code (row[3]) */
|
||||
SocNot->HieCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
||||
/* Get institution code (row[4]) */
|
||||
SocNot->InsCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
/* Get file/post... code (row[4]) */
|
||||
SocNot->Cod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
|
||||
/* Get centre code (row[5]) */
|
||||
SocNot->CtrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
||||
/* Get degree code (row[6]) */
|
||||
SocNot->DegCod = Str_ConvertStrCodToLongCod (row[6]);
|
||||
|
||||
/* Get course code (row[7]) */
|
||||
SocNot->CrsCod = Str_ConvertStrCodToLongCod (row[7]);
|
||||
|
||||
/* Get file/post... code (row[8]) */
|
||||
SocNot->Cod = Str_ConvertStrCodToLongCod (row[8]);
|
||||
|
||||
/* Get time of the note (row[9]) */
|
||||
SocNot->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[9]);
|
||||
/* Get time of the note (row[5]) */
|
||||
SocNot->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[5]);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef enum
|
|||
/* Users tab */
|
||||
|
||||
/* Social tab */
|
||||
Soc_NOTE_SOCIAL_POST = 10,
|
||||
Soc_NOTE_SOCIAL_POST = 10,
|
||||
Soc_NOTE_FORUM_POST = 11,
|
||||
|
||||
/* Messages tab */
|
||||
|
|
Loading…
Reference in New Issue