mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 11:50:30 +02:00
Forum: Experimental topic/thread split feature added. (requires e_DEVELOPER to be true in e107_config.php)
This commit is contained in:
@@ -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-]*)/?\??(.*)',
|
||||
|
@@ -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()
|
||||
{
|
||||
|
@@ -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("<div class='row-fluid'><div>{FORUM_POST_BREADCRUMB}</div></div>",true,$sc);
|
||||
|
||||
|
||||
|
||||
$text .= e107::getMessage()->setTitle("Warning!",E_MESSAGE_ERROR)->addError("This post, and every post below it will be moved into a new thread/topic.")->render();
|
||||
|
||||
$text .= "
|
||||
<form class='forum-horizontal' method='post' action='".e_REQUEST_URI."'>
|
||||
<div>
|
||||
<table class='table table-striped'>
|
||||
<tr><td>".LAN_FORUM_3050."</td>
|
||||
<td><div class='alert alert-warning' style='margin:0'>".$tp->toHTML($this->data['post_entry'], true)."</div></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>".LAN_FORUM_3051.": </td>
|
||||
<td>".$this->forumSelect('forum_split',$this->data['forum_id'], 'required=1')."
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td >".LAN_FORUM_3042."</td>
|
||||
<td>
|
||||
|
||||
".$frm->text('new_thread_title', $tp->toForm($this->data['thread_name'], 250))."
|
||||
|
||||
</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class='center'>
|
||||
<input class='btn btn-primary button' type='submit' name='split_thread' value=\"".LAN_FORUM_3052."\" />
|
||||
<a class='btn btn-default button' href='".e_REFERER_SELF."' >".LAN_CANCEL."</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>";
|
||||
|
||||
|
||||
$ns->tablerender(LAN_FORUM_3052, $text);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render a drop-down list of forums.
|
||||
* @param $name
|
||||
* @param mixed $curVal
|
||||
* @param string|array $opts
|
||||
* @return string
|
||||
*/
|
||||
private function forumSelect($name, $curVal=null, $opts=null)
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
|
||||
$qry = "
|
||||
SELECT f.forum_id, f.forum_name, fp.forum_name AS forum_parent, sp.forum_name AS sub_parent
|
||||
FROM `#forum` AS f
|
||||
@@ -674,7 +749,6 @@ class forum_post_handler
|
||||
|
||||
$fList = $sql->retrieve($qry,true);
|
||||
|
||||
|
||||
$opts = array();
|
||||
$currentName = "";
|
||||
|
||||
@@ -700,6 +774,25 @@ class forum_post_handler
|
||||
}
|
||||
|
||||
|
||||
return e107::getForm()->select($name, $opts, $curVal, $opts, $currentName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render Move Form.
|
||||
*/
|
||||
private function renderFormMove()
|
||||
{
|
||||
if(!deftrue('MODERATOR'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$frm = e107::getForm();
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
|
||||
|
||||
$text = "
|
||||
<form class='forum-horizontal' method='post' action='".e_REQUEST_URI."'>
|
||||
<div>
|
||||
@@ -715,7 +808,7 @@ class forum_post_handler
|
||||
|
||||
<tr>
|
||||
<td>".LAN_FORUM_5019.": </td>
|
||||
<td>".$frm->select('forum_move', $opts, $this->data['forum_id'], 'required=1', $currentName)."
|
||||
<td>".$this->forumSelect('forum_move', $this->data['forum_id'], 'required=1')."
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1171,12 +1264,12 @@ class forum_post_handler
|
||||
}
|
||||
|
||||
|
||||
function moveThread($posted)
|
||||
private function moveThread($posted)
|
||||
{
|
||||
|
||||
if(!deftrue('MODERATOR'))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
@@ -1215,6 +1308,73 @@ class forum_post_handler
|
||||
|
||||
|
||||
|
||||
function splitThread($post)
|
||||
{
|
||||
if(!deftrue('MODERATOR'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$threadInfo = array();
|
||||
$threadInfo['thread_sticky'] = 0;
|
||||
$threadInfo['thread_name'] = $post['new_thread_title'];
|
||||
$threadInfo['thread_forum_id'] = (!empty($post['forum_split'])) ? intval($post['forum_split']) : $this->data['post_forum'];
|
||||
$threadInfo['thread_active'] = 1;
|
||||
$threadInfo['thread_datestamp'] = $this->data['post_datestamp'];
|
||||
$threadInfo['thread_views'] = 0;
|
||||
$threadInfo['thread_user'] = $this->data['post_user'];
|
||||
|
||||
|
||||
print_a($this->data);
|
||||
|
||||
if($ret = $this->forumObj->threadAdd($threadInfo, false))
|
||||
{
|
||||
e107::getMessage()->addSuccess("Created new thread #".$ret['threadid']);
|
||||
$update = array(
|
||||
'post_thread' => $ret['threadid'],
|
||||
'post_forum' => $threadInfo['thread_forum_id'],
|
||||
'WHERE' => "post_thread = ".$this->data['post_thread']." AND post_id >= ".$this->data['post_id']
|
||||
|
||||
);
|
||||
|
||||
if($result = e107::getDb()->update('forum_post', $update))
|
||||
{
|
||||
|
||||
e107::getMessage()->addSuccess("Moved ".$result." posts to topic #". $ret['threadid']);
|
||||
|
||||
|
||||
// Update old thread.
|
||||
|
||||
if(!$this->forumObj->threadUpdateCounts($this->data['post_thread']))
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't update thread replies for original topic #". $this->data['post_thread']);
|
||||
}
|
||||
|
||||
if(!$this->forumObj->forumUpdateLastpost('thread',$this->data['post_thread']))
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't update last post user for original topic #". $this->data['post_thread']);
|
||||
|
||||
}
|
||||
|
||||
// Update new thread.
|
||||
|
||||
if(!$this->forumObj->threadUpdateCounts($ret['threadid']))
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't update thread replies for #". $ret['threadid']);
|
||||
}
|
||||
|
||||
if(!$this->forumObj->forumUpdateLastpost('thread',$ret['threadid']))
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't update last post user for #". $ret['threadid']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updateThread()
|
||||
{
|
||||
|
@@ -883,6 +883,7 @@ function fadminoptions($thread_info)
|
||||
//FIXME - not fully working.
|
||||
|
||||
$moveUrl = e107::url('forum','move', $thread_info);
|
||||
$splitUrl = e107::url('forum','split', $thread_info);
|
||||
|
||||
$lockUnlock = ($thread_info['thread_active'] ) ? 'lock' : 'unlock';
|
||||
$stickUnstick = ($thread_info['thread_sticky'] == 1) ? 'unstick' : 'stick';
|
||||
@@ -904,6 +905,12 @@ function fadminoptions($thread_info)
|
||||
|
||||
$text .= "<li class='text-right'><a href='{$moveUrl}'>Move ".$tp->toGlyph('move')."</i></a></li>";
|
||||
|
||||
if(e_DEVELOPER)
|
||||
{
|
||||
// $text .= "<li class='text-right'><a href='{$splitUrl}'>Split ".$tp->toGlyph('scissors')."</i></a></li>";
|
||||
// print_a($thread_info);
|
||||
}
|
||||
|
||||
/*
|
||||
$text .= "<li><input type='image' ".IMAGE_admin_delete." name='deleteThread_{$threadId}' value='thread_action' onclick=\"return confirm_({$threadId})\" /> Delete</li>";
|
||||
|
||||
|
@@ -219,6 +219,7 @@ define("LAN_FORUM_3038", "Normal"); // LAN_1
|
||||
define("LAN_FORUM_3039", "Deactivate emoticons for this post"); // LAN_FORUMPOST_EMOTES
|
||||
define("LAN_FORUM_3040", "Enable/disable email tracking (email sent when reply is posted)"); // LAN_380
|
||||
define("LAN_FORUM_3041", "Enable/disable tracking of this topic");
|
||||
define("LAN_FORUM_3042", "New Topic/Subject");
|
||||
// missing 41-21
|
||||
|
||||
// forum_posted_template
|
||||
@@ -229,7 +230,9 @@ define("LAN_FORUM_3046", "Click here to view your poll"); // LAN_414
|
||||
define("LAN_FORUM_3047", "Your message has been successfully posted."); // LAN_324
|
||||
define("LAN_FORUM_3048", "Click here to view your message"); // LAN_325
|
||||
define("LAN_FORUM_3049", "Your reply has been successfully posted."); // LAN_415
|
||||
|
||||
define("LAN_FORUM_3050", "Split point");
|
||||
define("LAN_FORUM_3051", "New location");
|
||||
define("LAN_FORUM_3052", "Split Thread");
|
||||
|
||||
|
||||
// forum_icons_template
|
||||
|
@@ -604,9 +604,9 @@ class plugin_forum_view_shortcodes extends e_shortcode
|
||||
$url = e107::url('forum','move', array('thread_id'=>$this->postInfo['post_thread']));
|
||||
$text .= "<li class='text-right'><a href='" . $url."'>".LAN_FORUM_2042." ".$tp->toGlyph('move')."</a></a></li>";
|
||||
}
|
||||
else //TODO
|
||||
elseif(e_DEVELOPER ===true) //TODO
|
||||
{
|
||||
// $text .= "<li class='text-right'><a href='" . e107::getUrl()->create('forum/thread/split', array('id' => $this->postInfo['post_id'], 'post'=>$this->postInfo['post_id']))."'>".LAN_FORUM_2043." ".$tp->toGlyph('cut')."</a></li>";
|
||||
$text .= "<li class='text-right'><a href='" . e107::url('forum','split', array('thread_id'=>$this->postInfo['post_thread'], 'post_id' => $this->postInfo['post_id']))."'>".LAN_FORUM_2043." ".$tp->toGlyph('cut')."</a></li>";
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -331,7 +331,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['thread'] = "
|
||||
<li id='post-{POSTID}' class='forum-viewtopic-post'>
|
||||
<div class='hidden-xs row row-fluid btn-navbar navbar-btn'>
|
||||
|
||||
{SETIMAGE: w=100&h=0&crop=0}
|
||||
{SETIMAGE: w=100&h=100&crop=1}
|
||||
<div class='col-xs-2 span2 left text-left'>
|
||||
<div class='row'>
|
||||
<div class='col-xs-12 col-md-12 forum-user-combo'>{USERCOMBO}<br />{CUSTOMTITLE}</div>
|
||||
|
Reference in New Issue
Block a user