Skip to content

Commit

Permalink
Merge pull request #3 from mambax7/master
Browse files Browse the repository at this point in the history
more PSR-2
  • Loading branch information
mambax7 committed Mar 30, 2015
2 parents ec4730c + 43caf54 commit 85ea101
Show file tree
Hide file tree
Showing 92 changed files with 1,997 additions and 2,019 deletions.
70 changes: 35 additions & 35 deletions newbb/action.post.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
redirect_header($_SERVER['HTTP_REFERER'], 2, _MD_NORIGHTTOACCESS);
}

$post_handler =& xoops_getmodulehandler('post', 'newbb');
$topic_handler =& xoops_getmodulehandler('topic', 'newbb');
$forum_handler =& xoops_getmodulehandler('forum', 'newbb');
$postHandler =& xoops_getmodulehandler('post', 'newbb');
$topicHandler =& xoops_getmodulehandler('topic', 'newbb');
$forumHandler =& xoops_getmodulehandler('forum', 'newbb');
if (empty($topic_id)) {
$forum_obj = null;
} else {
$topic_obj =& $topic_handler->get($topic_id);
$topic_obj =& $topicHandler->get($topic_id);
$forum_id = $topic_obj->getVar('forum_id');
$forum_obj =& $forum_handler->get($forum_id);
$forum_obj =& $forumHandler->get($forum_id);
}
$isadmin = newbb_isAdmin($forum_obj);

Expand All @@ -47,20 +47,20 @@
$topics = array();
$forums = array();
foreach ($post_id as $post) {
$post_obj =& $post_handler->get($post);
$post_obj =& $postHandler->get($post);
if ($post_obj->getVar("topic_id") < 1) {
continue;
}
$post_handler->approve($post_obj, true);
$postHandler->approve($post_obj, true);
$topics[$post_obj->getVar("topic_id")] = 1;
$forums[$post_obj->getVar("forum_id")] = 1;
unset($post_obj);
}
foreach (array_keys($topics) as $topic) {
$topic_handler->synchronization($topic);
$topicHandler->synchronization($topic);
}
foreach (array_keys($forums) as $forum) {
$forum_handler->synchronization($forum);
$forumHandler->synchronization($forum);
}
break;
case "approve":
Expand All @@ -69,32 +69,32 @@
$topics = array();
$forums = array();
$criteria = new Criteria("post_id", "(" . implode(",", $post_id) . ")", "IN");
$posts_obj =& $post_handler->getObjects($criteria, true);
$posts_obj =& $postHandler->getObjects($criteria, true);
foreach ($post_id as $post) {
$post_obj =& $posts_obj[$post];
if (!empty($topic_id) && $topic_id != $post_obj->getVar("topic_id")) {
continue;
}
$post_handler->approve($post_obj);
$postHandler->approve($post_obj);
$topics[$post_obj->getVar("topic_id")] = $post;
$forums[$post_obj->getVar("forum_id")] = 1;
}
foreach (array_keys($topics) as $topic) {
$topic_handler->synchronization($topic);
$topicHandler->synchronization($topic);
}
foreach (array_keys($forums) as $forum) {
$forum_handler->synchronization($forum);
$forumHandler->synchronization($forum);
}

if (empty($xoopsModuleConfig['notification_enabled'])) {
if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) {
break;
}

$criteria_topic = new Criteria("topic_id", "(" . implode(",", array_keys($topics)) . ")", "IN");
$topic_list =& $topic_handler->getList($criteria_topic, true);
$topic_list =& $topicHandler->getList($criteria_topic, true);

$criteria_forum = new Criteria("forum_id", "(" . implode(",", array_keys($forums)) . ")", "IN");
$forum_list =& $forum_handler->getList($criteria_forum);
$forum_list =& $forumHandler->getList($criteria_forum);

include_once 'include/notification.inc.php';
$notification_handler =& xoops_gethandler('notification');
Expand All @@ -120,70 +120,70 @@
$topics = array();
$forums = array();
foreach ($post_id as $post) {
$post_obj =& $post_handler->get($post);
$post_obj =& $postHandler->get($post);
if (!empty($topic_id) && $topic_id != $post_obj->getVar("topic_id")) {
continue;
}
$topics[$post_obj->getVar("topic_id")] = 1;
$forums[$post_obj->getVar("forum_id")] = 1;
$post_handler->delete($post_obj, true);
$postHandler->delete($post_obj, true);
unset($post_obj);
}
foreach (array_keys($topics) as $topic) {
$topic_handler->synchronization($topic);
$topicHandler->synchronization($topic);
}
foreach (array_keys($forums) as $forum) {
$forum_handler->synchronization($forum);
$forumHandler->synchronization($forum);
}
break;
case "split":
$post_obj =& $post_handler->get($post_id);
$post_obj =& $postHandler->get($post_id);
if (empty($post_id) || $post_obj->isTopic()) {
break;
}
$topic_id = $post_obj->getVar("topic_id");

