Version 15.93.5

This commit is contained in:
Antonio Cañas Vargas 2016-01-03 19:30:59 +01:00
parent f69f790d7e
commit d665a38ab6
7 changed files with 133 additions and 73 deletions

View File

@ -924,7 +924,7 @@ CREATE TABLE IF NOT EXISTS social_notes (
Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N',
TimeNote DATETIME NOT NULL,
UNIQUE INDEX(NotCod),
INDEX(SocialNote),
UNIQUE INDEX(NoteType,Cod),
INDEX(UsrCod),
INDEX(TimeNote));
--

View File

@ -118,13 +118,22 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.93.4 (2016-01-03)"
#define Log_PLATFORM_VERSION "SWAD 15.93.5 (2016-01-03)"
#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.93.5: Jan 03, 2016 Social notes are marked as unavailable when a notice is removed. (190406 lines)
6 changes necessary in database:
CREATE UNIQUE INDEX NotCod ON social_notes (NotCod);
DROP INDEX SocCod ON social_notes;
DROP INDEX TimeEvent ON social_notes;
CREATE INDEX TimeNote ON social_notes (TimeNote);
DROP INDEX SocialEvent ON social_notes;
CREATE UNIQUE INDEX NoteTypeCod ON social_notes (NoteType,Cod);
Version 15.93.4: Jan 03, 2016 Changes in links to actions in social timeline.
New field Unavailable in table of social notes. (190354 lines)
1 change necessary in database:

View File

@ -1960,7 +1960,7 @@ mysql> DESCRIBE social_notes;
"Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N',"
"TimeNote DATETIME NOT NULL,"
"UNIQUE INDEX(NotCod),"
"INDEX(NoteType),"
"UNIQUE INDEX(NoteType,Cod),"
"INDEX(UsrCod),"
"INDEX(TimeNote))");

View File

@ -332,6 +332,9 @@ void Not_RemoveNotice (void)
/***** Mark possible notifications as removed *****/
Ntf_SetNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod);
/***** Mark possible social note as unavailable *****/
Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NOTE_NOTICE,NotCod);
/***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);
}

View File

@ -818,7 +818,7 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_Notif
void Ntf_SetNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod)
{
char Query[512];
char Query[256];
/***** Set notification as seen by me *****/
if (ToUsrCod > 0) // If the user code is specified

View File

