Skip to content

Commit

Permalink
Merge pull request #55 from mambax7/master
Browse files Browse the repository at this point in the history
4.33 Final
  • Loading branch information
mambax7 authored Mar 25, 2018
2 parents b6319e8 + 680272f commit c0603bc
Show file tree
Hide file tree
Showing 131 changed files with 1,358 additions and 1,347 deletions.
24 changes: 12 additions & 12 deletions action.post.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$uid = XoopsRequest::getInt('uid', 0, 'GET');

$op = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET');
$op = in_array($op, array('approve', 'delete', 'restore', 'split'), true) ? $op : '';
$op = in_array($op, ['approve', 'delete', 'restore', 'split'], true) ? $op : '';
$mode = XoopsRequest::getInt('mode', 1, 'GET');

if (0 === count($post_id) || 0 === count($op)) {
Expand Down Expand Up @@ -43,8 +43,8 @@
case 'restore':
$post_id = array_values($post_id);
sort($post_id);
$topics = array();
$forums = array();
$topics = [];
$forums = [];
foreach ($post_id as $post) {
$post_obj = $postHandler->get($post);
if ($post_obj->getVar('topic_id') < 1) {
Expand All @@ -65,8 +65,8 @@
case 'approve':
$post_id = array_values($post_id);
sort($post_id);
$topics = array();
$forums = array();
$topics = [];
$forums = [];
$criteria = new Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN');
$posts_obj = $postHandler->getObjects($criteria, true);
foreach ($post_id as $post) {
Expand Down Expand Up @@ -98,7 +98,7 @@
include_once __DIR__ . '/include/notification.inc.php';
$notificationHandler = xoops_getHandler('notification');
foreach ($post_id as $post) {
$tags = array();
$tags = [];
$tags['THREAD_NAME'] = $topic_list[$posts_obj[$post]->getVar('topic_id')];
$tags['THREAD_URL'] = XOOPS_URL
. '/modules/'
Expand All @@ -122,8 +122,8 @@
case 'delete':
$post_id = array_values($post_id);
rsort($post_id);
$topics = array();
$forums = array();
$topics = [];
$forums = [];
foreach ($post_id as $post) {
$post_obj = $postHandler->get($post);
if (!empty($topic_id) && $topic_id !== $post_obj->getVar('topic_id')) {
Expand Down Expand Up @@ -165,12 +165,12 @@
$postHandler->insert($post_obj);

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

unset($criteria);
$post_update = array();
$post_update = [];
foreach ($posts as $postid => $pid) {
// if (!in_array($pid, array_keys($posts))) {
if (!array_key_exists($pid, $posts)) {
Expand Down
10 changes: 5 additions & 5 deletions action.topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$topic_id = XoopsRequest::getArray('topic_id', null, 'POST');

$op = XoopsRequest::getCmd('op', '', 'POST');
$op = in_array($op, array('approve', 'delete', 'restore', 'move'), true) ? $op : '';
$op = in_array($op, ['approve', 'delete', 'restore', 'move'], true) ? $op : '';

if (0 === count($topic_id) || 0 === count($op)) {
// irmtfan - issue with javascript:history.go(-1)
Expand All @@ -32,7 +32,7 @@
}
switch ($op) {
case 'restore':
$forums = array();
$forums = [];
$topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
Expand All @@ -48,7 +48,7 @@
unset($topics_obj, $forums_obj);
break;
case 'approve':
$forums = array();
$forums = [];
$topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
Expand All @@ -71,7 +71,7 @@
$notificationHandler = xoops_getHandler('notification');
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
$tags = array();
$tags = [];
$tags['THREAD_NAME'] = $topic_obj->getVar('topic_title');
$tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $id . '&amp;forum=' . $topic_obj->getVar('forum_id');
$tags['FORUM_NAME'] = $forums_obj[$topic_obj->getVar('forum_id')]->getVar('forum_name');
Expand All @@ -92,7 +92,7 @@
unset($topics_obj, $forums_obj);
break;
case 'delete':
$forums = array();
$forums = [];
$topics_obj = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
foreach (array_keys($topics_obj) as $id) {
$topic_obj =& $topics_obj[$id];
Expand Down
8 changes: 4 additions & 4 deletions admin/admin_cat_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function editCategory(XoopsObject $category_obj = null)

case 'del':
if (!XoopsRequest::getBool('confirm', '', 'POST')) {
xoops_confirm(array('op' => 'del', 'cat_id' => XoopsRequest::getInt('cat_id', 0, 'GET'), 'confirm' => 1), 'admin_cat_manager.php', _AM_NEWBB_WAYSYWTDTTAL);
xoops_confirm(['op' => 'del', 'cat_id' => XoopsRequest::getInt('cat_id', 0, 'GET'), 'confirm' => 1], 'admin_cat_manager.php', _AM_NEWBB_WAYSYWTDTTAL);
break;
} else {
$category_obj = $categoryHandler->create(false);
Expand Down Expand Up @@ -184,9 +184,9 @@ function editCategory(XoopsObject $category_obj = null)
echo '</tr>';

foreach ($categories as $key => $onecat) {
$cat_edit_link = "<a href=\"admin_cat_manager.php?op=mod&cat_id=" . $onecat->getVar('cat_id') . "\">" . newbbDisplayImage('admin_edit', _EDIT) . '</a>';
$cat_del_link = "<a href=\"admin_cat_manager.php?op=del&cat_id=" . $onecat->getVar('cat_id') . "\">" . newbbDisplayImage('admin_delete', _DELETE) . '</a>';
$cat_title_link = "<a href=\"" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php?cat=' . $onecat->getVar('cat_id') . "\">" . $onecat->getVar('cat_title') . '</a>';
$cat_edit_link = '<a href="admin_cat_manager.php?op=mod&cat_id=' . $onecat->getVar('cat_id') . '">' . newbbDisplayImage('admin_edit', _EDIT) . '</a>';
$cat_del_link = '<a href="admin_cat_manager.php?op=del&cat_id=' . $onecat->getVar('cat_id') . '">' . newbbDisplayImage('admin_delete', _DELETE) . '</a>';
$cat_title_link = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php?cat=' . $onecat->getVar('cat_id') . '">' . $onecat->getVar('cat_title') . '</a>';

echo "<tr class='odd' align='left'>";
echo '<td>' . $cat_title_link . '</td>';
Expand Down
4 changes: 2 additions & 2 deletions admin/admin_digest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
case 'delete':
$digest_ids = XoopsRequest::getArray('digest_id', '', 'POST');
$digestHandler = xoops_getModuleHandler('digest', 'newbb');
if ($digest_ids !== '') {
if ('' !== $digest_ids) {
foreach ($digest_ids as $did => $value) {
$digestHandler->delete($did);
}
Expand All @@ -66,7 +66,7 @@
echo "<td class='bg3' width='2%'>" . _DELETE . '</td>';
echo '</tr>';

$digests = array();
$digests = [];
$digestHandler = xoops_getModuleHandler('digest', 'newbb');
$digests = $digestHandler->getAllDigests($start, $limit);
foreach ($digests as $digest) {
Expand Down
30 changes: 15 additions & 15 deletions admin/admin_forum_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
if (XoopsRequest::getInt('dest_forum', 0, 'POST')) {
$dest = XoopsRequest::getInt('dest_forum', 0, 'POST');
if ($dest > 0) {
$pid = (int)$dest;
$pid = $dest;
$forum_dest = $forumHandler->get($pid);
$cid = $forum_dest->getVar('cat_id');
unset($forum_dest);
} else {
$cid = abs((int)$dest);
$cid = abs($dest);
$pid = 0;
}
$forum_obj = $forumHandler->get($forum_id);
Expand Down Expand Up @@ -152,13 +152,13 @@
$forum_obj->setVar('forum_name', XoopsRequest::getString('forum_name', '', 'POST'));
$forum_obj->setVar('forum_desc', XoopsRequest::getString('forum_desc', '', 'POST'));
$forum_obj->setVar('forum_order', XoopsRequest::getInt('forum_order', 0, 'POST'));
$forum_obj->setVar('forum_moderator', XoopsRequest::getArray('forum_moderator', array(), 'POST'));
$forum_obj->setVar('forum_moderator', XoopsRequest::getArray('forum_moderator', [], 'POST'));
$forum_obj->setVar('parent_forum', XoopsRequest::getInt('parent_forum', 0, 'POST'));
$forum_obj->setVar('attach_maxkb', XoopsRequest::getInt('attach_maxkb', 0, 'POST'));
$forum_obj->setVar('attach_ext', XoopsRequest::getString('attach_ext', '', 'POST'));
$forum_obj->setVar('hot_threshold', XoopsRequest::getInt('hot_threshold', 0, 'POST'));
if (XoopsRequest::getInt('parent_forum', 0, 'POST')) {
$parent_obj = $forumHandler->get(XoopsRequest::getInt('parent_forum', 0, 'POST'), array('cat_id'));
$parent_obj = $forumHandler->get(XoopsRequest::getInt('parent_forum', 0, 'POST'), ['cat_id']);
$_POST['cat_id'] = $parent_obj->getVar('cat_id');
}
$forum_obj->setVar('cat_id', XoopsRequest::getInt('cat_id', 0, 'POST'));
Expand Down Expand Up @@ -202,7 +202,7 @@

case 'del':
if (1 !== XoopsRequest::getInt('confirm', 0, 'POST')) {
xoops_confirm(array('op' => 'del', 'forum' => XoopsRequest::getInt('forum', 0, 'GET'), 'confirm' => 1), 'admin_forum_manager.php', _AM_NEWBB_TWDAFAP);
xoops_confirm(['op' => 'del', 'forum' => XoopsRequest::getInt('forum', 0, 'GET'), 'confirm' => 1], 'admin_forum_manager.php', _AM_NEWBB_TWDAFAP);
break;
} else {
$forum_obj = $forumHandler->get(XoopsRequest::getInt('forum', 0, 'POST'));
Expand Down Expand Up @@ -261,10 +261,10 @@
foreach (array_keys($categories) as $c) {
$category = $categories[$c];
$cat_id = $c;
$cat_link = "<a href=\"" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?viewcat=' . $cat_id . "\">" . $category . '</a>';
$cat_edit_link = "<a href=\"admin_cat_manager.php?op=mod&amp;cat_id=" . $cat_id . "\">" . newbbDisplayImage('admin_edit', _EDIT) . '</a>';
$cat_del_link = "<a href=\"admin_cat_manager.php?op=del&amp;cat_id=" . $cat_id . "\">" . newbbDisplayImage('admin_delete', _DELETE) . '</a>';
$forum_add_link = "<a href=\"admin_forum_manager.php?op=addforum&amp;cat_id=" . $cat_id . "\">" . newbbDisplayImage('new_forum') . '</a>';
$cat_link = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?viewcat=' . $cat_id . '">' . $category . '</a>';
$cat_edit_link = '<a href="admin_cat_manager.php?op=mod&amp;cat_id=' . $cat_id . '">' . newbbDisplayImage('admin_edit', _EDIT) . '</a>';
$cat_del_link = '<a href="admin_cat_manager.php?op=del&amp;cat_id=' . $cat_id . '">' . newbbDisplayImage('admin_delete', _DELETE) . '</a>';
$forum_add_link = '<a href="admin_forum_manager.php?op=addforum&amp;cat_id=' . $cat_id . '">' . newbbDisplayImage('new_forum') . '</a>';
$echo .= "<tr class='even' align='left'>";
$echo .= "<td width='100%' colspan='2'><strong>" . $cat_link . '</strong></td>';
$echo .= "<td align='center'>" . $cat_edit_link . '</td>';
Expand All @@ -279,12 +279,12 @@
$i = 0;
foreach (array_keys($forums[$c]) as $f) {
$forum = $forums[$c][$f];
$f_link = $forum['prefix'] . "<a href=\"" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewforum.php?forum=' . $f . "\">" . $forum['forum_name'] . '</a>';
$f_edit_link = "<a href=\"admin_forum_manager.php?op=mod&amp;forum=" . $f . "\">" . newbbDisplayImage('admin_edit', _AM_NEWBB_EDIT) . '</a>';
$f_del_link = "<a href=\"admin_forum_manager.php?op=del&amp;forum=" . $f . "\">" . newbbDisplayImage('admin_delete', _AM_NEWBB_DELETE) . '</a>';
$sf_add_link = "<a href=\"admin_forum_manager.php?op=addforum&amp;cat_id=" . $c . '&forum=' . $f . "\">" . newbbDisplayImage('new_forum', _AM_NEWBB_CREATEFORUM) . '</a>';
$f_move_link = "<a href=\"admin_forum_manager.php?op=moveforum&amp;forum=" . $f . "\">" . newbbDisplayImage('admin_move', _AM_NEWBB_MOVE) . '</a>';
$f_merge_link = "<a href=\"admin_forum_manager.php?op=mergeforum&amp;forum=" . $f . "\">" . newbbDisplayImage('admin_merge', _AM_NEWBB_MERGE) . '</a>';
$f_link = $forum['prefix'] . '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewforum.php?forum=' . $f . '">' . $forum['forum_name'] . '</a>';
$f_edit_link = '<a href="admin_forum_manager.php?op=mod&amp;forum=' . $f . '">' . newbbDisplayImage('admin_edit', _AM_NEWBB_EDIT) . '</a>';
$f_del_link = '<a href="admin_forum_manager.php?op=del&amp;forum=' . $f . '">' . newbbDisplayImage('admin_delete', _AM_NEWBB_DELETE) . '</a>';
$sf_add_link = '<a href="admin_forum_manager.php?op=addforum&amp;cat_id=' . $c . '&forum=' . $f . '">' . newbbDisplayImage('new_forum', _AM_NEWBB_CREATEFORUM) . '</a>';
$f_move_link = '<a href="admin_forum_manager.php?op=moveforum&amp;forum=' . $f . '">' . newbbDisplayImage('admin_move', _AM_NEWBB_MOVE) . '</a>';
$f_merge_link = '<a href="admin_forum_manager.php?op=mergeforum&amp;forum=' . $f . '">' . newbbDisplayImage('admin_merge', _AM_NEWBB_MERGE) . '</a>';

$class = (($i++) % 2) ? 'odd' : 'even';
$echo .= "<tr class='" . $class . "' align='left'><td></td>";
Expand Down
22 changes: 11 additions & 11 deletions admin/admin_forum_prune.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@
if ($lock) {
$sql .= ' AND t.topic_status <> 1 ';
}
if ($hot !== 0) {
if (0 !== $hot) {
$sql .= ' AND t.topic_replies < ' . $hot . ' ';
}

$sql .= ' AND p.post_time<= ' . $prune_ddays . ' ';
// Ok now we have the sql query completed, go for topic_id's and posts_id's
$topics = array();
$topics = [];
if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
return _MD_ERROR;
}
// Dave_L code
while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
$topics[] = $row['topic_id'];
}
$topics_number = count($topics);
Expand All @@ -98,12 +98,12 @@
if ('' !== $topic_list) {
$sql = 'SELECT post_id FROM ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' WHERE topic_id IN (' . $topic_list . ')';

$posts = array();
$posts = [];
if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
return _MD_ERROR;
}
// Dave_L code
while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
$posts[] = $row['post_id'];
}
$posts_number = count($posts);
Expand All @@ -124,7 +124,7 @@
}
} else {
// ARCHIVING POSTS
if ($archive == 1) {
if (1 == $archive) {
$result = $GLOBALS['xoopsDB']->query('SELECT p.topic_id, p.post_id, t.post_text FROM '
. $GLOBALS['xoopsDB']->prefix('bb_posts')
. ' p, '
Expand Down Expand Up @@ -172,15 +172,15 @@
// $result = $GLOBALS['xoopsDB']->query();
// Days selected by selbox (better error control :lol:)
$days = new XoopsFormSelect(_AM_NEWBB_PRUNE_DAYS, 'days', null, 1, false);
$days->addOptionArray(array(
$days->addOptionArray([
604800 => _AM_NEWBB_PRUNE_WEEK,
1209600 => _AM_NEWBB_PRUNE_2WEEKS,
2592000 => _AM_NEWBB_PRUNE_MONTH,
5184000 => _AM_NEWBB_PRUNE_2MONTH,
10368000 => _AM_NEWBB_PRUNE_4MONTH,
31536000 => _AM_NEWBB_PRUNE_YEAR,
63072000 => _AM_NEWBB_PRUNE_2YEARS
));
]);
$sform->addElement($days);
// START irmtfan remove hardcode db access
include_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/footer.php'); // to include js files
Expand All @@ -202,7 +202,7 @@
do {
$checkbox->addOption($myrow['forum_id'], $myrow['forum_name']);
$radiobox->addOption($myrow['forum_id'], $myrow['forum_name']);
} while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result));
} while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result);
} else {
echo "NO FORUMS";
}
Expand Down Expand Up @@ -231,15 +231,15 @@
$sform->addElement($lock_confirmation);

$hot_confirmation = new XoopsFormSelect(_AM_NEWBB_PRUNE_HOT, 'hot', null, 1, false);
$hot_confirmation->addOptionArray(array(
$hot_confirmation->addOptionArray([
'0' => 0,
'5' => 5,
'10' => 10,
'15' => 15,
'20' => 20,
'25' => 25,
'30' => 30
));
]);
$sform->addElement($hot_confirmation);

$sform->addElement(/*$radiobox*/
Expand Down
10 changes: 5 additions & 5 deletions admin/admin_forum_reorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
redirect_header('admin_forum_reorder.php', 1, _AM_NEWBB_BOARDREORDER);
} else {
include_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/class/xoopsformloader.php');
$orders = array();
$cat_orders = array();
$forum = array();
$cat = array();
$orders = [];
$cat_orders = [];
$forum = [];
$cat = [];

xoops_cp_header();
echo '<fieldset>';
Expand All @@ -77,7 +77,7 @@
$categoryHandler = xoops_getModuleHandler('category', 'newbb');
$criteriaCategory = new CriteriaCompo(new criteria('1', 1));
$criteriaCategory->setSort('cat_order');
$categories = $categoryHandler->getAll($criteriaCategory, array('cat_id', 'cat_order', 'cat_title'));
$categories = $categoryHandler->getAll($criteriaCategory, ['cat_id', 'cat_order', 'cat_title']);
$forums = $forumHandler->getTree(array_keys($categories), 0, 'all', '&nbsp;&nbsp;&nbsp;&nbsp;');
foreach (array_keys($categories) as $c) {
echo '<tr>';
Expand Down
Loading

0 comments on commit c0603bc

Please sign in to comment.