$newtopic =& $topic_handler->create();
$newtopic =& $topicHandler->create();
$newtopic->setVar("topic_title", $post_obj->getVar("subject"), true);
$newtopic->setVar("topic_poster", $post_obj->getVar("uid"), true);
$newtopic->setVar("forum_id", $post_obj->getVar("forum_id"), true);
$newtopic->setVar("topic_time", $post_obj->getVar("post_time"), true);
$newtopic->setVar("poster_name", $post_obj->getVar("poster_name"), true);
$newtopic->setVar("approved", 1, true);
$topic_handler->insert($newtopic, true);
$topicHandler->insert($newtopic, true);
$new_topic_id = $newtopic->getVar('topic_id');

$pid = $post_obj->getVar("pid");

$post_obj->setVar("topic_id", $new_topic_id, true);
$post_obj->setVar("pid", 0, true);
$post_handler->insert($post_obj);
$postHandler->insert($post_obj);

/* split a single post */
if ($mode == 1) {
$criteria = new CriteriaCompo(new Criteria("topic_id", $topic_id));
$criteria->add(new Criteria('pid', $post_id));
$post_handler->updateAll("pid", $pid, $criteria, true);
$postHandler->updateAll("pid", $pid, $criteria, true);
/* split a post and its children posts */
} elseif ($mode == 2) {
include_once $GLOBALS['xoops']->path('class/xoopstree.php');
$mytree = new XoopsTree($xoopsDB->prefix("bb_posts"), "post_id", "pid");
$mytree = new XoopsTree($GLOBALS['xoopsDB']->prefix("bb_posts"), "post_id", "pid");
$posts = $mytree->getAllChildId($post_id);
if (count($posts) > 0) {
$criteria = new Criteria('post_id', "(" . implode(",", $posts) . ")", "IN");
$post_handler->updateAll("topic_id", $new_topic_id, $criteria, true);
$postHandler->updateAll("topic_id", $new_topic_id, $criteria, true);
}
/* split a post and all posts coming after */
} elseif ($mode == 3) {
$criteria = new CriteriaCompo(new Criteria("topic_id", $topic_id));
$criteria->add(new Criteria('post_id', $post_id, ">"));
$post_handler->updateAll("topic_id", $new_topic_id, $criteria, true);
$postHandler->updateAll("topic_id", $new_topic_id, $criteria, true);

unset($criteria);
$criteria = new CriteriaCompo(new Criteria("topic_id", $new_topic_id));
$criteria->add(new Criteria('post_id', $post_id, ">"));
$post_handler->identifierName = "pid";
$posts = $post_handler->getList($criteria);
$postHandler->identifierName = "pid";
$posts = $postHandler->getList($criteria);

unset($criteria);
$post_update = array();
Expand All @@ -194,15 +194,15 @@
}
if (count($post_update)) {
$criteria = new Criteria('post_id', "(" . implode(",", $post_update) . ")", "IN");
$post_handler->updateAll("pid", $post_id, $criteria, true);
$postHandler->updateAll("pid", $post_id, $criteria, true);
}
}

$forum_id = $post_obj->getVar("forum_id");
$topic_handler->synchronization($topic_id);
$topic_handler->synchronization($new_topic_id);
$sql = sprintf("UPDATE %s SET forum_topics = forum_topics+1 WHERE forum_id = %u", $xoopsDB->prefix("bb_forums"), $forum_id);
$result = $xoopsDB->queryF($sql);
$topicHandler->synchronization($topic_id);
$topicHandler->synchronization($new_topic_id);
$sql = sprintf("UPDATE %s SET forum_topics = forum_topics+1 WHERE forum_id = %u", $GLOBALS['xoopsDB']->prefix("bb_forums"), $forum_id);
$result = $GLOBALS['xoopsDB']->queryF($sql);

break;
}
Expand Down
60 changes: 30 additions & 30 deletions newbb/action.topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}

$topic_id = array_values($topic_id);
$topic_handler =& xoops_getmodulehandler('topic', 'newbb');
$forum_handler =& xoops_getmodulehandler('forum', 'newbb');
$topicHandler =& xoops_getmodulehandler('topic', 'newbb');
$forumHandler =& xoops_getmodulehandler('forum', 'newbb');

$isadmin = newbb_isAdmin($forum_id);

Expand All @@ -34,37 +34,37 @@
switch ($op) {
case "restore":
$forums = array();
$topics_obj =& $topic_handler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
$topics_obj =& $topicHandler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
$topic_handler->approve($topic_obj);
$topic_handler->synchronization($topic_obj);
$topicHandler->approve($topic_obj);
$topicHandler->synchronization($topic_obj);
$forums[$topic_obj->getVar("forum_id")] = 1;
}
$criteria_forum = new Criteria("forum_id", "(" . implode(",", array_keys($forums)) . ")", "IN");
$forums_obj =& $forum_handler->getAll($criteria_forum);
$forums_obj =& $forumHandler->getAll($criteria_forum);
foreach (array_keys($forums_obj) as $id) {
$forum_handler->synchronization($forums_obj[$id]);
$forumHandler->synchronization($forums_obj[$id]);
}
unset($topics_obj, $forums_obj);
break;
case "approve":
$forums = array();
$topics_obj =& $topic_handler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
$topics_obj =& $topicHandler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
$topic_handler->approve($topic_obj);
$topic_handler->synchronization($topic_obj);
$topicHandler->approve($topic_obj);
$topicHandler->synchronization($topic_obj);
$forums[$topic_obj->getVar("forum_id")] = 1;
}

