diff --git a/e107_plugins/forum/e_url.php b/e107_plugins/forum/e_url.php index 2e6702acd..70554b95d 100644 --- a/e107_plugins/forum/e_url.php +++ b/e107_plugins/forum/e_url.php @@ -54,6 +54,10 @@ class forum_url // plugin-folder + '_url' 'sef' => 'forum/post/?f=move&id={thread_id}', ); + $config['split'] = array( + 'sef' => 'forum/post/?f=split&id={thread_id}&post={post_id}', + ); + $config['topic'] = array( 'regex' => 'forum\/([^\/]*)\/([\d]*)(?:\/|-)([\w-]*)/?\??(.*)', // 'regex' => '^forum/(.*)/(\d*)(?:-|/)([\w-]*)/?\??(.*)', diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index a9d3a8a7a..3b19c3530 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -825,12 +825,18 @@ class e107forum if($newThreadId = e107::getDb()->insert('forum_thread', $info)) { - - $postInfo['post_thread'] = $newThreadId; - - if(!$newPostId = $this->postAdd($postInfo, false)) + if($postInfo !== false) { - e107::getMessage()->addDebug("There was a problem: ".print_a($postInfo,true)); + $postInfo['post_thread'] = $newThreadId; + + if(!$newPostId = $this->postAdd($postInfo, false)) + { + e107::getMessage()->addDebug("There was a problem: ".print_a($postInfo,true)); + } + } + else + { + $newPostId = 0; } $this->threadMarkAsRead($newThreadId); @@ -1020,7 +1026,8 @@ class e107forum LIMIT {$start}, {$num} "; } - if($sql->gen($qry)) + + if($sql->gen($qry)!==false) { $ret = array(); while($row = $sql->fetch()) @@ -1269,7 +1276,9 @@ class e107forum $sql = e107::getDb(); $tp = e107::getParser(); - $sql2 = new db; + $sql2 = e107::getDb('sql2'); + + if ($type == 'thread') { $id = (int)$id; @@ -1285,15 +1294,20 @@ class e107forum $tmp['thread_lastuser'] = 0; $tmp['thread_lastuser_anon'] = ($lpInfo['post_user_anon'] ? $lpInfo['post_user_anon'] : 'Anonymous'); } + $tmp['thread_lastpost'] = $lpInfo['post_datestamp']; $info = array(); $info['data'] = $tmp; // $info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread']; $info['WHERE'] = 'thread_id = '.$id; + $sql->update('forum_thread', $info); return $lpInfo; } + + + if ($type == 'forum') { if ($id == 'all') @@ -2032,6 +2046,22 @@ class e107forum } + /** + * @param $threadID + * @return int + */ + function threadUpdateCounts($threadID) + { + $sql = e107::getDb(); + + $replies = $sql->count('forum_post', '(*)', 'WHERE post_thread='.$threadID); + + return $sql->update('forum_thread', "thread_total_replies={$replies} WHERE thread_id=".$threadID); + + } + + + function getUserCounts() { diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 8c048e5b1..49ae93e4d 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -71,8 +71,13 @@ class forum_post_handler $this->data = $this->processGet(); + $this->checkPerms($this->data['forum_id']); - $this->processPosted(); + + if($this->processPosted() === false) + { + return false; + } if($this->action == 'report') { @@ -82,6 +87,10 @@ class forum_post_handler { $this->renderFormMove(); } + elseif($this->action == 'split') + { + $this->renderFormSplit(); + } else { $this->renderForm(); @@ -141,6 +150,7 @@ class forum_post_handler case 'edit': case "quote": case "report": + case 'split': $postInfo = $this->forumObj->postGet($this->post, 'post'); $forumInfo = $this->forumObj->forumGet($postInfo['post_forum']); $data = array_merge($postInfo ,$forumInfo); @@ -193,6 +203,12 @@ class forum_post_handler $this->moveThread($_POST); } + if(!empty($_POST['split_thread'])) + { + $this->splitThread($_POST); + return false; + } + if(isset($_POST['update_reply'])) { $this->updateReply(); @@ -213,7 +229,7 @@ class forum_post_handler $this->submitReport(); } - + return true; } @@ -650,7 +666,7 @@ class forum_post_handler } - function renderFormMove() + private function renderFormSplit() { if(!deftrue('MODERATOR')) { @@ -663,6 +679,65 @@ class forum_post_handler $tp = e107::getParser(); $ns = e107::getRender(); + $sc = e107::getScBatch('post', 'forum')->setScVar('forum', $this->forumObj)->setScVar('threadInfo', vartrue($this->data))->setVars($this->data); + $text = $tp->parseTemplate("