mirror of https://github.com/acanas/swad-core.git
Version 15.192.1
This commit is contained in:
parent
ad2f5dbeac
commit
9dc27436c3
|
@ -133,13 +133,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.192 (2016-04-10)"
|
#define Log_PLATFORM_VERSION "SWAD 15.192.1 (2016-04-10)"
|
||||||
#define CSS_FILE "swad15.192.css"
|
#define CSS_FILE "swad15.192.css"
|
||||||
#define JS_FILE "swad15.190.1.js"
|
#define JS_FILE "swad15.190.1.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// 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
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.192.1: Apr 10, 2016 Remove image attached to forum post when the post is removed. (199340 lines)
|
||||||
Version 15.192: Apr 10, 2016 Get image attached to forum post / message. (199332 lines)
|
Version 15.192: Apr 10, 2016 Get image attached to forum post / message. (199332 lines)
|
||||||
6 changes necessary in database:
|
6 changes necessary in database:
|
||||||
ALTER TABLE forum_post ADD COLUMN ImageName VARCHAR(43) NOT NULL AFTER Content;
|
ALTER TABLE forum_post ADD COLUMN ImageName VARCHAR(43) NOT NULL AFTER Content;
|
||||||
|
|
35
swad_forum.c
35
swad_forum.c
|
@ -259,7 +259,7 @@ static void For_InsertPstIntoBannedPstTable (long PstCod);
|
||||||
static long For_InsertForumPst (long ThrCod,long UsrCod,
|
static long For_InsertForumPst (long ThrCod,long UsrCod,
|
||||||
const char *Subject,const char *Content,
|
const char *Subject,const char *Content,
|
||||||
struct Image *Image);
|
struct Image *Image);
|
||||||
static bool For_RemoveForumPst (long PstCod);
|
static bool For_RemoveForumPst (long PstCod,struct Image *Image);
|
||||||
static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod);
|
static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod);
|
||||||
|
|
||||||
static long For_InsertForumThread (For_ForumType_t ForumType,long FirstPstCod);
|
static long For_InsertForumThread (For_ForumType_t ForumType,long FirstPstCod);
|
||||||
|
@ -478,12 +478,15 @@ static long For_InsertForumPst (long ThrCod,long UsrCod,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return true if the post thread is deleted
|
// Return true if the post thread is deleted
|
||||||
|
|
||||||
static bool For_RemoveForumPst (long PstCod)
|
static bool For_RemoveForumPst (long PstCod,struct Image *Image)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[512];
|
||||||
long ThrCod;
|
long ThrCod;
|
||||||
bool ThreadDeleted = false;
|
bool ThreadDeleted = false;
|
||||||
|
|
||||||
|
/***** Remove image file attached to forum post *****/
|
||||||
|
Img_RemoveImageFile (Image->Name);
|
||||||
|
|
||||||
/***** If the post is the only one in its thread, delete that thread *****/
|
/***** If the post is the only one in its thread, delete that thread *****/
|
||||||
if (For_NumPstsInThrWithPstCod (PstCod,&ThrCod) < 2)
|
if (For_NumPstsInThrWithPstCod (PstCod,&ThrCod) < 2)
|
||||||
{
|
{
|
||||||
|
@ -1312,7 +1315,6 @@ static void For_ShowAForumPost (struct ForumThread *Thr,unsigned PstNum,long Pst
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Get data of a forum post ************************/
|
/*************************** Get data of a forum post ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// If pointer to Image is NULL ==> do not get image
|
|
||||||
|
|
||||||
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
char *Subject, char *Content,struct Image *Image)
|
char *Subject, char *Content,struct Image *Image)
|
||||||
|
@ -1351,8 +1353,7 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
||||||
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
|
Content[Cns_MAX_BYTES_LONG_TEXT] = '\0';
|
||||||
|
|
||||||
/****** Get image name (row[4]) and title (row[5]) *****/
|
/****** Get image name (row[4]) and title (row[5]) *****/
|
||||||
if (Image)
|
Img_GetImageNameAndTitleFromRow (row[4],row[5],Image);
|
||||||
Img_GetImageNameAndTitleFromRow (row[4],row[5],Image);
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -4018,26 +4019,35 @@ void For_DelPst (void)
|
||||||
time_t CreatTimeUTC; // Creation time of a message
|
time_t CreatTimeUTC; // Creation time of a message
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT+1];
|
char Subject[Cns_MAX_BYTES_SUBJECT+1];
|
||||||
char OriginalContent[Cns_MAX_BYTES_TEXT+1];
|
char OriginalContent[Cns_MAX_BYTES_TEXT+1];
|
||||||
|
struct Image Image;
|
||||||
bool ThreadDeleted = false;
|
bool ThreadDeleted = false;
|
||||||
|
|
||||||
/***** Get the code of the message to delete *****/
|
/***** Get parameters *****/
|
||||||
|
/* Get the code of the message to remove */
|
||||||
PstCod = For_GetParamPstCod ();
|
PstCod = For_GetParamPstCod ();
|
||||||
|
|
||||||
/***** Delete the message *****/
|
|
||||||
/* Get order type, degree and course of the forum */
|
/* Get order type, degree and course of the forum */
|
||||||
For_GetParamsForum ();
|
For_GetParamsForum ();
|
||||||
|
|
||||||
/* Set forum type */
|
/* Set forum type */
|
||||||
For_SetForumTypeAndRestrictAccess ();
|
For_SetForumTypeAndRestrictAccess ();
|
||||||
|
|
||||||
/* Get the thread number */
|
/* Get the thread number */
|
||||||
ThrCod = For_GetParamThrCod ();
|
ThrCod = For_GetParamThrCod ();
|
||||||
|
|
||||||
|
/***** Initialize image *****/
|
||||||
|
Img_ImageConstructor (&Image);
|
||||||
|
|
||||||
|
/***** Get forum post data *****/
|
||||||
|
For_GetPstData (PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
||||||
|
Subject,OriginalContent,&Image);
|
||||||
|
|
||||||
|
/***** Check if I can remove the post *****/
|
||||||
/* Check if the message really exists, if it has not been removed */
|
/* Check if the message really exists, if it has not been removed */
|
||||||
if (!For_GetIfForumPstExists (PstCod))
|
if (!For_GetIfForumPstExists (PstCod))
|
||||||
Lay_ShowErrorAndExit ("The post to remove no longer exists.");
|
Lay_ShowErrorAndExit ("The post to remove no longer exists.");
|
||||||
|
|
||||||
/* Check if I am the author of the message */
|
/* Check if I am the author of the message */
|
||||||
For_GetPstData (PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
|
||||||
Subject,OriginalContent,NULL);
|
|
||||||
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod)
|
if (Gbl.Usrs.Me.UsrDat.UsrCod != UsrDat.UsrCod)
|
||||||
Lay_ShowErrorAndExit ("You can not remove post because you aren't the author.");
|
Lay_ShowErrorAndExit ("You can not remove post because you aren't the author.");
|
||||||
|
|
||||||
|
@ -4045,8 +4055,11 @@ void For_DelPst (void)
|
||||||
if (PstCod != For_GetLastPstCod (ThrCod))
|
if (PstCod != For_GetLastPstCod (ThrCod))
|
||||||
Lay_ShowErrorAndExit ("You can not remove post because it is not the last of the thread.");
|
Lay_ShowErrorAndExit ("You can not remove post because it is not the last of the thread.");
|
||||||
|
|
||||||
/* Remove the message */
|
/***** Remove the post *****/
|
||||||
ThreadDeleted = For_RemoveForumPst (PstCod);
|
ThreadDeleted = For_RemoveForumPst (PstCod,&Image);
|
||||||
|
|
||||||
|
/***** Free image *****/
|
||||||
|
Img_ImageDestructor (&Image);
|
||||||
|
|
||||||
/***** Mark possible notifications as removed *****/
|
/***** Mark possible notifications as removed *****/
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,PstCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,PstCod);
|
||||||
|
|
Loading…
Reference in New Issue