From 357b1ea2d6636bbb0f7112a58baf3e1835cd4b77 Mon Sep 17 00:00:00 2001 From: Git Date: Sat, 19 Apr 2014 08:00:50 +0000 Subject: [PATCH] Empty commit --- classes/comments.class.php | 12 +++++++++++- classes/notificationsmanager.class.php | 1 + sections/ajax/announcements.php | 3 ++- sections/collages/new_handle.php | 2 +- sections/comments/take_edit.php | 3 ++- sections/feeds/index.php | 3 ++- static/functions/comments.js | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/classes/comments.class.php b/classes/comments.class.php index 2dc43af5..8821684f 100644 --- a/classes/comments.class.php +++ b/classes/comments.class.php @@ -48,9 +48,10 @@ public static function post($Page, $PageID, $Body) { * Edit a comment * @param int $PostID * @param string $NewBody + * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit * @todo move permission check out of here/remove hardcoded error(404) */ - public static function edit($PostID, $NewBody) { + public static function edit($PostID, $NewBody, $SendPM = false) { $QueryID = G::$DB->get_query_id(); G::$DB->query(" @@ -103,6 +104,15 @@ public static function edit($PostID, $NewBody) { G::$DB->set_query_id($QueryID); + if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) { + // Send a PM to the user to notify them of the edit + $PMSubject = "Your comment #$PostID has been edited"; + $PMurl = site_url()."comments.php?action=jump&postid=$PostID"; + $ProfLink = '[url='.site_url().'user.php?id='.G::$LoggedUser['ID'].']'.G::$LoggedUser['Username'].'[/url]'; + $PMBody = "One of your comments has been edited by $ProfLink: [url]{$PMurl}[/url]"; + Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody); + } + return true; // TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query } diff --git a/classes/notificationsmanager.class.php b/classes/notificationsmanager.class.php index b205d473..76f2f678 100644 --- a/classes/notificationsmanager.class.php +++ b/classes/notificationsmanager.class.php @@ -464,6 +464,7 @@ public static function clear_blog($Blog) { SELECT b.ID, um.Username, + b.UserID, b.Title, b.Body, b.Time, diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php index d17f9dea..eff908b3 100644 --- a/sections/ajax/announcements.php +++ b/sections/ajax/announcements.php @@ -30,6 +30,7 @@ SELECT b.ID, um.Username, + b.UserID, b.Title, b.Body, b.Time, @@ -43,7 +44,7 @@ } $JsonBlog = array(); for ($i = 0; $i < 5; $i++) { - list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $Blog[$i]; + list($BlogID, $Author, $AuthorID, $Title, $Body, $BlogTime, $ThreadID) = $Blog[$i]; $JsonBlog[] = array( 'blogId' => (int)$BlogID, 'author' => $Author, diff --git a/sections/collages/new_handle.php b/sections/collages/new_handle.php index 43a174ab..289ead34 100644 --- a/sections/collages/new_handle.php +++ b/sections/collages/new_handle.php @@ -27,7 +27,7 @@ $i++; } } -$Val->SetFields('description', '1', 'string', 'The description must be at least 10 characters', array('maxlength' => 65535, 'minlength' => 10)); +$Val->SetFields('description', '1', 'string', 'The description must be between 10 and 65535 characters', array('maxlength' => 65535, 'minlength' => 10)); $Err = $Val->ValidateForm($_POST); diff --git a/sections/comments/take_edit.php b/sections/comments/take_edit.php index ee384650..6e1f4db2 100644 --- a/sections/comments/take_edit.php +++ b/sections/comments/take_edit.php @@ -9,7 +9,8 @@ error('Your posting privileges have been removed.'); } -Comments::edit((int)$_POST['postid'], $_POST['body']); +$SendPM = isset($_POST['pm']) && $_POST['pm']; +Comments::edit((int)$_POST['postid'], $_POST['body'], $SendPM); // This gets sent to the browser, which echoes it in place of the old body echo Text::full_format($_POST['body']); diff --git a/sections/feeds/index.php b/sections/feeds/index.php index 81a6db5b..cd43e637 100644 --- a/sections/feeds/index.php +++ b/sections/feeds/index.php @@ -81,6 +81,7 @@ SELECT b.ID, um.Username, + b.UserID, b.Title, b.Body, b.Time, @@ -93,7 +94,7 @@ $Cache->cache_value('Blog', $Blog, 1209600); } foreach ($Blog as $BlogItem) { - list($BlogID, $Author, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem; + list($BlogID, $Author, $AuthorID, $Title, $Body, $BlogTime, $ThreadID) = $BlogItem; if ($ThreadID) { echo $Feed->item($Title, Text::strip_bbcode($Body), "forums.php?action=viewthread&threadid=$ThreadID", SITE_NAME.' Staff', '', '', $BlogTime); } else { diff --git a/static/functions/comments.js b/static/functions/comments.js index 0ae51725..b309433a 100644 --- a/static/functions/comments.js +++ b/static/functions/comments.js @@ -194,6 +194,7 @@ function Save_Edit(postid) { $('#bar' + postid).raw().innerHTML = ""; $('#preview' + postid).raw().innerHTML = response; $('#editbox' + postid).ghide(); + $('#pmbox' + postid).ghide(); }); } }