$criteria_forum = new Criteria("forum_id", "(" . implode(",", array_keys($forums)) . ")", "IN");
$forums_obj =& $forum_handler->getAll($criteria_forum);
$forums_obj =& $forumHandler->getAll($criteria_forum);
foreach (array_keys($forums_obj) as $id) {
$forum_handler->synchronization($forums_obj[$id]);
$forumHandler->synchronization($forums_obj[$id]);
}

if (empty($xoopsModuleConfig['notification_enabled'])) {
if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) {
break;
}

Expand All @@ -79,7 +79,7 @@
$tags['FORUM_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $topic_obj->getVar('forum_id');
$notification_handler->triggerEvent('global', 0, 'new_thread', $tags);
$notification_handler->triggerEvent('forum', $topic_obj->getVar('forum_id'), 'new_thread', $tags);
$post_obj =& $topic_handler->getTopPost($id);
$post_obj =& $topicHandler->getTopPost($id);
$tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_obj->getVar("post_id");
$notification_handler->triggerEvent('thread', $id, 'new_post', $tags);
$notification_handler->triggerEvent('forum', $topic_obj->getVar('forum_id'), 'new_post', $tags);
Expand All @@ -94,37 +94,37 @@
break;
case "delete":
$forums = array();
$topics_obj =& $topic_handler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
$topics_obj =& $topicHandler->getAll(new Criteria("topic_id", "(" . implode(",", $topic_id) . ")", "IN"));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
// irmtfan should be set to false to not delete topic from database
$topic_handler->delete($topic_obj, false);
$topic_handler->synchronization($topic_obj);
$topicHandler->delete($topic_obj, false);
$topicHandler->synchronization($topic_obj);
$forums[$topic_obj->getVar("forum_id")] = 1;
}

$criteria_forum = new Criteria("forum_id", "(" . implode(",", array_keys($forums)) . ")", "IN");
$forums_obj =& $forum_handler->getAll($criteria_forum);
$forums_obj =& $forumHandler->getAll($criteria_forum);
foreach (array_keys($forums_obj) as $id) {
$forum_handler->synchronization($forums_obj[$id]);
$forumHandler->synchronization($forums_obj[$id]);
}
unset($topics_obj, $forums_obj);
break;
case "move":
if (XoopsRequest::getInt('newforum', 0, 'POST') && XoopsRequest::getInt('newforum', 0, 'POST') != $forum_id
&& $forum_handler->getPermission(XoopsRequest::getInt('newforum', 0, 'POST'), 'post')
&& $forumHandler->getPermission(XoopsRequest::getInt('newforum', 0, 'POST'), 'post')
) {
$criteria = new Criteria('topic_id', "(" . implode(",", $topic_id) . ")", "IN");
$post_handler =& xoops_getmodulehandler('post', 'newbb');
$post_handler->updateAll("forum_id", XoopsRequest::getInt('newforum', 0, 'POST'), $criteria, true);
$topic_handler->updateAll("forum_id", XoopsRequest::getInt('newforum', 0, 'POST'), $criteria, true);
$forum_handler->synchronization(XoopsRequest::getInt('newforum', 0, 'POST'));
$forum_handler->synchronization($forum_id);
$postHandler =& xoops_getmodulehandler('post', 'newbb');
$postHandler->updateAll("forum_id", XoopsRequest::getInt('newforum', 0, 'POST'), $criteria, true);
$topicHandler->updateAll("forum_id", XoopsRequest::getInt('newforum', 0, 'POST'), $criteria, true);
$forumHandler->synchronization(XoopsRequest::getInt('newforum', 0, 'POST'));
$forumHandler->synchronization($forum_id);
} else {
include $GLOBALS['xoops']->path('header.php');
$category_handler =& xoops_getmodulehandler('category', 'newbb');
$categories = $category_handler->getByPermission('access');
$forums = $forum_handler->getForumsByCategory(array_keys($categories), 'post', false);
$categoryHandler =& xoops_getmodulehandler('category', 'newbb');
$categories = $categoryHandler->getByPermission('access');
$forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false);

$box = '<select name="newforum" size="1">';
if (count($categories) > 0 && count($forums) > 0) {
Expand Down Expand Up @@ -167,8 +167,8 @@
}
break;
}
$stats_handler = xoops_getmodulehandler('stats', 'newbb');
$stats_handler->reset();
$statsHandler = xoops_getmodulehandler('stats', 'newbb');
$statsHandler->reset();
if (empty($forum_id)) {
redirect_header(XOOPS_URL . "/modules/newbb/list.topic.php", 2, _MD_DBUPDATED);
} else {
Expand Down
Loading

0 comments on commit 85ea101

Please sign in to comment.