@ -132,11 +132,11 @@ extern struct Globals Gbl;
static void Soc_ShowTimeline (const char *Query,Act_Action_t UpdateAction);
static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPublishing *SocPub);
static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
const struct SocialNote *SocNot,
struct SocialNote *SocNot,
bool WritingTimeline,bool LastInList);
static void Soc_WriteNoteDate (time_t TimeUTC);
static void Soc_GetAndWriteSocialPost (long PstCod);
static void Soc_PutFormGoToAction (const struct SocialNote *SocNot,long CrsCod);
static void Soc_PutFormGoToAction (struct SocialNote *SocNot,long CrsCod);
static void Soc_GetNoteSummary (const struct SocialNote *SocNot,
char *SummaryStr,unsigned MaxChars);
static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub);
@ -344,9 +344,11 @@ static void Soc_GetDataOfSocialPublishingFromRow (MYSQL_ROW row,struct SocialPub
/*****************************************************************************/
/***************************** Write social note *****************************/
/*****************************************************************************/
// Pointer SocNot is not const because the field Unavailable...
// ...can be marked as true inside this function
static void Soc_WriteSocialNote (const struct SocialPublishing *SocPub,
const struct SocialNote *SocNot,
struct SocialNote *SocNot,
bool WritingTimeline,bool LastInList)
{
extern const char *Txt_Forum;
@ -608,7 +610,7 @@ static void Soc_GetAndWriteSocialPost (long PstCod)
/********* Put form to go to an action depending on the social note **********/
/*****************************************************************************/
static void Soc_PutFormGoToAction (const struct SocialNote *SocNot,long CrsCod)
static void Soc_PutFormGoToAction (struct SocialNote *SocNot,long CrsCod)
{
extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM];
extern const char *The_ClassForm[The_NUM_THEMES];
@ -620,77 +622,93 @@ static void Soc_PutFormGoToAction (const struct SocialNote *SocNot,long CrsCod)
long DegCod = -1L;
long GrpCod = -1L;
/***** Parameters depending on the type of note *****/
switch (SocNot->NoteType)
if (SocNot->Unavailable || // File/notice... pointer by this social note is unavailable
Gbl.InsideForm) // Inside another form
{
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
FileMetadata.FilCod = SocNot->Cod;
if (FileMetadata.FilCod > 0)
{
Brw_GetFileMetadataByCod (&FileMetadata);
if (FileMetadata.FilCod > 0) // Found
Brw_GetCrsGrpFromFileMetadata (FileMetadata.FileBrowser,FileMetadata.Cod,
&InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod);
}
if (FileMetadata.FilCod > 0)
{
/***** Do not put form *****/
fprintf (Gbl.F.Out,"%s",Txt_SOCIAL_NOTE[SocNot->NoteType]);
if (SocNot->Unavailable)
fprintf (Gbl.F.Out," (%s)",Txt_not_available);
}
else // Not inside another form
{
/***** Parameters depending on the type of note *****/
switch (SocNot->NoteType)
{
case Soc_NOTE_INS_DOC_PUB_FILE:
case Soc_NOTE_INS_SHA_PUB_FILE:
case Soc_NOTE_CTR_DOC_PUB_FILE:
case Soc_NOTE_CTR_SHA_PUB_FILE:
case Soc_NOTE_DEG_DOC_PUB_FILE:
case Soc_NOTE_DEG_SHA_PUB_FILE:
case Soc_NOTE_CRS_DOC_PUB_FILE:
case Soc_NOTE_CRS_SHA_PUB_FILE:
FileMetadata.FilCod = SocNot->Cod;
if (FileMetadata.FilCod > 0)
{
Brw_GetFileMetadataByCod (&FileMetadata);
if (FileMetadata.FilCod > 0) // Found
Brw_GetCrsGrpFromFileMetadata (FileMetadata.FileBrowser,FileMetadata.Cod,
&InsCod,&CtrCod,&DegCod,&CrsCod,&GrpCod);
}
if (FileMetadata.FilCod > 0)
{
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
}
else
{
Soc_MarkSocialNoteAsUnavailableUsingNotCod (SocNot->NotCod);
SocNot->Unavailable = true;
}
break;
case Soc_NOTE_NOTICE:
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
Not_PutHiddenParamNotCod (SocNot->Cod);
break;
case Soc_NOTE_FORUM_POST:
Act_FormStart (For_ActionsSeeFor[Gbl.Forum.ForumType]);
For_PutAllHiddenParamsForum ();
break;
default:
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
break;
}
if (SocNot->Unavailable)
fprintf (Gbl.F.Out,"%s (%s)",
Txt_SOCIAL_NOTE[SocNot->NoteType],Txt_not_available);
else
{
/***** Parameter to go to another place in hierarchy *****/
if (CrsCod > 0) // Course specified
{
if (CrsCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (CrsCod); // Go to another course
}
else if (DegCod > 0) // Degree specified
{
if (DegCod != Gbl.CurrentDeg.Deg.DegCod) // Not the current degree
Deg_PutParamDegCod (DegCod); // Go to another degree
}
else if (CtrCod > 0) // Centre specified
{
if (CtrCod != Gbl.CurrentCtr.Ctr.CtrCod) // Not the current centre
Ctr_PutParamCtrCod (CtrCod); // Go to another centre
}
else if (InsCod > 0) // Institution specified
{
if (InsCod != Gbl.CurrentIns.Ins.InsCod) // Not the current institution
Ins_PutParamInsCod (InsCod); // Go to another institution
}
break;
case Soc_NOTE_NOTICE:
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
Not_PutHiddenParamNotCod (SocNot->Cod);
break;
case Soc_NOTE_FORUM_POST:
Act_FormStart (For_ActionsSeeFor[Gbl.Forum.ForumType]);
For_PutAllHiddenParamsForum ();
break;
default:
Act_FormStart (Soc_DefaultActions[SocNot->NoteType]);
break;
}
if (Gbl.InsideForm)
{
/***** Parameter to go to another place in hierarchy *****/
if (CrsCod > 0) // Course specified
{
if (CrsCod != Gbl.CurrentCrs.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (CrsCod); // Go to another course
/***** Link and end form *****/
Act_LinkFormSubmit (Txt_SOCIAL_NOTE[SocNot->NoteType],
The_ClassForm[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"%s</a>",Txt_SOCIAL_NOTE[SocNot->NoteType]);
Act_FormEnd ();
}
else if (DegCod > 0) // Degree specified
{
if (DegCod != Gbl.CurrentDeg.Deg.DegCod) // Not the current degree
Deg_PutParamDegCod (DegCod); // Go to another degree
}
else if (CtrCod > 0) // Centre specified
{
if (CtrCod != Gbl.CurrentCtr.Ctr.CtrCod) // Not the current centre
Ctr_PutParamCtrCod (CtrCod); // Go to another centre
}
else if (InsCod > 0) // Institution specified
{
if (InsCod != Gbl.CurrentIns.Ins.InsCod) // Not the current institution
Ins_PutParamInsCod (InsCod); // Go to another institution
}
/***** Link and end form *****/
Act_LinkFormSubmit (Txt_SOCIAL_NOTE[SocNot->NoteType],
The_ClassForm[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,"%s</a>",Txt_SOCIAL_NOTE[SocNot->NoteType]);
Act_FormEnd ();
}
else // Not inside a form
fprintf (Gbl.F.Out,"%s (%s)",
Txt_SOCIAL_NOTE[SocNot->NoteType],Txt_not_available);
}
/*****************************************************************************/
@ -779,6 +797,32 @@ void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod)
Soc_PublishSocialNoteInTimeline (&SocPub);
}
/*****************************************************************************/
/********************** Mark a social note as unavailable ********************/
/*****************************************************************************/
void Soc_MarkSocialNoteAsUnavailableUsingNotCod (long NotCod)
{
char Query[256];
/***** Mark the social note as unavailable *****/
sprintf (Query,"UPDATE social_notes SET Unavailable='Y'"
" WHERE NotCod='%ld'",
NotCod);
DB_QueryUPDATE (Query,"can not mark social note as unavailable");
}
void Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NoteType_t NoteType,long Cod)
{
char Query[256];
/***** Mark the social note as unavailable *****/
sprintf (Query,"UPDATE social_notes SET Unavailable='Y'"
" WHERE NoteType='%u' AND Cod='%ld'",
(unsigned) NoteType,Cod);
DB_QueryUPDATE (Query,"can not mark social note as unavailable");
}
/*****************************************************************************/
/***************** Put contextual link to write a new post *******************/
/*****************************************************************************/
@ -1282,6 +1326,8 @@ static void Soc_RequestRemovalSocialPublishing (void)
else
Act_FormStart (ActRemSocPubGbl);
Soc_PutHiddenParamPubCod (SocPub.PubCod);
/* Warning message */
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment);
/* Show social note */

View File

@ -85,6 +85,8 @@ void Soc_ShowTimelineUsr (void);
void Soc_ShowTimelineGbl (void);
void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod);
void Soc_MarkSocialNoteAsUnavailableUsingNotCod (long NotCod);
void Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NoteType_t NoteType,long Cod);
void Soc_FormSocialPostGbl (void);
void Soc_FormSocialPostUsr (void);