mirror of https://github.com/acanas/swad-core.git
Version 15.84.1
This commit is contained in:
parent
866ae0e8ca
commit
49212cb5ad
|
@ -1003,6 +1003,7 @@ Social:
|
|||
|
||||
xxx. ActReqSocPst Write a public social post to be displayed in the timeline
|
||||
xxx. ActRcvSocPst Receive a public social post to be displayed in the timeline
|
||||
xxx. ActReqRemSocEvn Request the removal of a social event
|
||||
xxx. ActRemSocEvn Remove a social event
|
||||
835. ActSeePubPrf Show a public user's profile
|
||||
836. ActCal1stClkTim Calculate first click time from log and store into user's figures
|
||||
|
@ -2312,6 +2313,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
|
||||
/* ActReqSocPst */{1491,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_FormSocialPost ,NULL},
|
||||
/* ActRcvSocPst */{1492,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_ReceiveSocialPost ,NULL},
|
||||
/* ActReqRemSocEvn */{1494,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RequestRemovalSocialEvent ,NULL},
|
||||
/* ActRemSocEvn */{1493,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RemoveSocialEvent ,NULL},
|
||||
|
||||
/* ActSeePubPrf */{1402,-1,TabSoc,ActReqPubPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_GetUsrCodAndShowUserProfile,NULL},
|
||||
|
@ -4155,6 +4157,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq
|
|||
ActReqSocPst, // #1491
|
||||
ActRcvSocPst, // #1492
|
||||
ActRemSocEvn, // #1493
|
||||
ActReqRemSocEvn, // #1494
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -71,9 +71,9 @@ typedef enum
|
|||
|
||||
typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
|
||||
|
||||
#define Act_NUM_ACTIONS (7+52+15+90+72+67+205+183+143+17+169+27+82)
|
||||
#define Act_NUM_ACTIONS (7+52+15+90+72+67+205+183+143+18+169+27+82)
|
||||
|
||||
#define Act_MAX_ACTION_COD 1493
|
||||
#define Act_MAX_ACTION_COD 1494
|
||||
|
||||
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20
|
||||
|
||||
|
@ -1042,21 +1042,22 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica
|
|||
// Secondary actions
|
||||
#define ActReqSocPst (ActLstClk+ 4)
|
||||
#define ActRcvSocPst (ActLstClk+ 5)
|
||||
#define ActRemSocEvn (ActLstClk+ 6)
|
||||
#define ActReqRemSocEvn (ActLstClk+ 6)
|
||||
#define ActRemSocEvn (ActLstClk+ 7)
|
||||
|
||||
#define ActSeePubPrf (ActLstClk+ 7)
|
||||
#define ActCal1stClkTim (ActLstClk+ 8)
|
||||
#define ActCalNumClk (ActLstClk+ 9)
|
||||
#define ActCalNumFilVie (ActLstClk+ 10)
|
||||
#define ActCalNumForPst (ActLstClk+ 11)
|
||||
#define ActCalNumMsgSnt (ActLstClk+ 12)
|
||||
#define ActSeePubPrf (ActLstClk+ 8)
|
||||
#define ActCal1stClkTim (ActLstClk+ 9)
|
||||
#define ActCalNumClk (ActLstClk+ 10)
|
||||
#define ActCalNumFilVie (ActLstClk+ 11)
|
||||
#define ActCalNumForPst (ActLstClk+ 12)
|
||||
#define ActCalNumMsgSnt (ActLstClk+ 13)
|
||||
|
||||
#define ActFolUsr (ActLstClk+ 13)
|
||||
#define ActUnfUsr (ActLstClk+ 14)
|
||||
#define ActSeeFlg (ActLstClk+ 15)
|
||||
#define ActSeeFlr (ActLstClk+ 16)
|
||||
#define ActFolUsr (ActLstClk+ 14)
|
||||
#define ActUnfUsr (ActLstClk+ 15)
|
||||
#define ActSeeFlg (ActLstClk+ 16)
|
||||
#define ActSeeFlr (ActLstClk+ 17)
|
||||
|
||||
#define ActCht (ActLstClk+ 17)
|
||||
#define ActCht (ActLstClk+ 18)
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Messages tab ********************************/
|
||||
|
|
|
@ -116,13 +116,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.84 (2015-12-30)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.84.1 (2015-12-30)"
|
||||
#define CSS_FILE "swad15.80.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.84.1: Dec 30, 2015 Request confirmation before removing a social post. (189419 lines)
|
||||
Version 15.84: Dec 30, 2015 Remove social post. (189316 lines)
|
||||
Version 15.83.1: Dec 30, 2015 Fixed bug in user's public profile. (189210 lines)
|
||||
Version 15.83: Dec 30, 2015 Form to remove a social post. (189209 lines)
|
||||
|
|
459
swad_social.c
459
swad_social.c
|
@ -122,10 +122,13 @@ extern struct Globals Gbl;
|
|||
|
||||
static unsigned long Soc_ShowTimeline (const char *Query);
|
||||
static Soc_SocialEvent_t Soc_GetSocialEventFromDB (const char *Str);
|
||||
static void Soc_WriteSocialEvent (const struct SocialEvent *Soc,
|
||||
struct UsrData *UsrDat,
|
||||
bool PutIconRemove);
|
||||
static void Soc_WriteEventDate (time_t TimeUTC);
|
||||
static void Soc_StartFormGoToAction (Soc_SocialEvent_t SocialEvent,
|
||||
long CrsCod,long Cod);
|
||||
static void Soc_GetEventSummary (Soc_SocialEvent_t SocialEvent,long Cod,
|
||||
static void Soc_GetEventSummary (const struct SocialEvent *Soc,
|
||||
char *SummaryStr,unsigned MaxChars);
|
||||
|
||||
static void Soc_PutLinkToWriteANewPost (void);
|
||||
|
@ -135,6 +138,7 @@ static void Soc_PutFormToRemoveSocialEvent (long SocCod);
|
|||
static void Soc_PutHiddenParamSocCod (long SocCod);
|
||||
static long Soc_GetParamSocCod (void);
|
||||
static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc);
|
||||
static void Soc_GetDataOfSocialEventFromRow (MYSQL_ROW row,struct SocialEvent *Soc);
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Show social activity (timeline) of a selected user **************/
|
||||
|
@ -197,34 +201,13 @@ void Soc_ShowFollowingTimeline (void)
|
|||
|
||||
static unsigned long Soc_ShowTimeline (const char *Query)
|
||||
{
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
extern const char *Txt_Public_activity;
|
||||
extern const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS];
|
||||
extern const char *Txt_Forum;
|
||||
extern const char *Txt_Course;
|
||||
extern const char *Txt_Degree;
|
||||
extern const char *Txt_Centre;
|
||||
extern const char *Txt_Institution;
|
||||
extern const char *Txt_Country;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumEvents;
|
||||
unsigned long NumEvent;
|
||||
long SocCod;
|
||||
Soc_SocialEvent_t SocialEvent;
|
||||
struct SocialEvent Soc;
|
||||
struct UsrData UsrDat;
|
||||
bool ItsMine; // I am the author of a social event
|
||||
struct Country Cty;
|
||||
struct Institution Ins;
|
||||
struct Centre Ctr;
|
||||
struct Degree Deg;
|
||||
struct Course Crs;
|
||||
long Cod;
|
||||
char ForumName[512];
|
||||
time_t DateTimeUTC; // Date-time of the event
|
||||
bool ShowPhoto = false;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
char SummaryStr[Cns_MAX_BYTES_TEXT+1];
|
||||
|
||||
/***** Get timeline from database *****/
|
||||
NumEvents = DB_QuerySELECT (Query,&mysql_res,"can not get social events");
|
||||
|
@ -244,141 +227,12 @@ static unsigned long Soc_ShowTimeline (const char *Query)
|
|||
NumEvent < NumEvents;
|
||||
NumEvent++)
|
||||
{
|
||||
/***** Get next social event *****/
|
||||
/* Get next social event */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Soc_GetDataOfSocialEventFromRow (row,&Soc);
|
||||
|
||||
/* Get social code (row[0]) */
|
||||
SocCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get event type (row[1]) */
|
||||
SocialEvent = Soc_GetSocialEventFromDB ((const char *) row[1]);
|
||||
|
||||
/* Get (from) user code (row[2]) */
|
||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat); // Get user's data from the database
|
||||
ItsMine = (Gbl.Usrs.Me.Logged &&
|
||||
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/* Get country code (row[3]) */
|
||||
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_BASIC_DATA);
|
||||
|
||||
/* Get institution code (row[4]) */
|
||||
Ins.InsCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
|
||||
|
||||
/* Get centre code (row[5]) */
|
||||
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
Ctr_GetDataOfCentreByCod (&Ctr);
|
||||
|
||||
/* Get degree code (row[6]) */
|
||||
Deg.DegCod = Str_ConvertStrCodToLongCod (row[6]);
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
||||
/* Get course code (row[7]) */
|
||||
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[7]);
|
||||
Crs_GetDataOfCourseByCod (&Crs);
|
||||
|
||||
/* Get file/post... code (row[8]) */
|
||||
Cod = Str_ConvertStrCodToLongCod (row[8]);
|
||||
|
||||
/* Get forum type of the post */
|
||||
if (SocialEvent == Soc_EVENT_FORUM_POST)
|
||||
{
|
||||
Gbl.Forum.ForumType = For_GetForumTypeOfAPost (Cod);
|
||||
For_SetForumName (Gbl.Forum.ForumType,
|
||||
&Ins,
|
||||
&Ctr,
|
||||
&Deg,
|
||||
&Crs,
|
||||
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
|
||||
Gbl.Forum.Ins.InsCod = Ins.InsCod;
|
||||
Gbl.Forum.Ctr.CtrCod = Ctr.CtrCod;
|
||||
Gbl.Forum.Deg.DegCod = Deg.DegCod;
|
||||
Gbl.Forum.Crs.CrsCod = Crs.CrsCod;
|
||||
}
|
||||
|
||||
/* Get time of the event (row[9]) */
|
||||
DateTimeUTC = Dat_GetUNIXTimeFromStr (row[9]);
|
||||
|
||||
/***** Write row for this social event *****/
|
||||
fprintf (Gbl.F.Out,"<li>");
|
||||
|
||||
/* Left: write author's photo */
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_LEFT_PHOTO\">");
|
||||
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&UsrDat,PhotoURL);
|
||||
Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL :
|
||||
NULL,
|
||||
"PHOTO60x80",Pho_ZOOM);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/* Right: author's name, time and summary */
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_CONTAINER\">");
|
||||
|
||||
/* Write author's full name and nickname */
|
||||
Str_LimitLengthHTMLStr (UsrDat.FullName,20);
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">"
|
||||
"<span class=\"DAT_N_BOLD\">%s</span>"
|
||||
"<span class=\"DAT_LIGHT\"> @%s</span>"
|
||||
"</div>",
|
||||
UsrDat.FullName,UsrDat.Nickname);
|
||||
|
||||
/* Write date and time */
|
||||
Soc_WriteEventDate (DateTimeUTC);
|
||||
|
||||
if (SocialEvent == Soc_EVENT_SOCIAL_POST)
|
||||
{
|
||||
/* Write post content */
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">");
|
||||
Soc_GetAndWriteSocialPost (Cod);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/* Write form to remove this event */
|
||||
if (ItsMine)
|
||||
Soc_PutFormToRemoveSocialEvent (SocCod);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write event type and location */
|
||||
fprintf (Gbl.F.Out,"<div>");
|
||||
Soc_StartFormGoToAction (SocialEvent,Crs.CrsCod,Cod);
|
||||
Act_LinkFormSubmit (Txt_SOCIAL_EVENT[SocialEvent],
|
||||
The_ClassForm[Gbl.Prefs.Theme]);
|
||||
fprintf (Gbl.F.Out,"%s</a>",
|
||||
Txt_SOCIAL_EVENT[SocialEvent]);
|
||||
Act_FormEnd ();
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
if (SocialEvent == Soc_EVENT_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]);
|
||||
|
||||
/* Write content of the event */
|
||||
Soc_GetEventSummary (SocialEvent,Cod,
|
||||
SummaryStr,Soc_MAX_BYTES_SUMMARY);
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
|
||||
}
|
||||
|
||||
/* End of right part */
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/* End of list element */
|
||||
fprintf (Gbl.F.Out,"</li>");
|
||||
/* Write row for this social event */
|
||||
Soc_WriteSocialEvent (&Soc,&UsrDat,true);
|
||||
}
|
||||
|
||||
/***** List end *****/
|
||||
|
@ -410,6 +264,154 @@ static Soc_SocialEvent_t Soc_GetSocialEventFromDB (const char *Str)
|
|||
return Soc_EVENT_UNKNOWN;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Write social event *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Soc_WriteSocialEvent (const struct SocialEvent *Soc,
|
||||
struct UsrData *UsrDat,
|
||||
bool PutIconRemove)
|
||||
{
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
extern const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS];
|
||||
extern const char *Txt_Forum;
|
||||
extern const char *Txt_Course;
|
||||
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;
|
||||
struct Course Crs;
|
||||
bool ShowPhoto = false;
|
||||
char PhotoURL[PATH_MAX+1];
|
||||
char ForumName[512];
|
||||
char SummaryStr[Cns_MAX_BYTES_TEXT+1];
|
||||
|
||||
/***** Get details *****/
|
||||
/* Get author data */
|
||||
UsrDat->UsrCod = Soc->UsrCod;
|
||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat);
|
||||
|
||||
/* Get country data */
|
||||
Cty.CtyCod = Soc->CtyCod;
|
||||
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_BASIC_DATA);
|
||||
|
||||
/* Get institution data */
|
||||
Ins.InsCod = Soc->InsCod;
|
||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
|
||||
|
||||
/* Get centre data */
|
||||
Ctr.CtrCod = Soc->CtrCod;
|
||||
Ctr_GetDataOfCentreByCod (&Ctr);
|
||||
|
||||
/* Get degree data */
|
||||
Deg.DegCod = Soc->DegCod;
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
||||
/* Get course data */
|
||||
Crs.CrsCod = Soc->CrsCod;
|
||||
Crs_GetDataOfCourseByCod (&Crs);
|
||||
|
||||
/* Get forum type of the post */
|
||||
if (Soc->SocialEvent == Soc_EVENT_FORUM_POST)
|
||||
{
|
||||
Gbl.Forum.ForumType = For_GetForumTypeOfAPost (Soc->Cod);
|
||||
For_SetForumName (Gbl.Forum.ForumType,
|
||||
&Ins,
|
||||
&Ctr,
|
||||
&Deg,
|
||||
&Crs,
|
||||
ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language
|
||||
Gbl.Forum.Ins.InsCod = Ins.InsCod;
|
||||
Gbl.Forum.Ctr.CtrCod = Ctr.CtrCod;
|
||||
Gbl.Forum.Deg.DegCod = Deg.DegCod;
|
||||
Gbl.Forum.Crs.CrsCod = Crs.CrsCod;
|
||||
}
|
||||
|
||||
/***** Start list item *****/
|
||||
fprintf (Gbl.F.Out,"<li>");
|
||||
|
||||
/***** Left: write author's photo *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_LEFT_PHOTO\">");
|
||||
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
||||
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
||||
NULL,
|
||||
"PHOTO60x80",Pho_ZOOM);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/***** Right: author's name, time and summary *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_CONTAINER\">");
|
||||
|
||||
/* Write author's full name and nickname */
|
||||
Str_LimitLengthHTMLStr (UsrDat->FullName,20);
|
||||
fprintf (Gbl.F.Out,"<div class=\"SOCIAL_RIGHT_AUTHOR\">"
|
||||
"<span class=\"DAT_N_BOLD\">%s</span>"
|
||||
"<span class=\"DAT_LIGHT\"> @%s</span>"
|
||||
"</div>",
|
||||
UsrDat->FullName,UsrDat->Nickname);
|
||||
|
||||
/* Write date and time */
|
||||
Soc_WriteEventDate (Soc->DateTimeUTC);
|
||||
|
||||
if (Soc->SocialEvent == Soc_EVENT_SOCIAL_POST)
|
||||
{
|
||||
/* Write post content */
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">");
|
||||
Soc_GetAndWriteSocialPost (Soc->Cod);
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/* Write form to remove this event */
|
||||
if (PutIconRemove &&
|
||||
Gbl.Usrs.Me.Logged &&
|
||||
UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author
|
||||
Soc_PutFormToRemoveSocialEvent (Soc->SocCod);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write event type and location */
|
||||
fprintf (Gbl.F.Out,"<div>");
|
||||
Soc_StartFormGoToAction (Soc->SocialEvent,Crs.CrsCod,Soc->Cod);
|
||||
Act_LinkFormSubmit (Txt_SOCIAL_EVENT[Soc->SocialEvent],
|
||||
The_ClassForm[Gbl.Prefs.Theme]);
|
||||
fprintf (Gbl.F.Out,"%s</a>",
|
||||
Txt_SOCIAL_EVENT[Soc->SocialEvent]);
|
||||
Act_FormEnd ();
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
if (Soc->SocialEvent == Soc_EVENT_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]);
|
||||
|
||||
/* Write content of the event */
|
||||
Soc_GetEventSummary (Soc,SummaryStr,Soc_MAX_BYTES_SUMMARY);
|
||||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%s</div>",SummaryStr);
|
||||
}
|
||||
|
||||
/* End of right part */
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
|
||||
/***** End list item *****/
|
||||
fprintf (Gbl.F.Out,"</li>");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Write the date of creation of a social event ***************/
|
||||
/*****************************************************************************/
|
||||
|
@ -529,12 +531,12 @@ static void Soc_StartFormGoToAction (Soc_SocialEvent_t SocialEvent,
|
|||
/******************* Get social event summary and content ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Soc_GetEventSummary (Soc_SocialEvent_t SocialEvent,long Cod,
|
||||
static void Soc_GetEventSummary (const struct SocialEvent *Soc,
|
||||
char *SummaryStr,unsigned MaxChars)
|
||||
{
|
||||
SummaryStr[0] = '\0';
|
||||
|
||||
switch (SocialEvent)
|
||||
switch (Soc->SocialEvent)
|
||||
{
|
||||
case Soc_EVENT_UNKNOWN:
|
||||
break;
|
||||
|
@ -546,19 +548,19 @@ static void Soc_GetEventSummary (Soc_SocialEvent_t SocialEvent,long Cod,
|
|||
case Soc_EVENT_DEG_SHA_PUB_FILE:
|
||||
case Soc_EVENT_CRS_DOC_PUB_FILE:
|
||||
case Soc_EVENT_CRS_SHA_PUB_FILE:
|
||||
Brw_GetSummaryAndContentOrSharedFile (SummaryStr,NULL,Cod,MaxChars,false);
|
||||
Brw_GetSummaryAndContentOrSharedFile (SummaryStr,NULL,Soc->Cod,MaxChars,false);
|
||||
break;
|
||||
case Soc_EVENT_EXAM_ANNOUNCEMENT:
|
||||
Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,NULL,Cod,MaxChars,false);
|
||||
Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,NULL,Soc->Cod,MaxChars,false);
|
||||
break;
|
||||
case Soc_EVENT_SOCIAL_POST:
|
||||
// TODO: Implement social posts
|
||||
// Not applicable
|
||||
break;
|
||||
case Soc_EVENT_NOTICE:
|
||||
Not_GetSummaryAndContentNotice (SummaryStr,NULL,Cod,MaxChars,false);
|
||||
Not_GetSummaryAndContentNotice (SummaryStr,NULL,Soc->Cod,MaxChars,false);
|
||||
break;
|
||||
case Soc_EVENT_FORUM_POST:
|
||||
For_GetSummaryAndContentForumPst (SummaryStr,NULL,Cod,MaxChars,false);
|
||||
For_GetSummaryAndContentForumPst (SummaryStr,NULL,Soc->Cod,MaxChars,false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +733,7 @@ static void Soc_PutFormToRemoveSocialEvent (long SocCod)
|
|||
extern const char *Txt_Remove;
|
||||
|
||||
/***** Form to remove social post *****/
|
||||
Act_FormStart (ActRemSocEvn);
|
||||
Act_FormStart (ActReqRemSocEvn);
|
||||
Soc_PutHiddenParamSocCod (SocCod);
|
||||
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_OPT ICON_HIGHLIGHT\">"
|
||||
"<input type=\"image\""
|
||||
|
@ -772,11 +774,63 @@ static long Soc_GetParamSocCod (void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Remove social event ****************************/
|
||||
/******************* Request the removal of a social event *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Soc_RequestRemovalSocialEvent (void)
|
||||
{
|
||||
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
|
||||
extern const char *Txt_Remove;
|
||||
struct SocialEvent Soc;
|
||||
bool ICanRemove;
|
||||
struct UsrData UsrDat;
|
||||
|
||||
/***** Get the code of the social event to remove *****/
|
||||
Soc.SocCod = Soc_GetParamSocCod ();
|
||||
|
||||
/***** Get data of social event *****/
|
||||
Soc_GetDataOfSocialEventByCod (&Soc);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
Soc.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod &&
|
||||
Soc.SocialEvent == Soc_EVENT_SOCIAL_POST);
|
||||
if (ICanRemove)
|
||||
{
|
||||
/***** Initialize structure with user's data *****/
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
|
||||
/***** Form to ask for confirmation to remove this social post *****/
|
||||
/* Start form */
|
||||
Act_FormStart (ActRemSocEvn);
|
||||
Soc_PutHiddenParamSocCod (Soc.SocCod);
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_Do_you_really_want_to_remove_the_following_comment);
|
||||
|
||||
/* Show social event */
|
||||
Lay_StartRoundFrame ("560px",NULL);
|
||||
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
|
||||
Soc_WriteSocialEvent (&Soc,&UsrDat,false);
|
||||
fprintf (Gbl.F.Out,"</ul>");
|
||||
Lay_EndRoundFrame ();
|
||||
|
||||
/* End form */
|
||||
Lay_PutRemoveButton (Txt_Remove);
|
||||
Act_FormEnd ();
|
||||
|
||||
/***** Free memory used for user's data *****/
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
}
|
||||
|
||||
/***** Write timeline again *****/
|
||||
Soc_ShowFollowingTimeline ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Remove a social event ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Soc_RemoveSocialEvent (void)
|
||||
{
|
||||
extern const char *Txt_Comment_removed;
|
||||
struct SocialEvent Soc;
|
||||
bool ICanRemove;
|
||||
char Query[128];
|
||||
|
@ -784,7 +838,7 @@ void Soc_RemoveSocialEvent (void)
|
|||
/***** Get the code of the social event to remove *****/
|
||||
Soc.SocCod = Soc_GetParamSocCod ();
|
||||
|
||||
/***** Get social event author *****/
|
||||
/***** Get data of social event *****/
|
||||
Soc_GetDataOfSocialEventByCod (&Soc);
|
||||
|
||||
ICanRemove = (Gbl.Usrs.Me.Logged &&
|
||||
|
@ -802,6 +856,9 @@ void Soc_RemoveSocialEvent (void)
|
|||
sprintf (Query,"DELETE FROM social_post WHERE PstCod='%ld'",Soc.Cod);
|
||||
DB_QueryDELETE (Query,"can not remove a social post");
|
||||
}
|
||||
|
||||
/***** Message of success *****/
|
||||
Lay_ShowAlert (Lay_SUCCESS,Txt_Comment_removed);
|
||||
}
|
||||
|
||||
/***** Write timeline after removing *****/
|
||||
|
@ -819,46 +876,21 @@ static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc)
|
|||
MYSQL_ROW row;
|
||||
|
||||
/***** Get data of social event from database *****/
|
||||
sprintf (Query,"SELECT SocialEvent,UsrCod,"
|
||||
sprintf (Query,"SELECT SocCod,SocialEvent,UsrCod,"
|
||||
"CtyCod,InsCod,CtrCod,DegCod,CrsCod,"
|
||||
"Cod,UNIX_TIMESTAMP(TimeEvent)"
|
||||
" FROM social"
|
||||
" WHERE SocCod='%ld'",
|
||||
Soc->SocCod);
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social event") == 1)
|
||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social event"))
|
||||
{
|
||||
/***** Get social event *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get event type (row[0]) */
|
||||
Soc->SocialEvent = Soc_GetSocialEventFromDB ((const char *) row[0]);
|
||||
|
||||
/* Get (from) user code (row[1]) */
|
||||
Soc->UsrCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
||||
/* Get country code (row[2]) */
|
||||
Soc->CtyCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
||||
/* Get institution code (row[3]) */
|
||||
Soc->InsCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
||||
/* Get centre code (row[4]) */
|
||||
Soc->CtrCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
|
||||
/* Get degree code (row[5]) */
|
||||
Soc->DegCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
||||
/* Get course code (row[6]) */
|
||||
Soc->CrsCod = Str_ConvertStrCodToLongCod (row[6]);
|
||||
|
||||
/* Get file/post... code (row[7]) */
|
||||
Soc->Cod = Str_ConvertStrCodToLongCod (row[7]);
|
||||
|
||||
/* Get time of the event (row[8]) */
|
||||
Soc->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[8]);
|
||||
Soc_GetDataOfSocialEventFromRow (row,Soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
/***** Reset fields of social event *****/
|
||||
Soc->SocialEvent = Soc_EVENT_UNKNOWN;
|
||||
Soc->UsrCod = -1L;
|
||||
Soc->CtyCod =
|
||||
|
@ -870,3 +902,40 @@ static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc)
|
|||
Soc->DateTimeUTC = (time_t) 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get assignment data using its code **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Soc_GetDataOfSocialEventFromRow (MYSQL_ROW row,struct SocialEvent *Soc)
|
||||
{
|
||||
/* Get social code (row[0]) */
|
||||
Soc->SocCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get event type (row[1]) */
|
||||
Soc->SocialEvent = Soc_GetSocialEventFromDB ((const char *) row[1]);
|
||||
|
||||
/* Get (from) user code (row[2]) */
|
||||
Soc->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
||||
/* Get country code (row[3]) */
|
||||
Soc->CtyCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
||||
/* Get institution code (row[4]) */
|
||||
Soc->InsCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
|
||||
/* Get centre code (row[5]) */
|
||||
Soc->CtrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
||||
/* Get degree code (row[6]) */
|
||||
Soc->DegCod = Str_ConvertStrCodToLongCod (row[6]);
|
||||
|
||||
/* Get course code (row[7]) */
|
||||
Soc->CrsCod = Str_ConvertStrCodToLongCod (row[7]);
|
||||
|
||||
/* Get file/post... code (row[8]) */
|
||||
Soc->Cod = Str_ConvertStrCodToLongCod (row[8]);
|
||||
|
||||
/* Get time of the event (row[9]) */
|
||||
Soc->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[9]);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ void Soc_StoreSocialEvent (Soc_SocialEvent_t SocialEvent,long Cod);
|
|||
void Soc_FormSocialPost (void);
|
||||
void Soc_ReceiveSocialPost (void);
|
||||
|
||||
void Soc_RequestRemovalSocialEvent (void);
|
||||
void Soc_RemoveSocialEvent (void);
|
||||
|
||||
#endif
|
||||
|
|
50
swad_text.c
50
swad_text.c
|
@ -4603,6 +4603,27 @@ const char *Txt_columns =
|
|||
"colunas";
|
||||
#endif
|
||||
|
||||
const char *Txt_Comment_removed =
|
||||
#if L==1
|
||||
"Comentari eliminat.";
|
||||
#elif L==2
|
||||
"Kommentar entfernt.";
|
||||
#elif L==3
|
||||
"Comment removed.";
|
||||
#elif L==4
|
||||
"Comentario eliminado";
|
||||
#elif L==5
|
||||
"Commentaire supprimé.";
|
||||
#elif L==6
|
||||
"Comentario eliminado."; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Commento rimosso.";
|
||||
#elif L==8
|
||||
"Komentarz usuniete.";
|
||||
#elif L==9
|
||||
"Comentário removido.";
|
||||
#endif
|
||||
|
||||
const char *Txt_Comments =
|
||||
#if L==1
|
||||
"Comentaris";
|
||||
|
@ -8583,15 +8604,15 @@ const char *Txt_Do_you_really_want_to_remove_the_folder_X = // Warning: it is ve
|
|||
|
||||
const char *Txt_Do_you_really_want_to_remove_the_following_notice =
|
||||
#if L==1
|
||||
"¿Realmente desea eliminar el siguiente aviso?"; // Necessita traduccio
|
||||
"De veres voleu eliminar el següent avís?";
|
||||
#elif L==2
|
||||
"Do you really want to remove the following notice?"; // Need Übersetzung
|
||||
"Wollen Sie wirklich, um die folgende Ankündigung zu entfernen?";
|
||||
#elif L==3
|
||||
"Do you really want to remove the following notice?";
|
||||
#elif L==4
|
||||
"¿Realmente desea eliminar el siguiente aviso?";
|
||||
#elif L==5
|
||||
"Do you really want to remove the following notice?"; // Besoin de traduction
|
||||
"Voulez-vous vraiment supprimer l'avis suivant?";
|
||||
#elif L==6
|
||||
"¿Realmente desea eliminar el siguiente aviso?"; // Okoteve traducción
|
||||
#elif L==7
|
||||
|
@ -8599,7 +8620,28 @@ const char *Txt_Do_you_really_want_to_remove_the_following_notice =
|
|||
#elif L==8
|
||||
"Czy na pewno chcesz usunac nastepujace obwieszczenie?";
|
||||
#elif L==9
|
||||
"Do you really want to remove the following notice>?"; // Necessita de tradução
|
||||
"Você realmente deseja remover o seguinte aviso?";
|
||||
#endif
|
||||
|
||||
const char *Txt_Do_you_really_want_to_remove_the_following_comment =
|
||||
#if L==1
|
||||
"De veres voleu eliminar el següent comentari?";
|
||||
#elif L==2
|
||||
"Wollen Sie wirklich, um die folgende Kommentar zu entfernen?";
|
||||
#elif L==3
|
||||
"Do you really want to remove the following comment?";
|
||||
#elif L==4
|
||||
"¿Realmente desea eliminar el siguiente comentario?";
|
||||
#elif L==5
|
||||
"Voulez-vous vraiment supprimer le commentaire suivant?";
|
||||
#elif L==6
|
||||
"¿Realmente desea eliminar el siguiente comentario?"; // Okoteve traducción
|
||||
#elif L==7
|
||||
"Vuoi realmente rimuovere il seguente commento?";
|
||||
#elif L==8
|
||||
"Czy na pewno chcesz usunac nastepujace komentarz?";
|
||||
#elif L==9
|
||||
"Você realmente deseja remover o seguinte comentário?";
|
||||
#endif
|
||||
|
||||
const char *Txt_Do_you_really_want_to_remove_the_following_user_as_an_administrator_of_the_centre_X = // Warning: it is very important to include %s in the following sentences
|
||||
|
|
Loading…
Reference in New Issue