- <{if $forum.forum_lastpost_subject}>
+ <{if $forum.forum_lastpost_subject|default:''}>
<{$forum.forum_lastpost_time}> <{$smarty.const._MD_NEWBB_BY}> <{$forum.forum_lastpost_user}>
]
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_notification_select.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_notification_select.tpl
index 2712af35..7900984f 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_notification_select.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_notification_select.tpl
@@ -3,8 +3,7 @@
<{$lang_notificationoptions}>
@@ -27,7 +26,7 @@
checked="checked"<{/if}> >
+ <{if $event.subscribed}>checked<{/if}> >
<{$event.caption}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_search.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_search.tpl
index fb8ee230..fd653e9f 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_search.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_search.tpl
@@ -2,7 +2,7 @@
<{$forumindex}>
<{$smarty.const._SR_SEARCH}>
-<{if $search_info}>
+<{if $search_info|default:''}>
<{include file="db:newbb_searchresults.tpl" results=$results}>
<{/if}>
@@ -50,7 +50,7 @@
<{$smarty.const._MD_NEWBB_SELECT_STARTLAG}>
-
+
@@ -59,11 +59,11 @@
<{$smarty.const._MD_NEWBB_SELECT_HTML}>
- <{$selecthtml_radio}>
+ <{$selecthtml_radio|default:''}>
<{$smarty.const._MD_NEWBB_SELECT_EXCLUDE}>
- <{$selectexclude_check_box}>
+ <{$selectexclude_check_box|default:''}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_searchresults.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_searchresults.tpl
index c6879351..ef95ba48 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_searchresults.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_searchresults.tpl
@@ -35,11 +35,11 @@
<{/section}>
- <{if $search_next or $search_prev}>
+ <{if $search_next|default:'' or $search_prev|default:''}>
- <{$search_prev}>
- <{$search_next}>
+ <{$search_prev|default:''}>
+ <{$search_next|default:''}>
<{/if}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_thread.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_thread.tpl
index 650aebdd..e296f7ef 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_thread.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_thread.tpl
@@ -1,12 +1,12 @@
- <{if $forum_post_prefix === null }>
+ <{if $forum_post_prefix|default:'' === null }>
<{assign var=forum_post_prefix value="forumpost"}>
<{/if}>
<{$topic_post.poster.link}>
- <{if $topic_post.poster.uid gt -1}>
+ <{if $topic_post.poster.uid|default:'' gt -1}>
<{if $topic_post.poster.uid != 0}>
<{if $topic_post.poster.avatar != "blank.gif"}>
@@ -77,7 +77,7 @@
IP: <{$topic_post.poster_ip}>
<{/if}>
- <{if $topic_post.poster.uid gt 0}>
+ <{if $topic_post.poster.uid|default:'' gt 0}>
<{$smarty.const._MD_NEWBB_POSTEDON}><{$topic_post.post_date}>
<{/if}>
@@ -89,7 +89,7 @@
<{$topic_post.post_title}>
<{if $topic_post.post_id > 0}>
-
+
#<{$topic_post.post_no}>
<{/if}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewall.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewall.tpl
index b63560b1..d1ab651f 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewall.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewall.tpl
@@ -1,9 +1,9 @@
<{$smarty.const._MD_NEWBB_FORUMHOME}>
- <{if $parent_forum}>
+ <{if $parent_forum|default:''}>
<{$parent_name}>
<{$forum_name}>
- <{elseif $forum_name}>
+ <{elseif $forum_name|default:''}>
<{$forum_name}>
<{/if}>
<{if $current}>
@@ -81,7 +81,7 @@
<{$filter.title}>
<{/foreach}>
--------
- <{foreach item=filter from=$types}>
+ <{foreach item=filter from=$types|default:null}>
<{$filter.title}>
<{/foreach}>
@@ -146,7 +146,7 @@
- <{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}>
+ <{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''|replace:' //':'/'}>
@@ -196,7 +196,7 @@
<{$topic.topic_icon}><{$topic.sticky}> <{$topic.digest}><{$topic.poll}>
- <{$topic.topic_title}> <{$topic.attachment}> <{$topic.topic_page_jump}>
+ <{$topic.topic_title}><{$topic.attachment|default:''}> <{$topic.topic_page_jump}>
<{$headers.publish.title}>: <{$topic.topic_time}>
@@ -243,7 +243,7 @@
<{if $pagenav}>
- <{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}>
+
<{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''|replace:' //':'/'}>
<{/if}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewforum.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewforum.tpl
index 949b12a4..4ded45ea 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewforum.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewforum.tpl
@@ -27,7 +27,7 @@
<{/if}>
<{/if}>
- <{if $forum_topictype}><{$forum_topictype}><{/if}>
+ <{if $forum_topictype|default:''}><{$forum_topictype}><{/if}>
<{if $forum_topicstatus}>
<{$forum_topicstatus}>
@@ -41,7 +41,7 @@
- <{if $subforum}>
+ <{if $subforum|default:''}>
<{include file="db:newbb_viewforum_subforum.tpl"}>
<{/if}>
@@ -173,7 +173,7 @@
<{$topic.topic_title}>
-
+<{* <{$topic.attachment}> <{$topic.topic_page_jump}> *}>
<{$topic.topic_poster}>
<{$topic.topic_time}>
diff --git a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl
index a4cb24be..ed0ccc38 100644
--- a/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl
+++ b/EXTRA/themes/xbootstrap/modules/newbb/newbb_viewtopic.tpl
@@ -14,7 +14,7 @@
<{$topic_title|strip_tags}> <{if $topicstatus}><{$topicstatus}><{/if}>
- <{if $tagbar}>
+ <{if $tagbar|default:false}>
<{include file="db:tag_bar.tpl"}>
@@ -44,29 +44,29 @@
<{/if}>
- <{if $viewer_level gt 1}>
-
<{/if}>
<{if $mode lte 1}>
- <{if $topic_poll}>
+ <{if $topic_poll|default:''}>
<{if $topic_pollresult}>
<{include file="db:newbb_poll_results.tpl" poll=$poll}>
<{else}>
@@ -143,7 +143,7 @@
<{$act.name}>
<{/foreach}>
<{/if}>
- <{if $adminpoll_actions|is_array && count($adminpoll_actions) > 0 }>
+ <{if $adminpoll_actions|default:null|is_array && count($adminpoll_actions) > 0 }>
--------
<{$smarty.const._MD_NEWBB_POLLOPTIONADMIN}>
<{foreach item=actpoll from=$adminpoll_actions}>
@@ -233,22 +233,22 @@
<{include file='db:newbb_notification_select.tpl'}>
-
+
+<{* *}>
+
diff --git a/assets/css/index.php b/assets/css/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/css/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/assets/images/category/index.php b/assets/images/category/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/images/category/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/assets/images/filetypes/index.php b/assets/images/filetypes/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/images/filetypes/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/assets/images/icons/index.php b/assets/images/icons/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/images/icons/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/assets/images/index.php b/assets/images/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/images/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/assets/images/menu/index.php b/assets/images/menu/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/images/menu/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/assets/index.php b/assets/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/assets/js/index.php b/assets/js/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/assets/js/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/blocks/index.php b/blocks/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/blocks/index.php
@@ -0,0 +1,3 @@
+, irmtfan
* @author The Persian Xoops Support Site
* @since 4.3
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper,
+ TopicRenderer
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
if (defined('LIST_TOPIC_DEFINED')) {
return;
@@ -53,7 +55,7 @@ function newbb_list_topic_show($options)
{
$newbbConfig = newbbLoadConfig(); // load all newbb configs
- $topicRenderer = new Newbb\TopicRenderer();
+ $topicRenderer = new TopicRenderer();
$topicRenderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']); // Vistitor's level: 0 - anonymous; 1 - user; 2 - moderator or admin
$topicRenderer->force = true; // force against static vars for parse
@@ -71,22 +73,24 @@ function newbb_list_topic_show($options)
// set and parse values:
// forum: parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
- $topicRenderer->setVars([
- 'status' => $optionsStatus,
- 'uid' => $options[1],
- 'lastposter' => $options[2],
- 'type' => $options[3],
- 'sort' => $options[4],
- 'order' => $options[5],
- 'since' => $options[7],
- 'forum' => $optionsForum,
- ]);
+ $topicRenderer->setVars(
+ [
+ 'status' => $optionsStatus,
+ 'uid' => $options[1],
+ 'lastposter' => $options[2],
+ 'type' => $options[3],
+ 'sort' => $options[4],
+ 'order' => $options[5],
+ 'since' => $options[7],
+ 'forum' => $optionsForum,
+ ]
+ );
$block = [];
// headers to display in block
$block['headers'] = $topicRenderer->getHeader($options[8]);
// render a list of topics using all above criterias
- list($block['topics'], $block['sticky']) = $topicRenderer->renderTopics();
+ [$block['topics'], $block['sticky']] = $topicRenderer->renderTopics();
// show index navigation
$block['indexNav'] = !empty($options[9]);
@@ -105,7 +109,7 @@ function newbb_list_topic_edit($options)
// $form = new \XoopsBlockForm(); //reserve for 2.6
$form = new \XoopsThemeForm(_MB_NEWBB_DISPLAYMODE_DESC, 'list_topic', '');
- $topicRenderer = new Newbb\TopicRenderer();
+ $topicRenderer = new TopicRenderer();
$topicRenderer->userlevel = 2; // 2 - moderator or admin
// status element
@@ -182,10 +186,10 @@ function newbb_list_topic_edit($options)
$optionsForum = explode(',', $options[12]);
require_once dirname(__DIR__) . '/include/functions.forum.php';
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
//get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
// Get accessible forums
- $accessForums = $forumHandler->getIdsByValues(array_map('intval', $optionsForum));
+ $accessForums = $forumHandler->getIdsByValues(array_map('\intval', $optionsForum));
$isAll = (0 === count($optionsForum) || empty($optionsForum[0]));
$forumSel = ""; // if user dont select any it select "0"
$forumSel .= 'path('modules/newbb/include/functions.ini.php');
@@ -77,13 +79,13 @@ function b_newbb_show($options)
if (!isset($accessForums)) {
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
if (!$accessForums = $permHandler->getForums()) {
return $block;
}
}
if (!empty($options[6])) {
- $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums
+ $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
$allowedForums = array_intersect($myallowedForums, $accessForums);
} else {
$allowedForums = $accessForums;
@@ -98,10 +100,8 @@ function b_newbb_show($options)
$newbbConfig = newbbLoadConfig();
if (!empty($newbbConfig['do_rewrite'])) {
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
- } else {
- if (!defined('SEO_MODULE_NAME')) {
- define('SEO_MODULE_NAME', 'modules/newbb');
- }
+ } elseif (!defined('SEO_MODULE_NAME')) {
+ define('SEO_MODULE_NAME', 'modules/newbb');
}
$query = 'SELECT'
@@ -153,7 +153,7 @@ function b_newbb_show($options)
if (count($types) > 0) {
/** @var Newbb\TypeHandler $typeHandler */
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
}
@@ -167,10 +167,10 @@ function b_newbb_show($options)
$topic['post_id'] = $arr['post_id'];
$topic['topic_status'] = $arr['topic_status'];
$topic['forum_id'] = $arr['forum_id'];
- $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']);
+ $topic['forum_name'] = htmlspecialchars($arr['forum_name']);
$topic['id'] = $arr['topic_id'];
- $title = $myts->htmlSpecialChars($arr['topic_title']);
+ $title = htmlspecialchars($arr['topic_title']);
if (!empty($options[5])) {
$title = xoops_substr($title, 0, $options[5]);
}
@@ -181,7 +181,7 @@ function b_newbb_show($options)
if (!empty($author_name[$arr['uid']])) {
$topic_poster = $author_name[$arr['uid']];
} else {
- $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
+ $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
}
$topic['topic_poster'] = $topic_poster;
$topic['topic_page_jump'] = $topic_page_jump;
@@ -270,22 +270,20 @@ function b_newbb_topic_show($options)
$newbbConfig = newbbLoadConfig();
if (!empty($newbbConfig['do_rewrite'])) {
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
- } else {
- if (!defined('SEO_MODULE_NAME')) {
- define('SEO_MODULE_NAME', 'modules/newbb');
- }
+ } elseif (!defined('SEO_MODULE_NAME')) {
+ define('SEO_MODULE_NAME', 'modules/newbb');
}
if (!isset($accessForums)) {
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
if (!$accessForums = $permHandler->getForums()) {
return $block;
}
}
if (!empty($options[6])) {
- $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums
+ $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
$allowedForums = array_intersect($myallowedForums, $accessForums);
} else {
$allowedForums = $accessForums;
@@ -297,22 +295,9 @@ function b_newbb_topic_show($options)
$forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')';
$approveCriteria = ' AND t.approved = 1';
- $query = 'SELECT'
- . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,'
- . ' f.forum_name'
- . ' FROM '
- . $GLOBALS['xoopsDB']->prefix('newbb_topics')
- . ' AS t '
- . ' LEFT JOIN '
- . $GLOBALS['xoopsDB']->prefix('newbb_forums')
- . ' AS f ON f.forum_id=t.forum_id'
- . ' WHERE 1=1 '
- . $forumCriteria
- . $approveCriteria
- . $extraCriteria
- . ' ORDER BY '
- . $order
- . ' DESC';
+ $query = 'SELECT' . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,' . ' f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' AS t ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix(
+ 'newbb_forums'
+ ) . ' AS f ON f.forum_id=t.forum_id' . ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC';
$result = $GLOBALS['xoopsDB']->query($query, $options[1], 0);
@@ -338,7 +323,7 @@ function b_newbb_topic_show($options)
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true);
if (count($types) > 0) {
/** @var Newbb\TypeHandler $typeHandler */
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
}
@@ -348,10 +333,10 @@ function b_newbb_topic_show($options)
$topic = [];
$topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] ';
$topic['forum_id'] = $arr['forum_id'];
- $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']);
+ $topic['forum_name'] = htmlspecialchars($arr['forum_name']);
$topic['id'] = $arr['topic_id'];
- $title = $myts->htmlSpecialChars($arr['topic_title']);
+ $title = htmlspecialchars($arr['topic_title']);
if (!empty($options[5])) {
$title = xoops_substr($title, 0, $options[5]);
}
@@ -362,7 +347,7 @@ function b_newbb_topic_show($options)
if (!empty($author_name[$arr['topic_poster']])) {
$topic_poster = $author_name[$arr['topic_poster']];
} else {
- $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
+ $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
}
$topic['topic_poster'] = $topic_poster;
// irmtfan remove $topic_page_jump because there is no last post
@@ -440,7 +425,7 @@ function b_newbb_post_show($options)
if (!isset($accessForums)) {
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
if (!$accessForums = $permHandler->getForums()) {
return $block;
}
@@ -449,14 +434,12 @@ function b_newbb_post_show($options)
$newbbConfig = newbbLoadConfig();
if (!empty($newbbConfig['do_rewrite'])) {
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php');
- } else {
- if (!defined('SEO_MODULE_NAME')) {
- define('SEO_MODULE_NAME', 'modules/newbb');
- }
+ } elseif (!defined('SEO_MODULE_NAME')) {
+ define('SEO_MODULE_NAME', 'modules/newbb');
}
if (!empty($options[6])) {
- $myallowedForums = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums
+ $myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
$allowedForums = array_intersect($myallowedForums, $accessForums);
} else {
$allowedForums = $accessForums;
@@ -507,10 +490,10 @@ function b_newbb_post_show($options)
//$topic['jump_post'] = "" . $last_post_icon . ' ';
$topic = [];
$topic['forum_id'] = $arr['forum_id'];
- $topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']);
+ $topic['forum_name'] = htmlspecialchars($arr['forum_name']);
//$topic['id'] = $arr['topic_id'];
- $title = $myts->htmlSpecialChars($arr['subject']);
+ $title = htmlspecialchars($arr['subject']);
if ('text' !== $options[0] && !empty($options[5])) {
$title = xoops_substr($title, 0, $options[5]);
}
@@ -520,7 +503,7 @@ function b_newbb_post_show($options)
if (!empty($author_name[$arr['uid']])) {
$topic_poster = $author_name[$arr['uid']];
} else {
- $topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
+ $topic_poster = htmlspecialchars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']);
}
$topic['topic_poster'] = $topic_poster;
@@ -613,14 +596,14 @@ function b_newbb_author_show($options)
if (!isset($accessForums)) {
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
if (!$accessForums = $permHandler->getForums()) {
return $block;
}
}
if (!empty($options[5])) {
- $myallowedForums = array_filter(array_slice($options, 5), 'b_newbb_array_filter'); // get allowed forums
+ $myallowedForums = array_filter(array_slice($options, 5), '\b_newbb_array_filter'); // get allowed forums
$allowedForums = array_intersect($myallowedForums, $accessForums);
} else {
$allowedForums = $accessForums;
@@ -658,7 +641,7 @@ function b_newbb_author_show($options)
require_once dirname(__DIR__) . '/include/functions.user.php';
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']);
foreach (array_keys($author) as $uid) {
- $author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]);
+ $author[$uid]['name'] = htmlspecialchars($author_name[$uid]);
}
$block['authors'] = &$author;
$block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view;
@@ -713,7 +696,7 @@ function b_newbb_edit($options)
$form .= ' ' . _MB_NEWBB_FORUMLIST;
- $optionsForum = array_filter(array_slice($options, 6), 'b_newbb_array_filter'); // get allowed forums
+ $optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums
$isAll = (0 === count($optionsForum) || empty($optionsForum[0]));
$form .= ' ';
$form .= 'loadLanguage('blocks');
@@ -991,8 +973,7 @@ function b_newbb_custom_topic($options)
*/
function b_newbb_custom_post($options)
{
- /** @var \XoopsModules\Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
// if no newbb module block set, we have to include the language file
$helper->loadLanguage('blocks');
@@ -1013,8 +994,7 @@ function b_newbb_custom_post($options)
*/
function b_newbb_custom_author($options)
{
- /** @var \XoopsModules\Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
// if no newbb module block set, we have to include the language file
$helper->loadLanguage('blocks');
diff --git a/blocks/newbb_block_tag.php b/blocks/newbb_block_tag.php
index 1f17492b..ef7daf05 100644
--- a/blocks/newbb_block_tag.php
+++ b/blocks/newbb_block_tag.php
@@ -3,7 +3,7 @@
* Tag blocks for NewBB 4.0+
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb/tag
@@ -11,16 +11,14 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**#@+
* Function to display tag cloud
* @param $options
- * @return array|null
+ * @return array|null|bool
*/
function newbb_tag_block_cloud_show($options)
{
- if ((!class_exists('TagFormTag') ) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
+ if ((!class_exists('TagFormTag')) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
return null;
}
$block_content = tag_block_cloud_show($options, 'newbb');
@@ -34,7 +32,7 @@ function newbb_tag_block_cloud_show($options)
*/
function newbb_tag_block_cloud_edit($options)
{
- if ((!class_exists('TagFormTag') ) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
+ if ((!class_exists('TagFormTag')) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
return null;
}
$form = tag_block_cloud_edit($options);
@@ -45,11 +43,11 @@ function newbb_tag_block_cloud_edit($options)
/**#@+
* Function to display top tag list
* @param $options
- * @return array|null
+ * @return array|null|bool
*/
function newbb_tag_block_top_show($options)
{
- if ((!class_exists('TagFormTag') ) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
+ if ((!class_exists('TagFormTag')) || (class_exists('TagFormTag') && !@require $GLOBALS['xoops']->path('modules/tag/blocks/block.php'))) {
return null;
}
$block_content = tag_block_top_show($options, 'newbb');
diff --git a/class/Category.php b/class/Category.php
index bc8a74dd..30d12685 100644
--- a/class/Category.php
+++ b/class/Category.php
@@ -6,23 +6,21 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
class Category extends \XoopsObject
{
public function __construct()
{
parent::__construct();
- $this->initVar('cat_id', XOBJ_DTYPE_INT);
- $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX);
- $this->initVar('cat_image', XOBJ_DTYPE_SOURCE, 'blank.gif');
- $this->initVar('cat_description', XOBJ_DTYPE_TXTAREA);
- $this->initVar('cat_order', XOBJ_DTYPE_INT, 99);
- $this->initVar('cat_url', XOBJ_DTYPE_URL);
+ $this->initVar('cat_id', \XOBJ_DTYPE_INT);
+ $this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('cat_image', \XOBJ_DTYPE_SOURCE, 'blank.gif');
+ $this->initVar('cat_description', \XOBJ_DTYPE_TXTAREA);
+ $this->initVar('cat_order', \XOBJ_DTYPE_INT, 99);
+ $this->initVar('cat_url', \XOBJ_DTYPE_URL);
}
}
diff --git a/class/CategoryHandler.php b/class/CategoryHandler.php
index 435e94dd..46526ddc 100644
--- a/class/CategoryHandler.php
+++ b/class/CategoryHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,8 +14,6 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Class CategoryHandler
*/
@@ -30,21 +28,21 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param string $perm
+ * @param string $perm
* @return mixed
*/
public function getIdsByPermission($perm = 'access')
{
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->getCategories($perm);
}
/**
- * @param string $permission
- * @param null $tags
- * @param bool $asObject
+ * @param string $permission
+ * @param null $tags
+ * @param bool $asObject
* @return array
*/
public function &getByPermission($permission = 'access', $tags = null, $asObject = true)
@@ -53,7 +51,7 @@ public function &getByPermission($permission = 'access', $tags = null, $asObject
if (!$valid_ids = $this->getIdsByPermission($permission)) {
return $categories;
}
- $criteria = new \Criteria('cat_id', '(' . implode(', ', $valid_ids) . ')', 'IN');
+ $criteria = new \Criteria('cat_id', '(' . \implode(', ', $valid_ids) . ')', 'IN');
$criteria->setSort('cat_order');
$categories = $this->getAll($criteria, $tags, $asObject);
@@ -62,7 +60,7 @@ public function &getByPermission($permission = 'access', $tags = null, $asObject
/**
* @param \XoopsObject $category
- * @param bool $force
+ * @param bool $force
* @return mixed
*/
public function insert(\XoopsObject $category, $force = true)
@@ -81,7 +79,7 @@ public function insert(\XoopsObject $category, $force = true)
/**
* @param \XoopsObject $category
- * @param bool $force
+ * @param bool $force
* @return bool|mixed
* @internal param Category $category
*/
@@ -92,9 +90,10 @@ public function delete(\XoopsObject $category, $force = false)//delete(Category
return false;
}
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forumHandler->deleteAll(new \Criteria('cat_id', $category->getVar('cat_id')), true, true);
- if ($result = parent::delete($category)) {
+ $result = parent::delete($category);
+ if ($result) {
// Delete group permissions
return $this->deletePermission($category);
}
@@ -106,8 +105,8 @@ public function delete(\XoopsObject $category, $force = false)//delete(Category
/**
* Check permission for a category
*
- * @param Category|int $category object or id
- * @param string $perm permission name
+ * @param Category|int $category object or id
+ * @param string $perm permission name
*
* @return bool
*/
@@ -117,9 +116,9 @@ public function getPermission($category, $perm = 'access')
return true;
}
- $cat_id = is_object($category) ? $category->getVar('cat_id') : (int)$category;
+ $cat_id = \is_object($category) ? $category->getVar('cat_id') : (int)$category;
/** @var PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->getPermission('category', $perm, $cat_id);
}
@@ -131,7 +130,7 @@ public function getPermission($category, $perm = 'access')
public function deletePermission(Category $category)
{
/** @var PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->deleteByCategory($category->getVar('cat_id'));
}
@@ -143,13 +142,13 @@ public function deletePermission(Category $category)
public function applyPermissionTemplate(Category $category)
{
/** @var PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->setCategoryPermission($category->getVar('cat_id'));
}
/**
- * @param mixed $object
+ * @param mixed $object
* @return bool
*/
public function synchronization($object = null)
diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php
index fb05a16c..513aca6e 100644
--- a/class/Common/Breadcrumb.php
+++ b/class/Common/Breadcrumb.php
@@ -26,7 +26,6 @@
* $breadcrumb->addLink( 'bread 3', 'index3.php' );
* echo $breadcrumb->render();
*/
-defined('XOOPS_ROOT_PATH') || die('XOOPS Root Path not defined');
/**
* Class Breadcrumb
@@ -35,13 +34,12 @@ class Breadcrumb
{
/** @var string */
private $dirname;
-
/** @var array */
private $bread = [];
public function __construct()
{
- $this->dirname = basename(dirname(dirname(__DIR__)));
+ $this->dirname = \basename(\dirname(\dirname(__DIR__)));
}
/**
@@ -59,23 +57,35 @@ public function addLink($title = '', $link = '')
}
/**
- * Render Pedigree BreadCrumb
+ * Render BreadCrumb
*
* @return string
*/
public function render()
{
- if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
- require_once $GLOBALS['xoops']->path('class/theme.php');
+ /*
+ TODO if you want to use the render code below,
+ 1) create ./templates/chess_common_breadcrumb.tpl)
+ 2) add declaration to xoops_version.php
+ */
+ /*
+ if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) {
+ require $GLOBALS['xoops']->path('class/theme.php');
+
$GLOBALS['xoTheme'] = new \xos_opal_Theme();
}
- require_once $GLOBALS['xoops']->path('class/template.php');
+ require $GLOBALS['xoops']->path('class/template.php');
+
$breadcrumbTpl = new \XoopsTpl();
+
$breadcrumbTpl->assign('breadcrumb', $this->bread);
+
$html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
+
unset($breadcrumbTpl);
return $html;
+ */
}
}
diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php
index aaeacdfd..b15f1adf 100644
--- a/class/Common/Configurator.php
+++ b/class/Common/Configurator.php
@@ -17,12 +17,10 @@
* @copyright XOOPS Project (https://xoops.org)
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author XOOPS Development Team
- * @package Publisher
+ * @package
* @since 1.05
*/
-// require_once dirname(dirname(__DIR__)) . '/include/common.php';
-
/**
* Class Configurator
*/
@@ -44,11 +42,10 @@ class Configurator
*/
public function __construct()
{
- $moduleDirName = basename(dirname(dirname(__DIR__)));
+ $moduleDirName = \basename(\dirname(\dirname(__DIR__)));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
- require_once dirname(dirname(__DIR__)) . '/include/config.php';
- $config = getConfig();
+ $config = require \dirname(\dirname(__DIR__)) . '/config/config.php';
$this->name = $config->name;
$this->paths = $config->paths;
diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php
index 359ecdb8..9f61b2c2 100644
--- a/class/Common/FilesManagement.php
+++ b/class/Common/FilesManagement.php
@@ -12,6 +12,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
+use XoopsUser;
+
+
+
/**
* @copyright XOOPS Project (https://xoops.org)
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
@@ -27,15 +31,14 @@ trait FilesManagement
public static function createFolder($folder)
{
try {
- if (!file_exists($folder)) {
+ if (!is_dir($folder)) {
if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) {
throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
}
file_put_contents($folder . '/index.html', '');
}
- }
- catch (\Exception $e) {
+ } catch (\Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n", ' ';
}
}
@@ -78,15 +81,15 @@ public static function recurseCopy($src, $dst)
*
* @param string $src source directory to delete
*
- * @uses \Xmf\Module\Helper::getHelper()
+ * @return bool true on success
* @uses \Xmf\Module\Helper::isUserAdmin()
*
- * @return bool true on success
+ * @uses \Xmf\Module\Helper::getHelper()
*/
public static function deleteDirectory($src)
{
// Only continue if user is a 'global' Admin
- if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
+ if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
return false;
}
@@ -103,11 +106,8 @@ public static function deleteDirectory($src)
if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
break;
}
- } else {
- // delete the file
- if (!($success = unlink($fileInfo->getRealPath()))) {
- break;
- }
+ } elseif (!($success = unlink($fileInfo->getRealPath()))) {
+ break;
}
}
// now delete this (sub)directory if all the files are gone
@@ -134,7 +134,7 @@ public static function deleteDirectory($src)
public static function rrmdir($src)
{
// Only continue if user is a 'global' Admin
- if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
+ if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
return false;
}
@@ -174,7 +174,7 @@ public static function rrmdir($src)
public static function rmove($src, $dest)
{
// Only continue if user is a 'global' Admin
- if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
+ if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
return false;
}
@@ -209,15 +209,15 @@ public static function rmove($src, $dest)
* @param string $src - Source of files being moved
* @param string $dest - Destination of files being moved
*
- * @uses \Xmf\Module\Helper::getHelper()
+ * @return bool true on success
* @uses \Xmf\Module\Helper::isUserAdmin()
*
- * @return bool true on success
+ * @uses \Xmf\Module\Helper::getHelper()
*/
public static function rcopy($src, $dest)
{
// Only continue if user is a 'global' Admin
- if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
+ if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
return false;
}
diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php
index a68b546f..5f21b221 100644
--- a/class/Common/Migrate.php
+++ b/class/Common/Migrate.php
@@ -14,6 +14,9 @@
use XoopsModules\Newbb;
+
+
+
/**
* Class Migrate synchronize existing tables with target schema
*
@@ -21,7 +24,7 @@
* @package Newbb
* @author Richard Griffith
* @copyright 2016 XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @link https://xoops.org
*/
class Migrate extends \Xmf\Database\Migrate
@@ -34,7 +37,6 @@ class Migrate extends \Xmf\Database\Migrate
*/
public function __construct(Newbb\Common\Configurator $configurator)
{
-
$this->renameTables = $configurator->renameTables;
$moduleDirName = basename(dirname(dirname(__DIR__)));
@@ -51,17 +53,19 @@ private function changePrefix()
$this->tableHandler->renameTable($oldName, $newName);
} else {
// Newbb\Helper::getInstance()->getModule()->setErrors('Could not migrate table: '. $oldName . '! The table ' .$newName . ' already exist!');
- Newbb\Helper::getInstance()->getModule()->setErrors(''
- . 'Could not migrate table: '
- . ' '
- . $oldName
- . ''
- . ' The table '
- . ' '
- . $newName
- . ''
- . ' already exist!'
- . ' ');
+ Newbb\Helper::getInstance()->getModule()->setErrors(
+ ''
+ . 'Could not migrate table: '
+ . ' '
+ . $oldName
+ . ''
+ . ' The table '
+ . ' '
+ . $newName
+ . ''
+ . ' already exist!'
+ . ' '
+ );
trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!');
}
@@ -96,8 +100,8 @@ private function moveDoColumns()
{
$tableName = 'newbb_posts_text';
$srcTableName = 'newbb_posts';
- if (false !== $this->tableHandler->useTable($tableName)
- && false !== $this->tableHandler->useTable($srcTableName)) {
+ if ($this->tableHandler->useTable($tableName)
+ && $this->tableHandler->useTable($srcTableName)) {
$attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
if (false === $attributes) {
$this->synchronizeTable($tableName);
diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php
index efbd3dd1..9e2f7261 100644
--- a/class/Common/ServerStats.php
+++ b/class/Common/ServerStats.php
@@ -27,28 +27,28 @@ trait ServerStats
public static function getServerStats()
{
//mb $wfdownloads = WfdownloadsWfdownloads::getInstance();
- $moduleDirName = basename(dirname(dirname(__DIR__)));
+ $moduleDirName = \basename(\dirname(\dirname(__DIR__)));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
- xoops_loadLanguage('common', $moduleDirName);
+ \xoops_loadLanguage('common', $moduleDirName);
$html = '';
// $sql = 'SELECT metavalue';
// $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
// $sql .= " WHERE metakey='version' LIMIT 1";
// $query = $GLOBALS['xoopsDB']->query($sql);
// list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
- $html .= "" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . " \n";
+ $html .= "" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . " \n";
$html .= "\n";
// $html .= '
' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "
\n";
// $html .= "
\n";
// $html .= "
\n";
- $html .= '
' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
\n";
+ $html .= '
' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "
\n";
$html .= "
\n";
- $gdlib = function_exists('gd_info') ? '' . constant('CO_' . $moduleDirNameUpper . '_GDON') . ' ' : '' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ' ';
- $html .= '' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
- if (function_exists('gd_info')) {
+ $gdlib = \function_exists('gd_info') ? '' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . ' ' : '' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . ' ';
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
+ if (\function_exists('gd_info')) {
if (true === ($gdlib = gd_info())) {
- $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ' ';
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '' . $gdlib['GD Version'] . ' ';
}
}
//
@@ -58,18 +58,18 @@ public static function getServerStats()
// $registerglobals = (!ini_get('register_globals')) ? "" . constant('CO_' . $moduleDirNameUpper . '_OFF') . ' ' : "" . constant('CO_' . $moduleDirNameUpper . '_ON') . ' ';
// $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
//
- $downloads = ini_get('file_uploads') ? '' . constant('CO_' . $moduleDirNameUpper . '_ON') . ' ' : '' . constant('CO_' . $moduleDirNameUpper . '_OFF') . ' ';
- $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
+ $downloads = \ini_get('file_uploads') ? '' . \constant('CO_' . $moduleDirNameUpper . '_ON') . ' ' : '' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . ' ';
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
- $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . ini_get('upload_max_filesize') . " \n";
- $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . ini_get('post_max_size') . " \n";
- $html .= ' ' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . ini_get('memory_limit') . " \n";
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' ' . \ini_get('upload_max_filesize') . " \n";
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' ' . \ini_get('post_max_size') . " \n";
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' ' . \ini_get('memory_limit') . " \n";
$html .= " \n";
$html .= "
\n";
- $html .= '' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . " \n";
+ $html .= ' ' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' ' . XOOPS_ROOT_PATH . " \n";
$html .= " \n";
$html .= "
\n";
- $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
+ $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
$html .= '
';
$html .= ' ';
diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php
new file mode 100644
index 00000000..282f473b
--- /dev/null
+++ b/class/Common/SysUtility.php
@@ -0,0 +1,229 @@
+
+ * @author Mamba
+ */
+
+use MyTextSanitizer;
+use XoopsFormDhtmlTextArea;
+use XoopsFormTextArea;
+use XoopsModules\Newbb\Helper;
+
+/**
+ * Class SysUtility
+ */
+class SysUtility
+{
+ use VersionChecks;
+
+ //checkVerXoops, checkVerPhp Traits
+
+ use ServerStats;
+
+ // getServerStats Trait
+
+ use FilesManagement;
+
+ // Files Management Trait
+
+ /**
+ * truncateHtml can truncate a string up to a number of characters while preserving whole words and HTML tags
+ * www.gsdesign.ro/blog/cut-html-string-without-breaking-the-tags
+ * www.cakephp.org
+ *
+ * @param string $text String to truncate.
+ * @param int $length Length of returned string, including ellipsis.
+ * @param string $ending Ending to be appended to the trimmed string.
+ * @param bool $exact If false, $text will not be cut mid-word
+ * @param bool $considerHtml If true, HTML tags would be handled correctly
+ *
+ * @return string Trimmed string.
+ */
+ public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
+ {
+ if ($considerHtml) {
+ // if the plain text is shorter than the maximum length, return the whole text
+ if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
+ return $text;
+ }
+ // splits all html-tags to scanable lines
+ \preg_match_all('/(<.+?' . '>)?([^<>]*)/s', $text, $lines, \PREG_SET_ORDER);
+ $total_length = mb_strlen($ending);
+ $open_tags = [];
+ $truncate = '';
+ foreach ($lines as $line_matchings) {
+ // if there is any html-tag in this line, handle it and add it (uncounted) to the output
+ if (!empty($line_matchings[1])) {
+ // if it's an "empty element" with or without xhtml-conform closing slash
+ if (\preg_match('/^<(\s*.+?\/\s*|\s*(img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param)(\s.+?)?)>$/is', $line_matchings[1])) {
+ // do nothing
+ // if tag is a closing tag
+ } elseif (\preg_match('/^<\s*\/([^\s]+?)\s*>$/s', $line_matchings[1], $tag_matchings)) {
+ // delete tag from $open_tags list
+ $pos = \array_search($tag_matchings[1], $open_tags, true);
+ if (false !== $pos) {
+ unset($open_tags[$pos]);
+ }
+ // if tag is an opening tag
+ } elseif (\preg_match('/^<\s*([^\s>!]+).*?' . '>$/s', $line_matchings[1], $tag_matchings)) {
+ // add tag to the beginning of $open_tags list
+ \array_unshift($open_tags, mb_strtolower($tag_matchings[1]));
+ }
+ // add html-tag to $truncate'd text
+ $truncate .= $line_matchings[1];
+ }
+ // calculate the length of the plain text part of the line; handle entities as one character
+ $content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
+ if ($total_length + $content_length > $length) {
+ // the number of characters which are left
+ $left = $length - $total_length;
+ $entities_length = 0;
+ // search for html entities
+ if (\preg_match_all('/&[0-9a-z]{2,8};|[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
+ // calculate the real length of all entities in the legal range
+ foreach ($entities[0] as $entity) {
+ if ($left >= $entity[1] + 1 - $entities_length) {
+ $left--;
+ $entities_length += mb_strlen($entity[0]);
+ } else {
+ // no more characters left
+ break;
+ }
+ }
+ }
+ $truncate .= mb_substr($line_matchings[2], 0, $left + $entities_length);
+ // maximum lenght is reached, so get off the loop
+ break;
+ }
+ $truncate .= $line_matchings[2];
+ $total_length += $content_length;
+
+ // if the maximum length is reached, get off the loop
+ if ($total_length >= $length) {
+ break;
+ }
+ }
+ } else {
+ if (mb_strlen($text) <= $length) {
+ return $text;
+ }
+ $truncate = mb_substr($text, 0, $length - mb_strlen($ending));
+ }
+ // if the words shouldn't be cut in the middle...
+ if (!$exact) {
+ // ...search the last occurance of a space...
+ $spacepos = mb_strrpos($truncate, ' ');
+ if (isset($spacepos)) {
+ // ...and cut the text in this position
+ $truncate = mb_substr($truncate, 0, $spacepos);
+ }
+ }
+ // add the defined ending to the text
+ $truncate .= $ending;
+ if ($considerHtml) {
+ // close all unclosed html-tags
+ foreach ($open_tags as $tag) {
+ $truncate .= '' . $tag . '>';
+ }
+ }
+
+ return $truncate;
+ }
+
+ /**
+ * @param \Xmf\Module\Helper $helper
+ * @param array|null $options
+ * @return \XoopsFormDhtmlTextArea|\XoopsFormEditor
+ */
+ public static function getEditor($helper = null, $options = null)
+ {
+ /** @var Helper $helper */
+ if (null === $options) {
+ $options = [];
+ $options['name'] = 'Editor';
+ $options['value'] = 'Editor';
+ $options['rows'] = 10;
+ $options['cols'] = '100%';
+ $options['width'] = '100%';
+ $options['height'] = '400px';
+ }
+
+ if (null === $helper) {
+ $helper = Helper::getInstance();
+ }
+
+ $isAdmin = $helper->isUserAdmin();
+
+ if (\class_exists('XoopsFormEditor')) {
+ if ($isAdmin) {
+ $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorAdmin'), $options, $nohtml = false, $onfailure = 'textarea');
+ } else {
+ $descEditor = new \XoopsFormEditor(\ucfirst($options['name']), $helper->getConfig('editorUser'), $options, $nohtml = false, $onfailure = 'textarea');
+ }
+ } else {
+ $descEditor = new \XoopsFormDhtmlTextArea(\ucfirst($options['name']), $options['name'], $options['value'], '100%', '100%');
+ }
+
+ // $form->addElement($descEditor);
+
+ return $descEditor;
+ }
+
+ /**
+ * @param $fieldname
+ * @param $table
+ *
+ * @return bool
+ */
+ public function fieldExists($fieldname, $table)
+ {
+ global $xoopsDB;
+ $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'");
+
+ return ($xoopsDB->getRowsNum($result) > 0);
+ }
+
+ /**
+ * @param array|string $tableName
+ * @param int $id_field
+ * @param int $id
+ *
+ * @return mixed
+ */
+ public static function cloneRecord($tableName, $id_field, $id)
+ {
+ $new_id = false;
+ $table = $GLOBALS['xoopsDB']->prefix($tableName);
+ // copy content of the record you wish to clone
+ $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), MYSQLI_ASSOC) or exit('Could not select record');
+ // set the auto-incremented id's value to blank.
+ unset($tempTable[$id_field]);
+ // insert cloned copy of the original record
+ $result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . implode(', ', array_keys($tempTable)) . ") VALUES ('" . implode("', '", array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error());
+
+ if ($result) {
+ // Return the new id
+ $new_id = $GLOBALS['xoopsDB']->getInsertId();
+ }
+ return $new_id;
+ }
+}
diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php
index 2c18f9b9..d4f3b143 100644
--- a/class/Common/VersionChecks.php
+++ b/class/Common/VersionChecks.php
@@ -22,32 +22,31 @@ trait VersionChecks
/**
* Verifies XOOPS version meets minimum requirements for this module
* @static
- * @param \XoopsModule $module
+ * @param \XoopsModule|null $module
*
- * @param null|string $requiredVer
+ * @param null|string $requiredVer
* @return bool true if meets requirements, false if not
*/
public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
{
- $moduleDirName = basename(dirname(dirname(__DIR__)));
+ $moduleDirName = \basename(\dirname(\dirname(__DIR__)));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
if (null === $module) {
$module = \XoopsModule::getByDirname($moduleDirName);
}
- xoops_loadLanguage('admin', $moduleDirName);
- xoops_loadLanguage('common', $moduleDirName);
-
+ \xoops_loadLanguage('admin', $moduleDirName);
+ \xoops_loadLanguage('common', $moduleDirName);
//check for minimum XOOPS version
- $currentVer = mb_substr(XOOPS_VERSION, 6); // get the numeric part of string
+ $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string
if (null === $requiredVer) {
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
}
$success = true;
- if (version_compare($currentVer, $requiredVer, '<')) {
+ if (\version_compare($currentVer, $requiredVer, '<')) {
$success = false;
- $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
+ $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
}
return $success;
@@ -62,23 +61,23 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer =
*/
public static function checkVerPhp(\XoopsModule $module = null)
{
- $moduleDirName = basename(dirname(dirname(__DIR__)));
+ $moduleDirName = \basename(\dirname(\dirname(__DIR__)));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
if (null === $module) {
$module = \XoopsModule::getByDirname($moduleDirName);
}
- xoops_loadLanguage('admin', $moduleDirName);
- xoops_loadLanguage('common', $moduleDirName);
+ \xoops_loadLanguage('admin', $moduleDirName);
+ \xoops_loadLanguage('common', $moduleDirName);
// check for minimum PHP version
$success = true;
- $verNum = PHP_VERSION;
+ $verNum = \PHP_VERSION;
$reqVer = &$module->getInfo('min_php');
if (false !== $reqVer && '' !== $reqVer) {
- if (version_compare($verNum, $reqVer, '<')) {
- $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
+ if (\version_compare($verNum, $reqVer, '<')) {
+ $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
$success = false;
}
}
@@ -99,7 +98,7 @@ public static function checkVerPhp(\XoopsModule $module = null)
public static function checkVerModule($helper, $source = 'github', $default = 'master')
{
- $moduleDirName = basename(dirname(dirname(__DIR__)));
+ $moduleDirName = \basename(\dirname(\dirname(__DIR__)));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
$update = '';
$repository = 'XoopsModules25x/' . $moduleDirName;
@@ -107,42 +106,42 @@ public static function checkVerModule($helper, $source = 'github', $default = 'm
$ret = '';
$infoReleasesUrl = "https://api.github.com/repos/$repository/releases";
if ('github' === $source) {
- if (function_exists('curl_init') && false !== ($curlHandle = curl_init())) {
- curl_setopt($curlHandle, CURLOPT_URL, $infoReleasesUrl);
- curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curlHandle, CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
- $curlReturn = curl_exec($curlHandle);
+ if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) {
+ \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl);
+ \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true);
+ \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized'
+ \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]);
+ $curlReturn = \curl_exec($curlHandle);
if (false === $curlReturn) {
- trigger_error(curl_error($curlHandle));
- } elseif (false !== strpos($curlReturn, 'Not Found')) {
- trigger_error('Repository Not Found: ' . $infoReleasesUrl);
+ \trigger_error(\curl_error($curlHandle));
+ } elseif (false !== \strpos($curlReturn, 'Not Found')) {
+ \trigger_error('Repository Not Found: ' . $infoReleasesUrl);
} else {
$file = json_decode($curlReturn, false);
- $latestVersionLink = sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default);
+ $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default);
$latestVersion = $file[0]->tag_name;
$prerelease = $file[0]->prerelease;
if ('master' !== $latestVersionLink) {
- $update = constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
+ $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion;
}
//"PHP-standardized" version
$latestVersion = mb_strtolower($latestVersion);
if (false !== mb_strpos($latestVersion, 'final')) {
- $latestVersion = str_replace('_', '', mb_strtolower($latestVersion));
- $latestVersion = str_replace('final', '', mb_strtolower($latestVersion));
+ $latestVersion = \str_replace('_', '', mb_strtolower($latestVersion));
+ $latestVersion = \str_replace('final', '', mb_strtolower($latestVersion));
}
$moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status'));
//"PHP-standardized" version
- $moduleVersion = str_replace(' ', '', mb_strtolower($moduleVersion));
+ $moduleVersion = \str_replace(' ', '', mb_strtolower($moduleVersion));
// $moduleVersion = '1.0'; //for testing only
// $moduleDirName = 'publisher'; //for testing only
- if (!$prerelease && version_compare($moduleVersion, $latestVersion, '<')) {
+ if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) {
$ret = [];
$ret[] = $update;
$ret[] = $latestVersionLink;
}
}
- curl_close($curlHandle);
+ \curl_close($curlHandle);
}
}
return $ret;
diff --git a/class/Common/index.html b/class/Common/index.html
deleted file mode 100644
index 990cbd60..00000000
--- a/class/Common/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/class/Common/index.php b/class/Common/index.php
new file mode 100644
index 00000000..6a505435
--- /dev/null
+++ b/class/Common/index.php
@@ -0,0 +1,2 @@
+
* @since 4.00
* @package module::newbb
@@ -16,7 +16,6 @@ class Digest extends \XoopsObject
public $digest_id;
public $digest_time;
public $digest_content;
-
public $items;
public $isHtml = false;
public $isSummary = true;
@@ -24,9 +23,9 @@ class Digest extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('digest_id', XOBJ_DTYPE_INT);
- $this->initVar('digest_time', XOBJ_DTYPE_INT);
- $this->initVar('digest_content', XOBJ_DTYPE_TXTAREA);
+ $this->initVar('digest_id', \XOBJ_DTYPE_INT);
+ $this->initVar('digest_time', \XOBJ_DTYPE_INT);
+ $this->initVar('digest_content', \XOBJ_DTYPE_TXTAREA);
$this->items = [];
}
@@ -64,35 +63,35 @@ public function cleanup($text)
{
global $myts;
- $clean = stripslashes($text);
+ $clean = \stripslashes($text);
$clean = &$myts->displayTarea($clean, 1, 0, 1);
- $clean = strip_tags($clean);
- $clean = htmlspecialchars($clean, ENT_QUOTES);
+ $clean = \strip_tags($clean);
+ $clean = \htmlspecialchars($clean, \ENT_QUOTES);
return $clean;
}
/**
- * @param bool $isSummary
- * @param bool $isHtml
+ * @param bool $isSummary
+ * @param bool $isHtml
* @return bool
*/
public function buildContent($isSummary = true, $isHtml = false)
{
- $digest_count = count($this->items);
+ $digest_count = \count($this->items);
$content = '';
if ($digest_count > 0) {
$linebreak = $isHtml ? ' ' : "\n";
- for ($i = 0; $i < $digest_count; ++$i) {
+ foreach ($this->items as $i => $iValue) {
if ($isHtml) {
- $content .= ($i + 1) . '. ' . $this->items[$i]['title'] . ' ';
+ $content .= ($i + 1) . '. ' . $iValue['title'] . ' ';
} else {
- $content .= ($i + 1) . '. ' . $this->items[$i]['title'] . $linebreak . $this->items[$i]['link'];
+ $content .= ($i + 1) . '. ' . $iValue['title'] . $linebreak . $iValue['link'];
}
- $content .= $linebreak . $this->items[$i]['author'];
+ $content .= $linebreak . $iValue['author'];
if ($isSummary) {
- $content .= $linebreak . $this->items[$i]['summary'];
+ $content .= $linebreak . $iValue['summary'];
}
$content .= $linebreak . $linebreak;
}
diff --git a/class/DigestHandler.php b/class/DigestHandler.php
index 20016a95..203dd5b4 100644
--- a/class/DigestHandler.php
+++ b/class/DigestHandler.php
@@ -6,12 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
+use Xmf\Metagen;
use XoopsModules\Newbb;
/**
@@ -32,7 +33,7 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param bool $isForced
+ * @param bool $isForced
* @return int
*/
public function process($isForced = false)
@@ -69,7 +70,7 @@ public function notify(\XoopsObject $digest)
{
//$content = $digest->getVar('digest_content');
/** @var \XoopsNotificationHandler $notificationHandler */
- $notificationHandler = xoops_getHandler('notification');
+ $notificationHandler = \xoops_getHandler('notification');
$tags['DIGEST_ID'] = $digest->getVar('digest_id');
$tags['DIGEST_CONTENT'] = $digest->getVar('digest_content', 'E');
$notificationHandler->triggerEvent('global', 0, 'digest', $tags);
@@ -79,7 +80,7 @@ public function notify(\XoopsObject $digest)
/**
* @param $start
- * @param int $perpage
+ * @param int $perpage
* @return array
*/
public function getAllDigests($start = 0, $perpage = 5)
@@ -92,10 +93,11 @@ public function getAllDigests($start = 0, $perpage = 5)
$result = $this->db->query($sql, $perpage, $start);
$ret = [];
// $reportHandler = Newbb\Helper::getInstance()->getHandler('Report');
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $ret[] = $myrow; // return as array
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $ret[] = $myrow; // return as array
+ }
}
-
return $ret;
}
@@ -136,19 +138,19 @@ public function checkStatus()
$this->getLastDigest();
}
$deadline = (1 == $GLOBALS['xoopsModuleConfig']['email_digest']) ? 60 * 60 * 24 : 60 * 60 * 24 * 7;
- $time_diff = time() - $this->last_digest;
+ $time_diff = \time() - $this->last_digest;
return $time_diff - $deadline;
}
/**
- * @param \XoopsObject $digest
- * @param bool $force flag to force the query execution despite security settings
+ * @param \XoopsObject $digest
+ * @param bool $force flag to force the query execution despite security settings
* @return mixed object ID or false
*/
public function insert(\XoopsObject $digest, $force = true)
{
- $digest->setVar('digest_time', time());
+ $digest->setVar('digest_time', \time());
return parent::insert($digest, $force);
/*
@@ -172,7 +174,7 @@ public function insert(\XoopsObject $digest, $force = true)
/**
* @param \XoopsObject $digest
- * @param bool $force (ignored)
+ * @param bool $force (ignored)
* @return bool FALSE if failed.
*/
public function delete(\XoopsObject $digest, $force = false)
@@ -190,25 +192,25 @@ public function delete(\XoopsObject $digest, $force = false)
}
/**
- * @param \XoopsObject $digest
+ * @param Digest $digest
* @return bool
*/
- public function buildDigest(\XoopsObject $digest)
+ public function buildDigest(Digest $digest)
{
global $xoopsModule;
- if (!defined('SUMMARY_LENGTH')) {
- define('SUMMARY_LENGTH', 100);
+ if (!\defined('SUMMARY_LENGTH')) {
+ \define('SUMMARY_LENGTH', 100);
}
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$thisUser = $GLOBALS['xoopsUser'];
$GLOBALS['xoopsUser'] = null; // To get posts accessible by anonymous
$GLOBALS['xoopsUser'] = $thisUser;
$accessForums = $forumHandler->getIdsByPermission(); // get all accessible forums
- $forumCriteria = ' AND t.forum_id IN (' . implode(',', $accessForums) . ')';
+ $forumCriteria = ' AND t.forum_id IN (' . \implode(',', $accessForums) . ')';
$approveCriteria = ' AND t.approved = 1 AND p.approved = 1';
$time_criteria = ' AND t.digest_time > ' . $this->last_digest;
@@ -238,14 +240,14 @@ public function buildDigest(\XoopsObject $digest)
$users[$row['uid']] = 1;
$rows[] = $row;
}
- if (count($rows) < 1) {
+ if (\count($rows) < 1) {
return false;
}
- $uids = array_keys($users);
- if (count($uids) > 0) {
+ $uids = \array_keys($users);
+ if (\count($uids) > 0) {
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
- $user_criteria = new \Criteria('uid', '(' . implode(',', $uids) . ')', 'IN');
+ $memberHandler = \xoops_getHandler('member');
+ $user_criteria = new \Criteria('uid', '(' . \implode(',', $uids) . ')', 'IN');
$users = $memberHandler->getUsers($user_criteria, true);
} else {
$users = [];
@@ -253,7 +255,7 @@ public function buildDigest(\XoopsObject $digest)
foreach ($rows as $topic) {
if ($topic['uid'] > 0) {
- if (isset($users[$topic['uid']]) && is_object($users[$topic['uid']])
+ if (isset($users[$topic['uid']]) && \is_object($users[$topic['uid']])
&& $users[$topic['uid']]->isActive()) {
$topic['uname'] = $users[$topic['uid']]->getVar('uname');
} else {
@@ -262,8 +264,8 @@ public function buildDigest(\XoopsObject $digest)
} else {
$topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'];
}
- $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH);
- $author = $topic['uname'] . ' (' . formatTimestamp($topic['topic_time']) . ')';
+ $summary = Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH);
+ $author = $topic['uname'] . ' (' . \formatTimestamp($topic['topic_time']) . ')';
$link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id'];
$title = $topic['topic_title'];
$digest->addItem($title, $link, $author, $summary);
diff --git a/class/Forum.php b/class/Forum.php
index 669053a4..671fba40 100644
--- a/class/Forum.php
+++ b/class/Forum.php
@@ -13,32 +13,30 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
class Forum extends \XoopsObject
{
public function __construct()
{
parent::__construct();
- $this->initVar('forum_id', XOBJ_DTYPE_INT);
- $this->initVar('forum_name', XOBJ_DTYPE_TXTBOX);
- $this->initVar('forum_desc', XOBJ_DTYPE_TXTAREA);
- $this->initVar('forum_moderator', XOBJ_DTYPE_ARRAY, serialize([]));
- $this->initVar('forum_topics', XOBJ_DTYPE_INT);
- $this->initVar('forum_posts', XOBJ_DTYPE_INT);
- $this->initVar('forum_last_post_id', XOBJ_DTYPE_INT);
- $this->initVar('cat_id', XOBJ_DTYPE_INT);
- $this->initVar('parent_forum', XOBJ_DTYPE_INT);
- $this->initVar('hot_threshold', XOBJ_DTYPE_INT, 20);
- $this->initVar('attach_maxkb', XOBJ_DTYPE_INT, 500);
- $this->initVar('attach_ext', XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png');
- $this->initVar('forum_order', XOBJ_DTYPE_INT, 99);
- $this->initVar('dohtml', XOBJ_DTYPE_INT, 1);
+ $this->initVar('forum_id', \XOBJ_DTYPE_INT);
+ $this->initVar('forum_name', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('forum_desc', \XOBJ_DTYPE_TXTAREA);
+ $this->initVar('forum_moderator', \XOBJ_DTYPE_ARRAY, \serialize([]));
+ $this->initVar('forum_topics', \XOBJ_DTYPE_INT);
+ $this->initVar('forum_posts', \XOBJ_DTYPE_INT);
+ $this->initVar('forum_last_post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('cat_id', \XOBJ_DTYPE_INT);
+ $this->initVar('parent_forum', \XOBJ_DTYPE_INT);
+ $this->initVar('hot_threshold', \XOBJ_DTYPE_INT, 20);
+ $this->initVar('attach_maxkb', \XOBJ_DTYPE_INT, 500);
+ $this->initVar('attach_ext', \XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png');
+ $this->initVar('forum_order', \XOBJ_DTYPE_INT, 99);
+ $this->initVar('dohtml', \XOBJ_DTYPE_INT, 1);
}
/**
@@ -51,8 +49,8 @@ public function dispForumModerators()
return $ret;
}
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.user.php');
- $moderators = newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
- $ret = implode(', ', $moderators);
+ $moderators = \newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
+ $ret = \implode(', ', $moderators);
return $ret;
}
diff --git a/class/ForumHandler.php b/class/ForumHandler.php
index db293332..aba83b2c 100644
--- a/class/ForumHandler.php
+++ b/class/ForumHandler.php
@@ -13,7 +13,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
@@ -21,8 +21,6 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Class ForumHandler
*/
@@ -38,7 +36,7 @@ public function __construct(\XoopsDatabase $db = null)
/**
* @param \XoopsObject $object
- * @param bool $force
+ * @param bool $force
* @return bool
* @internal param \XoopsObject $forum
*/
@@ -58,17 +56,17 @@ public function insert(\XoopsObject $object, $force = true) //insert($forum)
/**
* @param \XoopsObject $forum
- * @param bool $force
+ * @param bool $force
* @return bool
*/
public function delete(\XoopsObject $forum, $force = false) //delete(&$forum)
{
global $xoopsModule;
// RMV-NOTIFY
- xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'forum', $forum->getVar('forum_id'));
+ \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'forum', $forum->getVar('forum_id'));
// Get list of all topics in forum, to delete them too
/** @var Newbb\TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
$topicHandler->deleteAll(new \Criteria('forum_id', $forum->getVar('forum_id')), true, true);
$this->updateAll('parent_forum', $forum->getVar('parent_forum'), new \Criteria('parent_forum', $forum->getVar('forum_id')));
$this->deletePermission($forum);
@@ -77,22 +75,22 @@ public function delete(\XoopsObject $forum, $force = false) //delete(&$forum)
}
/**
- * @param string $perm
+ * @param string $perm
* @return mixed
*/
public function getIdsByPermission($perm = 'access')
{
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->getForums($perm);
}
/**
- * @param int|array $cat
- * @param string $permission
- * @param null $tags
- * @param bool $asObject
+ * @param int|array $cat
+ * @param string $permission
+ * @param null $tags
+ * @param bool $asObject
* @return array
*/
public function &getByPermission($cat = 0, $permission = 'access', $tags = null, $asObject = true)
@@ -102,11 +100,11 @@ public function &getByPermission($cat = 0, $permission = 'access', $tags = null,
return $_cachedForums;
}
- $criteria = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $valid_ids) . ')', 'IN'));
- if (is_numeric($cat) && $cat > 0) {
+ $criteria = new \CriteriaCompo(new \Criteria('forum_id', '(' . \implode(', ', $valid_ids) . ')', 'IN'));
+ if (\is_numeric($cat) && $cat > 0) {
$criteria->add(new \Criteria('cat_id', (int)$cat));
- } elseif ($cat && is_array($cat)) {
- $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat) . ')', 'IN'));
+ } elseif ($cat && \is_array($cat)) {
+ $criteria->add(new \Criteria('cat_id', '(' . \implode(', ', $cat) . ')', 'IN'));
}
$criteria->setSort('forum_order');
$criteria->setOrder('ASC');
@@ -116,13 +114,13 @@ public function &getByPermission($cat = 0, $permission = 'access', $tags = null,
}
/**
- * @param int $categoryid
- * @param string $permission
- * @param bool $asObject
- * @param null $tags
+ * @param int $categoryid
+ * @param string $permission
+ * @param bool $asObject
+ * @param null $tags
* @return array
*/
- public function &getForumsByCategory($categoryid = 0, $permission = '', $asObject = true, $tags = null)
+ public function getForumsByCategory($categoryid = 0, $permission = '', $asObject = true, $tags = null)
{
$forums = $this->getByPermission($categoryid, $permission, $tags);
if ($asObject) {
@@ -132,10 +130,10 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec
$forums_array = [];
$array_cat = [];
$array_forum = [];
- if (!is_array($forums)) {
+ if (!\is_array($forums)) {
return [];
}
- foreach (array_keys($forums) as $forumid) {
+ foreach (\array_keys($forums) as $forumid) {
$forum = $forums[$forumid];
$forums_array[$forum->getVar('parent_forum')][$forumid] = [
'cid' => $forum->getVar('cat_id'),
@@ -153,7 +151,7 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec
}
$array_forum[$forum['cid']][$key] = $forum;
}
- ksort($array_forum);
+ \ksort($array_forum);
unset($forums, $forums_array);
return $array_forum;
@@ -161,13 +159,19 @@ public function &getForumsByCategory($categoryid = 0, $permission = '', $asObjec
/**
* @param $forum
- * @param null $criteria
+ * @param null $criteria
* @return array
*/
- public function getAllTopics(&$forum, $criteria = null)
+ public function getAllTopics($forum, $criteria = null)
{
- global $myts, $viewAllForums;
+ global $myts, $viewAllForums, $xoopsUser;
$startdate = '';
+ $type = '';
+ $status = '';
+ $excerpt = '';
+ $sort = '';
+ $order = '';
+ $start = '';
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php');
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.session.php');
@@ -180,15 +184,15 @@ public function getAllTopics(&$forum, $criteria = null)
${$var} = $criteria[$var];
}
- $topic_lastread = newbbGetCookie('LT', true);
+ $topic_lastread = \newbbGetCookie('LT', true);
$criteria_forum = '';
- if (is_object($forum)) {
+ if (\is_object($forum)) {
$criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id');
$hot_threshold = $forum->getVar('hot_threshold');
} else {
$hot_threshold = 10;
- if ($forum && is_array($forum)) {
- $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')';
+ if ($forum && \is_array($forum)) {
+ $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')';
} elseif (!empty($forum)) {
$criteria_forum = ' AND t.forum_id =' . (int)$forum;
}
@@ -212,28 +216,28 @@ public function getAllTopics(&$forum, $criteria = null)
if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) {
} elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
// START irmtfan use read_uid to find the unread posts when the user is logged in
- $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
+ $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
if (!empty($read_uid)) {
$leftjoin .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' ';
$criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
}
-
// END irmtfan use read_uid to find the unread posts when the user is logged in
} elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
// START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
- if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
+ $time_criterion = \max($GLOBALS['last_visit'], $startdate);
+ if ($time_criterion) {
$criteria_post = ' p.post_time > ' . $time_criterion; // for all users
$topics = [];
- $topic_lastread = newbbGetCookie('LT', true);
- if (count($topic_lastread) > 0) {
+ $topic_lastread = \newbbGetCookie('LT', true);
+ if (\count($topic_lastread) > 0) {
foreach ($topic_lastread as $id => $time) {
if ($time > $time_criterion) {
$topics[] = $id;
}
}
}
- if (count($topics) > 0) {
- $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
+ if (\count($topics) > 0) {
+ $criteria_extra = ' AND t.topic_id NOT IN (' . \implode(',', $topics) . ')';
}
}
// END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
@@ -270,8 +274,8 @@ public function getAllTopics(&$forum, $criteria = null)
$sort = 't.topic_poster';
}
- $sort_array[] = trim($sort . ' ' . $order);
- $sortby = implode(', ', array_filter($sort_array));
+ $sort_array[] = \trim($sort . ' ' . $order);
+ $sortby = \implode(', ', \array_filter($sort_array));
if (empty($sortby)) {
$sortby = 't.topic_last_post_id DESC';
}
@@ -279,7 +283,7 @@ public function getAllTopics(&$forum, $criteria = null)
$sql = 'SELECT ' . $select . ' FROM ' . $from . ' WHERE ' . $where . ' ORDER BY ' . $sortby;
if (!$result = $this->db->query($sql, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start)) {
- redirect_header('index.php', 2, _MD_NEWBB_ERROROCCURED);
+ \redirect_header('index.php', 2, \_MD_NEWBB_ERROROCCURED);
}
$sticky = 0;
@@ -289,7 +293,7 @@ public function getAllTopics(&$forum, $criteria = null)
$types = [];
/** @var Newbb\TypeHandler $typeHandler */
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
$typen = $typeHandler->getByForum($forum->getVar('forum_id'));
while (false !== ($myrow = $this->db->fetchArray($result))) {
if ($myrow['topic_sticky']) {
@@ -301,32 +305,32 @@ public function getAllTopics(&$forum, $criteria = null)
if ($myrow['topic_haspoll']) {
if ($myrow['topic_sticky']) {
- $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) . ' ' . newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL);
+ $topic_icon = \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY) . ' ' . \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL);
} else {
- $topic_icon = newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL);
+ $topic_icon = \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL);
}
} elseif ($myrow['topic_sticky']) {
- $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY);
+ $topic_icon = \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY);
} elseif (!empty($myrow['icon'])) {
- $topic_icon = ' ';
+ $topic_icon = ' ';
} else {
$topic_icon = ' ';
}
// ------------------------------------------------------
// rating_img
- $rating = number_format($myrow['rating'] / 2, 0);
+ $rating = \number_format($myrow['rating'] / 2, 0);
// irmtfan - add alt key for rating
if ($rating < 1) {
- $rating_img = newbbDisplayImage('blank');
+ $rating_img = \newbbDisplayImage('blank');
} else {
- $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
+ $rating_img = \newbbDisplayImage('rate' . $rating, \constant('_MD_NEWBB_RATE' . $rating));
}
// ------------------------------------------------------
// topic_page_jump
$topic_page_jump = '';
$topic_page_jump_icon = '';
- $totalpages = ceil(($myrow['topic_replies'] + 1) / $GLOBALS['xoopsModuleConfig']['posts_per_page']);
+ $totalpages = \ceil(($myrow['topic_replies'] + 1) / $GLOBALS['xoopsModuleConfig']['posts_per_page']);
if ($totalpages > 1) {
$topic_page_jump .= ' ';
$append = false;
@@ -344,7 +348,7 @@ public function getAllTopics(&$forum, $criteria = null)
}
}
// irmtfan - move here for both topics with and without pages
- $topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ' ';
+ $topic_page_jump_icon = "" . \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ' ';
// ------------------------------------------------------
// => topic array
@@ -353,7 +357,7 @@ public function getAllTopics(&$forum, $criteria = null)
$forum_link = '' . $viewAllForums[$myrow['forum_id']]['forum_name'] . ' ';
}
- $topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
+ $topic_title = htmlspecialchars($myrow['topic_title']);
// irmtfan remove here and move to for loop
//if ($myrow['type_id'] > 0) {
//$topic_title = '['.$typen[$myrow["type_id"]]["type_name"].'] '.$topic_title.'';
@@ -364,18 +368,18 @@ public function getAllTopics(&$forum, $criteria = null)
if (0 == $excerpt) {
$topic_excerpt = '';
- } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbbIsAdmin($forum)) {
+ } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !\newbbIsAdmin($forum)) {
$topic_excerpt = '';
} else {
- $topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt);
- $topic_excerpt = str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt));
+ $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt);
+ $topic_excerpt = \str_replace('[', '[', htmlspecialchars($topic_excerpt));
}
// START irmtfan move here
//BigKev73 > Adding this code to support jumping directly to the last read post if that value exists for a user, block also would need to change to support same functionality
$topicLink ='viewtopic.php?topic_id=' . $myrow['topic_id'];
- if (isXoopsUser){
+ if ($xoopsUser){
$lastRead = newbbGetRead('topic', $myrow['topic_id']);
if (isset($lastRead)){
if (!empty($lastRead)){
@@ -404,12 +408,12 @@ public function getAllTopics(&$forum, $criteria = null)
//mb
'topic_poster_uid' => $myrow['topic_poster'],
- 'topic_poster_name' => $myts->htmlSpecialChars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']),
+ 'topic_poster_name' => htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']),
'topic_views' => $myrow['topic_views'],
- 'topic_time' => newbbFormatTimestamp($myrow['topic_time']),
- 'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']),
+ 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']),
+ 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']),
'topic_last_poster_uid' => $myrow['uid'],
- 'topic_last_poster_name' => $myts->htmlSpecialChars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']),
+ 'topic_last_poster_name' => htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']),
'topic_forum_link' => $forum_link,
'topic_excerpt' => $topic_excerpt,
'stick' => empty($myrow['topic_sticky']),
@@ -433,14 +437,14 @@ public function getAllTopics(&$forum, $criteria = null)
}
}// irmtfan while end
// START irmtfan move to a for loop
- $posters_name = newbbGetUnameFromIds(array_keys($posters), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
+ $posters_name = \newbbGetUnameFromIds(\array_keys($posters), $GLOBALS['xoopsModuleConfig']['show_realname'], true);
//$topic_poster = newbbGetUnameFromId($myrow['topic_poster'], $GLOBALS['xoopsModuleConfig']['show_realname'], true);
//$topic_last_poster = newbbGetUnameFromId($myrow['uid'], $GLOBALS['xoopsModuleConfig']['show_realname'], true);
- $topic_isRead = newbbIsRead('topic', $reads);
- foreach (array_keys($topics) as $id) {
+ $topic_isRead = \newbbIsRead('topic', $reads);
+ foreach (\array_keys($topics) as $id) {
$topics[$id]['topic_read'] = empty($topic_isRead[$id]) ? 0 : 1; // add topic-read/topic-new smarty variable
if (!empty($topics[$id]['type_id']) && isset($typen[$topics[$id]['type_id']])) {
- $topics[$id]['topic_title'] = getTopicTitle($topics[$id]['topic_title'], $typen[$topics[$id]['type_id']]['type_name'], $typen[$topics[$id]['type_id']]['type_color']);
+ $topics[$id]['topic_title'] = \getTopicTitle($topics[$id]['topic_title'], $typen[$topics[$id]['type_id']]['type_name'], $typen[$topics[$id]['type_id']]['type_color']);
}
//$topic_prefix = (!empty($typen[$myrow['type_id']])) ? getTopicTitle("", $typen[$myrow['type_id']]["type_name"], $typen[$myrow['type_id']]["type_color"]) : "";
$topics[$id]['topic_poster'] = !empty($posters_name[$topics[$id]['topic_poster_uid']]) ? $posters_name[$topics[$id]['topic_poster_uid']] : $topics[$id]['topic_poster_name'];
@@ -448,31 +452,30 @@ public function getAllTopics(&$forum, $criteria = null)
// ------------------------------------------------------
// topic_folder: priority: newhot -> hot/new -> regular
- list($topic_status, $topic_digest, $topic_replies) = $topics[$id]['stats'];
+ [$topic_status, $topic_digest, $topic_replies] = $topics[$id]['stats'];
if (1 == $topic_status) {
$topic_folder = 'topic_locked';
- $topic_folder_text = _MD_NEWBB_TOPICLOCKED;
+ $topic_folder_text = \_MD_NEWBB_TOPICLOCKED;
+ } elseif ($topic_digest) {
+ $topic_folder = 'topic_digest';
+ $topic_folder_text = \_MD_NEWBB_TOPICDIGEST;
+ } elseif ($topic_replies >= $hot_threshold) {
+ $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot';
+ $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2;
} else {
- if ($topic_digest) {
- $topic_folder = 'topic_digest';
- $topic_folder_text = _MD_NEWBB_TOPICDIGEST;
- } elseif ($topic_replies >= $hot_threshold) {
- $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot';
- $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : _MD_NEWBB_MORETHAN2;
- } else {
- $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic';
- $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS;
- }
+ $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic';
+ $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS;
}
- $topics[$id]['topic_folder'] = newbbDisplayImage($topic_folder, $topic_folder_text);
+ $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text);
unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name'], $topics[$id]['stats']);
} // irmtfan end for loop
// END irmtfan move to a for loop
- if (count($topics) > 0) {
- $sql = ' SELECT DISTINCT topic_id FROM ' . $this->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')';
- if ($result = $this->db->query($sql)) {
+ if (\count($topics) > 0) {
+ $sql = ' SELECT DISTINCT topic_id FROM ' . $this->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . \implode(',', \array_keys($topics)) . ')';
+ $result = $this->db->query($sql);
+ if ($result) {
while (list($topic_id) = $this->db->fetchRow($result)) {
- $topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT);
+ $topics[$topic_id]['attachment'] = ' ' . \newbbDisplayImage('attachment', \_MD_NEWBB_TOPICSHASATT);
}
}
}
@@ -486,7 +489,7 @@ public function getAllTopics(&$forum, $criteria = null)
* @param $type
* @return null|int
*/
- public function getTopicCount(&$forum, $startdate, $type)
+ public function getTopicCount($forum, $startdate, $type)
{
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.session.php');
@@ -506,28 +509,28 @@ public function getTopicCount(&$forum, $startdate, $type)
} elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
// START irmtfan use read_uid to find the unread posts when the user is logged in
- $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
+ $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
if (!empty($read_uid)) {
$leftjoin .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' ';
$criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
}
-
// END irmtfan use read_uid to find the unread posts when the user is logged in
} elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
// START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
- if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
+ $time_criterion = \max($GLOBALS['last_visit'], $startdate);
+ if ($time_criterion) {
$criteria_post = ' p.post_time > ' . $time_criterion; // for all users
$topics = [];
- $topic_lastread = newbbGetCookie('LT', true);
- if (count($topic_lastread) > 0) {
+ $topic_lastread = \newbbGetCookie('LT', true);
+ if (\count($topic_lastread) > 0) {
foreach ($topic_lastread as $id => $time) {
if ($time > $time_criterion) {
$topics[] = $id;
}
}
}
- if (count($topics) > 0) {
- $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
+ if (\count($topics) > 0) {
+ $criteria_extra = ' AND t.topic_id NOT IN (' . \implode(',', $topics) . ')';
}
}
// END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
@@ -546,14 +549,12 @@ public function getTopicCount(&$forum, $startdate, $type)
break;
}
$criteria_forum = '';
- if (is_object($forum)) {
+ if (\is_object($forum)) {
$criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id');
- } else {
- if ($forum && is_array($forum)) {
- $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')';
- } elseif (!empty($forum)) {
- $criteria_forum = ' AND t.forum_id =' . (int)$forum;
- }
+ } elseif ($forum && \is_array($forum)) {
+ $criteria_forum = ' AND t.forum_id IN (' . \implode(',', \array_keys($forum)) . ')';
+ } elseif (!empty($forum)) {
+ $criteria_forum = ' AND t.forum_id =' . (int)$forum;
}
$sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_topics') . ' t ' . $leftjoin;
@@ -572,8 +573,8 @@ public function getTopicCount(&$forum, $startdate, $type)
/**
* @param $forum
- * @param string $type
- * @param bool $checkCategory
+ * @param string $type
+ * @param bool $checkCategory
* @return bool
*/
public function getPermission($forum, $type = 'access', $checkCategory = true)
@@ -585,21 +586,21 @@ public function getPermission($forum, $type = 'access', $checkCategory = true)
return true;
}
- require_once dirname(__DIR__) . '/include/functions.user.php';
- if (newbbIsAdmin($forum)) {
+ require_once \dirname(__DIR__) . '/include/functions.user.php';
+ if (\newbbIsAdmin($forum)) {
return true;
}
//if ($GLOBALS["xoopsUserIsAdmin"] && $xoopsModule->getVar("dirname") === "newbb") {
//return true;
//}
- if (!is_object($forum)) {
+ if (!\is_object($forum)) {
$forum = $this->get($forum);
}
if (!empty($checkCategory)) {
/** @var Newbb\CategoryHandler $categoryHandler */
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
$categoryPerm = $categoryHandler->getPermission($forum->getVar('cat_id'));
if (!$categoryPerm) {
return false;
@@ -614,7 +615,7 @@ public function getPermission($forum, $type = 'access', $checkCategory = true)
//} else {
$forum_id = $forum->getVar('forum_id');
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
$permission = $permHandler->getPermission('forum', $type, $forum_id);
//}
// END irmtfan commented and removed
@@ -625,10 +626,10 @@ public function getPermission($forum, $type = 'access', $checkCategory = true)
* @param $forum
* @return mixed
*/
- public function deletePermission(&$forum)
+ public function deletePermission($forum)
{
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->deleteByForum($forum->getVar('forum_id'));
}
@@ -637,10 +638,10 @@ public function deletePermission(&$forum)
* @param $forum
* @return mixed
*/
- public function applyPermissionTemplate(&$forum)
+ public function applyPermissionTemplate($forum)
{
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
return $permHandler->applyTemplate($forum->getVar('forum_id'));
}
@@ -662,14 +663,14 @@ function isForum($forum)
/**
* clean orphan forums from database
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
- * @param array $forum_ids forum IDs
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
+ * @param array $forum_ids forum IDs
* @return bool true on success
*/
// START irmtfan rewrite forum cleanOrphan function. add parent_forum and cat_id orphan check
- // public function cleanOrphan(array $forum_ids = array())
+ // public function cleanOrphan(array $forum_ids = [])
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '', $forum_ids = [])
{
// check parent_forum orphan forums
@@ -686,17 +687,17 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
" OR parent_forum = forum_id";
*/
$criteria = new \CriteriaCompo();
- $criteria->add(new \Criteria('parent_forum', '(' . implode(', ', $forum_ids) . ')', 'NOT IN'), 'AND');
+ $criteria->add(new \Criteria('parent_forum', '(' . \implode(', ', $forum_ids) . ')', 'NOT IN'), 'AND');
$criteria->add(new \Criteria('parent_forum', '`forum_id`', '='), 'OR');
$b1 = $this->updateAll('parent_forum', 0, $criteria, true);
// check cat_id orphan forums
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
$cat_ids = $categoryHandler->getIds();
if (empty($cat_ids)) {
return false;
}
$criteria = new \CriteriaCompo();
- $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat_ids) . ')', 'NOT IN'), 'AND');
+ $criteria->add(new \Criteria('cat_id', '(' . \implode(', ', $cat_ids) . ')', 'NOT IN'), 'AND');
$b2 = $this->updateAll('cat_id', $cat_ids[0], $criteria, true);
return ($b1 && $b2);
@@ -707,7 +708,7 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
/**
* forum data synchronization
*
- * @param mixed $object null for all forums; integer for forum_id; object for forum object
+ * @param mixed $object null for all forums; integer for forum_id; object for forum object
* @return bool
* @internal param int $mode 1 for stats only; 2 for forum index data only; 0 for both
*/
@@ -723,7 +724,7 @@ public function synchronization($object = null)
return true;
}
- if (!is_object($object)) {
+ if (!\is_object($object)) {
$object = $this->get((int)$object);
}
@@ -732,10 +733,12 @@ public function synchronization($object = null)
}
$sql = 'SELECT MAX(post_id) AS last_post, COUNT(*) AS total FROM ' . $this->db->prefix('newbb_posts') . ' AS p LEFT JOIN ' . $this->db->prefix('newbb_topics') . ' AS t ON p.topic_id=t.topic_id WHERE p.approved=1 AND t.approved=1 AND p.forum_id = ' . $object->getVar('forum_id');
- if ($result = $this->db->query($sql)) {
+ $result = $this->db->query($sql);
+ if ($result) {
$last_post = 0;
$posts = 0;
- if ($row = $this->db->fetchArray($result)) {
+ $row = $this->db->fetchArray($result);
+ if ($row) {
$last_post = (int)$row['last_post'];
$posts = (int)$row['total'];
}
@@ -747,9 +750,11 @@ public function synchronization($object = null)
}
}
- $sql = 'SELECT COUNT(*) AS total FROM ' . $this->db->prefix('newbb_topics') . ' WHERE approved=1 AND forum_id = ' . $object->getVar('forum_id');
- if ($result = $this->db->query($sql)) {
- if ($row = $this->db->fetchArray($result)) {
+ $sql = 'SELECT COUNT(*) AS total FROM ' . $this->db->prefix('newbb_topics') . ' WHERE approved=1 AND forum_id = ' . $object->getVar('forum_id');
+ $result = $this->db->query($sql);
+ if ($result) {
+ $row = $this->db->fetchArray($result);
+ if ($row) {
if ($object->getVar('forum_topics') !== $row['total']) {
$object->setVar('forum_topics', $row['total']);
}
@@ -761,7 +766,7 @@ public function synchronization($object = null)
}
/**
- * @param null $passedSubForums
+ * @param null $passedSubForums
* @return array
*/
public function getSubforumStats($passedSubForums = null)
@@ -770,7 +775,7 @@ public function getSubforumStats($passedSubForums = null)
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.forum.php');
- $subForumTree = newbbGetSubForum();
+ $subForumTree = \newbbGetSubForum();
if (empty($passedSubForums)) {
$sub_forums = $subForumTree;
} else {
@@ -780,16 +785,16 @@ public function getSubforumStats($passedSubForums = null)
}
$forums_id = [];
- foreach (array_keys($sub_forums) as $id) {
+ foreach (\array_keys($sub_forums) as $id) {
if (empty($sub_forums[$id])) {
continue;
}
- $forums_id = array_merge($forums_id, $sub_forums[$id]);
+ $forums_id = \array_merge($forums_id, $sub_forums[$id]);
}
if (!$forums_id) {
return $stats;
}
- $sql = ' SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id' . ' FROM ' . $this->table . ' WHERE forum_id IN (' . implode(', ', $forums_id) . ')';
+ $sql = ' SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id' . ' FROM ' . $this->table . ' WHERE forum_id IN (' . \implode(', ', $forums_id) . ')';
if (!$result = $this->db->query($sql)) {
return $stats;
}
@@ -799,7 +804,7 @@ public function getSubforumStats($passedSubForums = null)
$forum_stats[$row['id']] = ['topics' => $row['topics'], 'posts' => $row['posts']];
}
- foreach (array_keys($sub_forums) as $id) {
+ foreach (\array_keys($sub_forums) as $id) {
if (empty($sub_forums[$id])) {
continue;
}
@@ -815,8 +820,8 @@ public function getSubforumStats($passedSubForums = null)
/**
* @param $forums
- * @param int $length_title_index
- * @param int $count_subforum
+ * @param int $length_title_index
+ * @param int $count_subforum
* @return array
*/
public function &display($forums, $length_title_index = 30, $count_subforum = 1)
@@ -825,30 +830,30 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
$posts = [];
$postsObject = [];
- foreach (array_keys($forums) as $id) {
+ foreach (\array_keys($forums) as $id) {
$posts[] = $forums[$id]['forum_last_post_id'];
}
if (!empty($posts)) {
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$tags_post = ['uid', 'topic_id', 'post_time', 'poster_name', 'icon'];
if (!empty($length_title_index)) {
$tags_post[] = 'subject';
}
- $posts = $postHandler->getAll(new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'), $tags_post, false);
+ $posts = $postHandler->getAll(new \Criteria('post_id', '(' . \implode(', ', $posts) . ')', 'IN'), $tags_post, false);
}
// Get topic/post stats per forum
$stats_forum = [];
if (!empty($count_subforum)) {
- $stats_forum = $this->getSubforumStats(array_keys($forums)); // irmtfan uncomment to count sub forum posts/topics
+ $stats_forum = $this->getSubforumStats(\array_keys($forums)); // irmtfan uncomment to count sub forum posts/topics
}
$users = [];
$reads = [];
$topics = [];
- foreach (array_keys($forums) as $id) {
+ foreach (\array_keys($forums) as $id) {
$forum = &$forums[$id];
if (!$forum['forum_last_post_id']) {
@@ -859,9 +864,10 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
continue;
}
- $users[] = $post['uid'];
- if ($moderators[$id] = $forum['forum_moderator']) {
- $users = array_merge($users, $moderators[$id]);
+ $users[] = $post['uid'];
+ $moderators[$id] = $forum['forum_moderator'];
+ if ($moderators[$id]) {
+ $users = \array_merge($users, $moderators[$id]);
}
// reads
@@ -874,13 +880,13 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.time.php');
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php');
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.read.php');
- $forum_isread = newbbIsRead('forum', $reads);
- $users_linked = newbbGetUnameFromIds(array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
+ $forum_isread = \newbbIsRead('forum', $reads);
+ $users_linked = \newbbGetUnameFromIds(\array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true);
$forums_array = [];
- $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
+ $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']);
- foreach (array_keys($forums) as $id) {
+ foreach (\array_keys($forums) as $id) {
$forum = &$forums[$id];
$_forum_data = [];
@@ -900,13 +906,14 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
$forum_moderators[] = @$users_linked[$moderator];
}
}
- $_forum_data['forum_moderators'] = implode(', ', $forum_moderators);
+ $_forum_data['forum_moderators'] = \implode(', ', $forum_moderators);
// irmtfan change if/endif to if{} method
- if ($post_id = $forum['forum_last_post_id']) {
+ $post_id = $forum['forum_last_post_id'];
+ if ($post_id) {
$post = &$posts[$post_id];
$_forum_data['forum_lastpost_id'] = $post_id;
- $_forum_data['forum_lastpost_time'] = newbbFormatTimestamp($post['post_time']);
+ $_forum_data['forum_lastpost_time'] = \newbbFormatTimestamp($post['post_time']);
if (!empty($users_linked[$post['uid']])) {
$_forum_data['forum_lastpost_user'] = $users_linked[$post['uid']];
} elseif ($poster_name = $post['poster_name']) {
@@ -917,18 +924,18 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
if (!empty($length_title_index)) {
$subject = $post['subject'];
if ($length_title_index < 255) {
- $subject = xoops_substr($subject, 0, $length_title_index);
+ $subject = \xoops_substr($subject, 0, $length_title_index);
}
$_forum_data['forum_lastpost_subject'] = $subject;
}
// irmtfan - remove icon_path and use newbbDisplayImage
- $_forum_data['forum_lastpost_icon'] = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST);
+ $_forum_data['forum_lastpost_icon'] = \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST);
// START irmtfan change the method to add read smarty
if (empty($forum_isread[$id])) {
- $_forum_data['forum_folder'] = newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS);
+ $_forum_data['forum_folder'] = \newbbDisplayImage('forum_new', \_MD_NEWBB_NEWPOSTS);
$_forum_data['forum_read'] = 0; // irmtfan add forum-read/forum-new smarty variable
} else {
- $_forum_data['forum_folder'] = newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS);
+ $_forum_data['forum_folder'] = \newbbDisplayImage('forum', \_MD_NEWBB_NONEWPOSTS);
$_forum_data['forum_read'] = 1; // irmtfan add forum-read/forum-new smarty variable
}
// END irmtfan change the method to add read smarty
@@ -944,29 +951,29 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1)
*
* {@link newbbTree}
*
- * @param int $cat_id category ID
- * @param int $pid Top forum ID
- * @param string $permission permission type
- * @param string $prefix prefix for display
- * @param string|array|null $tags variables to fetch
+ * @param int $cat_id category ID
+ * @param int $pid Top forum ID
+ * @param string $permission permission type
+ * @param string $prefix prefix for display
+ * @param string|array|null $tags variables to fetch
* @return array associative array of category IDs and sanitized titles
*/
public function &getTree($cat_id = 0, $pid = 0, $permission = 'access', $prefix = '--', $tags = null)
{
$pid = (int)$pid;
$perm_string = $permission;
- if (!is_array($tags) || 0 === count($tags)) {
+ if (!\is_array($tags) || 0 === \count($tags)) {
$tags = ['forum_id', 'parent_forum', 'forum_name', 'forum_order', 'cat_id'];
}
$forumsObject = $this->getByPermission($cat_id, $perm_string, $tags);
-// require_once __DIR__ . '/Tree.php';
+ // require_once __DIR__ . '/Tree.php';
$forums_structured = [];
- foreach (array_keys($forumsObject) as $key) {
+ foreach (\array_keys($forumsObject) as $key) {
$forums_structured[$forumsObject[$key]->getVar('cat_id')][$key] = $forumsObject[$key];
}
- foreach (array_keys($forums_structured) as $cid) {
+ foreach (\array_keys($forums_structured) as $cid) {
$tree = new ObjectTree($forums_structured[$cid]);
$forum_array[$cid] = $tree->makeTree($prefix, $pid, $tags);
unset($tree);
@@ -980,29 +987,29 @@ public function &getTree($cat_id = 0, $pid = 0, $permission = 'access', $prefix
*
* {@link newbbTree}
*
- * @param int $cat_id category ID
- * @param int $pid Top forum ID
- * @param string $permission permission type
- * @param string|array|null $tags variables to fetch
- * @param int $depth level of subcategories
+ * @param int $cat_id category ID
+ * @param int $pid Top forum ID
+ * @param string $permission permission type
+ * @param string|array|null $tags variables to fetch
+ * @param int $depth level of subcategories
* @return array associative array of category IDs and sanitized titles
*/
public function &getArrayTree($cat_id = 0, $pid = 0, $permission = 'access', $tags = null, $depth = 0)
{
$pid = (int)$pid;
$perm_string = $permission;
- if (!is_array($tags) || 0 === count($tags)) {
+ if (!\is_array($tags) || 0 === \count($tags)) {
$tags = ['forum_id', 'parent_forum', 'forum_name', 'forum_order', 'cat_id'];
}
$forumsObject = $this->getByPermission($cat_id, $perm_string, $tags);
-// require_once __DIR__ . '/Tree.php';
+ // require_once __DIR__ . '/Tree.php';
$forums_structured = [];
- foreach (array_keys($forumsObject) as $key) {
+ foreach (\array_keys($forumsObject) as $key) {
$forumObject = &$forumsObject[$key];
$forums_structured[$forumObject->getVar('cat_id')][$key] = $forumsObject[$key];
}
- foreach (array_keys($forums_structured) as $cid) {
+ foreach (\array_keys($forums_structured) as $cid) {
$tree = new ObjectTree($forums_structured[$cid]);
$forum_array[$cid] = $tree->makeArrayTree($pid, $tags, $depth);
unset($tree);
@@ -1023,10 +1030,10 @@ public function &getParents($object)
}
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.forum.php');
- if (!$parents = newbbGetParentForum($object->getVar('forum_id'))) {
+ if (!$parents = \newbbGetParentForum($object->getVar('forum_id'))) {
return $ret;
}
- $parents_list = $this->getList(new \Criteria('forum_id', '(' . implode(', ', $parents) . ')', 'IN'));
+ $parents_list = $this->getList(new \Criteria('forum_id', '(' . \implode(', ', $parents) . ')', 'IN'));
foreach ($parents as $key => $id) {
$ret[] = ['forum_id' => $id, 'forum_name' => $parents_list[$id]];
}
@@ -1040,9 +1047,9 @@ public function &getParents($object)
/**
* function for get forum Ids by positive and negative values
*
- * @param int|text|array $values : positive values = forums | negative values = cats | $values=0 = all valid forums, $permission , true/false $parse_cats
- * @param string $permission
- * @param bool $parse_cats
+ * @param int|text|array $values : positive values = forums | negative values = cats | $values=0 = all valid forums, $permission , true/false $parse_cats
+ * @param string $permission
+ * @param bool $parse_cats
* @return array|mixed $validForums
*/
public function getIdsByValues($values = 0, $permission = 'access', $parse_cats = true)
@@ -1053,7 +1060,7 @@ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats
if (empty($values)) {
return $validForums;
}
- $values = is_numeric($values) ? [$values] : $values;
+ $values = \is_numeric($values) ? [$values] : $values;
//parse negative values to category IDs
$forums = [];
$cats = [];
@@ -1064,19 +1071,18 @@ public function getIdsByValues($values = 0, $permission = 'access', $parse_cats
} elseif ($val > 0) {
$forums[] = $val;
} else {
- $cats[] = abs($val);
+ $cats[] = \abs($val);
}
}
// if dont want to parse categories OR no cats return all forums
if (empty($parse_cats) || empty($cats)) {
- return array_intersect($validForums, $forums);
+ return \array_intersect($validForums, $forums);
}
// Get all forums by category IDs
$forumObjs = $this->getForumsByCategory($cats, $permission, true);
- $forums = array_merge($forums, array_keys($forumObjs));
+ $forums = \array_merge($forums, \array_keys($forumObjs));
- return array_intersect($validForums, $forums);
+ return \array_intersect($validForums, $forums);
}
-
// END irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
}
diff --git a/class/GroupFormCheckBox.php b/class/GroupFormCheckBox.php
index d3deab2c..a011a18b 100644
--- a/class/GroupFormCheckBox.php
+++ b/class/GroupFormCheckBox.php
@@ -33,14 +33,14 @@ public function __construct($caption, $name, $groupId, $values = null)
parent::__construct($caption, $name, $groupId, $values);
}
- /**
- * Renders checkbox options for an item tree
- *
- * @param string $tree
- * @param array $option
- * @param string $prefix
- * @param array $parentIds
- */
+ /**
+ * Renders checkbox options for an item tree
+ *
+ * @param string $tree
+ * @param array $option
+ * @param string $prefix
+ * @param array $parentIds
+ */
public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
{
if ($option['id'] > 0) {
@@ -57,24 +57,13 @@ public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = [])
$tree .= "var ele = xoopsGetElementById('" . $child_ele . "'); if (this.checked !== true) {ele.checked = false;}";
}
$tree .= '" value="1"';
- if (in_array($option['id'], $this->_value)) {
+ if (\in_array($option['id'], $this->_value)) {
$tree .= ' checked';
}
- $tree .= ' >'
- . $option['name']
- . ' \n";
+ $tree .= ' >' . $option['name'] . ' \n";
} else {
$tree .= $prefix . $option['name'] . ' \n";
}
diff --git a/class/GroupPermForm.php b/class/GroupPermForm.php
index 4885faba..898bfb53 100644
--- a/class/GroupPermForm.php
+++ b/class/GroupPermForm.php
@@ -44,19 +44,19 @@ public function newbb_XoopsGroupPermForm($title, $modid, $permname, $permdesc, $
public function render()
{
// load all child ids for javascript codes
- foreach (array_keys($this->_itemTree) as $item_id) {
+ foreach (\array_keys($this->_itemTree) as $item_id) {
$this->_itemTree[$item_id]['allchild'] = [];
$this->_loadAllChildItemIds($item_id, $this->_itemTree[$item_id]['allchild']);
}
/** @var \XoopsGroupPermHandler $grouppermHandler */
- $grouppermHandler = xoops_getHandler('groupperm');
+ $grouppermHandler = \xoops_getHandler('groupperm');
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$glist = $memberHandler->getGroupList();
- foreach (array_keys($glist) as $i) {
+ foreach (\array_keys($glist) as $i) {
// get selected item id(s) for each group
$selected = $grouppermHandler->getItemIds($this->_permName, $i, $this->_modid);
- $ele = new Newbb\GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
+ $ele = new GroupFormCheckBox($glist[$i], 'perms[' . $this->_permName . ']', $i, $selected);
$ele->setOptionTree($this->_itemTree);
$this->addElement($ele);
unset($ele);
@@ -69,8 +69,8 @@ public function render()
$ret .= "getExtra() . ">\n\n";
$elements = $this->getElements();
$hidden = '';
- foreach (array_keys($elements) as $i) {
- if (!is_object($elements[$i])) {
+ foreach (\array_keys($elements) as $i) {
+ if (!\is_object($elements[$i])) {
$ret .= $elements[$i];
} elseif (!$elements[$i]->isHidden()) {
$ret .= "" . $elements[$i]->getCaption();
diff --git a/class/Helper.php b/class/Helper.php
index 7698551f..700e4286 100644
--- a/class/Helper.php
+++ b/class/Helper.php
@@ -21,8 +21,6 @@
* @author XOOPS Development Team
*/
-//defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Class Helper
*/
@@ -36,7 +34,7 @@ class Helper extends \Xmf\Module\Helper
public function __construct($debug = false)
{
$this->debug = $debug;
- $moduleDirName = basename(dirname(__DIR__));
+ $moduleDirName = \basename(\dirname(__DIR__));
parent::__construct($moduleDirName);
}
@@ -49,7 +47,7 @@ public static function getInstance($debug = false)
{
static $instance;
if (null === $instance) {
- $instance = new static($debug);
+ $instance = new self($debug);
}
return $instance;
@@ -89,10 +87,17 @@ public function getDirname()
*/
public function getHandler($name)
{
- $db = \XoopsDatabaseFactory::getDatabaseConnection();
- $class = '\\XoopsModules\\' . ucfirst(mb_strtolower(basename(dirname(__DIR__)))) . '\\' . $name . 'Handler';
- $ret = new $class($db);
+ $ret = false;
+ $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler';
+ if (!\class_exists($class)) {
+ throw new \RuntimeException("Class '$class' not found");
+ }
+ /** @var \XoopsMySQLDatabase $db */
+ $db = \XoopsDatabaseFactory::getDatabaseConnection();
+ $helper = self::getInstance();
+ $ret = new $class($db, $helper);
+ $this->addLog("Getting handler '{$name}'");
return $ret;
}
}
diff --git a/class/IconHandler.php b/class/IconHandler.php
index 9b36db18..8d7c187b 100644
--- a/class/IconHandler.php
+++ b/class/IconHandler.php
@@ -6,14 +6,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Set forum image
*
@@ -41,22 +39,18 @@ class IconHandler
* reference to XOOPS template
*/
public $template;
-
/**
* image set
*/
private $forumImage = [];
-
/**
* prefix
*/
private $prefix = '';
-
/**
* postfix, including extension
*/
private $postfix = '.png';
-
/**
* images to be assigned to template
*/
@@ -77,7 +71,7 @@ public static function getInstance()
{
static $instance;
if (null === $instance) {
- $instance = new static();
+ $instance = new self();
}
return $instance;
@@ -86,9 +80,9 @@ public static function getInstance()
/**
* TODO: get compatible with new theme engine
* @param $type
- * @param string $dirname
- * @param string $default
- * @param string $endDir
+ * @param string $dirname
+ * @param string $default
+ * @param string $endDir
* @return mixed
*/
// START irmtfan - improve to get other "end dirnames" like "css" and "js" - change images with $endDir
@@ -103,18 +97,20 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima
$rel_dir = "modules/{$dirname}/{$endDir}";
// START irmtfan add default for all pathes
if (empty($default)) {
- $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}"));
+ $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}"));
} else {
- $path = is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH
- . "/default/{$rel_dir}/{$type}" : (is_dir(XOOPS_THEME_PATH
- . "/default/{$rel_dir}/{$default}/") ? XOOPS_THEME_PATH
- . "/default/{$rel_dir}/{$default}" : (is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$default}")) // XOOPS_ROOT_PATH
+ $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH
+ . "/default/{$rel_dir}/{$type}" : (\is_dir(
+ XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/"
+ ) ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path(
+ "modules/{$dirname}/templates/{$endDir}/{$default}"
+ )) // XOOPS_ROOT_PATH
) // XOOPS_THEME_PATH {$default}
) // XOOPS_THEME_PATH
); // $theme_path {$default}
}
// END irmtfan add default for all pathes
- $paths[$endDir . '/' . $type] = str_replace(XOOPS_ROOT_PATH, '', str_replace('\\', '/', $path));
+ $paths[$endDir . '/' . $type] = \str_replace(XOOPS_ROOT_PATH, '', \str_replace('\\', '/', $path));
return $paths[$endDir . '/' . $type];
}
@@ -125,10 +121,9 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima
* @param string $language
* @param string $dirname
*/
- public function init(/*$set = "default", */
- $language = 'english',
- $dirname = 'newbb')
- {
+ public function init(/*$set = "default", */ $language = 'english',
+ $dirname = 'newbb'
+ ) {
$this->forumImage = require_once $GLOBALS['xoops']->path("modules/{$dirname}/include/images.php");
$this->forumImage['icon'] = XOOPS_URL . $this->getPath('icon', $dirname) . '/';
@@ -161,8 +156,8 @@ public function getImageSource($image)
/**
* @param $image
- * @param string $alt
- * @param string $extra
+ * @param string $alt
+ * @param string $extra
* @return mixed
*/
public function getImage($image, $alt = '', $extra = '')
@@ -174,8 +169,8 @@ public function getImage($image, $alt = '', $extra = '')
/**
* @param $image
- * @param string $alt
- * @param string $extra
+ * @param string $alt
+ * @param string $extra
* @return string
*/
public function assignImage($image, $alt = '', $extra = '')
@@ -183,7 +178,7 @@ public function assignImage($image, $alt = '', $extra = '')
$this->setImage($image, $alt, $extra);
// START hacked by irmtfan - improve function to CSS3 buttons - add alt and title attributes - use span instead of button to support IE7&8
$tag = 'span';
- if ("class='forum_icon'" === $extra && in_array(mb_substr($image, 0, 2), ['t_', 'p_', 'up'])) {
+ if ("class='forum_icon'" === $extra && \in_array(mb_substr($image, 0, 2), ['t_', 'p_', 'up'])) {
$extra = "class='forum_icon forum_button'";
}
@@ -197,7 +192,7 @@ public function assignImage($image, $alt = '', $extra = '')
public function assignImages($images)
{
foreach ($images as $myImage) {
- list($image, $alt, $extra) = $myImage;
+ [$image, $alt, $extra] = $myImage;
$this->assignImage($image, $alt, $extra);
}
}
@@ -210,6 +205,6 @@ public function render()
//$this->template->assign_by_ref("image", $this->images);
$this->template->assign($this->images);
- return count($this->images);
+ return \count($this->images);
}
}
diff --git a/class/IpCheck.php b/class/IpCheck.php
index 86ceecd7..9e788519 100644
--- a/class/IpCheck.php
+++ b/class/IpCheck.php
@@ -11,13 +11,10 @@ class IpCheck
{
/** @var string */
private $ipin;
-
/** @var string */
private $ipout;
-
/** @var int */
private $ipver;
-
// Return IP type. 4 for IPv4, 6 for IPv6, 0 for bad IP.
/**
@@ -29,29 +26,27 @@ public function addressType($ipValue)
$this->ipver = 0;
// IPv4 addresses are easy-peasy
- if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+ if (\filter_var($this->ipin, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
$this->ipver = 4;
$this->ipout = $this->ipin;
}
// IPv6 is at least a little more complex.
- if (filter_var($this->ipin, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+ if (\filter_var($this->ipin, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
// Look for embedded IPv4 in an embedded IPv6 address, where FFFF is appended.
- if (0 === strncmp($this->ipin, '::FFFF:', 7)) {
+ if (0 === \strncmp($this->ipin, '::FFFF:', 7)) {
$ipv4addr = mb_substr($this->ipin, 7);
- if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+ if (\filter_var($ipv4addr, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
$this->ipver = 4;
$this->ipout = $ipv4addr;
}
-
// Look for an IPv4 address embedded as ::x.x.x.x
} elseif (0 === mb_strpos($this->ipin, '::')) {
$ipv4addr = mb_substr($this->ipin, 2);
- if (filter_var($ipv4addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+ if (\filter_var($ipv4addr, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
$this->ipver = 4;
$this->ipout = $ipv4addr;
}
-
// Otherwise, assume this an IPv6 address.
} else {
$this->ipver = 6;
@@ -69,9 +64,9 @@ public function addressType($ipValue)
public function isValidIpAddress($ip)
{
$value = 0;
- if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+ if (\filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
$value = 'A';
- } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+ } elseif (\filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
$value = 'AAAA';
}
diff --git a/class/KarmaHandler.php b/class/KarmaHandler.php
index 9ec16a4a..6c03572a 100644
--- a/class/KarmaHandler.php
+++ b/class/KarmaHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,7 +14,7 @@
class KarmaHandler
{
/**
- * @param null $user
+ * @param null $user
* @return int
*/
public function getUserKarma($user = null)
@@ -31,7 +31,7 @@ public function getUserKarma($user = null)
*/
public function calculateUserKarma($user)
{
- if (!is_object($user)) {
+ if (!\is_object($user)) {
$user_karma = 0;
} else {
$user_karma = $user->getVar('posts') * 50;
diff --git a/class/Moderate.php b/class/Moderate.php
index 959bfcbf..49ce798e 100644
--- a/class/Moderate.php
+++ b/class/Moderate.php
@@ -6,14 +6,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* A handler for User moderation management
*
@@ -27,12 +25,12 @@ class Moderate extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('mod_id', XOBJ_DTYPE_INT);
- $this->initVar('mod_start', XOBJ_DTYPE_INT);
- $this->initVar('mod_end', XOBJ_DTYPE_INT);
- $this->initVar('mod_desc', XOBJ_DTYPE_TXTBOX);
- $this->initVar('uid', XOBJ_DTYPE_INT);
- $this->initVar('ip', XOBJ_DTYPE_TXTBOX);
- $this->initVar('forum_id', XOBJ_DTYPE_INT);
+ $this->initVar('mod_id', \XOBJ_DTYPE_INT);
+ $this->initVar('mod_start', \XOBJ_DTYPE_INT);
+ $this->initVar('mod_end', \XOBJ_DTYPE_INT);
+ $this->initVar('mod_desc', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('uid', \XOBJ_DTYPE_INT);
+ $this->initVar('ip', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('forum_id', \XOBJ_DTYPE_INT);
}
}
diff --git a/class/ModerateHandler.php b/class/ModerateHandler.php
index cce2d89d..e170eb6e 100644
--- a/class/ModerateHandler.php
+++ b/class/ModerateHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,8 +14,6 @@
use Xmf\IPAddress;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Class ModerateHandler
*/
@@ -38,8 +36,8 @@ public function __construct(\XoopsDatabase $db = null)
*/
public function clearGarbage($expire = 0)
{
- $expire = time() - (int)$expire;
- $sql = sprintf('DELETE FROM `%s` WHERE mod_end < %u', $this->db->prefix('newbb_moderates'), $expire);
+ $expire = \time() - (int)$expire;
+ $sql = \sprintf('DELETE FROM `%s` WHERE mod_end < %u', $this->db->prefix('newbb_moderates'), $expire);
$this->db->queryF($sql);
}
@@ -47,20 +45,20 @@ public function clearGarbage($expire = 0)
* Check if a user is moderated, according to his uid and ip
*
*
- * @param int $uid user id
- * @param string|bool $ip user ip
- * @param int $forum
+ * @param int $uid user id
+ * @param string|bool $ip user ip
+ * @param int $forum
* @return bool true if IP is banned
*/
public function verifyUser($uid = -1, $ip = '', $forum = 0)
{
- error_reporting(E_ALL);
+ \error_reporting(\E_ALL);
// if user is admin do not suspend
- if (newbbIsAdmin($forum)) {
+ if (\newbbIsAdmin($forum)) {
return true;
}
- $uid = ($uid < 0) ? (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0) : (int)$uid;
+ $uid = ($uid < 0) ? (\is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0) : (int)$uid;
$criteria = new \CriteriaCompo(new \Criteria('uid', (int)$uid));
$forumCriteria = new \CriteriaCompo(new \Criteria('forum_id', 0), 'OR');
@@ -68,26 +66,26 @@ public function verifyUser($uid = -1, $ip = '', $forum = 0)
$forumCriteria->add(new \Criteria('forum_id', (int)$forum), 'OR');
}
$criteria->add($forumCriteria);
- $criteria->add(new \Criteria('mod_end', time(), '>'));
+ $criteria->add(new \Criteria('mod_end', \time(), '>'));
$matches = $this->getAll($criteria);
- if (0 === count($matches)) {
+ if (0 === \count($matches)) {
return true; // no matches
}
- if (count($matches) > 0 && $uid > 0) {
+ if (\count($matches) > 0 && $uid > 0) {
return false; // user is banned
}
// verify possible matches against IP address
$ip = empty($ip) ? IPAddress::fromRequest()->asReadable() : $ip;
foreach ($matches as $modMatch) {
- $rawModIp = trim($modMatch->getVar('ip', 'n'));
+ $rawModIp = \trim($modMatch->getVar('ip', 'n'));
if (empty($rawModIp)) {
return false; // banned without IP
}
- $parts = explode('/', $rawModIp);
+ $parts = \explode('/', $rawModIp);
$modIp = $parts[0];
$checkIp = new IPAddress($modIp);
if (false !== $checkIp->asReadable()) {
@@ -106,8 +104,8 @@ public function verifyUser($uid = -1, $ip = '', $forum = 0)
* Get latest expiration for a user moderation
*
*
- * @param mixed $item user id or ip
- * @param bool $isUid
+ * @param mixed $item user id or ip
+ * @param bool $isUid
* @return int
*/
public function getLatest($item, $isUid = true)
@@ -116,12 +114,12 @@ public function getLatest($item, $isUid = true)
if ($isUid) {
$criteria = 'uid =' . (int)$item;
} else {
- $ip_segs = explode('.', $item);
- $segs = min(count($ip_segs), 4);
+ $ip_segs = \explode('.', $item);
+ $segs = \min(\count($ip_segs), 4);
for ($i = 1; $i <= $segs; ++$i) {
- $ips[] = $this->db->quoteString(implode('.', array_slice($ip_segs, 0, $i)));
+ $ips[] = $this->db->quoteString(\implode('.', \array_slice($ip_segs, 0, $i)));
}
- $criteria = 'ip IN(' . implode(',', $ips) . ')';
+ $criteria = 'ip IN(' . \implode(',', $ips) . ')';
}
$sql = 'SELECT MAX(mod_end) AS expire FROM ' . $this->db->prefix('newbb_moderates') . ' WHERE ' . $criteria;
if (!$result = $this->db->query($sql)) {
@@ -135,9 +133,9 @@ public function getLatest($item, $isUid = true)
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
diff --git a/class/ObjectTree.php b/class/ObjectTree.php
index c6f98497..df96984a 100644
--- a/class/ObjectTree.php
+++ b/class/ObjectTree.php
@@ -28,10 +28,9 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
require_once $GLOBALS['xoops']->path('class/tree.php');
-if (!class_exists('ObjectTree')) {
+if (!\class_exists('ObjectTree')) {
/**
* Class ObjectTree
*/
@@ -41,7 +40,7 @@ class ObjectTree extends \XoopsObjectTree
* @param $objectArr
* @param null $rootId
*/
- public function __construct(&$objectArr, $rootId = null)
+ public function __construct($objectArr, $rootId = null)
{
parent::__construct($objectArr, 'forum_id', 'parent_forum', $rootId);
}
@@ -62,7 +61,7 @@ public function __construct(&$objectArr, $rootId = null)
protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $tags = null)
{
if ($key > 0) {
- if (count($tags) > 0) {
+ if (\count($tags) > 0) {
foreach ($tags as $tag) {
$ret[$key][$tag] = $this->tree[$key]['obj']->getVar($tag);
}
@@ -82,9 +81,9 @@ protected function makeTreeItems($key, &$ret, $prefix_orig, $prefix_curr = '', $
/**
* Make a select box with options from the tree
*
- * @param string $prefix String to indent deeper levels
- * @param int $key ID of the object to display as the root of select options
- * @param null $tags
+ * @param string $prefix String to indent deeper levels
+ * @param int $key ID of the object to display as the root of select options
+ * @param null $tags
* @return array|string HTML select box
* @internal param string $name Name of the select box
* @internal param string $fieldName Name of the member variable from the
@@ -100,17 +99,47 @@ public function &makeTree($prefix = '-', $key = 0, $tags = null)
return $ret;
}
+ /**
+ * Make options for a select box from
+ *
+ * @param string $fieldName Name of the member variable from the
+ * node objects that should be used as the title for the options.
+ * @param string $selected Value to display as selected
+ * @param int $key ID of the object to display as the root of select options
+ * @param string $ret (reference to a string when called from outside) Result from previous recursions
+ * @param string $prefix_orig String to indent items at deeper levels
+ * @param string $prefix_curr String to indent the current item
+ * @access private
+ */
+ public function _makeSelBoxOptions($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr = '')
+ {
+ if ($key > 0) {
+ $value = $this->tree[$key]['obj']->getVar($this->myId);
+ $ret .= 'tree[$key]['obj']->getVar($fieldName) . ' ';
+ $prefix_curr .= $prefix_orig;
+ }
+ if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) {
+ foreach ($this->tree[$key]['child'] as $childkey) {
+ $this->_makeSelBoxOptions($fieldName, $selected, $childkey, $ret, $prefix_orig, $prefix_curr);
+ }
+ }
+ }
+
/**
* Make a select box with options from the tree
*
- * @param string $name Name of the select box
- * @param string $fieldName Name of the member variable from the
+ * @param string $name Name of the select box
+ * @param string $fieldName Name of the member variable from the
* node objects that should be used as the title for the options.
- * @param string $prefix String to indent deeper levels
- * @param string $selected Value to display as selected
- * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy
- * @param int $key ID of the object to display as the root of select options
- * @param string $extra
+ * @param string $prefix String to indent deeper levels
+ * @param string $selected Value to display as selected
+ * @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy
+ * @param int $key ID of the object to display as the root of select options
+ * @param string $extra
* @return string HTML select box
*
* @deprecated since 2.5.9, please use makeSelectElement()
@@ -122,14 +151,15 @@ public function makeSelBox(
$selected = '',
$addEmptyOption = false,
$key = 0,
- $extra = '') //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0)
+ $extra = ''
+ ) //makeSelBox($name, $prefix = '-', $selected = '', $EmptyOption = false, $key = 0)
{
- $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
- trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},");
+ $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
+ \trigger_error("makeSelBox() is deprecated since 2.5.9, please use makeSelectElement(), accessed from {$trace[0]['file']} line {$trace[0]['line']},");
$ret = '';
if (!empty($addEmptyOption)) {
- $ret .= '' . (is_string($addEmptyOption) ? $addEmptyOption : '') . ' ';
+ $ret .= '' . (\is_string($addEmptyOption) ? $addEmptyOption : '') . ' ';
}
$this->_makeSelBoxOptions('forum_name', $selected, $key, $ret, $prefix);
$ret .= ' ';
@@ -140,9 +170,9 @@ public function makeSelBox(
/**
* Make a tree for the array of a given category
*
- * @param string $key top key of the tree
- * @param array $ret the tree
- * @param int $depth level of subcategories
+ * @param string $key top key of the tree
+ * @param array $ret the tree
+ * @param int $depth level of subcategories
* @internal param array $tags fields to be used
*/
public function getAllChildObject($key, &$ret, $depth = 0)
@@ -156,7 +186,7 @@ public function getAllChildObject($key, &$ret, $depth = 0)
if (isset($this->tree[$childkey]['obj'])) {
$ret['child'][$childkey] = $this->tree[$childkey]['obj'];
}
- $this->getAllChild_object($childkey, $ret['child'][$childkey], $depth);
+ $this->getAllChildObject($childkey, $ret['child'][$childkey], $depth);
}
}
}
@@ -164,8 +194,8 @@ public function getAllChildObject($key, &$ret, $depth = 0)
/**
* Make a tree for the array
*
- * @param int|string $key top key of the tree
- * @param int $depth level of subcategories
+ * @param int|string $key top key of the tree
+ * @param int $depth level of subcategories
* @return array
* @internal param array $tags fields to be used
*/
@@ -175,7 +205,7 @@ public function &makeObjectTree($key = 0, $depth = 0)
if ($depth > 0) {
++$depth;
}
- $this->getAllChild_object($key, $ret, $depth);
+ $this->getAllChildObject($key, $ret, $depth);
return $ret;
}
@@ -183,10 +213,10 @@ public function &makeObjectTree($key = 0, $depth = 0)
/**
* Make a tree for the array of a given category
*
- * @param string $key top key of the tree
- * @param array $ret the tree
- * @param array $tags fields to be used
- * @param int $depth level of subcategories
+ * @param string $key top key of the tree
+ * @param array $ret the tree
+ * @param array $tags fields to be used
+ * @param int $depth level of subcategories
*/
public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0)
{
@@ -197,7 +227,7 @@ public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0)
if (isset($this->tree[$key]['child'])) {
foreach ($this->tree[$key]['child'] as $childkey) {
if (isset($this->tree[$childkey]['obj'])) {
- if (count($tags) > 0) {
+ if (\count($tags) > 0) {
foreach ($tags as $tag) {
$ret['child'][$childkey][$tag] = $this->tree[$childkey]['obj']->getVar($tag);
}
@@ -214,9 +244,9 @@ public function getAllChildArray($key, &$ret, array $tags = [], $depth = 0)
/**
* Make a tree for the array
*
- * @param int|string $key top key of the tree
- * @param array $tags fields to be used
- * @param int $depth level of subcategories
+ * @param int|string $key top key of the tree
+ * @param array $tags fields to be used
+ * @param int $depth level of subcategories
* @return array
*/
public function &makeArrayTree($key = 0, $tags = null, $depth = 0)
@@ -233,9 +263,9 @@ public function &makeArrayTree($key = 0, $tags = null, $depth = 0)
/**#@+
* get all parent forums
*
- * @param string $key ID of the child object
- * @param array $ret (empty when called from outside) Result from previous recursions
- * @param int $uplevel (empty when called from outside) level of recursion
+ * @param string $key ID of the child object
+ * @param array $ret (empty when called from outside) Result from previous recursions
+ * @param int $uplevel (empty when called from outside) level of recursion
* @return array Array of parent nodes.
*/
public function &myGetParentForums($key, array $ret = [], $uplevel = 0)
@@ -245,7 +275,7 @@ public function &myGetParentForums($key, array $ret = [], $uplevel = 0)
if ($this->tree[$key]['parent'] !== $key) {
//$parents = $this->getParentForums($this->tree[$key]['parent'], $ret, $uplevel+1);
$parents = $this->getParentForums($this->tree[$key]['parent']);
- foreach (array_keys($parents) as $newkey) {
+ foreach (\array_keys($parents) as $newkey) {
$ret[$newkey] = $parents[$newkey];
}
}
@@ -256,7 +286,7 @@ public function &myGetParentForums($key, array $ret = [], $uplevel = 0)
/**
* @param $key
- * @param bool $reverse
+ * @param bool $reverse
* @return array
*/
public function &getParentForums($key, $reverse = true)
@@ -266,22 +296,21 @@ public function &getParentForums($key, $reverse = true)
if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) {
$pids[] = $this->tree[$this->tree[$key]['parent']]['obj']->getVar($this->myId);
$parents = $this->myGetParentForums($this->tree[$key]['parent'], $ret);
- foreach (array_keys($parents) as $newkey) {
- if (!is_object($newkey)) {
+ foreach (\array_keys($parents) as $newkey) {
+ if (!\is_object($newkey)) {
continue;
}
$ret[] = $parents[$newkey]->getVar($this->myId);
}
}
if ($reverse) {
- $pids = array_reverse($ret) + $pids;
+ $pids = \array_reverse($ret) + $pids;
} else {
$pids += $ret;
}
return $pids;
}
-
/**#@-*/
}
}
diff --git a/class/OnlineHandler.php b/class/OnlineHandler.php
index 9ba69713..140a6c22 100644
--- a/class/OnlineHandler.php
+++ b/class/OnlineHandler.php
@@ -6,16 +6,19 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
+use Criteria;
+use CriteriaElement;
+use Smarty;
use Xmf\IPAddress;
+use XoopsDatabase;
use XoopsModules\Newbb;
-
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var \XoopsOnlineHandler $xoopsOnlineHandler */
require_once dirname(__DIR__) . '/include/functions.config.php';
@@ -34,8 +37,11 @@ class OnlineHandler
* OnlineHandler constructor.
* @param \XoopsDatabase|null $db
*/
- public function __construct(\XoopsDatabase $db = null)
+ public function __construct(XoopsDatabase $db = null)
{
+ if (null === $db) {
+ $db = \XoopsDatabaseFactory::getDatabaseConnection();
+ }
$this->db = $db;
}
@@ -82,8 +88,9 @@ public function update()
$name = '';
}
- $xoops_onlineHandler = xoops_getHandler('online');
- $xoopsupdate = $xoops_onlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable());
+ /** @var \XoopsOnlineHandler $xoopsOnlineHandler */
+ $xoopsOnlineHandler = xoops_getHandler('online');
+ $xoopsupdate = $xoopsOnlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable());
if (!$xoopsupdate) {
//xoops_error("newbb online upate error");
}
@@ -95,15 +102,15 @@ public function update()
/**
* @param $xoopsTpl
*/
- public function render(\Smarty $xoopsTpl)
+ public function render(Smarty $xoopsTpl)
{
require_once dirname(__DIR__) . '/include/functions.render.php';
require_once dirname(__DIR__) . '/include/functions.user.php';
$criteria = null;
if ($this->topic_id) {
- $criteria = new \Criteria('online_topic', $this->topic_id);
+ $criteria = new Criteria('online_topic', $this->topic_id);
} elseif ($this->forum_id) {
- $criteria = new \Criteria('online_forum', $this->forum_id);
+ $criteria = new Criteria('online_forum', $this->forum_id);
}
$users = $this->getAll($criteria);
$num_total = count($users);
@@ -111,14 +118,14 @@ public function render(\Smarty $xoopsTpl)
$num_user = 0;
$users_id = [];
$users_online = [];
- for ($i = 0; $i < $num_total; ++$i) {
- if (empty($users[$i]['online_uid'])) {
+ foreach ($users as $i => $iValue) {
+ if (empty($iValue['online_uid'])) {
continue;
}
$users_id[] = $users[$i]['online_uid'];
- $users_online[$users[$i]['online_uid']] = [
- 'link' => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
- 'uname' => $users[$i]['online_uname'],
+ $users_online[$iValue['online_uid']] = [
+ 'link' => XOOPS_URL . '/userinfo.php?uid=' . $iValue['online_uid'],
+ 'uname' => $iValue['online_uname'],
];
++$num_user;
}
@@ -130,7 +137,8 @@ public function render(\Smarty $xoopsTpl)
$online['num_anonymous'] = $num_anonymous;
$administrator_list = newbbIsModuleAdministrators($users_id);
$moderator_list = [];
- if ($member_list = array_diff(array_keys($administrator_list), $users_id)) {
+ $member_list = array_diff(array_keys($administrator_list), $users_id);
+ if ($member_list) {
if (is_object($this->forumObject)) {
$moderator_list = $this->forumObject->getVar('forum_moderator');
} else {
@@ -160,9 +168,9 @@ public function showOnline()
require_once dirname(__DIR__) . '/include/functions.user.php';
$criteria = null;
if ($this->topic_id) {
- $criteria = new \Criteria('online_topic', $this->topic_id);
+ $criteria = new Criteria('online_topic', $this->topic_id);
} elseif ($this->forum_id) {
- $criteria = new \Criteria('online_forum', $this->forum_id);
+ $criteria = new Criteria('online_forum', $this->forum_id);
}
$users = $this->getAll($criteria);
$num_total = count($users);
@@ -170,14 +178,14 @@ public function showOnline()
$num_user = 0;
$users_id = [];
$users_online = [];
- for ($i = 0; $i < $num_total; ++$i) {
- if (empty($users[$i]['online_uid'])) {
+ foreach ($users as $i => $iValue) {
+ if (empty($iValue['online_uid'])) {
continue;
}
$users_id[] = $users[$i]['online_uid'];
- $users_online[$users[$i]['online_uid']] = [
- 'link' => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
- 'uname' => $users[$i]['online_uname'],
+ $users_online[$iValue['online_uid']] = [
+ 'link' => XOOPS_URL . '/userinfo.php?uid=' . $iValue['online_uid'],
+ 'uname' => $iValue['online_uname'],
];
++$num_user;
}
@@ -190,7 +198,8 @@ public function showOnline()
$online['num_anonymous'] = $num_anonymous;
$administrator_list = newbbIsModuleAdministrators($users_id);
$moderator_list = [];
- if ($member_list = array_diff($users_id, array_keys($administrator_list))) {
+ $member_list = array_diff($users_id, array_keys($administrator_list));
+ if ($member_list) {
if (is_object($this->forumObject)) {
$moderator_list = $this->forumObject->getVar('forum_moderator');
} else {
@@ -215,11 +224,11 @@ public function showOnline()
/**
* Write online information to the database
*
- * @param int $uid UID of the active user
- * @param string $uname Username
+ * @param int $uid UID of the active user
+ * @param string $uname Username
* @param $time
- * @param string $forum_id Current forum_id
- * @param string $ip User's IP adress
+ * @param string $forum_id Current forum_id
+ * @param string $ip User's IP adress
* @param $topic_id
* @return bool TRUE on success
* @internal param string $timestamp
@@ -234,7 +243,7 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id)
} else {
$sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid . " AND online_ip='" . $ip . "'";
}
- list($count) = $this->db->fetchRow($this->db->queryF($sql));
+ [$count] = $this->db->fetchRow($this->db->queryF($sql));
if ($count > 0) {
$sql = 'UPDATE ' . $this->db->prefix('newbb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum_id . "', online_topic = '" . $topic_id . "' WHERE online_uid = " . $uid;
if (0 == $uid) {
@@ -248,9 +257,8 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id)
return false;
}
- /** @var \XoopsOnlineHandler $xoops_onlineHandler */
- $xoops_onlineHandler = xoops_getHandler('online');
- $xoopsOnlineTable = $xoops_onlineHandler->table;
+ $xoopsOnlineHandler = xoops_getHandler('online');
+ $xoopsOnlineTable = $xoopsOnlineHandler->table;
$sql = 'DELETE FROM '
. $this->db->prefix('newbb_online')
@@ -266,7 +274,8 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id)
. $xoopsModule->getVar('mid')
. ' AND online_uid = 0 ) )';
- if ($result = $this->db->queryF($sql)) {
+ $result = $this->db->queryF($sql);
+ if ($result) {
return true;
}
//xoops_error($this->db->error());
@@ -286,39 +295,37 @@ public function gc($expire)
$sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire);
$this->db->queryF($sql);
- $xoops_onlineHandler = xoops_getHandler('online');
- $xoops_onlineHandler->gc($expire);
+ $xoopsOnlineHandler = xoops_getHandler('online');
+ $xoopsOnlineHandler->gc($expire);
}
/**
* Get an array of online information
*
- * @param \CriteriaElement $criteria {@link \CriteriaElement}
+ * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link \CriteriaElement}
* @return array Array of associative arrays of online information
*/
- public function getAll(\CriteriaElement $criteria = null)
+ public function getAll($criteria = null)
{
$ret = [];
$limit = $start = 0;
$sql = 'SELECT * FROM ' . $this->db->prefix('newbb_online');
- if (is_object($criteria) && $criteria instanceof \CriteriaElement) {
+ if (is_object($criteria) && $criteria instanceof CriteriaElement) {
$sql .= ' ' . $criteria->renderWhere();
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
$result = $this->db->query($sql, $limit, $start);
- if (!$result) {
- return $ret;
- }
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $ret[] = $myrow;
- if ($myrow['online_uid'] > 0) {
- $this->user_ids[] = $myrow['online_uid'];
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $ret[] = $myrow;
+ if ($myrow['online_uid'] > 0) {
+ $this->user_ids[] = $myrow['online_uid'];
+ }
+ unset($myrow);
}
- unset($myrow);
+ $this->user_ids = array_unique($this->user_ids);
}
- $this->user_ids = array_unique($this->user_ids);
-
return $ret;
}
@@ -335,7 +342,7 @@ public function checkStatus($uids)
} else {
$sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online');
if (!empty($uids)) {
- $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('intval', $uids)) . ')';
+ $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('\intval', $uids)) . ')';
}
$result = $this->db->query($sql);
@@ -358,19 +365,19 @@ public function checkStatus($uids)
/**
* Count the number of online users
*
- * @param \CriteriaElement $criteria {@link CriteriaElement}
+ * @param \CriteriaElement|\CriteriaCompo|null $criteria {@link CriteriaElement}
* @return bool
*/
- public function getCount(\CriteriaElement $criteria = null)
+ public function getCount($criteria = null)
{
$sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online');
- if (is_object($criteria) && $criteria instanceof \CriteriaElement) {
+ if (is_object($criteria) && $criteria instanceof CriteriaElement) {
$sql .= ' ' . $criteria->renderWhere();
}
if (!$result = $this->db->query($sql)) {
return false;
}
- list($ret) = $this->db->fetchRow($result);
+ [$ret] = $this->db->fetchRow($result);
return $ret;
}
diff --git a/class/PermissionCategoryHandler.php b/class/PermissionCategoryHandler.php
index a07e5005..f69eb632 100644
--- a/class/PermissionCategoryHandler.php
+++ b/class/PermissionCategoryHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,8 +14,6 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
//defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php';
//define("NEWBB_HANDLER_PERMISSION_CATEGORY", 1);
@@ -36,7 +34,7 @@ public function __construct(\XoopsDatabase $db = null)
/**
* @param $mid
- * @param int $id
+ * @param int $id
* @return array
*/
public function getValidItems($mid, $id = 0)
@@ -62,7 +60,7 @@ public function deleteByCategory($cat_id)
return false;
}
/** @var \XoopsGroupPermHandler $grouppermHandler */
- $grouppermHandler = xoops_getHandler('groupperm');
+ $grouppermHandler = \xoops_getHandler('groupperm');
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
$criteria->add(new \Criteria('gperm_name', 'category_access'));
$criteria->add(new \Criteria('gperm_itemid', $cat_id));
@@ -72,28 +70,28 @@ public function deleteByCategory($cat_id)
/**
* @param $category
- * @param array $groups
+ * @param array $groups
* @return bool
*/
public function setCategoryPermission($category, array $groups = [])
{
- if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
+ if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
$mid = $GLOBALS['xoopsModule']->getVar('mid');
} else {
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
+ $moduleHandler = \xoops_getHandler('module');
$newbb = $moduleHandler->getByDirname('newbb');
$mid = $newbb->getVar('mid');
}
if (empty($groups)) {
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$glist = $memberHandler->getGroupList();
- $groups = array_keys($glist);
+ $groups = \array_keys($glist);
}
$ids = $this->getGroupIds('category_access', $category, $mid);
- $ids_add = array_diff($groups, $ids);
- $ids_rmv = array_diff($ids, $groups);
+ $ids_add = \array_diff($groups, $ids);
+ $ids_rmv = \array_diff($ids, $groups);
foreach ($ids_add as $group) {
$this->addRight('category_access', $category, $group, $mid);
}
diff --git a/class/PermissionForumHandler.php b/class/PermissionForumHandler.php
index e86d9dd4..b554ff46 100644
--- a/class/PermissionForumHandler.php
+++ b/class/PermissionForumHandler.php
@@ -6,24 +6,24 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
+use Xmf\IPAddress;
+use Xmf\Yaml;
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
//defined("NEWBB_HANDLER_PERMISSION") || require_once __DIR__ .'/permission.php';
//define("NEWBB_HANDLER_PERMISSION_FORUM", 1);
-if (defined('FORUM_PERM_ITEMS') && class_exists('ForumPermissionHandler')) {
+if (\defined('FORUM_PERM_ITEMS') && \class_exists('ForumPermissionHandler')) {
exit('access denied');
}
// irmtfan add pdf and print permissions.
-define('FORUM_PERM_ITEMS', 'access,view,post,reply,edit,delete,addpoll,vote,attach,noapprove,type,html,signature,pdf,print');
+\define('FORUM_PERM_ITEMS', 'access,view,post,reply,edit,delete,addpoll,vote,attach,noapprove,type,html,signature,pdf,print');
/**
* Class PermissionForumHandler
@@ -43,7 +43,7 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param bool $fullname
+ * @param bool $fullname
* @return array
*/
public function getValidPerms($fullname = false)
@@ -52,9 +52,9 @@ public function getValidPerms($fullname = false)
if (isset($validPerms[(int)$fullname])) {
return $validPerms[(int)$fullname];
}
- $items = array_filter(array_map('trim', explode(',', FORUM_PERM_ITEMS)));
+ $items = \array_filter(\array_map('\trim', \explode(',', FORUM_PERM_ITEMS)));
if (!empty($fullname)) {
- foreach (array_keys($items) as $key) {
+ foreach (\array_keys($items) as $key) {
$items[$key] = 'forum_' . $items[$key];
}
}
@@ -65,7 +65,7 @@ public function getValidPerms($fullname = false)
/**
* @param $mid
- * @param int $id
+ * @param int $id
* @return array
*/
public function getValidItems($mid, $id = 0)
@@ -76,13 +76,13 @@ public function getValidItems($mid, $id = 0)
return $full_items;
}
- require_once dirname(__DIR__) . '/include/functions.user.php';
- $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
- $ip = \Xmf\IPAddress::fromRequest()->asReadable();
+ require_once \dirname(__DIR__) . '/include/functions.user.php';
+ $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
+ $ip = IPAddress::fromRequest()->asReadable();
if (!empty($GLOBALS['xoopsModuleConfig']['enable_usermoderate']) && !isset($suspension[$uid][$id])
- && !newbbIsAdmin($id)) {
+ && !\newbbIsAdmin($id)) {
/** @var Newbb\ModerateHandler $moderateHandler */
- $moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate');
+ $moderateHandler = Helper::getInstance()->getHandler('Moderate');
if (!$moderateHandler->verifyUser($uid, '', $id)) {
$suspension[$uid][$ip][$id] = 1;
} else {
@@ -112,39 +112,39 @@ public function getValidItems($mid, $id = 0)
*/
/**
- * @param int|array $id
+ * @param int|array $id
* @return bool|array
*/
public function getPermissions($id = 0)
{
$permissions = [];
- if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
+ if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
$modid = $GLOBALS['xoopsModule']->getVar('mid');
} else {
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
+ $moduleHandler = \xoops_getHandler('module');
$xoopsNewBB = $moduleHandler->getByDirname('newbb');
$modid = $xoopsNewBB->getVar('mid');
unset($xoopsNewBB);
}
// Get user's groups
- $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
+ $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
// Create string of groupid's separated by commas, inserted in a set of brackets
- if (count($groups) < 1) {
+ if (\count($groups) < 1) {
return false;
}
// Create criteria for getting only the permissions regarding this module and this user's groups
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $modid));
- $criteria->add(new \Criteria('gperm_groupid', '(' . implode(',', $groups) . ')', 'IN'));
+ $criteria->add(new \Criteria('gperm_groupid', '(' . \implode(',', $groups) . ')', 'IN'));
if ($id) {
- if (is_array($id)) {
- $criteria->add(new \Criteria('gperm_itemid', '(' . implode(',', $id) . ')', 'IN'));
+ if (\is_array($id)) {
+ $criteria->add(new \Criteria('gperm_itemid', '(' . \implode(',', $id) . ')', 'IN'));
} else {
$criteria->add(new \Criteria('gperm_itemid', (int)$id));
}
}
- $gperm_names = implode(', ', $this->getValidItems($modid, $id));
+ $gperm_names = \implode(', ', $this->getValidItems($modid, $id));
// Add criteria for gpermnames
$criteria->add(new \Criteria('gperm_name', '(' . $gperm_names . ')', 'IN'));
@@ -163,9 +163,9 @@ public function getPermissions($id = 0)
}
/**
- * @param Forum|int $forum
- * @param bool $topic_locked
- * @param bool $isAdmin
+ * @param Forum|int $forum
+ * @param bool $topic_locked
+ * @param bool $isAdmin
* @return array
*/
public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = false)
@@ -173,7 +173,7 @@ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin =
$perm = [];
$forumId = $forum;
- if (is_object($forum)) {
+ if (\is_object($forum)) {
$forumId = $forum->getVar('forum_id');
}
@@ -188,9 +188,9 @@ public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin =
|| (isset($permission_set[$forumId]['forum_' . $item])
&& (!$topic_locked
|| 'view' === $item))) {
- $perm[] = constant('_MD_NEWBB_CAN_' . mb_strtoupper($item));
+ $perm[] = \constant('_MD_NEWBB_CAN_' . mb_strtoupper($item));
} else {
- $perm[] = constant('_MD_NEWBB_CANNOT_' . mb_strtoupper($item));
+ $perm[] = \constant('_MD_NEWBB_CANNOT_' . mb_strtoupper($item));
}
}
@@ -207,10 +207,11 @@ public function deleteByForum($forum_id)
if (empty($forum_id)) {
return false;
}
- $grouppermHandler = xoops_getHandler('groupperm');
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
+ $grouppermHandler = \xoops_getHandler('groupperm');
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid')));
$items = $this->getValidPerms(true);
- $criteria->add(new \Criteria('gperm_name', "('" . implode("', '", $items) . "')", 'IN'));
+ $criteria->add(new \Criteria('gperm_name', "('" . \implode("', '", $items) . "')", 'IN'));
$criteria->add(new \Criteria('gperm_itemid', $forum_id));
return $grouppermHandler->deleteAll($criteria);
@@ -218,7 +219,7 @@ public function deleteByForum($forum_id)
/**
* @param $forum
- * @param int $mid
+ * @param int $mid
* @return bool
*/
public function applyTemplate($forum, $mid = 0)
@@ -228,11 +229,11 @@ public function applyTemplate($forum, $mid = 0)
}
if (empty($mid)) {
- if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
+ if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
$mid = $GLOBALS['xoopsModule']->getVar('mid');
} else {
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
+ $moduleHandler = \xoops_getHandler('module');
$newbb = $moduleHandler->getByDirname('newbb');
$mid = $newbb->getVar('mid');
unset($newbb);
@@ -240,10 +241,10 @@ public function applyTemplate($forum, $mid = 0)
}
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$glist = $memberHandler->getGroupList();
$perms = $this->getValidPerms(true);
- foreach (array_keys($glist) as $group) {
+ foreach (\array_keys($glist) as $group) {
foreach ($perms as $perm) {
if (!empty($perm_template[$group][$perm])) {
$this->validateRight($perm, $forum, $group, $mid);
@@ -261,17 +262,17 @@ public function applyTemplate($forum, $mid = 0)
*/
public function getTemplate()
{
- $perms = \Xmf\Yaml::readWrapped($this->templateFilename);
+ $perms = Yaml::readWrapped($this->templateFilename);
return $perms;
}
/**
* @param array $perms
- * @return bool
+ * @return bool|int
*/
public function setTemplate($perms)
{
- return \Xmf\Yaml::saveWrapped($perms, $this->templateFilename);
+ return Yaml::saveWrapped($perms, $this->templateFilename);
}
}
diff --git a/class/PermissionHandler.php b/class/PermissionHandler.php
index 5f3afb9d..b9c9f7e9 100644
--- a/class/PermissionHandler.php
+++ b/class/PermissionHandler.php
@@ -6,21 +6,20 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
+use Xmf\Module\Helper\Cache;
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
-define('NEWBB_HANDLER_PERMISSION', 1);
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\define('NEWBB_HANDLER_PERMISSION', 1);
// Initializing XoopsGroupPermHandler if not loaded yet
-if (!class_exists('XoopsGroupPermHandler')) {
+if (!\class_exists('XoopsGroupPermHandler')) {
require_once $GLOBALS['xoops']->path('kernel/groupperm.php');
}
@@ -31,7 +30,6 @@ class PermissionHandler extends \XoopsGroupPermHandler
{
/** @var \Xmf\Module\Helper\Cache */
protected $cacheHelper;
-
/** @var array */
private $_handler;
@@ -40,7 +38,7 @@ class PermissionHandler extends \XoopsGroupPermHandler
*/
public function __construct(\XoopsDatabase $db = null)
{
- $this->cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $this->cacheHelper = new Cache('newbb');
$this->db = $db;
parent::__construct($db);
@@ -54,7 +52,7 @@ public function loadHandler($name)
{
if (!isset($this->_handler[$name])) {
// require_once __DIR__ . "/permission.{$name}.php";
- $className = '\\XoopsModules\\Newbb\\Permission' . ucfirst($name) . 'Handler';
+ $className = '\\XoopsModules\\Newbb\\Permission' . \ucfirst($name) . 'Handler';
$this->_handler[$name] = new $className($this->db);
}
@@ -62,7 +60,7 @@ public function loadHandler($name)
}
/**
- * @param bool $fullname
+ * @param bool $fullname
* @return mixed
*/
public function getValidForumPerms($fullname = false)
@@ -73,9 +71,9 @@ public function getValidForumPerms($fullname = false)
}
/**
- * @param int $forum
- * @param bool $topic_locked
- * @param bool $isAdmin
+ * @param int $forum
+ * @param bool $topic_locked
+ * @param bool $isAdmin
* @return mixed
*/
public function getPermissionTable($forum = 0, $topic_locked = false, $isAdmin = false)
@@ -112,7 +110,7 @@ public function deleteByCategory($cat_id)
/**
* @param $category
- * @param array $groups
+ * @param array $groups
* @return mixed
*/
public function setCategoryPermission($category, array $groups = [])
@@ -125,8 +123,8 @@ public function setCategoryPermission($category, array $groups = [])
/**
* @param $type
- * @param string $gperm_name
- * @param int $id
+ * @param string $gperm_name
+ * @param int $id
* @return bool
*/
public function getPermission($type, $gperm_name = 'access', $id = 0)
@@ -137,7 +135,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0)
$ret = true;
}
- $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
+ $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
if (!$groups) {
$ret = false;
}
@@ -145,7 +143,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0)
$ret = false;
}
- if (count(array_intersect($allowed_groups, $groups)) > 0) {
+ if (\count(\array_intersect($allowed_groups, $groups)) > 0) {
$ret = true;
}
@@ -153,7 +151,7 @@ public function getPermission($type, $gperm_name = 'access', $id = 0)
}
/**
- * @param string $perm_name
+ * @param string $perm_name
* @return array
*/
public function &getCategories($perm_name = 'access')
@@ -164,7 +162,7 @@ public function &getCategories($perm_name = 'access')
}
/**
- * @param string $perm_name
+ * @param string $perm_name
* @return array
*/
public function getForums($perm_name = 'access')
@@ -183,8 +181,8 @@ public function getAllowedItems($type, $perm_name)
{
$ret = [];
- $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
- if (count($groups) < 1) {
+ $groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [XOOPS_GROUP_ANONYMOUS];
+ if (\count($groups) < 1) {
return $ret;
}
@@ -198,32 +196,32 @@ public function getAllowedItems($type, $perm_name)
continue;
}
- if (array_intersect($groups, $allowed_groups)) {
+ if (\array_intersect($groups, $allowed_groups)) {
$allowed_items[$id] = 1;
}
}
unset($_cachedPerms);
- $ret = array_keys($allowed_items);
+ $ret = \array_keys($allowed_items);
return $ret;
}
/**
* @param $gperm_name
- * @param int $id
+ * @param int $id
* @return array
*/
public function getGroups($gperm_name, $id = 0)
{
$_cachedPerms = $this->loadPermData($gperm_name);
- $groups = empty($_cachedPerms[$id]) ? [] : array_unique($_cachedPerms[$id]);
+ $groups = empty($_cachedPerms[$id]) ? [] : \array_unique($_cachedPerms[$id]);
unset($_cachedPerms);
return $groups;
}
/**
- * @param string $perm_name
+ * @param string $perm_name
* @return array
*/
public function createPermData($perm_name = 'forum_all')
@@ -232,28 +230,30 @@ public function createPermData($perm_name = 'forum_all')
/** @var \XoopsModuleHandler $moduleHandler */
$perms = [];
- if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname')) {
+ if (\is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname')) {
$modid = $xoopsModule->getVar('mid');
} else {
- $moduleHandler = xoops_getHandler('module');
+ /** @var \XoopsModuleHandler $moduleHandler */
+ $moduleHandler = \xoops_getHandler('module');
$module = $moduleHandler->getByDirname('newbb');
$modid = $module->getVar('mid');
unset($module);
}
- if (in_array($perm_name, ['forum_all', 'category_all'])) {
+ if (\in_array($perm_name, ['forum_all', 'category_all'])) {
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
- $groups = array_keys($memberHandler->getGroupList());
+ $memberHandler = \xoops_getHandler('member');
+ $groups = \array_keys($memberHandler->getGroupList());
- $type = ('category_all' === $perm_name) ? 'category' : 'forum';
- $objectHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($type);
+ $type = ('category_all' === $perm_name) ? 'Category' : 'Forum';
+ /** @var \XoopsPersistableObjectHandler $objectHandler */
+ $objectHandler = Helper::getInstance()->getHandler($type);
$object_ids = $objectHandler->getIds();
foreach ($object_ids as $item_id) {
$perms[$perm_name][$item_id] = $groups;
}
} else {
- $grouppermHandler = xoops_getHandler('groupperm');
+ $grouppermHandler = \xoops_getHandler('groupperm');
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $modid));
if (!empty($perm_name) && 'forum_all' !== $perm_name && 'category_all' !== $perm_name) {
$criteria->add(new \Criteria('gperm_name', $perm_name));
@@ -266,8 +266,8 @@ public function createPermData($perm_name = 'forum_all')
$perms[$gperm->getVar('gperm_name')][$item_id][] = $group_id;
}
}
- if (count($perms) > 0) {
- foreach (array_keys($perms) as $perm) {
+ if (\count($perms) > 0) {
+ foreach (\array_keys($perms) as $perm) {
$this->cacheHelper->write("permission_{$perm}", $perms[$perm]);
}
}
@@ -277,7 +277,7 @@ public function createPermData($perm_name = 'forum_all')
}
/**
- * @param string $perm_name
+ * @param string $perm_name
* @return array|mixed|null
*/
public function &loadPermData($perm_name = 'forum_access')
@@ -293,17 +293,17 @@ public function &loadPermData($perm_name = 'forum_access')
* @param $perm
* @param $itemid
* @param $groupid
- * @param null $mid
+ * @param null $mid
* @return bool
*/
public function validateRight($perm, $itemid, $groupid, $mid = null)
{
if (empty($mid)) {
- if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
+ if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
$mid = $GLOBALS['xoopsModule']->getVar('mid');
} else {
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
+ $moduleHandler = \xoops_getHandler('module');
$mod = $moduleHandler->getByDirname('newbb');
$mid = $mod->getVar('mid');
unset($mod);
@@ -323,7 +323,7 @@ public function validateRight($perm, $itemid, $groupid, $mid = null)
*
* @param string $gperm_name Name of permission
* @param int $gperm_itemid ID of an item
- * @param int /array $gperm_groupid A group ID or an array of group IDs
+ * @param int /array $gperm_groupid A group ID or an array of group IDs
* @param int $gperm_modid ID of a module
*
* @return bool TRUE if permission is enabled
@@ -337,7 +337,7 @@ public function myCheckRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_
if ($gperm_itemid > 0) {
$criteria->add(new \Criteria('gperm_itemid', $gperm_itemid));
}
- if (is_array($gperm_groupid)) {
+ if (\is_array($gperm_groupid)) {
$criteria2 = new \CriteriaCompo();
foreach ($gperm_groupid as $gid) {
$criteria2->add(new \Criteria('gperm_groupid', $gid), 'OR');
@@ -357,24 +357,24 @@ public function myCheckRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_
* @param $perm
* @param $itemid
* @param $groupid
- * @param null $mid
+ * @param null $mid
* @return bool
*/
public function deleteRight($perm, $itemid, $groupid, $mid = null)
{
$this->cacheHelper->delete('permission');
if (null === $mid) {
- if (is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
+ if (\is_object($GLOBALS['xoopsModule']) && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) {
$mid = $GLOBALS['xoopsModule']->getVar('mid');
} else {
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
+ $moduleHandler = \xoops_getHandler('module');
$mod = $moduleHandler->getByDirname('newbb');
$mid = $mod->getVar('mid');
unset($mod);
}
}
- if (is_callable('parent::deleteRight')) {
+ if (\is_callable('parent::deleteRight')) {
return parent::deleteRight($perm, $itemid, $groupid, $mid);
}
$criteria = new \CriteriaCompo(new \Criteria('gperm_name', $perm));
@@ -394,7 +394,7 @@ public function deleteRight($perm, $itemid, $groupid, $mid = null)
/**
* @param $forum
- * @param int $mid
+ * @param int $mid
* @return mixed
*/
public function applyTemplate($forum, $mid = 0)
diff --git a/class/Plugin/index.html b/class/Plugin/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/class/Plugin/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/class/Plugin/index.php b/class/Plugin/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/class/Plugin/index.php
@@ -0,0 +1,3 @@
+
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
class Plugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface
{
/**
@@ -66,11 +67,10 @@ public function item($subscribe_from)
switch ($subscribe_from) {
case 'viewtopic.php':
- /** @var Newbb\TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
- $post_id = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0;
- $move = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : '';
- $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0;
+ /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = Helper::getInstance()->getHandler('Topic');
+ $post_id = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0;
+ $move = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : '';
+ $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0;
if (!empty($post_id)) {
$topicObject = $topicHandler->getByPost($post_id);
$topic_id = $topicObject->getVar('topic_id');
diff --git a/class/Post.php b/class/Post.php
index a0fe1581..2a5910d4 100644
--- a/class/Post.php
+++ b/class/Post.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -33,12 +33,11 @@
// ------------------------------------------------------------------------ //
use Xmf\Highlighter;
+use Xmf\IPAddress;
use Xmf\Request;
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Post
@@ -52,29 +51,29 @@ public function __construct()
{
parent::__construct();
- $this->initVar('post_id', XOBJ_DTYPE_INT);
- $this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true);
- $this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true);
- $this->initVar('post_time', XOBJ_DTYPE_INT, 0, true);
+ $this->initVar('post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_id', \XOBJ_DTYPE_INT, 0, true);
+ $this->initVar('forum_id', \XOBJ_DTYPE_INT, 0, true);
+ $this->initVar('post_time', \XOBJ_DTYPE_INT, 0, true);
// $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0);
- $this->initVar('poster_ip', XOBJ_DTYPE_TXTBOX, '');
- $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, '');
- $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true);
- $this->initVar('pid', XOBJ_DTYPE_INT, 0);
- $this->initVar('dohtml', XOBJ_DTYPE_INT, 0);
- $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1);
- $this->initVar('doxcode', XOBJ_DTYPE_INT, 1);
- $this->initVar('doimage', XOBJ_DTYPE_INT, 1);
- $this->initVar('dobr', XOBJ_DTYPE_INT, 1);
- $this->initVar('uid', XOBJ_DTYPE_INT, 1);
- $this->initVar('icon', XOBJ_DTYPE_TXTBOX, '');
- $this->initVar('attachsig', XOBJ_DTYPE_INT, 0);
- $this->initVar('approved', XOBJ_DTYPE_INT, 1);
- $this->initVar('post_karma', XOBJ_DTYPE_INT, 0);
- $this->initVar('require_reply', XOBJ_DTYPE_INT, 0);
- $this->initVar('attachment', XOBJ_DTYPE_TXTAREA, '');
- $this->initVar('post_text', XOBJ_DTYPE_TXTAREA, '');
- $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, '');
+ $this->initVar('poster_ip', \XOBJ_DTYPE_TXTBOX, '');
+ $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX, '');
+ $this->initVar('subject', \XOBJ_DTYPE_TXTBOX, '', true);
+ $this->initVar('pid', \XOBJ_DTYPE_INT, 0);
+ $this->initVar('dohtml', \XOBJ_DTYPE_INT, 0);
+ $this->initVar('dosmiley', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('doxcode', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('doimage', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('dobr', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('uid', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('icon', \XOBJ_DTYPE_TXTBOX, '');
+ $this->initVar('attachsig', \XOBJ_DTYPE_INT, 0);
+ $this->initVar('approved', \XOBJ_DTYPE_INT, 1);
+ $this->initVar('post_karma', \XOBJ_DTYPE_INT, 0);
+ $this->initVar('require_reply', \XOBJ_DTYPE_INT, 0);
+ $this->initVar('attachment', \XOBJ_DTYPE_TXTAREA, '');
+ $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA, '');
+ $this->initVar('post_edit', \XOBJ_DTYPE_TXTAREA, '');
}
// ////////////////////////////////////////////////////////////////////////////////////
@@ -85,14 +84,14 @@ public function __construct()
*/
public function getAttachment()
{
- if (count($this->attachmentArray)) {
+ if (\count($this->attachmentArray)) {
return $this->attachmentArray;
}
$attachment = $this->getVar('attachment');
if (empty($attachment)) {
$this->attachmentArray = [];
} else {
- $this->attachmentArray = @unserialize(base64_decode($attachment, true));
+ $this->attachmentArray = @\unserialize(\base64_decode($attachment, true));
}
return $this->attachmentArray;
@@ -118,8 +117,8 @@ public function incrementDownload($attachKey)
public function saveAttachment()
{
$attachmentSave = '';
- if ($this->attachmentArray && is_array($this->attachmentArray)) {
- $attachmentSave = base64_encode(serialize($this->attachmentArray));
+ if ($this->attachmentArray && \is_array($this->attachmentArray)) {
+ $attachmentSave = \base64_encode(\serialize($this->attachmentArray));
}
$this->setVar('attachment', $attachmentSave);
$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachmentSave) . ' WHERE post_id = ' . $this->getVar('post_id');
@@ -132,37 +131,37 @@ public function saveAttachment()
}
/**
- * @param array|null $attachArray
+ * @param array|null $attachArray
* @return bool
*/
public function deleteAttachment($attachArray = null)
{
$attachOld = $this->getAttachment();
- if (!is_array($attachOld) || count($attachOld) < 1) {
+ if (!\is_array($attachOld) || \count($attachOld) < 1) {
return true;
}
$this->attachmentArray = [];
if (null === $attachArray) {
- $attachArray = array_keys($attachOld);
+ $attachArray = \array_keys($attachOld);
} // to delete all!
- if (!is_array($attachArray)) {
+ if (!\is_array($attachArray)) {
$attachArray = [$attachArray];
}
foreach ($attachOld as $key => $attach) {
- if (in_array($key, $attachArray)) {
+ if (\in_array($key, $attachArray)) {
$file = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
- @unlink($file);
- $file = ($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved'])); // delete thumbnails
- @unlink($file);
+ @\unlink($file);
+ $file = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails
+ @\unlink($file);
continue;
}
$this->attachmentArray[$key] = $attach;
}
$attachmentSave = '';
- if ($this->attachmentArray && is_array($this->attachmentArray)) {
- $attachmentSave = base64_encode(serialize($this->attachmentArray));
+ if ($this->attachmentArray && \is_array($this->attachmentArray)) {
+ $attachmentSave = \base64_encode(\serialize($this->attachmentArray));
}
$this->setVar('attachment', $attachmentSave);
@@ -170,10 +169,10 @@ public function deleteAttachment($attachArray = null)
}
/**
- * @param string $name_saved
- * @param string $nameDisplay
- * @param string $mimetype
- * @param int $numDownload
+ * @param string $name_saved
+ * @param string $nameDisplay
+ * @param string $mimetype
+ * @param int $numDownload
* @return bool
*/
public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '', $numDownload = 0)
@@ -181,7 +180,7 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '
static $counter = 0;
$this->attachmentArray = $this->getAttachment();
if ($name_saved) {
- $key = (string)(time() + $counter++);
+ $key = (string)(\time() + $counter++);
$this->attachmentArray[$key] = [
'name_saved' => $name_saved,
// BigKev73 > without this change the nameDisplay will always get set to the $name_Saved, so in the forum it will show the on-disk filename instead of the name of the orginal file
@@ -195,8 +194,8 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '
];
}
$attachmentSave = null;
- if (is_array($this->attachmentArray)) {
- $attachmentSave = base64_encode(serialize($this->attachmentArray));
+ if (\is_array($this->attachmentArray)) {
+ $attachmentSave = \base64_encode(\serialize($this->attachmentArray));
}
$this->setVar('attachment', $attachmentSave);
@@ -205,7 +204,7 @@ public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '
/**
* TODO: refactor
- * @param bool $asSource
+ * @param bool $asSource
* @return string
*/
public function displayAttachment($asSource = false)
@@ -214,79 +213,77 @@ public function displayAttachment($asSource = false)
$post_attachment = '';
$attachments = $this->getAttachment();
- if ($attachments && is_array($attachments)) {
- $iconHandler = newbbGetIconHandler();
+ if ($attachments && \is_array($attachments)) {
+ $iconHandler = \newbbGetIconHandler();
$mime_path = $iconHandler->getPath('mime');
- require_once dirname(__DIR__) . '/include/functions.image.php';
+ require_once \dirname(__DIR__) . '/include/functions.image.php';
$image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!!
- $post_attachment .= '' . _MD_NEWBB_ATTACHMENT . ' :';
+ $post_attachment .= '' . \_MD_NEWBB_ATTACHMENT . ' :';
$post_attachment .= ' ';
foreach ($attachments as $key => $att) {
- $file_extension = ltrim(mb_strrchr($att['name_saved'], '.'), '.');
+ $file_extension = \ltrim(mb_strrchr($att['name_saved'], '.'), '.');
$filetype = $file_extension;
- if (file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) {
+ if (\file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) {
$icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif';
} else {
$icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif';
}
- $file_size = @filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
- $file_size = number_format($file_size / 1024, 2) . ' KB';
- if (in_array(mb_strtolower($file_extension), $image_extensions)
+ $file_size = @\filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
+ $file_size = \number_format($file_size / 1024, 2) . ' KB';
+ if (\in_array(mb_strtolower($file_extension), $image_extensions)
&& $GLOBALS['xoopsModuleConfig']['media_allowed']) {
$post_attachment .= ' ' . $att['nameDisplay'] . ' (' . $file_size . ') ';
- $post_attachment .= ' ' . newbbAttachmentImage($att['name_saved']);
+ $post_attachment .= ' ' . \newbbAttachmentImage($att['name_saved']);
$isDisplayed = true;
+ } elseif (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
+ $post_attachment .= ' '
+ . $att['nameDisplay']
+ . ' '
+ . \_MD_NEWBB_FILESIZE
+ . ': '
+ . $file_size
+ . '; '
+ . \_MD_NEWBB_HITS
+ . ': '
+ . $att['numDownload'];
+ } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0
+ && $GLOBALS['xoopsUser']->isactive()) {
+ $post_attachment .= ' '
+ . $att['nameDisplay']
+ . ' '
+ . \_MD_NEWBB_FILESIZE
+ . ': '
+ . $file_size
+ . '; '
+ . \_MD_NEWBB_HITS
+ . ': '
+ . $att['numDownload'];
} else {
- if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
- $post_attachment .= ' '
- . $att['nameDisplay']
- . ' '
- . _MD_NEWBB_FILESIZE
- . ': '
- . $file_size
- . '; '
- . _MD_NEWBB_HITS
- . ': '
- . $att['numDownload'];
- } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0
- && $GLOBALS['xoopsUser']->isactive()) {
- $post_attachment .= ' '
- . $att['nameDisplay']
- . ' '
- . _MD_NEWBB_FILESIZE
- . ': '
- . $file_size
- . '; '
- . _MD_NEWBB_HITS
- . ': '
- . $att['numDownload'];
- } else {
- $post_attachment .= _MD_NEWBB_SEENOTGUEST;
- }
+ $post_attachment .= _MD_NEWBB_SEENOTGUEST;
}
$post_attachment .= ' ';
}
@@ -299,19 +296,19 @@ public function displayAttachment($asSource = false)
// ////////////////////////////////////////////////////////////////////////////////////
/**
- * @param string $poster_name
- * @param string $post_editmsg
+ * @param string $poster_name
+ * @param string $post_editmsg
* @return bool
*/
public function setPostEdit($poster_name = '', $post_editmsg = '')
{
$edit_user = '';
if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
- || (time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60
+ || (\time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60
|| $this->getVar('approved') < 1) {
return true;
}
- if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
+ if (\is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) {
$edit_user = $GLOBALS['xoopsUser']->getVar('name');
} else {
@@ -321,18 +318,18 @@ public function setPostEdit($poster_name = '', $post_editmsg = '')
$post_edit = [];
$post_edit['edit_user'] = $edit_user; // (?) The proper way is to store uid instead of name.
// However, to save queries when displaying, the current way is ok.
- $post_edit['edit_time'] = time();
+ $post_edit['edit_time'] = \time();
$post_edit['edit_msg'] = $post_editmsg;
$post_edits = $this->getVar('post_edit');
if (!empty($post_edits)) {
- $post_edits = unserialize(base64_decode($post_edits, true));
+ $post_edits = \unserialize(\base64_decode($post_edits, true));
}
- if (!is_array($post_edits)) {
+ if (!\is_array($post_edits)) {
$post_edits = [];
}
$post_edits[] = $post_edit;
- $post_edit = base64_encode(serialize($post_edits));
+ $post_edit = \base64_encode(\serialize($post_edits));
unset($post_edits);
$this->setVar('post_edit', $post_edit);
@@ -353,12 +350,12 @@ public function displayPostEdit()
$post_edit = '';
$post_edits = $this->getVar('post_edit');
if (!empty($post_edits)) {
- $post_edits = unserialize(base64_decode($post_edits, true));
+ $post_edits = \unserialize(\base64_decode($post_edits, true));
}
- if (!isset($post_edits) || !is_array($post_edits)) {
+ if (!isset($post_edits) || !\is_array($post_edits)) {
$post_edits = [];
}
- if ($post_edits && is_array($post_edits)) {
+ if ($post_edits && \is_array($post_edits)) {
foreach ($post_edits as $postedit) {
$edit_time = (int)$postedit['edit_time'];
$edit_user = $postedit['edit_user'];
@@ -370,10 +367,10 @@ public function displayPostEdit()
// End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
// START hacked by irmtfan
// display/save all edit records.
- $post_edit .= _MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . _MD_NEWBB_ON . ' ' . formatTimestamp($edit_time) . ' ';
+ $post_edit .= \_MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . \_MD_NEWBB_ON . ' ' . \formatTimestamp($edit_time) . ' ';
// if reason is not empty
if ('' !== $edit_msg) {
- $post_edit .= _MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . ' ';
+ $post_edit .= \_MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . ' ';
}
// START hacked by irmtfan
}
@@ -388,32 +385,32 @@ public function displayPostEdit()
public function &getPostBody()
{
global $viewtopic_users;
- $newbbConfig = newbbLoadConfig();
- require_once dirname(__DIR__) . '/include/functions.user.php';
- require_once dirname(__DIR__) . '/include/functions.render.php';
+ $newbbConfig = \newbbLoadConfig();
+ require_once \dirname(__DIR__) . '/include/functions.user.php';
+ require_once \dirname(__DIR__) . '/include/functions.render.php';
- $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
+ $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
/** @var KarmaHandler $karmaHandler */
- $karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma');
+ $karmaHandler = Helper::getInstance()->getHandler('Karma');
$user_karma = $karmaHandler->getUserKarma();
$post = [];
$post['attachment'] = false;
- $post_text = newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
- if (newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
+ $post_text = \newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
+ if (\newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
$post['text'] = $post_text . ' ' . $this->displayAttachment();
} elseif ($newbbConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
- $post['text'] = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
+ $post['text'] = \sprintf(\_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
} elseif ($newbbConfig['allow_require_reply'] && $this->getVar('require_reply')
&& (!$uid || !isset($viewtopic_users[$uid]))) {
- $post['text'] = _MD_NEWBB_REPLY_REQUIREMENT;
+ $post['text'] = \_MD_NEWBB_REPLY_REQUIREMENT;
} else {
$post['text'] = $post_text . ' ' . $this->displayAttachment();
}
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$eachposter = $memberHandler->getUser($this->getVar('uid'));
- if (is_object($eachposter) && $eachposter->isActive()) {
+ if (\is_object($eachposter) && $eachposter->isActive()) {
if ($newbbConfig['show_realname'] && $eachposter->getVar('name')) {
$post['author'] = $eachposter->getVar('name');
} else {
@@ -424,7 +421,7 @@ public function &getPostBody()
$post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous'];
}
- $post['subject'] = newbbHtmlspecialchars($this->vars['subject']['value']);
+ $post['subject'] = \newbbHtmlspecialchars($this->vars['subject']['value']);
$post['date'] = $this->getVar('post_time');
@@ -440,32 +437,32 @@ public function isTopic()
}
/**
- * @param string $action_tag
+ * @param string $action_tag
* @return bool
*/
public function checkTimelimit($action_tag = 'edit_timelimit')
{
- $newbbConfig = newbbLoadConfig();
+ $newbbConfig = \newbbLoadConfig();
if (empty($newbbConfig['edit_timelimit'])) {
return true;
}
- return ($this->getVar('post_time') > time() - $newbbConfig[$action_tag] * 60);
+ return ($this->getVar('post_time') > \time() - $newbbConfig[$action_tag] * 60);
}
/**
- * @param int $uid
+ * @param int $uid
* @return bool
*/
public function checkIdentity($uid = -1)
{
- $uid = ($uid > -1) ? $uid : (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
+ $uid = ($uid > -1) ? $uid : (\is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
if ($this->getVar('uid') > 0) {
$user_ok = ($uid == $this->getVar('uid'));
} else {
static $user_ip;
if (!isset($user_ip)) {
- $user_ip = \Xmf\IPAddress::fromRequest()->asReadable();
+ $user_ip = IPAddress::fromRequest()->asReadable();
}
$user_ok = ($user_ip == $this->getVar('poster_ip'));
}
@@ -488,13 +485,13 @@ public function showPost($isAdmin)
static $post_NO = 0;
static $name_anonymous;
/** @var TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
if (null === $name_anonymous) {
- $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
+ $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']);
}
- require_once dirname(__DIR__) . '/include/functions.time.php';
- require_once dirname(__DIR__) . '/include/functions.render.php';
+ require_once \dirname(__DIR__) . '/include/functions.time.php';
+ require_once \dirname(__DIR__) . '/include/functions.render.php';
$post_id = $this->getVar('post_id');
$topic_id = $this->getVar('topic_id');
@@ -508,9 +505,9 @@ public function showPost($isAdmin)
$query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
}
}
- $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
+ $page_query = \htmlspecialchars(\implode('&', \array_values($query_array)), \ENT_QUOTES | \ENT_HTML5);
- $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
+ $uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
++$post_NO;
if ('desc' === mb_strtolower($order)) {
@@ -523,11 +520,11 @@ public function showPost($isAdmin)
$post_text = $this->getVar('post_text');
$post_attachment = $this->displayAttachment();
} elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
- $post_text = "" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
';
+ $post_text = "" . \sprintf(\_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '
';
$post_attachment = '';
} elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
- && (!$uid || !in_array($uid, $viewtopic_posters))) {
- $post_text = "" . _MD_NEWBB_REPLY_REQUIREMENT . '
';
+ && (!$uid || !\in_array($uid, $viewtopic_posters))) {
+ $post_text = "" . \_MD_NEWBB_REPLY_REQUIREMENT . '
';
$post_attachment = '';
} else {
$post_text = $this->getVar('post_text');
@@ -536,8 +533,9 @@ public function showPost($isAdmin)
// Hightlight search words
$post_title = $this->getVar('subject');
- if ($keywords = Request::getString('keywords', '', 'GET')) {
- //$keywords = $myts->htmlSpecialChars(trim(urldecode(Request::getString('keywords', '', 'GET'))));
+ $keywords = Request::getString('keywords', '', 'GET');
+ if ($keywords) {
+ //$keywords = htmlspecialchars(trim(urldecode(Request::getString('keywords', '', 'GET'))));
$post_text = Highlighter::apply($keywords, $post_text, '', ' ');
$post_title = Highlighter::apply($keywords, $post_title, '', ' ');
}
@@ -553,7 +551,8 @@ public function showPost($isAdmin)
];
}
- if ($posticon = $this->getVar('icon')) {
+ $posticon = $this->getVar('icon');
+ if ($posticon) {
$post_image = ' ';
} else {
$post_image = ' ';
@@ -564,12 +563,12 @@ public function showPost($isAdmin)
if ($isAdmin && ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid'))
&& $this->getVar('uid') > 0) {
- $mod_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
+ $mod_buttons['bann']['image'] = \newbbDisplayImage('p_bann', \_MD_NEWBB_SUSPEND_MANAGEMENT);
$mod_buttons['bann']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&uid=' . $this->getVar('uid');
- $mod_buttons['bann']['name'] = _MD_NEWBB_SUSPEND_MANAGEMENT;
- $thread_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
+ $mod_buttons['bann']['name'] = \_MD_NEWBB_SUSPEND_MANAGEMENT;
+ $thread_buttons['bann']['image'] = \newbbDisplayImage('p_bann', \_MD_NEWBB_SUSPEND_MANAGEMENT);
$thread_buttons['bann']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&uid=' . $this->getVar('uid');
- $thread_buttons['bann']['name'] = _MD_NEWBB_SUSPEND_MANAGEMENT;
+ $thread_buttons['bann']['name'] = \_MD_NEWBB_SUSPEND_MANAGEMENT;
}
if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
@@ -580,10 +579,10 @@ public function showPost($isAdmin)
$edit_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
if ($edit_ok) {
- $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
+ $thread_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT);
$thread_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
$thread_buttons['edit']['name'] = _EDIT;
- $mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
+ $mod_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT);
$mod_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
$mod_buttons['edit']['name'] = _EDIT;
}
@@ -593,110 +592,110 @@ public function showPost($isAdmin)
$delete_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
if ($delete_ok) {
- $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
+ $thread_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE);
$thread_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
$thread_buttons['delete']['name'] = _DELETE;
- $mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
+ $mod_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE);
$mod_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
$mod_buttons['delete']['name'] = _DELETE;
}
}
if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) {
- $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
+ $thread_buttons['reply']['image'] = \newbbDisplayImage('p_reply', \_MD_NEWBB_REPLY);
$thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
- $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY;
+ $thread_buttons['reply']['name'] = \_MD_NEWBB_REPLY;
- $thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE);
+ $thread_buttons['quote']['image'] = \newbbDisplayImage('p_quote', \_MD_NEWBB_QUOTE);
$thread_buttons['quote']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}"edac=1";
- $thread_buttons['quote']['name'] = _MD_NEWBB_QUOTE;
+ $thread_buttons['quote']['name'] = \_MD_NEWBB_QUOTE;
}
} else {
- $mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
+ $mod_buttons['edit']['image'] = \newbbDisplayImage('p_edit', _EDIT);
$mod_buttons['edit']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
$mod_buttons['edit']['name'] = _EDIT;
- $mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
+ $mod_buttons['delete']['image'] = \newbbDisplayImage('p_delete', _DELETE);
$mod_buttons['delete']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
$mod_buttons['delete']['name'] = _DELETE;
- $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
+ $thread_buttons['reply']['image'] = \newbbDisplayImage('p_reply', \_MD_NEWBB_REPLY);
$thread_buttons['reply']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
- $thread_buttons['reply']['name'] = _MD_NEWBB_REPLY;
+ $thread_buttons['reply']['name'] = \_MD_NEWBB_REPLY;
}
if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
- $thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT);
+ $thread_buttons['report']['image'] = \newbbDisplayImage('p_report', \_MD_NEWBB_REPORT);
$thread_buttons['report']['link'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/report.php?{$page_query}";
- $thread_buttons['report']['name'] = _MD_NEWBB_REPORT;
+ $thread_buttons['report']['name'] = \_MD_NEWBB_REPORT;
}
$thread_action = [];
// irmtfan add pdf permission
- if (file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')
+ if (\file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')
&& $topicHandler->getPermission($forum_id, $topic_status, 'pdf')) {
- $thread_action['pdf']['image'] = newbbDisplayImage('pdf', _MD_NEWBB_PDF);
+ $thread_action['pdf']['image'] = \newbbDisplayImage('pdf', \_MD_NEWBB_PDF);
$thread_action['pdf']['link'] = XOOPS_URL . '/modules/newbb/makepdf.php?type=post&pageid=0';
- $thread_action['pdf']['name'] = _MD_NEWBB_PDF;
+ $thread_action['pdf']['name'] = \_MD_NEWBB_PDF;
$thread_action['pdf']['target'] = '_blank';
}
// irmtfan add print permission
if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) {
- $thread_action['print']['image'] = newbbDisplayImage('printer', _MD_NEWBB_PRINT);
+ $thread_action['print']['image'] = \newbbDisplayImage('printer', \_MD_NEWBB_PRINT);
$thread_action['print']['link'] = XOOPS_URL . '/modules/newbb/print.php?form=2&forum=' . $forum_id . '&topic_id=' . $topic_id;
- $thread_action['print']['name'] = _MD_NEWBB_PRINT;
+ $thread_action['print']['name'] = \_MD_NEWBB_PRINT;
$thread_action['print']['target'] = '_blank';
}
if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) {
$full_title = $this->getVar('subject');
- $clean_title = preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
+ $clean_title = \preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
$full_link = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id;
- $thread_action['social_twitter']['image'] = newbbDisplayImage('twitter', _MD_NEWBB_SHARE_TWITTER);
+ $thread_action['social_twitter']['image'] = \newbbDisplayImage('twitter', \_MD_NEWBB_SHARE_TWITTER);
$thread_action['social_twitter']['link'] = 'http://twitter.com/share?text=' . $clean_title . '&url=' . $full_link;
- $thread_action['social_twitter']['name'] = _MD_NEWBB_SHARE_TWITTER;
+ $thread_action['social_twitter']['name'] = \_MD_NEWBB_SHARE_TWITTER;
$thread_action['social_twitter']['target'] = '_blank';
- $thread_action['social_facebook']['image'] = newbbDisplayImage('facebook', _MD_NEWBB_SHARE_FACEBOOK);
+ $thread_action['social_facebook']['image'] = \newbbDisplayImage('facebook', \_MD_NEWBB_SHARE_FACEBOOK);
$thread_action['social_facebook']['link'] = 'http://www.facebook.com/sharer.php?u=' . $full_link;
- $thread_action['social_facebook']['name'] = _MD_NEWBB_SHARE_FACEBOOK;
+ $thread_action['social_facebook']['name'] = \_MD_NEWBB_SHARE_FACEBOOK;
$thread_action['social_facebook']['target'] = '_blank';
- $thread_action['social_gplus']['image'] = newbbDisplayImage('googleplus', _MD_NEWBB_SHARE_GOOGLEPLUS);
+ $thread_action['social_gplus']['image'] = \newbbDisplayImage('googleplus', \_MD_NEWBB_SHARE_GOOGLEPLUS);
$thread_action['social_gplus']['link'] = 'https://plusone.google.com/_/+1/confirm?hl=en&url=' . $full_link;
- $thread_action['social_gplus']['name'] = _MD_NEWBB_SHARE_GOOGLEPLUS;
+ $thread_action['social_gplus']['name'] = \_MD_NEWBB_SHARE_GOOGLEPLUS;
$thread_action['social_gplus']['target'] = '_blank';
- $thread_action['social_linkedin']['image'] = newbbDisplayImage('linkedin', _MD_NEWBB_SHARE_LINKEDIN);
+ $thread_action['social_linkedin']['image'] = \newbbDisplayImage('linkedin', \_MD_NEWBB_SHARE_LINKEDIN);
$thread_action['social_linkedin']['link'] = 'http://www.linkedin.com/shareArticle?mini=true&title=' . $full_title . '&url=' . $full_link;
- $thread_action['social_linkedin']['name'] = _MD_NEWBB_SHARE_LINKEDIN;
+ $thread_action['social_linkedin']['name'] = \_MD_NEWBB_SHARE_LINKEDIN;
$thread_action['social_linkedin']['target'] = '_blank';
- $thread_action['social_delicious']['image'] = newbbDisplayImage('delicious', _MD_NEWBB_SHARE_DELICIOUS);
+ $thread_action['social_delicious']['image'] = \newbbDisplayImage('delicious', \_MD_NEWBB_SHARE_DELICIOUS);
$thread_action['social_delicious']['link'] = 'http://del.icio.us/post?title=' . $full_title . '&url=' . $full_link;
- $thread_action['social_delicious']['name'] = _MD_NEWBB_SHARE_DELICIOUS;
+ $thread_action['social_delicious']['name'] = \_MD_NEWBB_SHARE_DELICIOUS;
$thread_action['social_delicious']['target'] = '_blank';
- $thread_action['social_digg']['image'] = newbbDisplayImage('digg', _MD_NEWBB_SHARE_DIGG);
+ $thread_action['social_digg']['image'] = \newbbDisplayImage('digg', \_MD_NEWBB_SHARE_DIGG);
$thread_action['social_digg']['link'] = 'http://digg.com/submit?phase=2&title=' . $full_title . '&url=' . $full_link;
- $thread_action['social_digg']['name'] = _MD_NEWBB_SHARE_DIGG;
+ $thread_action['social_digg']['name'] = \_MD_NEWBB_SHARE_DIGG;
$thread_action['social_digg']['target'] = '_blank';
- $thread_action['social_reddit']['image'] = newbbDisplayImage('reddit', _MD_NEWBB_SHARE_REDDIT);
+ $thread_action['social_reddit']['image'] = \newbbDisplayImage('reddit', \_MD_NEWBB_SHARE_REDDIT);
$thread_action['social_reddit']['link'] = 'http://reddit.com/submit?title=' . $full_title . '&url=' . $full_link;
- $thread_action['social_reddit']['name'] = _MD_NEWBB_SHARE_REDDIT;
+ $thread_action['social_reddit']['name'] = \_MD_NEWBB_SHARE_REDDIT;
$thread_action['social_reddit']['target'] = '_blank';
- $thread_action['social_wong']['image'] = newbbDisplayImage('wong', _MD_NEWBB_SHARE_MRWONG);
+ $thread_action['social_wong']['image'] = \newbbDisplayImage('wong', \_MD_NEWBB_SHARE_MRWONG);
$thread_action['social_wong']['link'] = 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' . $full_link;
- $thread_action['social_wong']['name'] = _MD_NEWBB_SHARE_MRWONG;
+ $thread_action['social_wong']['name'] = \_MD_NEWBB_SHARE_MRWONG;
$thread_action['social_wong']['target'] = '_blank';
}
$post = [
'post_id' => $post_id,
'post_parent_id' => $this->getVar('pid'),
- 'post_date' => newbbFormatTimestamp($this->getVar('post_time')),
+ 'post_date' => \newbbFormatTimestamp($this->getVar('post_time')),
'post_image' => $post_image,
'post_title' => $post_title,
// irmtfan $post_title to add highlight keywords
@@ -715,7 +714,7 @@ public function showPost($isAdmin)
'post_permalink' => ' ',
];
- unset($thread_buttons, $mod_buttons, $eachposter);
+ unset($thread_buttons, $mod_buttons);
return $post;
}
diff --git a/class/PostHandler.php b/class/PostHandler.php
index 87a1bd06..e81e0dc3 100644
--- a/class/PostHandler.php
+++ b/class/PostHandler.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,11 +32,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-use XoopsModules\Newbb;
-
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class PostHandler
@@ -52,16 +48,17 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param mixed $id
- * @param null $var
+ * @param mixed $id
+ * @param null $var
* @return null|\XoopsObject
*/
public function get($id = null, $var = null) //get($id)
{
- $id = (int)$id;
- $post = null;
- $sql = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
- if ($array = $this->db->fetchArray($this->db->query($sql))) {
+ $id = (int)$id;
+ $post = null;
+ $sql = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
+ $array = $this->db->fetchArray($this->db->query($sql));
+ if ($array) {
$post = $this->create(false);
$post->assignVars($array);
}
@@ -70,13 +67,13 @@ public function get($id = null, $var = null) //get($id)
}
/**
- * @param int $limit
- * @param int $start
- * @param \CriteriaElement $criteria
- * @param null $fields
- * @param bool $asObject
- * @param int $topic_id
- * @param int $approved
+ * @param int $limit
+ * @param int $start
+ * @param \CriteriaElement|null $criteria
+ * @param null $fields
+ * @param bool $asObject
+ * @param int $topic_id
+ * @param int $approved
* @return array
*/
// public function getByLimit($topic_id, $limit, $approved = 1)
@@ -87,8 +84,8 @@ public function &getByLimit(
$fields = null,
$asObject = true,
$topic_id = 0,
- $approved = 1)
- {
+ $approved = 1
+ ) {
$sql = 'SELECT p.*, t.*, tp.topic_status FROM '
. $this->db->prefix('newbb_posts')
. ' p LEFT JOIN '
@@ -102,14 +99,15 @@ public function &getByLimit(
. ' ORDER BY p.post_time DESC';
$result = $this->db->query($sql, $limit, 0);
$ret = [];
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $post = $this->create(false);
- $post->assignVars($myrow);
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $post = $this->create(false);
+ $post->assignVars($myrow);
- $ret[$myrow['post_id']] = $post;
- unset($post);
+ $ret[$myrow['post_id']] = $post;
+ unset($post);
+ }
}
-
return $ret;
}
@@ -117,7 +115,7 @@ public function &getByLimit(
* @param Post $post
* @return mixed
*/
- public function getPostForPDF(&$post)
+ public function getPostForPDF($post)
{
return $post->getPostBody(true);
}
@@ -126,14 +124,14 @@ public function getPostForPDF(&$post)
* @param Post $post
* @return mixed
*/
- public function getPostForPrint(&$post)
+ public function getPostForPrint($post)
{
return $post->getPostBody();
}
/**
- * @param int|Post|\XoopsObject $post
- * @param bool $force
+ * @param int|Post $post
+ * @param bool $force
* @return bool
*/
public function approve(&$post, $force = false)
@@ -141,7 +139,7 @@ public function approve(&$post, $force = false)
if (empty($post)) {
return false;
}
- if (is_numeric($post)) {
+ if (\is_numeric($post)) {
$post = $this->get($post);
}
@@ -153,8 +151,8 @@ public function approve(&$post, $force = false)
$post->setVar('approved', 1);
$this->insert($post, true);
- /** @var Newbb\TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ /** @var TopicHandler $topicHandler */
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
$topicObject = $topicHandler->get($post->getVar('topic_id'));
if ($topicObject->getVar('topic_last_post_id') < $post->getVar('post_id')) {
$topicObject->setVar('topic_last_post_id', $post->getVar('post_id'));
@@ -166,8 +164,8 @@ public function approve(&$post, $force = false)
}
$topicHandler->insert($topicObject, true);
- /** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ /** @var ForumHandler $forumHandler */
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forumObject = $forumHandler->get($post->getVar('forum_id'));
if ($forumObject->getVar('forum_last_post_id') < $post->getVar('post_id')) {
$forumObject->setVar('forum_last_post_id', $post->getVar('post_id'));
@@ -181,9 +179,9 @@ public function approve(&$post, $force = false)
// Update user stats
if ($post->getVar('uid') > 0) {
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$poster = $memberHandler->getUser($post->getVar('uid'));
- if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
+ if (\is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
$poster->setVar('posts', $poster->getVar('posts') + 1);
$res = $memberHandler->insertUser($poster, true);
unset($poster);
@@ -192,7 +190,7 @@ public function approve(&$post, $force = false)
// Update forum stats
/** @var StatsHandler $statsHandler */
- $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats');
+ $statsHandler = Helper::getInstance()->getHandler('Stats');
$statsHandler->update($post->getVar('forum_id'), 'post');
if ($post->isTopic()) {
$statsHandler->update($post->getVar('forum_id'), 'topic');
@@ -202,8 +200,8 @@ public function approve(&$post, $force = false)
}
/**
- * @param \XoopsObject $post
- * @param bool $force
+ * @param Post $post
+ * @param bool $force
* @return bool
*/
public function insert(\XoopsObject $post, $force = true) //insert(&$post, $force = true)
@@ -212,13 +210,14 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc
// Set the post time
// The time should be "publish" time. To be adjusted later
if (!$post->getVar('post_time')) {
- $post->setVar('post_time', time());
+ $post->setVar('post_time', \time());
}
- /** @var Newbb\TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ /** @var TopicHandler $topicHandler */
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
// Verify the topic ID
- if ($topic_id = $post->getVar('topic_id')) {
+ $topic_id = $post->getVar('topic_id');
+ if ($topic_id) {
$topicObject = $topicHandler->get($topic_id);
// Invalid topic OR the topic is no approved and the post is not top post
if (!$topicObject// || (!$post->isTopic() && $topicObject->getVar("approved") < 1)
@@ -232,7 +231,7 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc
$post->setNew();
$topicObject = $topicHandler->create();
}
- $textHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Text');
+ $textHandler = Helper::getInstance()->getHandler('Text');
$post_text_vars = ['post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr'];
if ($post->isNew()) {
if (!$topic_id = $post->getVar('topic_id')) {
@@ -327,13 +326,13 @@ public function insert(\XoopsObject $post, $force = true) //insert(&$post, $forc
/**
* @param \XoopsObject|Post $post
- * @param bool $isDeleteOne
- * @param bool $force
+ * @param bool $isDeleteOne
+ * @param bool $force
* @return bool
*/
public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false)
{
- if (!is_object($post) || 0 == $post->getVar('post_id')) {
+ if (!\is_object($post) || 0 == $post->getVar('post_id')) {
return false;
}
@@ -350,10 +349,10 @@ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false)
return $this->myDelete($post, $force);
}
require_once $GLOBALS['xoops']->path('class/xoopstree.php');
- $mytree = new Newbb\Tree($this->db->prefix('newbb_posts'), 'post_id', 'pid');
+ $mytree = new Tree($this->db->prefix('newbb_posts'), 'post_id', 'pid');
$arr = $mytree->getAllChild($post->getVar('post_id'));
// irmtfan - delete childs in a reverse order
- for ($i = count($arr) - 1; $i >= 0; $i--) {
+ for ($i = \count($arr) - 1; $i >= 0; $i--) {
$childpost = $this->create(false);
$childpost->assignVars($arr[$i]);
$this->myDelete($childpost, $force);
@@ -365,15 +364,15 @@ public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false)
}
/**
- * @param Post|\XoopsObject $post
- * @param bool $force
+ * @param Post|\XoopsObject $post
+ * @param bool $force
* @return bool
*/
public function myDelete(Post $post, $force = false)
{
global $xoopsModule;
- if (!is_object($post) || 0 == $post->getVar('post_id')) {
+ if (!\is_object($post) || 0 == $post->getVar('post_id')) {
return false;
}
@@ -384,7 +383,7 @@ public function myDelete(Post $post, $force = false)
}
/* delete pending post directly */
} else {
- $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id'));
+ $sql = \sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id'));
if (!$result = $this->db->queryF($sql)) {
$post->setErrors('delete post error: ' . $sql);
@@ -392,7 +391,7 @@ public function myDelete(Post $post, $force = false)
}
$post->deleteAttachment();
- $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id'));
+ $sql = \sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id'));
if (!$result = $this->db->queryF($sql)) {
$post->setErrors('Could not remove post text: ' . $sql);
@@ -401,18 +400,18 @@ public function myDelete(Post $post, $force = false)
}
if ($post->isTopic()) {
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
/** @var Topic $topicObject */
$topicObject = $topicHandler->get($post->getVar('topic_id'));
- if (is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) {
+ if (\is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) {
$topiccount_toupdate = 1;
$topicObject->setVar('approved', -1);
$topicHandler->insert($topicObject);
- xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
+ \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
} else {
- if (is_object($topicObject)) {
+ if (\is_object($topicObject)) {
if ($topicObject->getVar('approved') > 0) {
- xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
+ \xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
}
$poll_id = $topicObject->getVar('poll_id');
@@ -421,11 +420,11 @@ public function myDelete(Post $post, $force = false)
// END irmtfan poll_module
}
- $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id'));
+ $sql = \sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id'));
if (!$result = $this->db->queryF($sql)) {
//xoops_error($this->db->error());
}
- $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id'));
+ $sql = \sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id'));
if (!$result = $this->db->queryF($sql)) {
//xoops_error($this->db->error());
}
@@ -446,9 +445,9 @@ public function myDelete(Post $post, $force = false)
// Update user stats
if ($post->getVar('uid') > 0) {
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$poster = $memberHandler->getUser($post->getVar('uid'));
- if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
+ if (\is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
$poster->setVar('posts', $poster->getVar('posts') - 1);
$res = $memberHandler->insertUser($poster, true);
unset($poster);
@@ -469,15 +468,15 @@ public function myDelete(Post $post, $force = false)
// START irmtfan enhance getPostCount when there is join (read_mode = 2)
/**
- * @param null $criteria
- * @param null $join
+ * @param \CriteriaElement|\CriteriaCompo|null $criteria
+ * @param null $join
* @return int|null
*/
public function getPostCount($criteria = null, $join = null)
{
// if not join get the count from XOOPS/class/model/stats as before
if (empty($join)) {
- return parent::getCount($criteria);
+ return $this->getCount($criteria);
}
$sql = 'SELECT COUNT(*) as count' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
@@ -503,10 +502,10 @@ public function getPostCount($criteria = null, $join = null)
*/
/**
- * @param null $criteria
- * @param int $limit
- * @param int $start
- * @param null $join
+ * @param \CriteriaElement|\CriteriaCompo|null $criteria
+ * @param int $limit
+ * @param int $start
+ * @param null $join
* @return array
*/
public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null)
@@ -523,17 +522,14 @@ public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join
}
}
$result = $this->db->query($sql, (int)$limit, (int)$start);
- if (!$result) {
- //xoops_error($this->db->error());
- return $ret;
- }
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $post = $this->create(false);
- $post->assignVars($myrow);
- $ret[$myrow['post_id']] = $post;
- unset($post);
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $post = $this->create(false);
+ $post->assignVars($myrow);
+ $ret[$myrow['post_id']] = $post;
+ unset($post);
+ }
}
-
return $ret;
}
@@ -549,9 +545,9 @@ public function synchronization()
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
@@ -572,14 +568,14 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
/**
* clean expired objects from database
*
- * @param int $expire time limit for expiration
+ * @param int $expire time limit for expiration
* @return bool true on success
*/
public function cleanExpires($expire = 0)
{
// irmtfan if 0 no cleanup look include/plugin.php
- if (!func_num_args()) {
- $newbbConfig = newbbLoadConfig();
+ if (!\func_num_args()) {
+ $newbbConfig = \newbbLoadConfig();
$expire = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7;
$expire = $expire * 24 * 3600; // days to seconds
}
@@ -588,7 +584,7 @@ public function cleanExpires($expire = 0)
}
$crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<='));
//if (!empty($expire)) {
- $crit_expire->add(new \Criteria('post_time', time() - (int)$expire, '<'));
+ $crit_expire->add(new \Criteria('post_time', \time() - (int)$expire, '<'));
//}
return $this->deleteAll($crit_expire, true/*, true*/);
diff --git a/class/Rate.php b/class/Rate.php
index 3ce28b26..5b9e5419 100644
--- a/class/Rate.php
+++ b/class/Rate.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,9 +32,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Rate
@@ -44,11 +42,11 @@ class Rate extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('ratingid', XOBJ_DTYPE_INT);
- $this->initVar('topic_id', XOBJ_DTYPE_INT);
- $this->initVar('ratinguser', XOBJ_DTYPE_INT);
- $this->initVar('rating', XOBJ_DTYPE_INT);
- $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT);
- $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX);
+ $this->initVar('ratingid', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_id', \XOBJ_DTYPE_INT);
+ $this->initVar('ratinguser', \XOBJ_DTYPE_INT);
+ $this->initVar('rating', \XOBJ_DTYPE_INT);
+ $this->initVar('ratingtimestamp', \XOBJ_DTYPE_INT);
+ $this->initVar('ratinghostname', \XOBJ_DTYPE_TXTBOX);
}
}
diff --git a/class/RateHandler.php b/class/RateHandler.php
index b7e25593..66620f80 100644
--- a/class/RateHandler.php
+++ b/class/RateHandler.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,9 +32,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class RateHandler
@@ -60,9 +58,9 @@ public function synchronization()
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
diff --git a/class/Read.php b/class/Read.php
index 35762273..2ab3df0a 100644
--- a/class/Read.php
+++ b/class/Read.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,9 +32,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* A handler for read/unread handling
@@ -53,10 +51,10 @@ public function __construct()
{
// parent::__construct("newbb_reads_" . $type);
parent::__construct();
- $this->initVar('read_id', XOBJ_DTYPE_INT);
- $this->initVar('uid', XOBJ_DTYPE_INT);
- $this->initVar('read_item', XOBJ_DTYPE_INT);
- $this->initVar('post_id', XOBJ_DTYPE_INT);
- $this->initVar('read_time', XOBJ_DTYPE_INT);
+ $this->initVar('read_id', \XOBJ_DTYPE_INT);
+ $this->initVar('uid', \XOBJ_DTYPE_INT);
+ $this->initVar('read_item', \XOBJ_DTYPE_INT);
+ $this->initVar('post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('read_time', \XOBJ_DTYPE_INT);
}
}
diff --git a/class/ReadHandler.php b/class/ReadHandler.php
index eeb192d9..8855125c 100644
--- a/class/ReadHandler.php
+++ b/class/ReadHandler.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,9 +32,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* A handler for read/unread handling
@@ -60,7 +58,6 @@ class ReadHandler extends \XoopsPersistableObjectHandler
* @var string
*/
public $type;
-
/**
* seconds records will persist.
* assigned from $GLOBALS['xoopsModuleConfig']["read_expire"]
@@ -70,10 +67,9 @@ class ReadHandler extends \XoopsPersistableObjectHandler
* -1 or any negative days = never records // irmtfan change comment
*
*
- * @var integer
+ * @var int
*/
public $lifetime;
-
/**
* storage mode for records.
* assigned from $GLOBALS['xoopsModuleConfig']["read_mode"]
@@ -83,7 +79,7 @@ class ReadHandler extends \XoopsPersistableObjectHandler
* 2 = stores in database
*
*
- * @var integer
+ * @var int
*/
public $mode;
@@ -96,7 +92,7 @@ public function __construct(\XoopsDatabase $db, $type)
$type = ('forum' === $type) ? 'forum' : 'topic';
parent::__construct($db, 'newbb_reads_' . $type, Read::class . $type, 'read_id', 'post_id');
$this->type = $type;
- $newbbConfig = newbbLoadConfig();
+ $newbbConfig = \newbbLoadConfig();
// irmtfan if read_expire = 0 dont clean
$this->lifetime = isset($newbbConfig['read_expire']) ? (int)$newbbConfig['read_expire'] * 24 * 3600 : 30 * 24 * 3600;
$this->mode = isset($newbbConfig['read_mode']) ? $newbbConfig['read_mode'] : 2;
@@ -125,7 +121,7 @@ public function clearGarbage()
return true;
}
// irmtfan move here and rephrase
- $expire = time() - (int)$this->lifetime;
+ $expire = \time() - (int)$this->lifetime;
$sql = 'DELETE FROM ' . $this->table . ' WHERE read_time < ' . $expire;
if (!$result = $this->db->queryF($sql)) {
//xoops_error($this->db->error());
@@ -139,7 +135,7 @@ public function clearGarbage()
/**
* @param $read_item
- * @param null $uid
+ * @param null $uid
* @return bool|mixed|null
*/
public function getRead($read_item, $uid = null)
@@ -163,7 +159,7 @@ public function getReadCookie($item_id)
$cookie_name = ('forum' === $this->type) ? 'LF' : 'LT';
$cookie_var = $item_id;
// irmtfan set true to return array
- $lastview = newbbGetCookie($cookie_name, true);
+ $lastview = \newbbGetCookie($cookie_name, true);
return @$lastview[$cookie_var];
}
@@ -176,7 +172,7 @@ public function getReadCookie($item_id)
public function getReadDb($read_item, $uid)
{
if (empty($uid)) {
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$uid = $GLOBALS['xoopsUser']->getVar('uid');
} else {
return false;
@@ -186,7 +182,7 @@ public function getReadDb($read_item, $uid)
if (!$result = $this->db->queryF($sql, 1)) {
return null;
}
- list($post_id) = $this->db->fetchRow($result);
+ [$post_id] = $this->db->fetchRow($result);
return $post_id;
}
@@ -194,7 +190,7 @@ public function getReadDb($read_item, $uid)
/**
* @param $read_item
* @param $post_id
- * @param null $uid
+ * @param null $uid
* @return bool|mixed|void
*/
public function setRead($read_item, $post_id, $uid = null)
@@ -217,9 +213,9 @@ public function setRead($read_item, $post_id, $uid = null)
public function setReadCookie($read_item, $post_id)
{
$cookie_name = ('forum' === $this->type) ? 'LF' : 'LT';
- $lastview = newbbGetCookie($cookie_name, true);
- $lastview[$read_item] = time();
- newbbSetCookie($cookie_name, $lastview);
+ $lastview = \newbbGetCookie($cookie_name, true);
+ $lastview[$read_item] = \time();
+ \newbbSetCookie($cookie_name, $lastview);
}
/**
@@ -231,14 +227,14 @@ public function setReadCookie($read_item, $post_id)
public function setReadDb($read_item, $post_id, $uid)
{
if (empty($uid)) {
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$uid = $GLOBALS['xoopsUser']->getVar('uid');
} else {
return false;
}
}
- $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid;
+ $sql = 'UPDATE ' . $this->table . ' SET post_id = ' . (int)$post_id . ',' . ' read_time =' . \time() . ' WHERE read_item = ' . (int)$read_item . ' AND uid = ' . (int)$uid;
if ($this->db->queryF($sql) && $this->db->getAffectedRows()) {
return true;
}
@@ -246,17 +242,17 @@ public function setReadDb($read_item, $post_id, $uid)
$object->setVar('read_item', $read_item);
$object->setVar('post_id', $post_id);
$object->setVar('uid', $uid);
- $object->setVar('read_time', time());
+ $object->setVar('read_time', \time());
- return parent::insert($object);
+ return $this->insert($object);
}
/**
* @param $items
- * @param null $uid
+ * @param null $uid
* @return array|null
*/
- public function isReadItems(&$items, $uid = null)
+ public function isReadItems($items, $uid = null)
{
$ret = null;
if (empty($this->mode)) {
@@ -276,14 +272,14 @@ public function isReadItems(&$items, $uid = null)
* @param $items
* @return array
*/
- public function isReadItemsCookie(&$items)
+ public function isReadItemsCookie($items)
{
$cookie_name = ('forum' === $this->type) ? 'LF' : 'LT';
- $cookie_vars = newbbGetCookie($cookie_name, true);
+ $cookie_vars = \newbbGetCookie($cookie_name, true);
$ret = [];
foreach ($items as $key => $last_update) {
- $ret[$key] = (max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update);
+ $ret[$key] = (\max(@$GLOBALS['last_visit'], @$cookie_vars[$key]) >= $last_update);
}
return $ret;
@@ -294,7 +290,7 @@ public function isReadItemsCookie(&$items)
* @param $uid
* @return array
*/
- public function isReadItemsDb(&$items, $uid)
+ public function isReadItemsDb($items, $uid)
{
$ret = [];
if (empty($items)) {
@@ -302,7 +298,7 @@ public function isReadItemsDb(&$items, $uid)
}
if (empty($uid)) {
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$uid = $GLOBALS['xoopsUser']->getVar('uid');
} else {
return $ret;
@@ -310,11 +306,11 @@ public function isReadItemsDb(&$items, $uid)
}
$criteria = new \CriteriaCompo(new \Criteria('uid', $uid));
- $criteria->add(new \Criteria('read_item', '(' . implode(', ', array_map('intval', array_keys($items))) . ')', 'IN'));
+ $criteria->add(new \Criteria('read_item', '(' . \implode(', ', \array_map('\intval', \array_keys($items))) . ')', 'IN'));
$itemsObject = $this->getAll($criteria, ['read_item', 'post_id']);
$items_list = [];
- foreach (array_keys($itemsObject) as $key) {
+ foreach (\array_keys($itemsObject) as $key) {
$items_list[$itemsObject[$key]->getVar('read_item')] = $itemsObject[$key]->getVar('post_id');
}
unset($itemsObject);
@@ -344,25 +340,25 @@ public function clearDuplicate()
$sql = 'CREATE TABLE ' . $this->table . '_duplicate LIKE ' . $this->table . '; ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
$sql = 'INSERT ' . $this->table . '_duplicate SELECT * FROM ' . $this->table . ' GROUP BY read_item, uid; ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
$sql = 'RENAME TABLE ' . $this->table . ' TO ' . $this->table . '_with_duplicate; ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
$sql = 'RENAME TABLE ' . $this->table . '_duplicate TO ' . $this->table . '; ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
@@ -371,20 +367,19 @@ public function clearDuplicate()
if (empty($result)) {
$sql .= 'ALTER TABLE ' . $this->table . ' ADD INDEX read_item_uid ( read_item, uid ); ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
}
$sql = 'DROP TABLE ' . $this->table . '_with_duplicate; ';
if (!$result = $this->db->queryF($sql)) {
- xoops_error($this->db->error() . ' ' . $sql);
+ \xoops_error($this->db->error() . ' ' . $sql);
return false;
}
return true;
}
-
// END irmtfan add clear duplicated rows function
}
diff --git a/class/Readforum.php b/class/Readforum.php
index 838e94db..aa3bee55 100644
--- a/class/Readforum.php
+++ b/class/Readforum.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
diff --git a/class/ReadforumHandler.php b/class/ReadforumHandler.php
index b1208cb6..80bd2043 100644
--- a/class/ReadforumHandler.php
+++ b/class/ReadforumHandler.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -61,9 +61,9 @@ public function __construct(\XoopsDatabase $db = null)
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
@@ -74,8 +74,8 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
}
/**
- * @param int $status
- * @param null $uid
+ * @param int $status
+ * @param null $uid
* @return bool
*/
public function setReadItems($status = 0, $uid = null)
@@ -92,23 +92,23 @@ public function setReadItems($status = 0, $uid = null)
}
/**
- * @param $status
- * @param $items
+ * @param int $status
+ * @param array|null $items
* @return bool
*/
- public function setReadItemsCookie($status, $items)
+ public function setReadItemsCookie($status, $items=null)
{
$cookie_name = 'LF';
$items = [];
if (!empty($status)) {
/** @var Newbb\ForumHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $itemHandler = Helper::getInstance()->getHandler('Forum');
$items_id = $itemHandler->getIds();
foreach ($items_id as $key) {
- $items[$key] = time();
+ $items[$key] = \time();
}
}
- newbbSetCookie($cookie_name, $items);
+ \newbbSetCookie($cookie_name, $items);
return true;
}
@@ -121,7 +121,7 @@ public function setReadItemsCookie($status, $items)
public function setReadItemsDb($status, $uid)
{
if (empty($uid)) {
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$uid = $GLOBALS['xoopsUser']->getVar('uid');
} else {
return false;
@@ -134,9 +134,9 @@ public function setReadItemsDb($status, $uid)
}
/** @var Newbb\ForumHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $itemHandler = Helper::getInstance()->getHandler('Forum');
$itemsObject = $itemHandler->getAll(null, ['forum_last_post_id']);
- foreach (array_keys($itemsObject) as $key) {
+ foreach (\array_keys($itemsObject) as $key) {
$this->setReadDb($key, $itemsObject[$key]->getVar('forum_last_post_id'), $uid);
}
unset($itemsObject);
diff --git a/class/Readtopic.php b/class/Readtopic.php
index d0b8e792..c51fcc1f 100644
--- a/class/Readtopic.php
+++ b/class/Readtopic.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
diff --git a/class/ReadtopicHandler.php b/class/ReadtopicHandler.php
index 00561778..1671331b 100644
--- a/class/ReadtopicHandler.php
+++ b/class/ReadtopicHandler.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -54,7 +54,7 @@ class ReadtopicHandler extends Newbb\ReadHandler
* maximum records per forum for one user.
* assigned from $GLOBALS['xoopsModuleConfig']["read_items"]
*
- * @var integer
+ * @var int
*/
private $items_per_forum;
@@ -64,16 +64,16 @@ class ReadtopicHandler extends Newbb\ReadHandler
public function __construct(\XoopsDatabase $db = null)
{
parent::__construct($db, 'topic');
- $newbbConfig = newbbLoadConfig();
+ $newbbConfig = \newbbLoadConfig();
$this->items_per_forum = isset($newbbConfig['read_items']) ? (int)$newbbConfig['read_items'] : 100;
}
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
@@ -97,9 +97,9 @@ public function clearGarbage()
}
/**
- * @param int $status
- * @param int $forum_id
- * @param null $uid
+ * @param int $status
+ * @param int $forum_id
+ * @param null $uid
* @return bool
*/
public function setReadItems($status = 0, $forum_id = 0, $uid = null)
@@ -123,10 +123,10 @@ public function setReadItems($status = 0, $forum_id = 0, $uid = null)
public function setReadItemsCookie($status, $forum_id)
{
$cookie_name = 'LT';
- $cookie_vars = newbbGetCookie($cookie_name, true);
+ $cookie_vars = \newbbGetCookie($cookie_name, true);
/** @var Newbb\TopicHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $itemHandler = Helper::getInstance()->getHandler('Topic');
$criteria = new \CriteriaCompo(new \Criteria('forum_id', $forum_id));
$criteria->setSort('topic_last_post_id');
$criteria->setOrder('DESC');
@@ -139,11 +139,11 @@ public function setReadItemsCookie($status, $forum_id)
unset($cookie_vars[$var]);
}
} else {
- $cookie_vars[$var] = time() /*$items[$var]*/
+ $cookie_vars[$var] = \time() /*$items[$var]*/
;
}
}
- newbbSetCookie($cookie_name, $cookie_vars);
+ \newbbSetCookie($cookie_name, $cookie_vars);
return true;
}
@@ -157,7 +157,7 @@ public function setReadItemsCookie($status, $forum_id)
public function setReadItemsDb($status, $forum_id, $uid)
{
if (empty($uid)) {
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$uid = $GLOBALS['xoopsUser']->getVar('uid');
} else {
return false;
@@ -165,7 +165,7 @@ public function setReadItemsDb($status, $forum_id, $uid)
}
/** @var Newbb\TopicHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $itemHandler = Helper::getInstance()->getHandler('Topic');
$criteria_topic = new \CriteriaCompo(new \Criteria('forum_id', $forum_id));
$criteria_topic->setSort('topic_last_post_id');
$criteria_topic->setOrder('DESC');
@@ -178,7 +178,7 @@ public function setReadItemsDb($status, $forum_id, $uid)
$sticky_id = $itemHandler->getIds($criteria_sticky);
$items = $items_id + $sticky_id;
$criteria = new \CriteriaCompo(new \Criteria('uid', $uid));
- $criteria->add(new \Criteria('read_item', '(' . implode(', ', $items) . ')', 'IN'));
+ $criteria->add(new \Criteria('read_item', '(' . \implode(', ', $items) . ')', 'IN'));
$this->deleteAll($criteria, true);
return true;
@@ -188,12 +188,12 @@ public function setReadItemsDb($status, $forum_id, $uid)
$stickyObject = $itemHandler->getAll($criteria_sticky, ['topic_last_post_id']);
$itemsObject += $stickyObject;
$items = [];
- foreach (array_keys($itemsObject) as $key) {
+ foreach (\array_keys($itemsObject) as $key) {
$items[$key] = $itemsObject[$key]->getVar('topic_last_post_id');
}
unset($itemsObject, $stickyObject);
- foreach (array_keys($items) as $key) {
+ foreach (\array_keys($items) as $key) {
$this->setReadDb($key, $items[$key], $uid);
}
diff --git a/class/Report.php b/class/Report.php
index 160483f5..ec00b962 100644
--- a/class/Report.php
+++ b/class/Report.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Report
@@ -24,13 +22,13 @@ class Report extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('report_id', XOBJ_DTYPE_INT);
- $this->initVar('post_id', XOBJ_DTYPE_INT);
- $this->initVar('reporter_uid', XOBJ_DTYPE_INT);
- $this->initVar('reporter_ip', XOBJ_DTYPE_TXTBOX);
- $this->initVar('report_time', XOBJ_DTYPE_INT);
- $this->initVar('report_text', XOBJ_DTYPE_TXTBOX);
- $this->initVar('report_result', XOBJ_DTYPE_INT);
- $this->initVar('report_memo', XOBJ_DTYPE_TXTBOX);
+ $this->initVar('report_id', \XOBJ_DTYPE_INT);
+ $this->initVar('post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('reporter_uid', \XOBJ_DTYPE_INT);
+ $this->initVar('reporter_ip', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('report_time', \XOBJ_DTYPE_INT);
+ $this->initVar('report_text', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('report_result', \XOBJ_DTYPE_INT);
+ $this->initVar('report_memo', \XOBJ_DTYPE_TXTBOX);
}
}
diff --git a/class/ReportHandler.php b/class/ReportHandler.php
index bf66fdbd..b03e142a 100644
--- a/class/ReportHandler.php
+++ b/class/ReportHandler.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class ReportHandler
@@ -39,25 +37,25 @@ public function getByPost($posts)
if (!$posts) {
return $ret;
}
- if (!is_array($posts)) {
+ if (!\is_array($posts)) {
$posts = [$posts];
}
- $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN');
+ $post_criteria = new \Criteria('post_id', '(' . \implode(', ', $posts) . ')', 'IN');
$ret = $this->getAll($post_criteria);
return $ret;
}
/**
- * @param int|array $forums
- * @param string $order
- * @param int $perpage
- * @param $start
- * @param int $report_result
- * @param int $reportId
+ * @param int|array $forums
+ * @param string $order
+ * @param int $perpage
+ * @param int $start
+ * @param int $report_result
+ * @param int $reportId
* @return array
*/
- public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start, $report_result = 0, $reportId = 0)
+ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start = 0, $report_result = 0, $reportId = 0)
{
$forumCriteria = '';
$row = [];
@@ -79,9 +77,9 @@ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start
if ($forums) {
$forumCriteria = '';
- } elseif (!is_array($forums)) {
+ } elseif (!\is_array($forums)) {
$forums = [$forums];
- $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')';
+ $forumCriteria = ' AND p.forum_id IN (' . \implode(',', $forums) . ')';
}
$tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id';
@@ -98,10 +96,11 @@ public function getAllReports($forums = 0, $order = 'ASC', $perpage = 0, &$start
$result = $this->db->query($sql, $perpage, $start);
$ret = [];
//$reportHandler = Newbb\Helper::getInstance()->getHandler('Report');
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $ret[] = $myrow; // return as array
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $ret[] = $myrow; // return as array
+ }
}
-
return $ret;
}
@@ -116,9 +115,9 @@ public function synchronization()
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
diff --git a/class/StatsHandler.php b/class/StatsHandler.php
index bdfbc0ea..1fe2af3d 100644
--- a/class/StatsHandler.php
+++ b/class/StatsHandler.php
@@ -6,25 +6,23 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+\defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
-defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
+\define('NEWBB_STATS_TYPE_TOPIC', 1);
+\define('NEWBB_STATS_TYPE_POST', 2);
+\define('NEWBB_STATS_TYPE_DIGEST', 3);
+\define('NEWBB_STATS_TYPE_VIEW', 4);
-define('NEWBB_STATS_TYPE_TOPIC', 1);
-define('NEWBB_STATS_TYPE_POST', 2);
-define('NEWBB_STATS_TYPE_DIGEST', 3);
-define('NEWBB_STATS_TYPE_VIEW', 4);
-
-define('NEWBB_STATS_PERIOD_TOTAL', 1);
-define('NEWBB_STATS_PERIOD_DAY', 2);
-define('NEWBB_STATS_PERIOD_WEEK', 3);
-define('NEWBB_STATS_PERIOD_MONTH', 4);
+\define('NEWBB_STATS_PERIOD_TOTAL', 1);
+\define('NEWBB_STATS_PERIOD_DAY', 2);
+\define('NEWBB_STATS_PERIOD_WEEK', 3);
+\define('NEWBB_STATS_PERIOD_MONTH', 4);
/**
* Stats for forum
@@ -44,21 +42,21 @@ class StatsHandler
public function __construct(\XoopsDatabase $db = null)
{
//$this->db = $db;
- //if (!$db || !($db instanceof XoopsDatabase)) {
+ //if (!$db || !($db instanceof \XoopsDatabase)) {
$this->db = $GLOBALS['xoopsDB'];
//}
$this->table = $this->db->prefix('newbb_stats');
}
/**
- * @param null|\XoopsDatabase $db
+ * @param null|\XoopsDatabase $db
* @return StatsHandler
*/
public static function getInstance(\XoopsDatabase $db = null)
{
static $instance;
if (null === $instance) {
- $instance = new static($db);
+ $instance = new self($db);
}
return $instance;
@@ -67,7 +65,7 @@ public static function getInstance(\XoopsDatabase $db = null)
/**
* @param $id
* @param $type
- * @param int $increment
+ * @param int $increment
* @return bool
*/
public function update($id, $type, $increment = 1)
@@ -75,7 +73,7 @@ public function update($id, $type, $increment = 1)
$id = (int)$id;
$increment = (int)$increment;
- if (empty($increment) || false === ($type = array_search($type, $this->param['type'], true))) {
+ if (empty($increment) || false === ($type = \array_search($type, $this->param['type'], true))) {
return false;
}
@@ -95,34 +93,34 @@ public function update($id, $type, $increment = 1)
. ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
. ' VALUES '
. " ('0', '{$increment}', '{$type}', '"
- . array_search('total', $this->param['period'], true)
+ . \array_search('total', $this->param['period'], true)
. "', NOW(), ''), "
. " ('0', '{$increment}', '{$type}', '"
- . array_search('day', $this->param['period'], true)
+ . \array_search('day', $this->param['period'], true)
. "', NOW(), '%Y%j'), "
. " ('0', '{$increment}', '{$type}', '"
- . array_search('week', $this->param['period'], true)
+ . \array_search('week', $this->param['period'], true)
. "', NOW(), '%Y%u'), "
. " ('0', '{$increment}', '{$type}', '"
- . array_search('month', $this->param['period'], true)
+ . \array_search('month', $this->param['period'], true)
. "', NOW(), '%Y%m')";
$result = $this->db->queryF($sql);
}
- if ($rows < 2 * count($this->param['period']) && !empty($id)) {
+ if ($rows < 2 * \count($this->param['period']) && !empty($id)) {
$sql = " INSERT INTO {$this->table}"
. ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
. ' VALUES '
. " ('{$id}', '{$increment}', '{$type}', '"
- . array_search('total', $this->param['period'], true)
+ . \array_search('total', $this->param['period'], true)
. "', NOW(), ''), "
. " ('{$id}', '{$increment}', '{$type}', '"
- . array_search('day', $this->param['period'], true)
+ . \array_search('day', $this->param['period'], true)
. "', NOW(), '%Y%j'), "
. " ('{$id}', '{$increment}', '{$type}', '"
- . array_search('week', $this->param['period'], true)
+ . \array_search('week', $this->param['period'], true)
. "', NOW(), '%Y%u'), "
. " ('{$id}', '{$increment}', '{$type}', '"
- . array_search('month', $this->param['period'], true)
+ . \array_search('month', $this->param['period'], true)
. "', NOW(), '%Y%m')";
$result = $this->db->queryF($sql);
}
@@ -131,35 +129,30 @@ public function update($id, $type, $increment = 1)
/**
* Get stats of "Today"
*
- * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all
- * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all
- * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all
+ * @param array $ids ID of forum: > 0, forum; 0 - global; empty - all
+ * @param array $types type of stats items: 1 - topic; 2 - post; 3 - digest; 4 - click; empty - all
+ * @param array $periods time period: 1 - all time; 2 - today; 3 - this week; 4 - this month; empty - all
* @return array
*/
- public function getStats(array $ids, array $types = [], array $periods = [])
+ public function getStats(array $ids = [], array $types = [], array $periods = [])
{
$ret = [];
$_types = [];
foreach ($types as $type) {
- $_types[] = array_search($type, $this->param['type'], true);
+ $_types[] = \array_search($type, $this->param['type'], true);
}
$_periods = [];
foreach ($periods as $period) {
- $_periods[] = array_search($period, $this->param['period'], true);
+ $_periods[] = \array_search($period, $this->param['period'], true);
}
- $sql = ' SELECT stats_id, stats_value, stats_type, stats_period '
- . " FROM {$this->table} "
- . ' WHERE '
- . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) "
- . ' '
- . (empty($ids) ? '' : 'AND stats_id IN ('
- . implode(', ', array_map('intval', $ids))
- . ')')
- . ' '
- . (empty($_types) ? '' : 'AND stats_type IN (' . implode(', ', $_types) . ')')
- . ' '
- . (empty($_periods) ? '' : 'AND stats_period IN (' . implode(', ', $_periods) . ')');
+ $sql = ' SELECT stats_id, stats_value, stats_type, stats_period ' . " FROM {$this->table} " . ' WHERE ' . " ( time_format = '' OR DATE_FORMAT(time_update, time_format) = DATE_FORMAT(NOW(), time_format) ) " . ' ' . (empty($ids) ? '' : 'AND stats_id IN (' . \implode(
+ ', ',
+ \array_map(
+ '\intval',
+ $ids
+ )
+ ) . ')') . ' ' . (empty($_types) ? '' : 'AND stats_type IN (' . \implode(', ', $_types) . ')') . ' ' . (empty($_periods) ? '' : 'AND stats_period IN (' . \implode(', ', $_periods) . ')');
$result = $this->db->query($sql);
while (false !== ($row = $this->db->fetchArray($result))) {
@@ -172,7 +165,7 @@ public function getStats(array $ids, array $types = [], array $periods = [])
public function reset()
{
$this->db->queryF('TRUNCATE TABLE ' . $this->table);
- $now = time();
+ $now = \time();
$time_start = [
'day' => '%Y%j',
'week' => '%Y%u',
@@ -185,83 +178,78 @@ public function reset()
while (list($forum_id) = $this->db->fetchRow($ret)) {
$sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}";
$result = $this->db->query($sql);
- list($topics, $views) = $this->db->fetchRow($result);
+ [$topics, $views] = $this->db->fetchRow($result);
$this->update($forum_id, 'topic', $topics);
$this->update($forum_id, 'view', $views);
$sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}";
$result = $this->db->query($sql);
- list($digests) = $this->db->fetchRow($result);
+ [$digests] = $this->db->fetchRow($result);
$this->update($forum_id, 'digest', $digests);
$sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}";
$result = $this->db->query($sql);
- list($posts) = $this->db->fetchRow($result);
+ [$posts] = $this->db->fetchRow($result);
$this->update($forum_id, 'post', $posts);
foreach ($time_start as $period => $format) {
$sql = ' SELECT COUNT(*), SUM(topic_views)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(topic_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')";
$result = $this->db->query($sql);
- list($topics, $views) = $this->db->fetchRow($result);
+ [$topics, $views] = $this->db->fetchRow($result);
$views = empty($views) ? 0 : $views; // null check
- $this->db->queryF(" INSERT INTO {$this->table}"
- . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
- . ' VALUES '
- . " ('{$forum_id}', '{$topics}', '"
- . array_search('topic', $this->param['type'], true)
- . "', '"
- . array_search($period, $this->param['period'], true)
- . "', NOW(), '{$format}')");
- $this->db->queryF(" INSERT INTO {$this->table}"
- . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
- . ' VALUES '
- . " ('{$forum_id}', '{$views}', '"
- . array_search('view', $this->param['type'], true)
- . "', '"
- . array_search($period, $this->param['period'], true)
- . "', NOW(), '{$format}')");
+ $this->db->queryF(
+ " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$topics}', '" . \array_search('topic', $this->param['type'], true) . "', '" . \array_search(
+ $period,
+ $this->param['period'],
+ true
+ ) . "', NOW(), '{$format}')"
+ );
+ $this->db->queryF(
+ " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$views}', '" . \array_search('view', $this->param['type'], true) . "', '" . \array_search(
+ $period,
+ $this->param['period'],
+ true
+ ) . "', NOW(), '{$format}')"
+ );
@$counts['topic'][$period] += $topics;
@$counts['view'][$period] += $views;
$sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_topics') . " WHERE approved=1 AND topic_digest >0 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(digest_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')";
$result = $this->db->query($sql);
- list($digests) = $this->db->fetchRow($result);
- $this->db->queryF(" INSERT INTO {$this->table}"
- . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
- . ' VALUES '
- . " ('{$forum_id}', '{$digests}', '"
- . array_search('digest', $this->param['type'], true)
- . "', '"
- . array_search($period, $this->param['period'], true)
- . "', NOW(), '{$format}')");
+ [$digests] = $this->db->fetchRow($result);
+ $this->db->queryF(
+ " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$digests}', '" . \array_search('digest', $this->param['type'], true) . "', '" . \array_search(
+ $period,
+ $this->param['period'],
+ true
+ ) . "', NOW(), '{$format}')"
+ );
@$counts['digest'][$period] += $digests;
$sql = ' SELECT COUNT(*)' . ' FROM ' . $this->db->prefix('newbb_posts') . " WHERE approved=1 AND forum_id = {$forum_id}" . " AND FROM_UNIXTIME(post_time, '{$format}') >= FROM_UNIXTIME({$now}, '{$format}')";
$result = $this->db->query($sql);
- list($posts) = $this->db->fetchRow($result);
- $this->db->queryF(" INSERT INTO {$this->table}"
- . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
- . ' VALUES '
- . " ('{$forum_id}', '{$posts}', '"
- . array_search('post', $this->param['type'], true)
- . "', '"
- . array_search($period, $this->param['period'], true)
- . "', NOW(), '{$format}')");
+ [$posts] = $this->db->fetchRow($result);
+ $this->db->queryF(
+ " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('{$forum_id}', '{$posts}', '" . \array_search('post', $this->param['type'], true) . "', '" . \array_search(
+ $period,
+ $this->param['period'],
+ true
+ ) . "', NOW(), '{$format}')"
+ );
@$counts['post'][$period] += $posts;
}
}
- $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . array_search('total', $this->param['period'], true));
+ $this->db->queryF(" DELETE FROM {$this->table}" . " WHERE stats_id = '0' AND stats_period <> " . \array_search('total', $this->param['period'], true));
foreach ($time_start as $period => $format) {
- foreach (array_keys($counts) as $type) {
- $this->db->queryF(" INSERT INTO {$this->table}"
- . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) '
- . ' VALUES '
- . " ('0', '{$counts[$type][$period]}', '"
- . array_search($type, $this->param['type'], true)
- . "', '"
- . array_search($period, $this->param['period'], true)
- . "', NOW(), '{$format}')");
+ foreach (\array_keys($counts) as $type) {
+ $this->db->queryF(
+ " INSERT INTO {$this->table}" . ' (`stats_id`, `stats_value`, `stats_type`, `stats_period`, `time_update`, `time_format`) ' . ' VALUES ' . " ('0', '{$counts[$type][$period]}', '" . \array_search($type, $this->param['type'], true) . "', '" . \array_search(
+ $period,
+ $this->param['period'],
+ true
+ ) . "', NOW(), '{$format}')"
+ );
}
}
}
diff --git a/class/Text.php b/class/Text.php
index 216f2409..903465cd 100644
--- a/class/Text.php
+++ b/class/Text.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Text
@@ -24,8 +22,8 @@ class Text extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('post_id', XOBJ_DTYPE_INT);
- $this->initVar('post_text', XOBJ_DTYPE_TXTAREA);
- $this->initVar('post_edit', XOBJ_DTYPE_SOURCE);
+ $this->initVar('post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA);
+ $this->initVar('post_edit', \XOBJ_DTYPE_SOURCE);
}
}
diff --git a/class/TextHandler.php b/class/TextHandler.php
index 928113eb..6d7331b7 100644
--- a/class/TextHandler.php
+++ b/class/TextHandler.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class TextHandler
@@ -32,9 +30,9 @@ public function __construct(\XoopsDatabase $db = null)
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
diff --git a/class/Topic.php b/class/Topic.php
index 282cd095..f4d03ce4 100644
--- a/class/Topic.php
+++ b/class/Topic.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -15,9 +15,7 @@
use XoopsModules\Newbb;
use XoopsModules\Xoopspoll;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Topic
@@ -27,26 +25,26 @@ class Topic extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('topic_id', XOBJ_DTYPE_INT);
- $this->initVar('topic_title', XOBJ_DTYPE_TXTBOX);
- $this->initVar('topic_poster', XOBJ_DTYPE_INT);
- $this->initVar('topic_time', XOBJ_DTYPE_INT);
- $this->initVar('topic_views', XOBJ_DTYPE_INT);
- $this->initVar('topic_replies', XOBJ_DTYPE_INT);
- $this->initVar('topic_last_post_id', XOBJ_DTYPE_INT);
- $this->initVar('forum_id', XOBJ_DTYPE_INT);
- $this->initVar('topic_status', XOBJ_DTYPE_INT);
- $this->initVar('type_id', XOBJ_DTYPE_INT);
- $this->initVar('topic_sticky', XOBJ_DTYPE_INT);
- $this->initVar('topic_digest', XOBJ_DTYPE_INT);
- $this->initVar('digest_time', XOBJ_DTYPE_INT);
- $this->initVar('approved', XOBJ_DTYPE_INT);
- $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX);
- $this->initVar('rating', XOBJ_DTYPE_OTHER);
- $this->initVar('votes', XOBJ_DTYPE_INT);
- $this->initVar('topic_haspoll', XOBJ_DTYPE_INT);
- $this->initVar('poll_id', XOBJ_DTYPE_INT);
- $this->initVar('topic_tags', XOBJ_DTYPE_SOURCE);
+ $this->initVar('topic_id', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_title', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('topic_poster', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_time', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_views', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_replies', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_last_post_id', \XOBJ_DTYPE_INT);
+ $this->initVar('forum_id', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_status', \XOBJ_DTYPE_INT);
+ $this->initVar('type_id', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_sticky', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_digest', \XOBJ_DTYPE_INT);
+ $this->initVar('digest_time', \XOBJ_DTYPE_INT);
+ $this->initVar('approved', \XOBJ_DTYPE_INT);
+ $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX);
+ $this->initVar('rating', \XOBJ_DTYPE_OTHER);
+ $this->initVar('votes', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_haspoll', \XOBJ_DTYPE_INT);
+ $this->initVar('poll_id', \XOBJ_DTYPE_INT);
+ $this->initVar('topic_tags', \XOBJ_DTYPE_SOURCE);
}
// irmtfan add LAST_INSERT_ID to enhance the mysql performances
@@ -67,14 +65,14 @@ public function getFullTitle()
if (!$this->getVar('type_id')) {
return $topic_title;
}
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
if (!$typeObject = $typeHandler->get($this->getVar('type_id'))) {
return $topic_title;
}
- require_once dirname(__DIR__) . '/include/functions.topic.php';
+ require_once \dirname(__DIR__) . '/include/functions.topic.php';
- return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color'));
+ return \getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color'));
}
// START irmtfan loadOldPoll function
@@ -83,7 +81,7 @@ public function getFullTitle()
* Load functions needed for old xoopspoll (older than version 1.4 by zyspec) and umfrage modules
*
* @access public
- * @param string $pollModule dirname of the poll module
+ * @param string $pollModule dirname of the poll module
* @return string|false $classPoll = the name of the old poll class eg: "XoopsPoll" | "Umfrage"
*/
public function loadOldPoll($pollModule = null)
@@ -92,7 +90,7 @@ public function loadOldPoll($pollModule = null)
if ($classPoll && null === $pollModule) {
return $classPoll;
}
- $newbbConfig = newbbLoadConfig();
+ $newbbConfig = \newbbLoadConfig();
if (null !== $pollModule) {
$newbbConfig['poll_module'] = $pollModule;
}
@@ -101,8 +99,8 @@ public function loadOldPoll($pollModule = null)
// require_once $relPath . 'option.php';
// require_once $relPath . 'log.php';
// require_once $relPath . 'renderer.php';
- $classes = get_declared_classes();
- foreach (array_reverse($classes) as $class) {
+ $classes = \get_declared_classes();
+ foreach (\array_reverse($classes) as $class) {
if (mb_strtolower($class) == $newbbConfig['poll_module']) {
$classPoll = $class;
@@ -120,7 +118,7 @@ public function loadOldPoll($pollModule = null)
* delete a poll in database
*
* @access public
- * @param int $poll_id
+ * @param int $poll_id
* @return bool
*/
public function deletePoll($poll_id)
@@ -129,10 +127,10 @@ public function deletePoll($poll_id)
return false;
}
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
- $newbbConfig = newbbLoadConfig();
+ $moduleHandler = \xoops_getHandler('module');
+ $newbbConfig = \newbbLoadConfig();
$pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']);
- if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) {
+ if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) {
return false;
}
// new xoopspoll module
@@ -146,7 +144,7 @@ public function deletePoll($poll_id)
/** @var \XoopsModules\XoopsPoll\LogHandler $logHandler */
$logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log');
$logHandler->deleteAll(new \Criteria('poll_id', $poll_id, '='));
- xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id);
+ \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll_id);
}
// old Xoopspoll or Umfrage or any clone from them
} else {
@@ -158,7 +156,7 @@ public function deletePoll($poll_id)
$classOption::deleteByPollId($poll->getVar('poll_id'));
$classLog = $classPoll . 'Log';
$classLog::deleteByPollId($poll->getVar('poll_id'));
- xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id'));
+ \xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id'));
}
} // end poll_module new or old
@@ -173,8 +171,8 @@ public function deletePoll($poll_id)
* get a poll object from a poll module.
* note: can be used to find if a poll exist in a module
* @access public
- * @param int $poll_id
- * @param string $pollModule dirname of the poll module
+ * @param int $poll_id
+ * @param string $pollModule dirname of the poll module
* @return bool|\XoopsObject poll
*/
public function getPoll($poll_id, $pollModule = null)
@@ -183,14 +181,14 @@ public function getPoll($poll_id, $pollModule = null)
return false;
}
/** @var \XoopsModuleHandler $moduleHandler */
- $moduleHandler = xoops_getHandler('module');
- $newbbConfig = newbbLoadConfig();
+ $moduleHandler = \xoops_getHandler('module');
+ $newbbConfig = \newbbLoadConfig();
if (null !== $pollModule) {
$newbbConfig['poll_module'] = $pollModule;
}
$pollModuleHandler = $moduleHandler->getByDirname($newbbConfig['poll_module']);
- if (!is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) {
+ if (!\is_object($pollModuleHandler) || !$pollModuleHandler->getVar('isactive')) {
return false;
}
// new xoopspoll module
@@ -205,6 +203,5 @@ public function getPoll($poll_id, $pollModule = null)
return $pollObject;
}
-
// END irmtfan add getPoll function
}
diff --git a/class/TopicHandler.php b/class/TopicHandler.php
index c43b1fc4..dbda1544 100644
--- a/class/TopicHandler.php
+++ b/class/TopicHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -15,9 +15,7 @@
use XoopsModules\Newbb;
use XoopsModules\Tag;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class TopicHandler
@@ -33,8 +31,8 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param mixed $id
- * @param null|array $fields
+ * @param mixed $id
+ * @param null|array $fields
* @return mixed|null
*/
public function get($id = null, $fields = null) //get($id, $var = null)
@@ -42,14 +40,14 @@ public function get($id = null, $fields = null) //get($id, $var = null)
$var = $fields;
$ret = null;
$tags = $var;
- if (!empty($var) && is_string($var)) {
+ if (!empty($var) && \is_string($var)) {
$tags = [$var];
}
if (!$topicObject = parent::get($id, $tags)) {
return $ret;
}
$ret = $topicObject;
- if (!empty($var) && is_string($var)) {
+ if (!empty($var) && \is_string($var)) {
$ret = @$topicObject->getVar($var);
}
@@ -58,22 +56,23 @@ public function get($id = null, $fields = null) //get($id, $var = null)
/**
* @param \XoopsObject $object
- * @param bool $force
+ * @param bool $force
* @return mixed
*/
public function insert(\XoopsObject $object, $force = true)
{
if (!$object->getVar('topic_time')) {
- $object->setVar('topic_time', time());
+ $object->setVar('topic_time', \time());
}
if (!parent::insert($object, $force) || !$object->getVar('approved')) {
return $object->getVar('topic_id');
}
- $newbbConfig = newbbLoadConfig();
- if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')
+ $newbbConfig = \newbbLoadConfig();
+ if (!empty($newbbConfig['do_tag']) && \class_exists('TagFormTag')
&& @require $GLOBALS['xoops']->path('modules/tag/include/functions.php')) {
- if ($tagHandler = tag_getTagHandler()) {
+ $tagHandler = \tag_getTagHandler();
+ if ($tagHandler) {
$tagHandler->updateByItem($object->getVar('topic_tags', 'n'), $object->getVar('topic_id'), 'newbb');
}
}
@@ -83,7 +82,7 @@ public function insert(\XoopsObject $object, $force = true)
/**
* @param $object
- * @param bool $force
+ * @param bool $force
* @return bool
*/
public function approve($object, $force = false)
@@ -98,13 +97,14 @@ public function approve($object, $force = false)
//xoops_error($this->db->error());
return false;
}
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$postsObject = $postHandler->getAll(new \Criteria('topic_id', $topic_id));
- foreach (array_keys($postsObject) as $post_id) {
+ foreach (\array_keys($postsObject) as $post_id) {
$postHandler->approve($postsObject[$post_id]);
}
unset($postsObject);
- $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats');
+ /** @var \XoopsModules\Newbb\StatsHandler $statsHandler */
+ $statsHandler = Helper::getInstance()->getHandler('Stats');
$statsHandler->update($object->getVar('forum_id'), 'topic');
return true;
@@ -132,9 +132,11 @@ public function &getByMove($topic_id, $action, $forum_id = 0)
{
$topic = null;
if (!empty($action)) {
- $sql = 'SELECT * FROM ' . $this->table . ' WHERE 1=1' . (($forum_id > 0) ? ' AND forum_id=' . (int)$forum_id : '') . ' AND topic_id ' . (($action > 0) ? '>' : '<') . (int)$topic_id . ' ORDER BY topic_id ' . (($action > 0) ? 'ASC' : 'DESC') . ' LIMIT 1';
- if ($result = $this->db->query($sql)) {
- if ($row = $this->db->fetchArray($result)) {
+ $sql = 'SELECT * FROM ' . $this->table . ' WHERE 1=1' . (($forum_id > 0) ? ' AND forum_id=' . (int)$forum_id : '') . ' AND topic_id ' . (($action > 0) ? '>' : '<') . (int)$topic_id . ' ORDER BY topic_id ' . (($action > 0) ? 'ASC' : 'DESC') . ' LIMIT 1';
+ $result = $this->db->query($sql);
+ if ($result) {
+ $row = $this->db->fetchArray($result);
+ if ($row) {
$topic = $this->create(false);
$topic->assignVars($row);
@@ -169,11 +171,11 @@ public function &getByPost($post_id)
}
/**
- * @param Topic $topic
- * @param string $type
+ * @param Topic $topic
+ * @param string $type
* @return mixed
*/
- public function getPostCount(&$topic, $type = '')
+ public function getPostCount($topic, $type = '')
{
switch ($type) {
case 'pending':
@@ -189,7 +191,7 @@ public function getPostCount(&$topic, $type = '')
$criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic->getVar('topic_id')));
$criteria->add(new \Criteria('approved', $approved));
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$count = $postHandler->getCount($criteria);
return $count;
@@ -214,7 +216,7 @@ public function &getTopPost($topic_id)
return $post;
}
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$myrow = $this->db->fetchArray($result);
/** @var Newbb\Post $post */
$post = $postHandler->create(false);
@@ -235,21 +237,21 @@ public function getTopPostId($topic_id)
//xoops_error($this->db->error());
return false;
}
- list($post_id) = $this->db->fetchRow($result);
+ [$post_id] = $this->db->fetchRow($result);
return $post_id;
}
/**
* @param $topic
- * @param string $order
- * @param int $perpage
- * @param $start
- * @param int $post_id
- * @param string $type
+ * @param string $order
+ * @param int $perpage
+ * @param int $start
+ * @param int $post_id
+ * @param string $type
* @return array
*/
- public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $post_id = 0, $type = '')
+ public function &getAllPosts($topic, $order = 'ASC', $perpage = 10, &$start = 0, $post_id = 0, $type = '')
{
$ret = [];
$perpage = ((int)$perpage > 0) ? (int)$perpage : (empty($GLOBALS['xoopsModuleConfig']['posts_per_page']) ? 10 : $GLOBALS['xoopsModuleConfig']['posts_per_page']);
@@ -280,7 +282,7 @@ public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $p
//xoops_error($this->db->error());
return $ret;
}
- list($position) = $this->db->fetchRow($result);
+ [$position] = $this->db->fetchRow($result);
$start = (int)($position / $perpage) * $perpage;
}
@@ -290,7 +292,7 @@ public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $p
//xoops_error($this->db->error());
return $ret;
}
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
while (false !== ($myrow = $this->db->fetchArray($result))) {
$post = $postHandler->create(false);
$post->assignVars($myrow);
@@ -303,13 +305,13 @@ public function &getAllPosts(&$topic, $order = 'ASC', $perpage = 10, &$start, $p
/**
* @param $postArray
- * @param int $pid
+ * @param int $pid
* @return mixed
*/
- public function &getPostTree(&$postArray, $pid = 0)
+ public function &getPostTree($postArray, $pid = 0)
{
// require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php');
- $NewBBTree = new Newbb\Tree('newbb_posts');
+ $NewBBTree = new Tree('newbb_posts');
$NewBBTree->setPrefix(' ');
$NewBBTree->setPostArray($postArray);
$NewBBTree->getPostTree($postsArray, $pid);
@@ -322,14 +324,14 @@ public function &getPostTree(&$postArray, $pid = 0)
* @param $postArray
* @return mixed
*/
- public function showTreeItem(&$topic, &$postArray)
+ public function showTreeItem($topic, &$postArray)
{
global $viewtopic_users, $myts;
- $postArray['post_time'] = newbbFormatTimestamp($postArray['post_time']);
+ $postArray['post_time'] = \newbbFormatTimestamp($postArray['post_time']);
if (!empty($postArray['icon'])) {
- $postArray['icon'] = ' ';
+ $postArray['icon'] = ' ';
} else {
$postArray['icon'] = ' ';
}
@@ -343,7 +345,7 @@ public function showTreeItem(&$topic, &$postArray)
$postArray['poster'] = '' . $viewtopic_users[$postArray['uid']]['name'] . ' ';
}
} else {
- $postArray['poster'] = empty($postArray['poster_name']) ? $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']) : $postArray['poster_name'];
+ $postArray['poster'] = empty($postArray['poster_name']) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']) : $postArray['poster_name'];
}
return $postArray;
@@ -351,47 +353,44 @@ public function showTreeItem(&$topic, &$postArray)
/**
* @param $topic
- * @param bool $isApproved
+ * @param bool $isApproved
* @return array
*/
- public function &getAllPosters(&$topic, $isApproved = true)
+ public function getAllPosters($topic, $isApproved = true)
{
+ $ret = [];
$sql = 'SELECT DISTINCT uid FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id=' . $topic->getVar('topic_id') . ' AND uid>0';
if ($isApproved) {
$sql .= ' AND approved = 1';
}
$result = $this->db->query($sql);
- if (!$result) {
- //xoops_error($this->db->error());
- return [];
- }
- $ret = [];
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $ret[] = $myrow['uid'];
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $ret[] = $myrow['uid'];
+ }
}
-
return $ret;
}
/**
* @param Topic|\XoopsObject $topic
- * @param bool $force
+ * @param bool $force
* @return bool
*/
public function delete(\XoopsObject $topic, $force = true)
{
- $topic_id = is_object($topic) ? $topic->getVar('topic_id') : (int)$topic;
+ $topic_id = \is_object($topic) ? $topic->getVar('topic_id') : (int)$topic;
if (empty($topic_id)) {
return false;
}
$postObject = $this->getTopPost($topic_id);
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$postHandler->delete($postObject, false, $force);
- $newbbConfig = newbbLoadConfig();
+ $newbbConfig = \newbbLoadConfig();
/** @var \XoopsModules\Tag\TagHandler $tagHandler */
- if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag') && $tagHandler = Tag\Helper::getInstance()->getHandler('Tag')) { //@xoops_getModuleHandler('tag', 'tag', true)) {
+ if (!empty($newbbConfig['do_tag']) && \class_exists('TagFormTag') && $tagHandler = Tag\Helper::getInstance()->getHandler('Tag')) { //@xoops_getModuleHandler('tag', 'tag', true)) {
$tagHandler->updateByItem([], $topic_id, 'newbb');
}
@@ -403,20 +402,20 @@ public function delete(\XoopsObject $topic, $force = true)
// $gperm_names = "'forum_can_post', 'forum_can_view', 'forum_can_reply', 'forum_can_edit', 'forum_can_delete', 'forum_can_addpoll', 'forum_can_vote', 'forum_can_attach', 'forum_can_noapprove'";
/**
- * @param Newbb\Forum $forum
- * @param int $topic_locked
- * @param string $type
+ * @param Newbb\Forum $forum
+ * @param int $topic_locked
+ * @param string $type
* @return bool
*/
public function getPermission($forum, $topic_locked = 0, $type = 'view')
{
static $_cachedTopicPerms;
- require_once dirname(__DIR__) . '/include/functions.user.php';
- if (newbbIsAdmin($forum)) {
+ require_once \dirname(__DIR__) . '/include/functions.user.php';
+ if (\newbbIsAdmin($forum)) {
return true;
}
- $forum_id = is_object($forum) ? $forum->getVar('forum_id') : (int)$forum;
+ $forum_id = \is_object($forum) ? $forum->getVar('forum_id') : (int)$forum;
if ($forum_id < 1) {
return false;
}
@@ -425,7 +424,7 @@ public function getPermission($forum, $topic_locked = 0, $type = 'view')
$permission = false;
} else {
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
$permission = $permHandler->getPermission('forum', $type, $forum_id);
}
@@ -435,9 +434,9 @@ public function getPermission($forum, $topic_locked = 0, $type = 'view')
/**
* clean orphan items from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
@@ -452,14 +451,14 @@ public function cleanOrphan($table_link = '', $field_link = '', $field_object =
/**
* clean expired objects from database
*
- * @param int $expire time limit for expiration
+ * @param int $expire time limit for expiration
* @return bool true on success
*/
public function cleanExpires($expire = 0)
{
// irmtfan if 0 no cleanup look include/plugin.php
- if (!func_num_args()) {
- $newbbConfig = newbbLoadConfig();
+ if (!\func_num_args()) {
+ $newbbConfig = \newbbLoadConfig();
$expire = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7;
$expire = $expire * 24 * 3600; // days to seconds
}
@@ -467,7 +466,7 @@ public function cleanExpires($expire = 0)
return false;
}
$crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<='));
- $crit_expire->add(new \Criteria('topic_time', time() - (int)$expire, '<'));
+ $crit_expire->add(new \Criteria('topic_time', \time() - (int)$expire, '<'));
return $this->deleteAll($crit_expire, true/*, true*/);
}
@@ -475,31 +474,31 @@ public function cleanExpires($expire = 0)
// START irmtfan - rewrite topic synchronization function. add pid sync and remove hard-code db access
/**
- * @param null $object
- * @param bool $force
+ * @param \XoopsObject|int|string|null $object
+ * @param bool $force
* @return bool
*/
public function synchronization($object = null, $force = true)
{
- if (!is_object($object)) {
+ if (!\is_object($object)) {
$object = $this->get((int)$object);
}
- if (!is_object($object) || !$object->getVar('topic_id')) {
+ if (!\is_object($object) || !$object->getVar('topic_id')) {
return false;
}
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$criteria = new \CriteriaCompo();
- $criteria->add(new \Criteria('topic_id', $object->getVar('topic_id')), 'AND');
+ $criteria->add(new \Criteria('topic_id', (string)$object->getVar('topic_id')), 'AND');
$criteria->add(new \Criteria('approved', 1), 'AND');
$post_ids = $postHandler->getIds($criteria);
if (empty($post_ids)) {
return false;
}
- $last_post = max($post_ids);
- $top_post = min($post_ids);
- $topic_replies = count($post_ids) - 1;
+ $last_post = \max($post_ids);
+ $top_post = \min($post_ids);
+ $topic_replies = \count($post_ids) - 1;
if ($object->getVar('topic_last_post_id') != $last_post) {
$object->setVar('topic_last_post_id', $last_post);
}
@@ -508,7 +507,7 @@ public function synchronization($object = null, $force = true)
}
$b1 = $this->insert($object, $force);
$criteria->add(new \Criteria('post_id', $top_post, '<>'), 'AND');
- $criteria->add(new \Criteria('pid', '(' . implode(', ', $post_ids) . ')', 'NOT IN'), 'AND');
+ $criteria->add(new \Criteria('pid', '(' . \implode(', ', $post_ids) . ')', 'NOT IN'), 'AND');
$b2 = $postHandler->updateAll('pid', $top_post, $criteria, $force);
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('post_id', $top_post, '='), 'AND');
@@ -528,10 +527,10 @@ public function synchronization($object = null, $force = true)
public function getActivePolls()
{
$pollDirs = [];
- $allDirs = xoops_getActiveModules();
+ $allDirs = \xoops_getActiveModules();
foreach ($allDirs as $dirname) {
// pollresults.php file is exist in all xoopspoll versions and umfrage versions
- if (file_exists($GLOBALS['xoops']->path('modules/' . $dirname . '/pollresults.php'))) {
+ if (\file_exists($GLOBALS['xoops']->path('modules/' . $dirname . '/pollresults.php'))) {
$pollDirs[$dirname] = $dirname;
}
}
@@ -546,7 +545,7 @@ public function getActivePolls()
/**
* find poll module that is in used in the current newbb installtion.
* @access public
- * @param array $pollDirs dirnames of all active poll modules
+ * @param array $pollDirs dirnames of all active poll modules
* @return bool|string $dir_def | true | false
* $dir_def: dirname of poll module that is in used in the current newbb installtion.
* true: no poll module is installed | newbb has no topic with poll | newbb has no topic
@@ -571,7 +570,7 @@ public function findPollModule(array $pollDirs = [])
$poll_idInMod = 0;
foreach ($pollDirs as $dirname) {
$pollObj = $tObj->getPoll($tObj->getVar('poll_id'), $dirname);
- if (is_object($pollObj) && ($pollObj->getVar('poll_id') == $tObj->getVar('poll_id'))) {
+ if (\is_object($pollObj) && ($pollObj->getVar('poll_id') == $tObj->getVar('poll_id'))) {
++$poll_idInMod;
$dir_def = $dirname;
}
@@ -579,7 +578,7 @@ public function findPollModule(array $pollDirs = [])
// Only one poll module should has this poll_id
// if 0 there is an error
if (0 == $poll_idInMod) {
- xoops_error("Error: Cannot find poll module for poll_id='{$tObj->getVar('poll_id')}'");
+ \xoops_error("Error: Cannot find poll module for poll_id='{$tObj->getVar('poll_id')}'");
return false;
}
@@ -590,10 +589,9 @@ public function findPollModule(array $pollDirs = [])
// if more than 1 continue
}
// if there is some topics but no module or more than one module have polls
- xoops_error("Error: Cannot find poll module that is in used in newbb!!! You should select the correct poll module yourself in newbb > preferences > poll module setting.");
+ \xoops_error(\_MD_NEWBB_ERROR_POLL_MODULE_NOT_FOUND);
return false;
}
-
// END irmtfan findPollModule
}
diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php
index 7055f7b7..17e68b0a 100644
--- a/class/TopicRenderer.php
+++ b/class/TopicRenderer.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -15,8 +15,6 @@
use Xmf\Request;
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Topic Renderer
*
@@ -27,56 +25,46 @@
class TopicRenderer
{
public $vars = [];
-
/**
* reference to moduleConfig
*/
public $config;
-
/**
* Current user has no access to current page
*/
private $noperm = false;
-
/**
* For multiple forums
*/
public $is_multiple = false;
-
/**
* force to parse vars (run against static vars) irmtfan
*/
public $force = false;
-
/**
* Vistitor's level: 0 - anonymous; 1 - user; 2 - moderator or admin
*/
public $userlevel = 0;
-
- public $query = [];
-
+ public $query = [];
/**
* reference to an object handler
*/
private $handler;
-
/**
* Requested page
*/
private $page = 'list.topic.php';
-
/**
* query variables
*/
private $args = ['forum', 'uid', 'lastposter', 'type', 'status', 'mode', 'sort', 'order', 'start', 'since'];
-
/**
* Constructor
*/
// public function TopicRenderer()
public function __construct()
{
- $this->handler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $this->handler = Helper::getInstance()->getHandler('Topic');
}
/**
@@ -87,7 +75,7 @@ public static function getInstance()
{
static $instance;
if (null === $instance) {
- $instance = new static();
+ $instance = new self();
}
return $instance;
@@ -247,7 +235,8 @@ public function myParseStatus($status = null)
} elseif (1 == $this->config['read_mode']) {
// START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
$startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0;
- if ($lastvisit = max($GLOBALS['last_visit'], $startdate)) {
+ $lastvisit = max($GLOBALS['last_visit'], $startdate);
+ if ($lastvisit) {
$readmode1query = '';
if ($lastvisit > $startdate) {
$readmode1query = 'p.post_time < ' . $lastvisit;
@@ -288,7 +277,8 @@ public function myParseStatus($status = null)
} elseif (1 == $this->config['read_mode']) {
// START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
$startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0;
- if ($lastvisit = max($GLOBALS['last_visit'], $startdate)) {
+ $lastvisit = max($GLOBALS['last_visit'], $startdate);
+ if ($lastvisit) {
if ($lastvisit > $startdate) {
$this->query['where'][] = 'p.post_time > ' . $lastvisit;
}
@@ -339,11 +329,10 @@ public function parseVar($var, $val)
{
switch ($var) {
case 'forum':
- /** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
// START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
// Get accessible forums
- $accessForums = $forumHandler->getIdsByValues(array_map('intval', @explode('|', $val)));
+ $accessForums = $forumHandler->getIdsByValues(array_map('\intval', @explode('|', $val)));
// Filter specified forums if any
//if (!empty($val) && $_forums = @explode('|', $val)) {
//$accessForums = array_intersect($accessForums, array_map('intval', $_forums));
@@ -362,13 +351,13 @@ public function parseVar($var, $val)
break;
case 'uid': // irmtfan add multi topic poster
if (-1 !== $val) {
- $val = implode(',', array_map('intval', explode(',', $val)));
+ $val = implode(',', array_map('\intval', explode(',', $val)));
$this->query['where'][] = 't.topic_poster IN ( ' . $val . ' )';
}
break;
case 'lastposter': // irmtfan add multi lastposter
if (-1 !== $val) {
- $val = implode(',', array_map('intval', explode(',', $val)));
+ $val = implode(',', array_map('\intval', explode(',', $val)));
$this->query['where'][] = 'p.uid IN ( ' . $val . ' )';
}
break;
@@ -407,7 +396,8 @@ public function parseVar($var, $val)
// END irmtfan to accept multiple status
break;
case 'sort':
- if ($sort = $this->getSort($val, 'sort')) {
+ $sort = $this->getSort($val, 'sort');
+ if ($sort) {
$this->query['sort'][] = $sort . (empty($this->vars['order']) ? ' DESC' : ' ASC');
} else { // irmtfan if sort is not in the list
$this->query['sort'][] = 't.topic_last_post_id' . (empty($this->vars['order']) ? ' DESC' : ' ASC');
@@ -453,8 +443,8 @@ public function parseVars()
}
/**
- * @param null $header
- * @param null $var
+ * @param null $header
+ * @param null $var
* @return array|null
*/
public function getSort($header = null, $var = null)
@@ -561,18 +551,21 @@ public function getSort($header = null, $var = null)
// START irmtfan add Display topic headers function
/**
- * @param null $header
+ * @param null $header
* @return array
*/
public function getHeader($header = null)
{
$headersSort = $this->getSort('', 'title');
// additional headers - important: those cannot be in sort anyway
- $headers = array_merge($headersSort, [
- 'attachment' => _MD_NEWBB_TOPICSHASATT, // show attachment smarty
- 'read' => _MD_NEWBB_MARK_UNREAD . '|' . _MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty
- 'pagenav' => _MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies?
- ]);
+ $headers = array_merge(
+ $headersSort,
+ [
+ 'attachment' => _MD_NEWBB_TOPICSHASATT, // show attachment smarty
+ 'read' => _MD_NEWBB_MARK_UNREAD . '|' . _MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty
+ 'pagenav' => _MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies?
+ ]
+ );
return $this->getFromKeys($headers, $header);
}
@@ -580,8 +573,8 @@ public function getHeader($header = null)
// END irmtfan add Display topic headers function
/**
- * @param null $type
- * @param null $status
+ * @param null $type
+ * @param null $status
* @return array
*/
public function getStatus($type = null, $status = null)
@@ -724,7 +717,7 @@ public function buildFilters(\Smarty $xoopsTpl)
}
/**
- * @param null $type_id
+ * @param null $type_id
* @return mixed
*/
public function getTypes($type_id = null)
@@ -732,7 +725,7 @@ public function getTypes($type_id = null)
static $types;
if (!isset($types)) {
/** @var Newbb\TypeHandler $typeHandler */
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
$types = $typeHandler->getByForum(explode('|', @$this->vars['forum']));
}
@@ -745,12 +738,12 @@ public function getTypes($type_id = null)
}
/**
- * @param \Smarty $xoopsTpl
+ * @param \Smarty $xoopsTpl
* @return bool
*/
public function buildTypes(\Smarty $xoopsTpl)
{
- $status = '';
+ $status = [];
if (!$types = $this->getTypes()) {
return true;
}
@@ -772,7 +765,7 @@ public function buildTypes(\Smarty $xoopsTpl)
}
/**
- * @param \Smarty $xoopsTpl
+ * @param \Smarty $xoopsTpl
* @return bool
*/
public function buildCurrent(\Smarty $xoopsTpl)
@@ -853,13 +846,13 @@ public function getCount()
if (!$result = $this->handler->db->query($sql)) {
return 0;
}
- list($count) = $this->handler->db->fetchRow($result);
+ [$count] = $this->handler->db->fetchRow($result);
return $count;
}
/**
- * @param \Smarty $xoopsTpl
+ * @param \Smarty|null $xoopsTpl
* @return array|void
*/
public function renderTopics(\Smarty $xoopsTpl = null)
@@ -924,7 +917,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
$reads = [];
$types = [];
$forums = [];
- $anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
+ $anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']);
while (false !== ($myrow = $this->handler->db->fetchArray($result))) {
if ($myrow['topic_sticky']) {
@@ -935,7 +928,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
// START irmtfan remove topic_icon hardcode smarty
// topic_icon: just regular topic_icon
if (!empty($myrow['icon'])) {
- $topic_icon = ' ';
+ $topic_icon = ' ';
} else {
$topic_icon = ' ';
}
@@ -978,7 +971,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
// ------------------------------------------------------
// => topic array
- $topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
+ $topic_title = htmlspecialchars($myrow['topic_title']);
// irmtfan use topic_title_excerpt for block topic title length
$topic_title_excerpt = $topic_title;
if (!empty($this->config['topic_title_excerpt'])) {
@@ -995,7 +988,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
$topic_excerpt = '';
} else {
$topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']);
- $topic_excerpt = str_replace('[', '[', $myts->htmlSpecialChars($topic_excerpt));
+ $topic_excerpt = str_replace('[', '[', htmlspecialchars($topic_excerpt));
}
$topics[$myrow['topic_id']] = [
@@ -1014,14 +1007,14 @@ public function renderTopics(\Smarty $xoopsTpl = null)
'topic_page_jump_icon' => $topic_page_jump_icon,
'topic_replies' => $myrow['topic_replies'],
'topic_poster_uid' => $myrow['topic_poster'],
- 'topic_poster_name' => !empty($myrow['poster_name']) ? $myts->htmlSpecialChars($myrow['poster_name']) : $anonymous,
+ 'topic_poster_name' => !empty($myrow['poster_name']) ? htmlspecialchars($myrow['poster_name']) : $anonymous,
'topic_views' => $myrow['topic_views'],
'topic_time' => newbbFormatTimestamp($myrow['topic_time']),
'topic_last_post_id' => $myrow['topic_last_post_id'],
//irmtfan added
'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']),
'topic_last_poster_uid' => $myrow['uid'],
- 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? $myts->htmlSpecialChars($myrow['last_poster_name']) : $anonymous,
+ 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? htmlspecialchars($myrow['last_poster_name']) : $anonymous,
'topic_forum' => $myrow['forum_id'],
'topic_excerpt' => $topic_excerpt,
'sticky' => $myrow['topic_sticky'] ? newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) : '',
@@ -1053,7 +1046,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
$posters_name = newbbGetUnameFromIds(array_keys($posters), $this->config['show_realname'], true);
$topic_isRead = newbbIsRead('topic', $reads);
/*
- $type_list = array();
+ $type_list = [];
if (count($types) > 0) {
$typeHandler = Newbb\Helper::getInstance()->getHandler('Type');
$type_list = $typeHandler->getAll(new \Criteria("type_id", "(".implode(", ", array_keys($types)).")", "IN"), null, false);
@@ -1061,7 +1054,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
*/
$type_list = $this->getTypes();
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
if (count($forums) > 0) {
$forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false);
@@ -1095,7 +1088,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
// $topic_folder_text = _MD_NEWBB_TOPICDIGEST;
if ($topics[$id]['topic_replies'] >= $forum_list[$topics[$id]['topic_forum']]['hot_threshold']) {
$topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot';
- $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : _MD_NEWBB_MORETHAN2;
+ $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2;
} else {
$topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic';
$topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS;
@@ -1109,8 +1102,9 @@ public function renderTopics(\Smarty $xoopsTpl = null)
}
if (count($topics) > 0) {
- $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')';
- if ($result = $this->handler->db->query($sql)) {
+ $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')';
+ $result = $this->handler->db->query($sql);
+ if ($result) {
while (list($topic_id) = $this->handler->db->fetchRow($result)) {
$topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT);
}
@@ -1131,7 +1125,7 @@ public function renderTopics(\Smarty $xoopsTpl = null)
/**
* @param $array
- * @param null $keys
+ * @param null $keys
* @return array
*/
public function getFromKeys($array, $keys = null)
@@ -1148,6 +1142,5 @@ public function getFromKeys($array, $keys = null)
return $ret;
}
-
// END irmtfan to create an array from selected keys of an array
}
diff --git a/class/Tree.php b/class/Tree.php
index 46d33197..a59aef1a 100644
--- a/class/Tree.php
+++ b/class/Tree.php
@@ -5,8 +5,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -32,20 +32,21 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+use XoopsTree;
+
+
+
require_once $GLOBALS['xoops']->path('class/xoopstree.php');
/**
* Class Tree
*/
-class Tree extends \XoopsTree
+class Tree extends XoopsTree
{
/** @var string */
private $prefix = ' ';
-
/** @var string */
private $increment = ' ';
-
/** @var array */
private $postArray = [];
@@ -89,8 +90,8 @@ public function setPostArray($postArray)
/**
* @param $postTree_array
- * @param int $pid
- * @param string $prefix
+ * @param int $pid
+ * @param string $prefix
* @return bool
*/
public function getPostTree(&$postTree_array, $pid = 0, $prefix = ' ')
diff --git a/class/Type.php b/class/Type.php
index 9b4c6de3..bcff68cc 100644
--- a/class/Type.php
+++ b/class/Type.php
@@ -6,14 +6,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Type
*
@@ -26,9 +24,9 @@ class Type extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('type_id', XOBJ_DTYPE_INT);
- $this->initVar('type_name', XOBJ_DTYPE_TXTBOX, '');
- $this->initVar('type_color', XOBJ_DTYPE_SOURCE, '');
- $this->initVar('type_description', XOBJ_DTYPE_TXTBOX, '');
+ $this->initVar('type_id', \XOBJ_DTYPE_INT);
+ $this->initVar('type_name', \XOBJ_DTYPE_TXTBOX, '');
+ $this->initVar('type_color', \XOBJ_DTYPE_SOURCE, '');
+ $this->initVar('type_description', \XOBJ_DTYPE_TXTBOX, '');
}
}
diff --git a/class/TypeHandler.php b/class/TypeHandler.php
index cf86fbe5..31b820f6 100644
--- a/class/TypeHandler.php
+++ b/class/TypeHandler.php
@@ -6,14 +6,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Type object handler class.
* @package module::newbb
@@ -34,14 +32,14 @@ public function __construct(\XoopsDatabase $db = null)
/**
* Get types linked to a forum
*
- * @param mixed $forums single forum ID or an array of forum IDs
+ * @param mixed $forums single forum ID or an array of forum IDs
* @return array associative array of types (name, color, order)
*/
public function getByForum($forums = null)
{
$ret = [];
- $forums = (is_array($forums) ? array_filter(array_map('intval', array_map('trim', $forums))) : (empty($forums) ? 0 : [(int)$forums]));
+ $forums = (\is_array($forums) ? \array_filter(\array_map('\intval', \array_map('\trim', $forums))) : (empty($forums) ? 0 : [(int)$forums]));
$sql = ' SELECT o.type_id, o.type_name, o.type_color, l.type_order'
. ' FROM '
@@ -50,30 +48,28 @@ public function getByForum($forums = null)
. " LEFT JOIN {$this->table} AS o ON o.{$this->keyName} = l.{$this->keyName} "
. ' WHERE '
. ' l.forum_id '
- . (empty($forums) ? 'IS NOT NULL' : 'IN (' . implode(', ', $forums) . ')')
+ . (empty($forums) ? 'IS NOT NULL' : 'IN (' . \implode(', ', $forums) . ')')
. ' ORDER BY l.type_order ASC';
- if (false === ($result = $this->db->query($sql))) {
- //xoops_error($this->db->error());
- return $ret;
- }
- while (false !== ($myrow = $this->db->fetchArray($result))) {
- $ret[$myrow[$this->keyName]] = [
- 'type_id' => $myrow[$this->keyName],
- 'type_order' => $myrow['type_order'],
- 'type_name' => htmlspecialchars($myrow['type_name'], ENT_QUOTES | ENT_HTML5),
- 'type_color' => htmlspecialchars($myrow['type_color'], ENT_QUOTES | ENT_HTML5),
- ];
+ $result = $this->db->query($sql);
+ if ($result) {
+ while (false !== ($myrow = $this->db->fetchArray($result))) {
+ $ret[$myrow[$this->keyName]] = [
+ 'type_id' => $myrow[$this->keyName],
+ 'type_order' => $myrow['type_order'],
+ 'type_name' => \htmlspecialchars($myrow['type_name'], \ENT_QUOTES | \ENT_HTML5),
+ 'type_color' => \htmlspecialchars($myrow['type_color'], \ENT_QUOTES | \ENT_HTML5),
+ ];
+ }
}
-
return $ret;
}
/**
* Update types linked to a forum
*
- * @param int $forum_id
- * @param array $types
+ * @param int $forum_id
+ * @param array $types
* @return bool
*/
public function updateByForum($forum_id, $types)
@@ -87,7 +83,7 @@ public function updateByForum($forum_id, $types)
$types_valid = [];
$types_add = [];
$types_update = [];
- foreach (array_keys($types_existing) as $key) {
+ foreach (\array_keys($types_existing) as $key) {
if (empty($types[$key])) {
continue;
}
@@ -96,18 +92,18 @@ public function updateByForum($forum_id, $types)
$types_update[] = $key;
}
}
- foreach (array_keys($types) as $key) {
+ foreach (\array_keys($types) as $key) {
if (!empty($types[$key]) && !isset($types_existing[$key])) {
$types_add[] = $key;
}
}
- $types_valid = array_filter($types_valid);
- $types_add = array_filter($types_add);
- $types_update = array_filter($types_update);
+ $types_valid = \array_filter($types_valid);
+ $types_add = \array_filter($types_add);
+ $types_update = \array_filter($types_update);
if (!empty($types_valid)) {
$sql = 'DELETE FROM ' . $this->db->prefix('newbb_type_forum') . ' WHERE ' . ' forum_id = ' . $forum_id . ' AND ' . // irmtfan bug fix: delete other forums types when update the type for a specific forum
- " {$this->keyName} NOT IN (" . implode(', ', $types_valid) . ')';
+ " {$this->keyName} NOT IN (" . \implode(', ', $types_valid) . ')';
if (false === ($result = $this->db->queryF($sql))) {
}
}
@@ -132,7 +128,7 @@ public function updateByForum($forum_id, $types)
//if (!in_array($key, $types_add)) continue;
$type_query[] = "({$key}, {$forum_id}, {$order})";
}
- $sql = 'INSERT INTO ' . $this->db->prefix('newbb_type_forum') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . implode(', ', $type_query);
+ $sql = 'INSERT INTO ' . $this->db->prefix('newbb_type_forum') . ' (type_id, forum_id, type_order) ' . ' VALUES ' . \implode(', ', $type_query);
if (false === ($result = $this->db->queryF($sql))) {
//xoops_error($this->db->error());
}
@@ -145,12 +141,12 @@ public function updateByForum($forum_id, $types)
* delete an object as well as links relying on it
*
* @param Type|\XoopsObject $object {@link Type}
- * @param bool $force flag to force the query execution despite security settings
+ * @param bool $force flag to force the query execution despite security settings
* @return bool
*/
public function delete(\XoopsObject $object, $force = true)
{
- if (!is_object($object) || !$object->getVar($this->keyName)) {
+ if (!\is_object($object) || !$object->getVar($this->keyName)) {
return false;
}
$queryFunc = empty($force) ? 'query' : 'queryF';
@@ -177,9 +173,9 @@ public function delete(\XoopsObject $object, $force = true)
/**
* clean orphan links from database
*
- * @param string $table_link
- * @param string $field_link
- * @param string $field_object
+ * @param string $table_link
+ * @param string $field_link
+ * @param string $field_object
* @return bool true on success
*/
public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
diff --git a/class/Uploader.php b/class/Uploader.php
index 2d229343..3c6ad882 100644
--- a/class/Uploader.php
+++ b/class/Uploader.php
@@ -6,14 +6,12 @@
* NewBB, XOOPS forum module
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
require_once $GLOBALS['xoops']->path('class/uploader.php');
/**
@@ -43,11 +41,11 @@ public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize = 0,
{
// $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight);
- if (!is_array($allowedMimeTypes)) {
+ if (!\is_array($allowedMimeTypes)) {
if (empty($allowedMimeTypes) || '*' === $allowedMimeTypes) {
$allowedMimeTypes = [];
} else {
- $allowedMimeTypes = array_filter(array_map('trim', explode('|', mb_strtolower($allowedMimeTypes))));
+ $allowedMimeTypes = \array_filter(\array_map('\trim', \explode('|', mb_strtolower($allowedMimeTypes))));
}
}
$_allowedMimeTypes = [];
@@ -99,7 +97,7 @@ public function setFileSizeCheck($value)
*/
public function getExt()
{
- $this->ext = mb_strtolower(ltrim(mb_strrchr($this->getMediaName(), '.'), '.'));
+ $this->ext = mb_strtolower(\ltrim(mb_strrchr($this->getMediaName(), '.'), '.'));
return $this->ext;
}
diff --git a/class/User.php b/class/User.php
index 8f861330..d6ebb028 100644
--- a/class/User.php
+++ b/class/User.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* @param $RPG
@@ -26,17 +24,17 @@ function newbb_calculateLevel($RPG, $RPGDIFF)
//$RPG = $user->getVar('posts');
//$RPGDIFF = $user->getVar('user_regdate');
- $today = time();
+ $today = \time();
$diff = $today - $RPGDIFF;
- $exp = round($diff / 86400, 0);
+ $exp = \round($diff / 86400, 0);
if ($exp <= 0) {
$exp = 1;
}
- $ppd = round($RPG / $exp, 0);
- $level = pow(log10($RPG),3);
- $ep = floor(100 * ($level - floor($level)));
- $showlevel = floor($level + 1);
- $hpmulti = round($ppd / 6, 1);
+ $ppd = \round($RPG / $exp, 0);
+ $level = \pow(\log10($RPG), 3);
+ $ep = \floor(100 * ($level - \floor($level)));
+ $showlevel = \floor($level + 1);
+ $hpmulti = \round($ppd / 6, 1);
if ($hpmulti > 1.5) {
$hpmulti = 1.5;
}
@@ -48,27 +46,27 @@ function newbb_calculateLevel($RPG, $RPGDIFF)
if ($hp >= 1) {
$hp = $maxhp;
} else {
- $hp = floor($hp * $maxhp);
+ $hp = \floor($hp * $maxhp);
}
- $hp = floor($hp);
- $maxhp = floor($maxhp);
+ $hp = \floor($hp);
+ $maxhp = \floor($maxhp);
$zhp = $maxhp;
if ($maxhp <= 0) {
$zhp = 1;
}
- $hpf = floor(100 * ($hp / $zhp)) - 1;
+ $hpf = \floor(100 * ($hp / $zhp)) - 1;
$maxmp = ($exp * $level) / 5;
$mp = $RPG / 3;
if ($mp >= $maxmp) {
$mp = $maxmp;
}
- $maxmp = floor($maxmp);
- $mp = floor($mp);
+ $maxmp = \floor($maxmp);
+ $mp = \floor($mp);
$zmp = $maxmp;
if ($maxmp <= 0) {
$zmp = 1;
}
- $mpf = floor(100 * ($mp / $zmp)) - 1;
+ $mpf = \floor(100 * ($mp / $zmp)) - 1;
if ($hpf >= 98) {
$hpf -= 2;
}
@@ -122,46 +120,51 @@ public function getUserbar()
'name' => _PROFILE,
];
- if (is_object($GLOBALS['xoopsUser'])) {
+ if (\is_object($GLOBALS['xoopsUser'])) {
$userbar['pm'] = [
'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $user->getVar('uid') . "', 'pmlite', 450, 380);",
- 'name' => _MD_NEWBB_PM,
+ 'name' => \_MD_NEWBB_PM,
];
}
if ($user->getVar('user_viewemail') || $isAdmin) {
$userbar['email'] = [
'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "', 'new');",
- 'name' => _MD_NEWBB_EMAIL,
+ 'name' => \_MD_NEWBB_EMAIL,
];
}
- if ($url = $user->getVar('url')) {
+ $url = $user->getVar('url');
+ if ($url) {
$userbar['url'] = [
'link' => "javascript:void window.open('" . $url . "', 'new');",
- 'name' => _MD_NEWBB_WWW,
+ 'name' => \_MD_NEWBB_WWW,
];
}
- if ($icq = $user->getVar('user_icq')) {
+ $icq = $user->getVar('user_icq');
+ if ($icq) {
$userbar['icq'] = [
'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $icq . "', 'new');",
- 'name' => _MD_NEWBB_ICQ,
+ 'name' => \_MD_NEWBB_ICQ,
];
}
- if ($aim = $user->getVar('user_aim')) {
+ $aim = $user->getVar('user_aim');
+ if ($aim) {
$userbar['aim'] = [
'link' => "javascript:void window.open('aim:goim?screenname=" . $aim . '&message=Hi+' . $aim . '+Are+you+there?' . "', 'new');",
- 'name' => _MD_NEWBB_AIM,
+ 'name' => \_MD_NEWBB_AIM,
];
}
- if ($yim = $user->getVar('user_yim')) {
+ $yim = $user->getVar('user_yim');
+ if ($yim) {
$userbar['yim'] = [
'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $yim . '&.src=pg' . "', 'new');",
- 'name' => _MD_NEWBB_YIM,
+ 'name' => \_MD_NEWBB_YIM,
];
}
- if ($msn = $user->getVar('user_msnm')) {
+ $msn = $user->getVar('user_msnm');
+ if ($msn) {
$userbar['msnm'] = [
'link' => "javascript:void window.open('http://members.msn.com?mem=" . $msn . "', 'new');",
- 'name' => _MD_NEWBB_MSNM,
+ 'name' => \_MD_NEWBB_MSNM,
];
}
@@ -180,7 +183,7 @@ public function getLevel()
if (2 == $GLOBALS['xoopsModuleConfig']['user_level']) {
static $rpg_images;
if (null === $rpg_images) {
- $iconHandler = newbbGetIconHandler();
+ $iconHandler = \newbbGetIconHandler();
$rpg_path = $iconHandler->getPath('rpg');
foreach (['img_left', 'img_backing', 'img_right', 'blue', 'green', 'orange'] as $img) {
// irmtfan fix: double "/" removed
@@ -196,13 +199,13 @@ public function getLevel()
. $rpg_images['img_right']
. "' alt='' >
";
- $info = _MD_NEWBB_LEVEL . ' ' . $level['level'] . '' . _MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . ' ' . sprintf($table, $rpg_images['orange'], $level['hp_width']);
- $info .= '' . _MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ' ' . sprintf($table, $rpg_images['green'], $level['mp_width']);
- $info .= '' . _MD_NEWBB_EXP . ' ' . $level['exp'] . ' ' . sprintf($table, $rpg_images['blue'], $level['exp_width']);
+ $info = \_MD_NEWBB_LEVEL . ' ' . $level['level'] . '' . \_MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . ' ' . \sprintf($table, $rpg_images['orange'], $level['hp_width']);
+ $info .= '' . \_MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ' ' . \sprintf($table, $rpg_images['green'], $level['mp_width']);
+ $info .= '' . \_MD_NEWBB_EXP . ' ' . $level['exp'] . ' ' . \sprintf($table, $rpg_images['blue'], $level['exp_width']);
} else {
- $info = _MD_NEWBB_LEVEL . ' ' . $level['level'] . '; ' . _MD_NEWBB_EXP . ' ' . $level['exp'] . ' ';
- $info .= '' . _MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . ' ';
- $info .= '' . _MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ' ';
+ $info = \_MD_NEWBB_LEVEL . ' ' . $level['level'] . '; ' . \_MD_NEWBB_EXP . ' ' . $level['exp'] . ' ';
+ $info .= '' . \_MD_NEWBB_HP . ' ' . $level['hp'] . ' / ' . $level['hp_max'] . ' ';
+ $info .= '' . \_MD_NEWBB_MP . ' ' . $level['mp'] . ' / ' . $level['mp_max'] . ' ';
}
return $info;
@@ -212,14 +215,14 @@ public function getLevel()
* @param \XoopsUser $user
* @return mixed
*/
- public function getInfo(&$user)
+ public function getInfo($user)
{
global $myts;
static $name_anonymous;
- if (!is_object($user) || !$user->isActive()) {
+ if (!\is_object($user) || !$user->isActive()) {
if (null === $name_anonymous) {
- $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
+ $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']);
}
return ['name' => $name_anonymous, 'link' => $name_anonymous];
@@ -247,7 +250,7 @@ public function getInfo(&$user)
//checks for user's groups
$userinfo['groups'] = [];
/** @var \XoopsMemberHandler $memberHandler */
- $memberHandler = xoops_getHandler('member');
+ $memberHandler = \xoops_getHandler('member');
$usergroups = $memberHandler->getGroupsByUser($userinfo['uid'], true);
foreach ($usergroups as $group) {
$userinfo['groups'][] = $group->getVar('name');
@@ -255,9 +258,9 @@ public function getInfo(&$user)
// END hacked by irmtfan - easier groups getting - can we use $_SESSION['xoopsUserGroups']???
$userinfo['from'] = $user->getVar('user_from');
- require_once dirname(__DIR__) . '/include/functions.time.php';
- $userinfo['regdate'] = newbbFormatTimestamp($user->getVar('user_regdate'), 'reg');
- $userinfo['last_login'] = newbbFormatTimestamp($user->getVar('last_login')); // irmtfan add last_login
+ require_once \dirname(__DIR__) . '/include/functions.time.php';
+ $userinfo['regdate'] = \newbbFormatTimestamp($user->getVar('user_regdate'), 'reg');
+ $userinfo['last_login'] = \newbbFormatTimestamp($user->getVar('last_login')); // irmtfan add last_login
$userinfo['posts'] = $user->getVar('posts');
diff --git a/class/UserHandler.php b/class/UserHandler.php
index 3a42a76a..2e9335ac 100644
--- a/class/UserHandler.php
+++ b/class/UserHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,9 +14,7 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class UserHandler
@@ -25,13 +23,10 @@ class UserHandler
{
/** @var array */
public $users = [];
-
/** @var bool */
private $enableGroup;
-
/** @var bool */
private $enableOnline;
-
/** @var array */
private $userlist = [];
@@ -47,16 +42,15 @@ public function __construct($enableGroup = true, $enableOnline = true)
public function loadUserInfo()
{
- /** @var Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
$helper->loadLanguage('user');
// @require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php');
- if (class_exists('UserLanguage')) {
- $handler = new Newbb\UserLanguage();
+ if (\class_exists('UserLanguage')) {
+ $handler = new UserLanguage();
} else {
$handler = new User();
}
- foreach (array_keys($this->users) as $uid) {
+ foreach (\array_keys($this->users) as $uid) {
$this->userlist[$uid] = $handler->getInfo($this->users[$uid]);
}
}
@@ -66,15 +60,15 @@ public function loadUserOnline()
if (empty($this->users) || !$this->enableOnline) {
return;
}
- require_once dirname(__DIR__) . '/include/functions.render.php';
- $image_online = newbbDisplayImage('online', _MD_NEWBB_ONLINE);
- $image_offline = newbbDisplayImage('offline', _MD_NEWBB_OFFLINE);
+ require_once \dirname(__DIR__) . '/include/functions.render.php';
+ $image_online = \newbbDisplayImage('online', \_MD_NEWBB_ONLINE);
+ $image_offline = \newbbDisplayImage('offline', \_MD_NEWBB_OFFLINE);
/** @var Newbb\OnlineHandler $onlineHandler */
- $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online');
- $onlines = $onlineHandler->checkStatus(array_keys($this->users));
+ $onlineHandler = Helper::getInstance()->getHandler('Online');
+ $onlines = $onlineHandler->checkStatus(\array_keys($this->users));
- foreach (array_keys($this->users) as $uid) {
+ foreach (\array_keys($this->users) as $uid) {
$this->userlist[$uid]['status'] = empty($onlines[$uid]) ? $image_offline : $image_online;
}
}
@@ -92,7 +86,7 @@ public function loadUserDigest()
return;
}
- $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . implode(', ', array_keys($this->users)) . ')';
+ $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . \implode(', ', \array_keys($this->users)) . ')';
$result = $GLOBALS['xoopsDB']->query($sql);
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
$this->userlist[$myrow['uid']]['digests'] = (int)$myrow['user_digests'];
diff --git a/class/Userstats.php b/class/Userstats.php
index 1df8ab7b..3cbeb2ee 100644
--- a/class/Userstats.php
+++ b/class/Userstats.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* Class Userstats
@@ -24,10 +22,10 @@ class Userstats extends \XoopsObject
public function __construct()
{
parent::__construct();
- $this->initVar('uid', XOBJ_DTYPE_INT);
- $this->initVar('user_topics', XOBJ_DTYPE_INT);
- $this->initVar('user_digests', XOBJ_DTYPE_INT);
- $this->initVar('user_posts', XOBJ_DTYPE_INT);
- $this->initVar('user_lastpost', XOBJ_DTYPE_INT);
+ $this->initVar('uid', \XOBJ_DTYPE_INT);
+ $this->initVar('user_topics', \XOBJ_DTYPE_INT);
+ $this->initVar('user_digests', \XOBJ_DTYPE_INT);
+ $this->initVar('user_posts', \XOBJ_DTYPE_INT);
+ $this->initVar('user_lastpost', \XOBJ_DTYPE_INT);
}
}
diff --git a/class/UserstatsHandler.php b/class/UserstatsHandler.php
index 8312c662..6fc86917 100644
--- a/class/UserstatsHandler.php
+++ b/class/UserstatsHandler.php
@@ -6,15 +6,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
* user stats
@@ -30,22 +28,22 @@ public function __construct(\XoopsDatabase $db = null)
}
/**
- * @param null $db
+ * @param null $db
* @return UserstatsHandler
*/
public static function getInstance($db = null)
{
static $instance;
if (null === $instance) {
- $instance = new static($db);
+ $instance = new self($db);
}
return $instance;
}
/**
- * @param mixed $id
- * @param null $fields
+ * @param mixed $id
+ * @param null $fields
* @return null|\XoopsObject
*/
public function get($id = null, $fields = null) //get($id)
@@ -91,7 +89,6 @@ public function getStats($id)
return $row;
}
-
/*
function insert(\XoopsObject $object, $force = true)
{
@@ -108,7 +105,7 @@ function insert(\XoopsObject $object, $force = true)
}
$queryFunc = empty($force) ? "query" : "queryF";
- $keys = array();
+ $keys = [];
foreach ($changedVars as $k => $v) {
$keys[] = " {$k} = {$v}";
}
diff --git a/class/Utility.php b/class/Utility.php
index 0babaa60..601645a4 100644
--- a/class/Utility.php
+++ b/class/Utility.php
@@ -2,29 +2,25 @@
namespace XoopsModules\Newbb;
-use XoopsModules\Newbb;
+use Xmf\Module\Helper\Cache;
+
+/** @var Helper $helper */
+
/**
* Class Utility
*/
-class Utility
+class Utility extends Common\SysUtility
{
- use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits
-
- use Common\ServerStats; // getServerStats Trait
-
- use Common\FilesManagement; // Files Management Trait
-
//--------------- Custom module methods -----------------------------
-
/**
* Verify that a mysql table exists
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $tablename
* @return bool
+ * @copyright (c) Hervé Thouzard
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
*/
public function tableExists($tablename)
{
@@ -38,12 +34,12 @@ public function tableExists($tablename)
/**
* Verify that a field exists inside a mysql table
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $fieldname
* @param $table
* @return bool
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
+ * @copyright (c) Hervé Thouzard
*/
public function fieldExists($fieldname, $table)
{
@@ -56,12 +52,12 @@ public function fieldExists($fieldname, $table)
/**
* Add a field to a mysql table
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $field
* @param $table
* @return bool|\mysqli_result
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
+ * @copyright (c) Hervé Thouzard
*/
public function addField($field, $table)
{
@@ -83,15 +79,14 @@ public static function prepareFolder($folder)
throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
}
file_put_contents($folder . '/index.html', '');
- }
- catch (\Exception $e) {
+ } catch (\Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n", ' ';
}
}
public static function cleanCache()
{
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
if (method_exists($cacheHelper, 'clear')) {
$cacheHelper->clear();
@@ -114,8 +109,7 @@ public static function cleanCache()
*/
public static function userIsAdmin()
{
- /** @var Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
static $newbbIsAdmin;
diff --git a/class/Xmlrss.php b/class/Xmlrss.php
index c8c0c3cd..d1ebcbf8 100644
--- a/class/Xmlrss.php
+++ b/class/Xmlrss.php
@@ -6,21 +6,19 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
//load_functions('locale');
/**
* Description
*
- * @param type $var description
+ * @param type $var description
* @return type description
* @link
*/
@@ -29,7 +27,6 @@ class Xmlrss
public $xml_version;
public $rss_version;
public $xml_encoding;
-
public $channel_title;
public $channel_link;
public $channel_desc;
@@ -39,14 +36,12 @@ class Xmlrss
public $channel_category;
public $channel_generator;
public $channel_language;
-
public $image_title;
public $image_url;
public $image_link;
public $image_description;
public $image_height;
public $image_width;
-
public $max_items;
public $max_item_description;
public $items = [];
@@ -75,14 +70,14 @@ public function setVarRss($var, $val)
/**
* @param $title
* @param $link
- * @param string $description
- * @param string $label
- * @param int|string $pubdate
+ * @param string $description
+ * @param string $label
+ * @param int|string $pubdate
* @return bool
*/
public function addItem($title, $link, $description = '', $label = '', $pubdate = 0)
{
- if (count($this->items) < $this->max_items) {
+ if (\count($this->items) < $this->max_items) {
if (!empty($label)) {
$label = '[' . $this->cleanup($label) . ']';
}
@@ -108,18 +103,18 @@ public function addItem($title, $link, $description = '', $label = '', $pubdate
/**
* @param $text
- * @param int $trim
+ * @param int $trim
* @return mixed|string
*/
public function cleanup($text, $trim = 0)
{
- if ('utf-8' === mb_strtolower($this->xml_encoding) && strncasecmp(_CHARSET, $this->xml_encoding, 5)) {
+ if ('utf-8' === mb_strtolower($this->xml_encoding) && \strncasecmp(_CHARSET, $this->xml_encoding, 5)) {
$text = \XoopsLocal::convert_encoding($text, 'utf-8');
}
if (!empty($trim)) {
- $text = xoops_substr($text, 0, (int)$trim);
+ $text = \xoops_substr($text, 0, (int)$trim);
}
- $text = htmlspecialchars($text, ENT_QUOTES);
+ $text = \htmlspecialchars($text, \ENT_QUOTES);
return $text;
}
diff --git a/class/XmlrssHandler.php b/class/XmlrssHandler.php
index 5608b9a8..d07f1dff 100644
--- a/class/XmlrssHandler.php
+++ b/class/XmlrssHandler.php
@@ -6,7 +6,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -14,9 +14,7 @@
use XoopsModules\Newbb;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
-defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
+\defined('NEWBB_FUNCTIONS_INI') || require $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
//load_functions('locale');
/**
@@ -29,7 +27,7 @@ class XmlrssHandler
*/
public function create()
{
- $xmlrss = new Newbb\Xmlrss();
+ $xmlrss = new Xmlrss();
return $xmlrss;
}
diff --git a/class/index.html b/class/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/class/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/class/index.php b/class/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/class/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/class/plugins/index.php b/class/plugins/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/class/plugins/index.php
@@ -0,0 +1,3 @@
+
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use Criteria;
+use XoopsModules\Newbb\{
+ Helper
+};
use XoopsModules\Tag;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
/**
* Get item fields:
* title
@@ -47,9 +48,9 @@ function newbb_tag_iteminfo(&$items)
}
}
/** @var TopicHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $itemHandler = Helper::getInstance()->getHandler('Topic');
/** @var \XoopsObject $itemsObject */
- $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true);
+ $itemsObject = $itemHandler->getObjects(new Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true);
foreach (array_keys($items) as $cat_id) {
foreach (array_keys($items[$cat_id]) as $item_id) {
@@ -80,7 +81,7 @@ function newbb_tag_iteminfo(&$items)
function newbb_tag_synchronization($mid)
{
/** @var TopicHandler $itemHandler */
- $itemHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $itemHandler = Helper::getInstance()->getHandler('Topic');
/** @var \XoopsPersistableObjectHandler $linkHandler */
$linkHandler = Tag\Helper::getInstance()->getHandler('Link');
diff --git a/class/utilities.php b/class/utilities.php
index fbef2445..20d404d0 100644
--- a/class/utilities.php
+++ b/class/utilities.php
@@ -8,11 +8,11 @@ class NewbbUtilities
/**
* Verify that a mysql table exists
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $tablename
* @return bool
+ * @copyright (c) Hervé Thouzard
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
*/
public function tableExists($tablename)
{
@@ -25,12 +25,12 @@ public function tableExists($tablename)
/**
* Verify that a field exists inside a mysql table
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $fieldname
* @param $table
* @return bool
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
+ * @copyright (c) Hervé Thouzard
*/
public function fieldExists($fieldname, $table)
{
@@ -43,12 +43,12 @@ public function fieldExists($fieldname, $table)
/**
* Add a field to a mysql table
*
- * @package News
- * @author Hervé Thouzard (http://www.herve-thouzard.com)
- * @copyright (c) Hervé Thouzard
* @param $field
* @param $table
* @return bool|\mysqli_result
+ * @package News
+ * @author Hervé Thouzard (http://www.herve-thouzard.com)
+ * @copyright (c) Hervé Thouzard
*/
public function addField($field, $table)
{
@@ -73,8 +73,7 @@ public static function prepareFolder($folder)
} else {
file_put_contents($folder . '/index.html', '');
}
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n", ' ';
}
}
diff --git a/class/xoopsformloader.php b/class/xoopsformloader.php
index 0c2364af..0c847746 100644
--- a/class/xoopsformloader.php
+++ b/class/xoopsformloader.php
@@ -1,7 +1,6 @@
path('Frameworks/compat/class/xoopsformloader.php')) {
- include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
+if (!@require_once $GLOBALS['xoops']->path('Frameworks/compat/class/xoopsformloader.php')) {
+ require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
}
diff --git a/config/admin.yml b/config/admin.yml
new file mode 100644
index 00000000..01b1f3f2
--- /dev/null
+++ b/config/admin.yml
@@ -0,0 +1 @@
+displaySampleButton: 1
\ No newline at end of file
diff --git a/config/config.php b/config/config.php
new file mode 100644
index 00000000..e20d3d5a
--- /dev/null
+++ b/config/config.php
@@ -0,0 +1,90 @@
+ $moduleDirNameUpper . ' Module Configurator',
+ 'paths' => [
+ 'dirname' => $moduleDirName,
+ 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
+ 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
+ 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName,
+ 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
+ ],
+ 'uploadFolders' => [
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
+ //XOOPS_UPLOAD_PATH . '/flags'
+ ],
+ 'copyBlankFiles' => [
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
+ //XOOPS_UPLOAD_PATH . '/flags'
+ ],
+
+ 'copyTestFolders' => [
+ [
+ XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/uploads',
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ ],
+ // [
+ // XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/testdata/thumbs',
+ // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs',
+ // ],
+ ],
+
+ 'templateFolders' => [
+ '/templates/',
+ // '/templates/blocks/',
+ // '/templates/admin/'
+ ],
+ 'oldFiles' => [
+ '/class/request.php',
+ '/class/registry.php',
+ '/class/utilities.php',
+ '/class/util.php',
+ // '/include/constants.php',
+ // '/include/functions.php',
+ '/ajaxrating.txt',
+ ],
+ 'oldFolders' => [
+ '/images',
+ '/css',
+ '/js',
+ '/tcpdf',
+ ],
+
+ 'renameTables' => [// 'XX_archive' => 'ZZZZ_archive',
+ ],
+ 'moduleStats' => [
+ // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1),
+ // 'totalitems' => $helper->getHandler('Item')->getItemsCount(),
+ // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
+ ],
+ 'modCopyright' => "
+ ",
+];
+
diff --git a/config/icons.php b/config/icons.php
new file mode 100644
index 00000000..fc532488
--- /dev/null
+++ b/config/icons.php
@@ -0,0 +1,21 @@
+ mb_strtoupper($moduleDirName) . ' IconConfigurator',
+ 'icons' => [
+ 'edit' => " ",
+ 'delete' => " ",
+ 'clone' => " ",
+ 'preview' => " ",
+ 'print' => " ",
+ 'pdf' => " ",
+ 'add' => " ",
+ '0' => " ",
+ '1' => " ",
+ ],
+];
diff --git a/config/imageconfig.php b/config/imageconfig.php
new file mode 100644
index 00000000..26e24087
--- /dev/null
+++ b/config/imageconfig.php
@@ -0,0 +1,42 @@
+ 'imageConfigs',
+ 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG',
+ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_CONFIG_DSC',
+ 'formtype' => 'line_break',
+ 'valuetype' => 'textbox',
+ 'default' => 'head',
+];
+
+$modversion['config'][] = [
+ 'name' => 'imageWidth',
+ 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH',
+ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_WIDTH_DSC',
+ 'formtype' => 'textbox',
+ 'valuetype' => 'int',
+ 'default' => 1200,
+]; // =1024/16
+
+$modversion['config'][] = [
+ 'name' => 'imageHeight',
+ 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT',
+ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_HEIGHT_DSC',
+ 'formtype' => 'textbox',
+ 'valuetype' => 'int',
+ 'default' => 800,
+]; // =768/16
+
+$modversion['config'][] = [
+ 'name' => 'imageUploadPath',
+ 'title' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH',
+ 'description' => 'CO_' . $moduleDirNameUpper . '_' . 'IMAGE_UPLOAD_PATH_DSC',
+ 'formtype' => 'textbox',
+ 'valuetype' => 'text',
+ 'default' => 'uploads/' . $modversion['dirname'] . '/images',
+];
+
diff --git a/config/index.php b/config/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/config/index.php
@@ -0,0 +1,3 @@
+ mb_strtoupper($moduleDirName) . ' PathConfigurator',
+ 'paths' => [
+ 'dirname' => $moduleDirName,
+ 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
+ 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
+ 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName,
+ 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
+ ],
+ 'uploadFolders' => [
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/category',
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/screenshots',
+ //XOOPS_UPLOAD_PATH . '/flags'
+ ],
+];
+
diff --git a/delete.php b/delete.php
index 36c435b2..8cb2c7b3 100644
--- a/delete.php
+++ b/delete.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -142,14 +142,18 @@
';
if ($isAdmin) {
- xoops_confirm([
- 'post_id' => $post_id,
- 'viewmode' => $viewmode,
- 'order' => $order,
- 'forum' => $forum,
- 'topic_id' => $topic_id,
- 'ok' => 99,
- ], 'delete.php', _MD_NEWBB_DEL_RELATED);
+ xoops_confirm(
+ [
+ 'post_id' => $post_id,
+ 'viewmode' => $viewmode,
+ 'order' => $order,
+ 'forum' => $forum,
+ 'topic_id' => $topic_id,
+ 'ok' => 99,
+ ],
+ 'delete.php',
+ _MD_NEWBB_DEL_RELATED
+ );
}
require_once $GLOBALS['xoops']->path('footer.php');
}
diff --git a/digest.php b/digest.php
index ec442b50..81eaf390 100644
--- a/digest.php
+++ b/digest.php
@@ -3,13 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
+
+/** @var Helper $helper */
// Why the skip-DB-security check defined only for XMLRPC? We also need it!!! ~_*
if (!defined('XOOPS_XMLRPC')) {
@@ -23,7 +26,7 @@
return false;
}
/** @var Newbb\DigestHandler $digestHandler */
-$digestHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Digest');
+$digestHandler = Helper::getInstance()->getHandler('Digest');
$msg = $digestHandler->process();
$msg .= ob_get_contents();
ob_end_clean();
diff --git a/dl_attachment.php b/dl_attachment.php
index 8f9ac3b3..d6a2c19f 100644
--- a/dl_attachment.php
+++ b/dl_attachment.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -57,7 +57,8 @@
if (!file_exists($file_saved)) {
exit(_MD_NEWBB_NO_SUCH_FILE);
}
-if ($down = $forumpost->incrementDownload($attachId)) {
+$down = $forumpost->incrementDownload($attachId);
+if ($down) {
$forumpost->saveAttachment();
}
unset($forumpost);
@@ -80,7 +81,6 @@
if (false === @ini_set('zlib.output_compression', 'Off')) {
throw new \RuntimeException('Setting of zlib.output_compression failed.');
}
-
}
if (function_exists('mb_http_output')) {
diff --git a/docs/changelog-rev10095.txt b/docs/changelog-rev10095.txt
deleted file mode 100644
index 18985670..00000000
--- a/docs/changelog-rev10095.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-date: 2012-08-25
-================================================
-1- Extra new lines removed from php files.
-newbb/votepolls.php, newbb/include/notification.inc.php, newbb/class/permission.forum.php, newbb/admin/admin_groupmod.php
-
-2- Apply Alfred Id in the head of php files:
-newbb/class/xoopsformloader.php, newbb/votepolls.php, newbb/class/tree.php, newbb/topicmanager.php, newbb/class/readtopic.php
-newbb/class/readforum.php, newbb/class/read.php, newbb/ratethread.php, newbb/class/rate.php, newbb/class/newbbtree.php
-newbb/blocks/newbb_block_tag.php, newbb/index.php, newbb/admin/*.php,
-newbb/include/sitemap.plugin.php, newbb/include/search.inc.php, newbb/include/notification.inc.php, newbb/include/functions.user.php,
-newbb/include/module.v100.php, newbb/include/module.v220.php, newbb/include/module.php, newbb/include/functions.ini.php
-newbb/include/form.forum.php,
-newbb/notification_update.php, newbb/report.php, newbb/reply.php
-
-3- Change the status of module to RC4.
-newbb/xoops_version.php
-
-4- Solve SEO (replace files from Alfred)
-newbb/viewpost.php, newbb/viewtopic.php, newbb/blocks/newbb_block.php
-
-5- Add do_latestedit config to display the latest edit (do_latestedit=0) or all edit (do_latestedit=1) by Alfred
-newbb/class/post.php, newbb/include/plugin.php
-
-6- Replace files from Alfred (better code, bug fixes, merge and develop):
-newbb/class/permission.php, newbb/class/forum.php, newbb/sql/mysql.400.sql, newbb/rss.php, newbb/admin/admin_permissions.php
-newbb/include/functions.image.php, newbb/include/form.post.php, newbb/viewforum.php
-newbb/seo.php, newbb/post.php, newbb/search.php, newbb/docs/changelog.txt, newbb/language/german/*.php
-
-7- Add new language definitions.
-newbb/language/english/admin.php, newbb/language/english/main.php, newbb/language/persian/admin.php, newbb/language/persian/main.php,
-newbb/docs/lang_diff.txt
-
-8- Fix Undefined variable: pseudo_height (Cesag/irmtfan)
-in newbb/include/functions.image.php line 86
-
-9- Change the default syncOnUpdate value to false. It is dangerous because it will delete all pending and deleted posts/topics/forums from database on update.
-newbb/include/plugin.php
-
-10- easier group getting - reduce queries - use Xoops API instead of directly access to db (irmtfan)
-newbb/class/user.php
diff --git a/docs/changelog-rev10109.txt b/docs/changelog-rev10109.txt
deleted file mode 100644
index 37ca1943..00000000
--- a/docs/changelog-rev10109.txt
+++ /dev/null
@@ -1,635 +0,0 @@
-date 2013-08-27
-===================================
-1- bug fix: Notice: Undefined index: fct in file /modules/newbb/xoops_version.php line 767 (Cesag)
-
-date 2013-08-24
-===================================
-1- bug fix: check if xoops poll module is available in newbb/admin/index.php (Cesag)
-2- bug fix: single quotes inside language definitions break onClick event (Cesag/Irmtfan/Mamba)
-
-date 2013-05-28
-===================================
-1- improve: rewrite topic synchronization function. add pid sync and remove hard-code db access in newbb/class/topic.php
-2- improve: rewrite forum cleanOrphan function. add parent_forum and cat_id orphan check in newbb/class/forum.php
-3- enhance: rewrite admin > sync and recon functions. remove hard-codes access to db. in newbb/admin/admin_synchronization.php and newbb/include/functions.recon.php
-4- improve: irmtfan - move cleanOrphan to synchronization function in newbb/include/functions.recon.php and newbb/class/topic.php
-
-date 2013-05-25
-===================================
-1- improve: add $formtype = "hidden" | "select" for poll_module config to be effect in Onupdate process. in newbb/xoops_version.php
-2- improve: findPollModule function: just select needed "poll_id" field from topic table in newbb/class/topic.php
-
-date 2013-05-23
-===================================
-1- add: findPollModule function to 'NewbbTopicHandler' class to find poll module that is in used in the current newbb installtion. in newbb/class/topic.php
-2- improve: add getActivePolls function to 'NewbbTopicHandler' class to get all active poll modules in the current xoops installtion. in newbb/class/topic.php
-3- add: add getPoll function to 'Topic' class to get a poll object from a poll module. in newbb/class/topic.php
-4- enhance: add a $pollModule dirname of the poll module to loadOldPoll function in 'Topic' class to Load functions needed for old poll module. in newbb/class/topic.php
-5- add: special check to find and save the used poll module on the newbb update process. in newbb/xoops_version.pp
-6- add: special check to find and save the used poll module on the newbb saving preferences process. in newbb/xoops_version.pp
-7- change version to 4.33 RC7 in newbb/xoops_version.php
-
-date 2013-05-22
-===================================
-bug fix: in topic merge: the old topic will be deleted if user input a not exist new topic in newbb/topicmanager.php
-improve: in topic merge: less query to update new topic_views in newbb/topicmanager.php
-fix: in topic merge: new forum should be synchronized after merge in newbb/topicmanager.php
-improve: in topic merge: better method for delete the old topic and synchronize the new topic, old forum and new forum in newbb/topicmanager.php
-add: in topic merge: if old topic has a poll and new topic has not a poll, move poll from old topic to new topic in newbb/topicmanager.php
-fix: in topic merge: update vote data instead of deleting them in newbb/topicmanager.php
-improve: add deletePoll function to 'Topic' class to use with ease in newbb/class/topic.php, newbb/class/post.php, newbb/topicmanager.php
-add: better poll module display link and version in admin index. in newbb/admin/index.php
-
-date 2013-05-21
-===================================
-1- poll_module: force user to only select poll module once in preferences in newbb/xoops_version.php
-2- bug fix: poll_module handler in newbb/class/post.php
-
-date 2013-05-19
-===================================
-1- add: poll_module: rewrite polls.php to accept xoopspoll 1.4 by zyspec and all old xoopspoll and umfrage versions and all clones.
-in newbb/class/topic.php and newbb/polls.php , newbb/votepolls.php , newbb/viewtopic.php , newbb/class/post.php , newbb/topicmanager.php
-and newbb/templates/newbb_poll_results.html , newbb/templates/newbb_poll_view.html
-and newbb/templates_fulldiv_opacity/newbb_poll_results.html , newbb/templates_fulldiv_opacity/newbb_poll_view.html
-
-2- add: $xoopspoll in header for backward compatibility. in newbb/header.php
-3- improve: priorities for default poll module : 1- xoopspoll 2- last element in array 3- if no poll module => 0 in newbb/xoops_version.php
-
-date 2013-05-19
-===================================
-1- add poll_module config to avoid writing hard-code poll dirname (eg: clones) in newbb/xoops_version.php and newbb/header.php and newbb/admin/index.php
-2- change version to 4.32 in newbb/xoops_version.php
-
-date 2013-05-14
-===================================
-1- add: itemId($item_name) plugin: any module can define a plugin to get its itemId based on item_name. now newbb:
-In newbb > viewtopic.php the topic_id is not always in the URL $_REQUEST.
-in newbb/class/plugin/userlog.php (2013/05/14)
-
-date 2013-04-23
-===================================
-1- add last_login to viewtopic.php (Mamba) in newbb/viewtopic.php and newbb/class/user.php and newbb/templates/newbb_thread.html and newbb/templates_fulldiv_opacity/newbb_thread.html
-
-date 2013-04-20
-===================================
-1- bug fix: remove ALTER TABLE `bb_posts` DROP INDEX `approved`; and add to mysql.php and change version to 431 in newbb/sql/mysql.430.sql and newbb/sql/mysql.php and newbb/xoops_version.php
-2- improve: add check version in user database to dont run update script if user has the latest version. in newbb/include/module.php
-3- Change status to RC6
-4- add: forum name in newbb/moderate.php
-date 2013-04-17
-===================================
-1- bug fix: should not ban the user in forum who is moderator of that forum. in newbb/include/form.post.php and newbb/class/moderate.php
-2- bug fix: uid=0 for anonymous users in newbb/class/moderate.php
-3- bug fix: if forum=0 should return true in any forum in newbb/class/moderate.php
-4- bug fix: should not show quick reply for suspend users otherwise they can post in newbb/viewtopic.php
-5- add: forum select box for admins to be able to suspend users in any forum or all forums in newbb/moderate.php
-6- bug fix: only show all bans for module admin - for moderator just show its forum_id bans in newbb/moderate.php
-
-date 2013-04-15
-===================================
-1- improve: add anon users to topic poster and last poster in NewbbTopicRenderer class (used in block and list.topic.php)
- newbb/class/topic.renderer.php, newbb/xoops_version.php,
- newbb/list.topic.php, newbb/blocks/list_topic.php
-
-date 2013-02-11
-===================================
-1- improve: add multi topic poster and multi last poster to NewbbTopicRenderer class (used in block and list.topic.php)
- newbb/class/topic.renderer.php, newbb/xoops_version.php,
- newbb/list.topic.php, newbb/blocks/list_topic.php
-
-2- improve and fix: multi status and multi display header in NewbbTopicRenderer class
-newbb/class/topic.renderer.php, newbb/list.topic.php, newbb/blocks/list_topic.php
-
-date 2013-02-07
-===================================
-1- improve: enhance the advance block. add more sorts: lastposttime, lastposter, lastpostmsgicon . add more display mode: attachment, read, pagenav
- newbb/class/topic.renderer.php, newbb/xoops_version.php,
- newbb/blocks/list_topic.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html
- newbb/language/LANG/main.php, newbb/docs/lang_diff.txt
-
-2- change default from sticky to lastpost
- newbb/class/topic.renderer.php
-
-3- bug fix: read status: read topics do not show for readmode = 1 in list.topic.php
- newbb/class/topic.renderer.php
-
-date 2013-02-06
-===================================
-1- bug fix: Undefined variable: forumCookie revert last change - use global instead of include_once
-in newbb/footer.php
-
-2- bug fix: Undefined index: newbb config in blocks activated in some modules like profile
-in newbb/class/post.php
-
-3- bug fix: dont show topic title in list.topic.php
-in newbb/class/topic.renderer.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html
-
-date 2013-02-05
-===================================
-1- bug fix: when update the type for a specific forum it delete other forum's types too.(important)
-in newbb/class/type.php
-
-2- bug fix: t.topic_rating to t.rating in viewforum and topic renderer pages
-in newbb/viewforum.php, newbb/class/topic.renderer.php
-
-3- bug fix: dont add sort to criteria if sort=null eg: /list.topic.php?sort= will cause db error
-in newbb/class/topic.renderer.php
-
-4- bug fix: if user set post_excerpt = 0 in preferences, there is no join in criteria and Undefined index: join error occured.
-in newbb/class/topic.renderer.php
-
-5- feature add: NewbbTopicRenderer class can accept multiple status. more status and sort is added.
-status supproted: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin)
-in newbb/class/topic.renderer.php
-
-6- feature add: add "topic_title_excerpt" setting. render topics with the specific title length. 0 = dont excerpt and show the whole topic title.
- in newbb/include/plugin.php, newbb/class/topic.renderer.php
-
-7- feature add: a new block for topics using NewbbTopicRenderer class.
- users can drop old "Recent Topics" and "Recent Replied Topics" block and use this block instead.
-in newbb/xoops_version.php, newbb/language/LANG/main.php, newbb/language/LANG/blocks.php, newbb/language/LANG/modinfo.php, newbb/docs/lang_diff.txt
-newbb/list.topic.php,
-add: newbb/blocks/list_topic.php, newbb/templates/blocks/newbb_block_list_topic.html, newbb/templates/js/language/english/newbb_validation.js
- newbb/templates_fulldiv_opacity/blocks/newbb_block_list_topic.html, newbb/templates_fulldiv_opacity/js/language/english/newbb_validation.js
-
-8- fix: remove hardcoded items from topic_icon and topic_folder smarty and add sticky, digest, poll, lock, publish time and rating smarty
-in newbb/templates_fulldiv_opacity/viewall.html, in newbb/templates/viewall.html
-
-9- bug fix: remove hardcoded access to database for creating forum selection box (multiple and single) in admin prune.
-in newbb/admin/admin_forum_prune.php
-
-10- fix: change $xoopsUser to $GLOBALS["xoopsUser"] because $xoopsUser is not defined in admin side
-in newbb/include/vars.php
-
-11- bug fix: Undefined variable: forumCookie
-in newbb/footer.php
-
-12- fix: _MD_NEWBB_GOTOLASTPOST already defined
-in newbb/blocks/newbb_block.php
-
-13- change the status to RC5
-in newbb/xoops_version.php
-
-date 2012-12-26
-===================================
-1- bug fix: Warning: xoopsOption[template_main] should be defined before including header.php in file /footer.php line 59
-in newbb/edit.php, newbb/header.php, newbb/index.php, newbb/list.topic.php, newbb/newtopic.php, newbb/post.php, newbb/reply.php,
-newbb/search.php, newbb/topicmanager.php, newbb/viewforum.php, newbb/viewpost.php, newbb/viewtopic.php
-
-2- improve: use addScript instead of xoops_module_header to add toggle script because some themes are not standard
-in newbb/header.php, newbb/footer.php
-
-3- bug fix: assign default values to variables to fix some notices
-in newbb/search.php
-
-4- bug fix: use addScript before include header.php
-in newbb/viewpost.php
-
-date 2012-12-25
-===================================
-1- bug fix: when vote in polls it should save user ip to db
-in newbb/votepolls.php
-
-2- bug fix: user is not allowed to vote when the poll is expired
-in newbb/viewtopic.php, newbb/votepolls.php
-
-3- bug fix: in edit poll page topic_id is missing in restart this poll url
-in newbb/polls.php
-
-date 2012-11-19
-===================================
-1- bug fix: in viewforum.php?forum=XXX . moderator have all access over the forum regardless of his/her group access.
-in newbb/class/forum.php
-
-date 2012-11-14
-===================================
-1- feature add: add pdf and print permissions. fix html and signature permission in new install.
-Important Note: you must set permissions for each group and each forum in newbb -> admin -> set permissions otherwise only newbb admins have permissions.
-in newbb/class/post.php, newbb/class/permission.forum.php, newbb/makepdf.php, newbb/print.php,
- newbb/language/LANG/main.php, newbb/language/LANG/admin.php, newbb/docs/lang_diff.txt
-
-2- FAQ add: after submit in newbb => admin => permissions it said "Sorry, you don't have the permission to access this area"
-in newbb/docs/readme.txt
-
-date 2012-11-12
-===================================
-1- bug fix: in full div templates set: in smarty replace: replacing tr/td to span was incorrectly done
-in newbb/templates_fulldiv_opacity/newbb_edit_post.html
-
-2- bug fix: in newbb/search.php: add selecthtml=0 to the next search link
-in newbb/search.php
-
-date 2012-11-08
-===================================
-1- bug fix: in viewforum.php?forum=XXX : change sort fields u.uname => t.topic_poster | t.topic_time => t.topic_id | "t.topic_ratings"=>_MD_RATINGS, | p.post_time => t.topic_last_post_id
-in newbb/viewforum.php
-
-date 2012-11-07
-===================================
-1- bug fix: in XOOPSCORE/search.php $xoopsModuleConfig and $xoopsModule is not set
-in newbb/include/search.inc.php
-
-date 2012-11-06
-===================================
-1- bug fix: in view all topic page: a typo "all" instead of all when the status is not set
-in newbb/class/topic.renderer.php
-
-date 2012-10-28
-===================================
-1- bug fix: getRead_cookie should return array. (important)
-in newbb/class/read.php
-
-2- improve: add LAST_INSERT_ID to enhance the mysql performances
-in newbb/class/topic.php
-
-3- improve: set IP as COOKIE prefix for anonymous users
-in newbb/include/vars.php, newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php
-
-4- bug fix: increment topic_views only if the topic is unread (important)
-in newbb/viewtopic.php
-
-date 2012-10-22
-===================================
-1- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread when read_mode = 1 (cookie)
-in newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php
-
-2- improve: change the read_mode = 2 (db) to read_mode = 1 (cookie) for anonymous users
-in newbb/include/functions.ini.php, newbb/include/plugin.php
-
-3- minor bug fix: <{$lastvisit}> smarty variable is added for all users (members and anons) it was wrongly only for members
-in newbb/index.php, newbb/templates/newbb_index.html, newbb/templates_fulldiv_opacity/newbb_index.html
-
-date 2012-10-20
-===================================
-1- bug fix: wrongly do not count sub forum posts/topics when count_subforum = 1
-in newbb/class/forum.php
-
-2- bug fix: $criteria_post and $criteria_count only for users
-in newbb/viewpost.php
-
-3- improve: add topic_read = 0/1 and forum_read = 0/1 smarty variables
-in newbb/class/forum.php, in newbb/class/topic.renderer.php,
-newbb/templates/newbb_index.php, newbb/templates/newbb_viewall.php, newbb/templates/newbb_viewforum.php, newbb/templates/css/language/LANG/style.css
-
-4- add: hack XOOPSCORE/search.php to use MODULE_NAME/search.php file instead of XOOPSCORE/search.php
-in XOOPS255/search.php
-
-5- add : new fulldiv template set (opacity)
-in newbb/templates_fulldiv_opacity/*.*
-
-date 2012-10-17
-===================================
-1- improve: add startlag, length, striptag=true/false, strip tages excludes in search form.
-in newbb/search.php, newbb/include/functions.text.php, newbb/templates/newbb_search.php, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt
-
-2- improve: in search form: dont show (skip) the result if both (post text) and (post subject) are empty.
-in newbb/search.php, newbb/include/functions.text.php
-
-3- improve: in search fucntion: ability to create criteria for both since and search topic
-in newbb/search.php
-
-4- comment add: the comment in class read about read_expire values was wrong
-in newbb/class/read.php
-
-5- improve: add default path for themes/default and themes/YOUR_THEME (images, css, js)
-in newbb/class/icon.php
-
-date 2012-10-15
-===================================
-1- bug fix: viewpost.php?status=new AND viewforum.php?forum=FFF&status=unread and list.topic.php?status=unread criteria was wrong when read_mode = 2(important)
-in newbb/viewpost.php, newbb/class/forum.php, newbb/class/topic.renderer.php
-
-2- bug fix: in view all topic page: if empty($_GET(status)) it will show all topics include deleted and pendings.
- the last solution removed in list.topic.php and move to topic.renderer.php because the last solution cause double query and error.
-in newbb/list.topic.php, newbb/class/topic.renderer.php
-
-3- bug fix: add read_item_uid indexes to avoid duplicate (read_item, uid) when submit a post (very important)
-newbb/sql/mysql.sql, newbb/sql/mysql.430.sql
-
-4- bug fix: add clearDuplicate function for clear duplicate rows in bb_reads_topic and bb_reads_forum tables. old newbb users should click on "Read Data" in newbb -> admin -> syncronization page. (very important)
-in newbb/class/read.php, newbb/admin/admin_synchronization.php, newbb/language/LANG/admin.php, newbb/docs/lang_diff.txt
-
-5- improve: add read_expire = 0 => no clean up reads tables
-in newbb/class/read.php, newbb/include/plugin.php
-
-date 2012-10-11
-===================================
-1- bug fix: viewpost.php?status=new was wrongly return the new posts and new posts counts based on read_mode=1 (cookie) when the read_mode=2 (database) (important)
-in newbb/viewpost.php and newbb/class/post.php
-
-date 2012-10-10
-===================================
-1- bug fix: in list.topic.php: remove empty arrays in getStatus function
-in newbb/class/topic.renderer.php
-
-2- bug fix: add template smarty variables to search.php to save the user inputs in submit. move select boxes from template to php file
-in newbb/templates/newbb_search.html, newbb/search.php
-
-3- bug fix: in search.php (previously in newbb_search.html): wrongly the andor value="all" (it should be value="AND"), change default andor="OR" to andor="AND" to be like XOOPS CORE setting
-in newbb/search.php
-
-4- bug fix: wrongly p.post_time = since (should be >= since)
-in newbb/class/topic.renderer.php
-
-5- bug fix: $hidvar should be <{$hidvar}> smarty. Improve $hidvar and $hidval in template
-in newbb/templates/newbb_viewall.html
-
-6- bug fix: we need old vars for selection boxes.
-in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html
-
-7- bug fix: remove name attribute from submit buttons when method=get
-in newbb/templates/newbb_index.html, newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, newbb/templates/newbb_search.html
-
-8- bug fix: wrongly dont parse negative values (categories) when newbb_forumSelectBox is multiple. add a new getIdsByValues function to class/forum.php
-in newbb/class/forum.php, newbb/include/search.inc.php, newbb/include/topic.renderer.php,
-
-9- bug fix: id="xo-pagenav" is hardcoded in the XOOPS Core 2.5.5 and 2.6 (mrphilong/irmtfan)
-in newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html,
-newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html
-
-10- feature add: add newbb_forumSelectBox multiple to list.topic.php
-in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html
-
-11- feature add: show search results: 1- post title 2- post text
-in newbb/search.php, newbb/templates/newbb_search.html, newbb/templates/newbb_searchresults.html, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt
-
-12- feature add: add "select text" and "highlighter" to search keywords. add a new file include/functions.text.php to handle text
-in newbb/include/functions.text.php, newbb/include/plugin.php, newbb/class/post.php, newbb/include/search.inc.php, newbb/search.php
-newbb/templates/css/language/LANG/style.css
-
-13- bug fix: remove hardcode database access, solve order issues, reduce queries, permissions issues. file include/search.inc.php is completely rewritten (important)
-in newbb/include/search.inc.php
-
-14- feature add: add topic search to viewtopic and viewpost
-in newbb/templates/newbb_viewtopic.html, newbb/search.php, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt
-
-15- bug fix: in list.topic.php the topic_link is hardcoded. add topic_excerpt
-in newbb/class/topic.renderer.php
-
-date 2012-10-02
-===================================
-1- feature add: jump to last post read in the topic when the post_id is not in the URL(kwaltman/irmtfan)
-in newbb/viewtopic.php, newbb/include/plugin.php
-
-2- bug fix: add topic_page_jump_icon for list.topic.php and link to the last post in viewforum.php and list.topic.php
-in newbb/class/forum.php, newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html
-
-3- bug fix: remove hardcode from blocks URLs. add topic url and topic last post icon smarty variables.
-in newbb/blocks/newbb_block.php, newbb/templates/blocks/newbb_block.html, newbb/templates/blocks/newbb_block_post.html, newbb/templates/blocks/newbb_block_topic.html
-
-4- improve and fix: in list.topic.php add topic_folder_text for alt , add forum_folder_text for alt
-in newbb/class/topic.renderer.php, newbb/class/forum.php
-
-5- improve: add alt key for rating
-in newbb/class/topic.renderer.php, newbb/class/forum.php, newbb/viewtopic.php
-
-6- fix: _MD_POSTER to _MD_TOPICPOSTER and _MD_DATE to _MD_LASTPOSTTIME and add $smarty.const._MD_BY
-in newbb/class/topic.renderer.php, newbb/templates/newbb_viewforum.html
-
-7- bug fix: many unneeded queries for newbb_isRead in viewforum.php, revise codes, move codes to a for loop(important)
-newbb/class/forum.php
-
-8- bug fix: in newbb/list.topic.php?forum=XXX - wrongly return the forum_id only when the forum_id is the first allowed forum (important)
-in newbb/class/topic.renderer.php
-
-9- improve: some modification in persian translation.
-in newbb/language/persian/main.php, newbb/language/persian/modinfo.php,
-
-date 2012-09-29
-===================================
-1- bug fix: since value is hardcoded badly when since=1000 (From 1000 days ago) it return 0 (current time)
-in newbb/include/functions.time.php
-
-2- bug fix: rewrite newbb_sinceSelectBox function. if the since array is empty do not show since select box. 0 and 365 had been hardcoded.
-in newbb/include/functions.time.php, newbb/xoops_version.php, newbb/language/english/modinfo.php
-
-3- bug fix: in viewforum - if no since in the _GET it should be 0 (Roby78/irmtfan)
-in newbb/viewforum.php
-
-4- bug fix: in search - not show the selected since entered by user in selection box.
-in newbb/search.php
-
-date 2012-09-26
-===================================
-1- bug fix: move semicolon from php files to template files. 'block;' => 'block' AND 'none;' => 'none'
-in newbb/index.php, newbb/viewtopic.php, newbb/templates/newbb_thread.html, newbb/templates/newbb_viewtopic.html, newbb/templates/newbb_index.html
-
-2- bug fix: Issue with javascript in redirect_header javascript:history.go(-1)
-in newbb/action.post.php, newbb/action.topic.php, newbb/polls.php, newbb/post.php, newbb/ratethread.php, newbb/topicmanager.php, newbb/votepolls.php
-
-3- bug fix: add messages for redirect_header
-in newbb/post.php, newbb/votepolls.php, newbb/admin/admin_report.php, newbb/language/english/main.php, newbb/language/english/admin.php, newbb/docs/lang_diff.txt
-
-4- fix and improve: add redirect header when no report is selected in admin_report.php in submit.
-newbb/admin/admin_report.php, newbb/language/english/admin.php, newbb/docs/lang_diff.txt
-
-5- bug fix: user dont see "the topic is locked" if the show_reg was set to 0. revise forum_post_or_register smarty and assign 3 new smraty variables: forum_post, forum_register, topic_lock
-in newbb/viewtopic.php
-
-6- bug fix: user can see rating when he dont have permission to post and/or reply.
-in newbb/viewtopic.php, newbb/templates/newbb_viewtopic.html
-
-7- bug fix: innerHTML change only if the TAG is not img.
-
-date 2012-09-25
-===================================
-1- bug fix: change the method of adding stylesheet and scripts from overrighting xoops_module_header smarty variable to $xoTheme.
-move codes from header.php to the new footer.php file. add local stylesheet and js for newbb blocks outside module space.
-modify:
-in newbb/action.post.php, newbb/action.topic.php, newbb/edit.php, newbb/header.php,
-newbb/index.php, newbb/list.topic.php, newbb/newtopic.php, newbb/polls.php,
-newbb/post.php, newbb/action.post.php, newbb/ratethread.php, newbb/reply.php
-newbb/search.php, newbb/topicmanager.php, newbb/viewforum.php, newbb/viewpost.php, newbb/viewtopic.php
-add:
-in newbb/footer.php
-
-2- improve: move js files from include/js to templates/js/language/LANG. all js files inside language directory will be added to header.
-move "style.css" file from templates/images/language/LANG to templates/css/language/LANG.
-in newbb/class/icon.php, newbb/footer.php, newbb/templates/js/language/LANG/*.js, newbb/templates/css/language/LANG/style.css
-
-3- delete unneeded files:
-newbb/include/pngbehavior.htc, newbb/include/newbb.htc, newbb/include/js/*.*
-
-4- bug fix: days should be changed to seconds.
-in newbb/class/post.php, newbb/class/topic.php
-
-date 2012-09-19
-===================================
-1- bug fix: in post delete process: wrongly delete parent post before childs but the right way is deleting childs before deleting parent post.(reverse order deleting)
-in newbb/class/post.php
-
-2- bug fix: solve nested forms issue when the pagenav type is select
-in newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html,
-newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html
-
-3- bug fix: xoops_module_header smarty variable is missing.
-newbb/edit.php, newbb/newtopic.php, newbb/post.php, newbb/reply.php
-
-
-date 2012-09-18
-===================================
-1- bug fix: in topic delete process: in view all and view forum: after delete selected topics all topics and their posts will be wrongly deleted from database.(very important)
-in newbb/action.topic.php
-
-2- bug fix: in post restore process: it will not approve post if approved = -1 (deleted) (important)
-in newbb/class/post.php
-
-3- bug fix: in post delete process: wrongly set new pid for not approved posts and set pid=0(very important)
-in newbb/class/post.php
-
-4- bug fix: wrongly check topic is not object after set it as object (important)
-in newbb/class/topic.php
-
-5- bug fix: in view all topic page: if empty($_GET(status)) it will show all topics include deleted and pendings.
-in newbb/list.topic.php
-
-6- bug fix: sync topic not added after delete
-in newbb/topicmanager.php
-
-7- bug fix: remove unneeded codes: manually approve posts after restore
-in newbb/topicmanager.php
-
-8- improve: ability to restore a topic in viewtopic page
-in newbb/topicmanager.php, newbb/viewtopic.php
-newbb/language/english/main.php, newbb/docs/lang_diff.txt
-
-9- fix: slash "/" missing in URL
-in newbb/topicmanager.php
-
-10- fix: add "mode" smarty variable in viewforum to see admin links
-in newbb/viewforum.php
-
-11- improve: in view all topic page: show all admin links in admin mode in the initial page loading
-newbb/templates/newbb_viewall.html
-
-12- bug fix: admin main sync wrongly delete all pending and deleted posts/topics (very important)
-in newbb/admin_synchronization.php
-
-13- bug fix: admin main sync (misc) wrongly delete all pending and deleted posts/topics when the pending_expire=0 in newbb/include/plugin.php (very important)
-in newbb/class/post.php, newbb/class/topic.php
-
-date 2012-09-16
-===================================
-1- improve: Add forum_post_prefix smarty variable to have unique Ids for posts. Add js function to scroll to current post in viewtopic.php links.
-in newbb/templates/newbb_thread.html , newbb/templates/newbb_viewtopic.html
-
-date 2012-09-11
-===============================
-1- bug fix: viewtopic admin mode action incorrectly on the topic instead of selected posts of the topic.(important)
-in newbb/templates/newbb_viewtopic.html
-2- change some reletive URLs to Full URLs (Roby73/irmtfan)
-in newbb/notification.inc.ini
-3- bug fix: redirect was not correct in subdomain (value=xoops_url removed)
-in newbb/templates/newbb_notification_select.html
-4- advertise post should not have admin buttons.
-in newbb/templates/newbb_thread.html
-5- revoke the last change rev 10170 and revert to rev 10102
-in newbb/xoops_version.php
-
-date 2012-09-10
-===============================
-1- bug fix: notification not show in newbb/viewtopic.php?post_id=XXXX URLs
-in newbb/xoops_version.php
-
-date 2012-09-10
-===============================
-1- back rank_image and rank_title to rank.image rank.title smarty variables to make consistency with old newbb versions.
-in newbb/class/user.php, newbb/templates/newbb_thread.html
-
-2- change some reletive URLs to Full URLs (Roby73/irmtfan)
-in newbb/viewforum.php, newbb/topicmanager.php, newbb/polls.php, newbb/templates/newbb_viewtopic.html
-
-3- add up and down icons smarty variables to templates.
-in newbb/viewpost.php, newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html
-
-
-date 2012-09-09
-==================
-1- some changes in persian language notifications.
-language/persian/modinfo.php
-2- add alt to down prev and next and change the templates
-newbb/viewtopic.php newbb/templates/newbb_viewpost.html and newbb/templates/newbb_viewtopic.html
-3- bug fix: js onclick xoopsCheckAll not work when polls is active in viewtopic admin mode.
-newbb/templates/newbb_viewtopic.html
-
-date 2012-09-05
-================================================
-1- minor bug fix: mistype in viewtopic and viewpost admin mode submit button when admin dont select any action
-in newbb_viewpost.html and newbb_viewtopic.html
-
-date 2012-09-01
-================================================
-1- add toggle $quickreply['expand'] to find quickreply hide/see
-newbb/viewtopic.php
-
-2- add alt and title to text links - change html tag to class="forum_icon forum_button" to support IE7&8
-newbb/class/icon.php, newbb/templates/images/language/english/style.css, newbb/include/display.php (juct change help comments)
-
-3- improve ToggleBlockCategory js to change icon.id and use innerHTML instead of textContent to support IE7&8
-newbb/include/js/newbb_toggle.js
-
-4- remove unneeded gif persian images
-newbb/templates/images/language/persian
-
-date 2012-08-30
-================================================
-1- add more and less icons - add t_qr_expand.png image and add show see definitions
-newbb/include/display.php, newbb/include/images.php
-newbb/templates/images/language/english/t_qr_expand.png
-newbb/language/english/main.php, newbb/docs/lang_diff.txt
-
-2- improve ToggleBlockCategory js to recognize a IMG tag
-newbb/include/js/newbb_toggle.js
-
-3- change all toggles in newbb to use ToggleBlockCategory - use newbbDisplayImage function for all toggles - alt and title and text links supported
-newbb/viewtopic.php, newbb/templates/newbb_viewtopic.html, newbb/templates/newbb_thread.html
-newbb/index.php, newbb/templates/newbb_index.html
-
-4- some hardcodes removed (<{$topic_post.post_edit}> and signature line
-newbb/templates/newbb_thread.html, newbb/templates/images/language/english/style.css
-
-date 2012-08-28
-================================================
-1- improve text link instead of buttons feature. Ability to set the display setting for each link in newbb/include/display.php
-newbb/include/plugin.php, newbb/include/display.php, newbb/include/functions.render.php
-
-2- add id={$image} for html tag
-newbb/class/icon.php
-
-date: 2012-08-27 - 2
-================================================
-1- improve text link instead of buttons to only show text buttons when: a) alt key is set b)display is not set to true c)only buttons like reply, edit
-newbb/include/functions.render.php, newbb/class/icon.php
-
-2- add alt key for quickreply button and remove one extra space ( ) and sort reply - addpoll - newtopic
-newbb/viewtopic.php, newbb/templates/newbb_viewtopic.html
-
-date: 2012-08-27
-================================================
-1- remove icon_path and use newbbDisplayImage
-newbb/class/forum.php, newbb/templates/newbb_index.html, newbb/templates/newbb_viewforum_subforum.html
-
-2- remove icon_path and define anonym icon and use newbbDisplayImage
-newbb/viewpost.php, newbb/viewtopic.php, newbb/include/images.php, newbb/templates/newbb_thread.html
-
-3- simplyify infobox and add alt and title show/hide definitions and alt key
-newbb/viewtopic.php, newbb/templates/newbb_thread.html, newbb/include/js/newbb_toggle.js, newbb/language/english/main.php newbb/docs/lang_diff.txt
-newbb/templates/images/language/english/style.css
-newbb/templates/images/icon/less.png
-
-4- a little correctness. dot removed
-newbb/class/user.php
-
-5- feature improve: css3 text buttons introduced and used (DCrussader/irmtfan)
-newbb/class/icon.php, newbb/templates/images/language/english/style.css class="forum_icon" id=$image_name
-
-date: 2012-08-26
-================================================
-1- merge with alfred.
-newbb/votepolls.php, newbb/polls.php, newbb/print.php, newbb/seo.php
-
-2- bug in getting $op and typo: addmor -> addmore
-newbb/polls.php
-
-3- better method for getting the customize/localize newbb style.css
-newbb/header.php
diff --git a/docs/changelog-rev9883.txt b/docs/changelog-rev9883.txt
deleted file mode 100644
index f42c146d..00000000
--- a/docs/changelog-rev9883.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-Changelog from rev.9883
-
-date: 2012-08-15
-================================================
-1- minor fix: double slash fixed in rpg url
-in newbb/class/user.php
-
-2- hardcode removed in rpg image alignment - align="left -> class="icon_left"
-in newbb/class/user.php
-
-3- some english/persian language definitions has been revised. All extra spaces/newlines have been removed.
-All changed to end method windows(CR+LF).See docs/lang_diff.txt for detail.
-in newbb/language/english/*.php, newbb/language/persian/*.php
-
-4- add lang_diff.txt
-in newbb/docs/lang_diff.txt
-
-5- expand readme.txt add guides to get a backup from old images before update, introduce Image customization and some FAQ
-in newbb/docs/readme.txt
-
-6- makepdf.php from black_beard - add RTL - remove unneeded TCPDF config language requirements - add multi-lang EMLH by GIJ and Xlanguage by phppp DJ.
-Add Forum Index - cat - forum - sub forum - topic names to the pdf header.
-in newbb/makepdf.php
-
-7- add local stylesheet (xoops_header) in print.php
-in newbb/print.php
-
-date: 2012-08-06
-================================================
-1- hardcode fix: using header php command instead of redirect_header XOOPS function (deka87/irmtfan)
-in newbb/search.php
-(Also hardcoded in latest core in xoops2.5.5/htdocs/search.php)
-
-2- hardcode fix: icon_path smarty variable was hardcoded in viewtopic and viewpost and is not defined in class/forum.php (irmtfan)
-in newbb/viewtopic.php, newbb/viewpost.php, newbb/class/forum.php
-
-3- hardcode icons and some hardcodes has been solved in templates:
-in newbb/templates/newbb_thread.html, newbb/templates/newbb_index.html, newbb/templates/newbb_viewforum_subforum.html
-
-4- add readme.txt for install and upgrade
-in docs/readme.txt
-
-5- a poll class misses in english style.css
-in newbb/templates/images/language/english/style.css
-
-date: 2012-08-04
-================================================
-1- bug fixed: error in newbb/polls.php when the strtotime is not defined in XoopsLocal class (irmtfan)
-solution: replace XoopsLocal::strtotime($end_time) by method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time)
-in newbb/polls.php
-2- more hardcodes in newbb/templates has been removed
-
-date: 2012-08-01
-================================================
-1- localization: input date localized (for other date systems like hegira) by replacing strtotime by XoopsLocal::strtotime
-in newbb/polls.php
-
-2- customization&localization: newbb style.css is fully localized and customized and is not hard-coded anymore.
-in newbb/header.php
-file changes:
--- deleted newbb/templates/style.css
--- added newbb/templates/images/language/english/style.css
--- added newbb/templates/images/language/persian/style.css
-priorities:
-if exist in themes/YOUR_THEME/modules/newbb/images/language/YOUR_LANG/style.css take it
-else if exist in themes/default/modules/newbb/images/language/YOUR_LANG/style.css take it
-else if exist in modules/newbb/templates/images/language/YOUR_LANG/style.css take it
-else if exist in modules/newbb/templates/images/language/english/style.css take it
-else if exist in modules/newbb/templates/style.css take it (for backward compatibility)
-
-3- many hardcodes in newbb/templates and style.css has been removed
-
-date: 2012-07-30
-================================================
-1- bug fix: edit not displayed when the reason is not filled (irmtfan)
-2- bug fix: only the last edit is recorded. (irmtfan/alfred)
-in newbb/class/post.php
-3- bug fix: 'noapprove' permission incorrectly recorded in database. (irmtfan)
-in newbb/class/permission.php
-4- bug fix: load user ranks has been hardcoded. it works in old/upgraded websites but not works in new installed websites. a new getting rank introduced. (black_beard/irmtfan)
-in newbb/class/user.php, newbb/templates/newbb_thread.html
-5- minor bug fix: mysql 5.1 was incorrectly needed (irmtfan)
-in newbb/xoops_version.php
-6- hardcode: some style.css color hardcodes has been removed. (irmtfan)
-in newbb/templates/style.css
-7- feature added: text links instead of buttons. (deka87/irmtfan)
-in newbb/class/icon.php , newbb/include/functions.render.php , newbb/include/plugin.php
\ No newline at end of file
diff --git a/docs/changelog.txt b/docs/changelog.txt
index 76fb4bfb..3af18839 100644
--- a/docs/changelog.txt
+++ b/docs/changelog.txt
@@ -1,3 +1,23 @@
+5.01 Beta 1 [2021-01-26] Dev: XOOPS 2.5.11, PHP 7.4.14, PHP 8.0.1
+
+- Facebook UI Style Rating (xd9527/mamba)
+- fix $status (goffy/zyspec)
+- fix split bug (bioskop/mamba)
+- update for XoopsPoll 2.01 (mamba)
+- renamed 'PHP_SELF' to 'SCRIPT_NAME' (mamba)
+- fix SetAttachment in Post.php PR#80 (BigKev73)
+- fix multi-file attachment in post.php PR#81 (BigKev73)
+- fix user jumping directly to the last post in ForumHandler.php PR#82 (BigKev73)
+- update newbb_block.php PR#83 (BigKev73)
+- PSR-12 Else if (mamba)
+- small fixes, cosmetics (mamba)
+- PHP8 template updates (mamba)
+- replace index.html with index.php (mamba)
+- fix blank.gif location (mamba)
+- fix missing isXoopsUser (mamba)
+- foreach (mamba)
+
+
5.00 Final (XOOPS 2.5.10) [2019-04-30] Dev: Xoops 2.5.10, PHP 7.3.4
- reversed to while (list()) (mamba)
diff --git a/docs/index.html b/docs/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/docs/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/docs/index.php b/docs/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/docs/index.php
@@ -0,0 +1,3 @@
+
* @since 4.00
* @package module::newbb
diff --git a/footer.php b/footer.php
index 000c20b0..89385444 100644
--- a/footer.php
+++ b/footer.php
@@ -11,15 +11,13 @@
/**
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package NEWBB
* @since 4.3
* @author irmtfan
* @author The Persian Xoops Support Site
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
global $xoTheme;
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.render.php');
diff --git a/header.php b/header.php
index fd9f56b6..f77d1369 100644
--- a/header.php
+++ b/header.php
@@ -3,18 +3,27 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
use Xmf\Request;
+use XoopsModules\Newbb\{Helper
+};
+
+/** @var Helper $helper */
require_once dirname(dirname(__DIR__)) . '/mainfile.php';
require_once __DIR__ . '/include/common.php';
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+$moduleDirName = basename(__DIR__);
+
+$helper = Helper::getInstance();
+// Load language files
+$helper->loadLanguage('main');
+
/** @var \XoopsLogger $xoopsLogger */
$xoopsLogger->startTime('newBB_Header');
// irmtfan assign newbb dirname then replace all. include xoops header.php (now commented and removed)
@@ -32,16 +41,14 @@
$redir = false;
if (true === mb_strpos(getenv('REQUEST_URI'), 'mark_read=') || true === mb_strpos(getenv('REQUEST_URI'), 'mark=')) {
// Mark Forums
- } else {
- if (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) {
- //rewrite only for files
-
- if ('' !== trim(getenv('SCRIPT_NAME'))) {
- if (false === mb_strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) {
- $redir = true;
- } elseif (getenv('QUERY_STRING')) {
- $redir = true;
- }
+ } elseif (in_array(basename(getenv('SCRIPT_NAME')), $toseo_url)) {
+ //rewrite only for files
+
+ if ('' !== trim(getenv('SCRIPT_NAME'))) {
+ if (false === mb_strpos(getenv('REQUEST_URI'), '/' . SEO_MODULE_NAME . '/')) {
+ $redir = true;
+ } elseif (getenv('QUERY_STRING')) {
+ $redir = true;
}
}
}
diff --git a/include/common.php b/include/common.php
index 3246b519..1a00131b 100644
--- a/include/common.php
+++ b/include/common.php
@@ -20,21 +20,23 @@
* @author XOOPS Development Team - Email: - Website:
*/
-use XoopsModules\Newbb;
+use Xmf\Module\Admin;
+use XoopsModules\Newbb\{Helper,
+ Utility
+};
+
+/** @var Helper $helper */
+/** @var Utility $utility */
+/** @var Admin $adminObject */
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
require_once dirname(__DIR__) . '/preloads/autoloader.php';
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
-/** @var \XoopsDatabase $db */
-/** @var Newbb\Helper $helper */
-/** @var Newbb\Utility $utility */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
-$helper = \XoopsModules\Newbb\Helper::getInstance();
-$utility = new Newbb\Utility();
-//$configurator = new Newbb\Common\Configurator();
+$helper = Helper::getInstance();
+$utility = new Utility();
$helper->loadLanguage('common');
@@ -76,7 +78,7 @@
// Load only if module is installed
//if (is_object($helper->getModule())) {
// // Find if the user is admin of the module
-// $publisherIsAdmin = Newbb\Utility::userIsAdmin();
+// $publisherIsAdmin = Utility::userIsAdmin();
//}
//$db = \XoopsDatabaseFactory::getDatabaseConnection();
@@ -122,8 +124,8 @@
/** @var Newbb\XmlrssHandler $xmlrssHandler */
$xmlrssHandler = $helper->getHandler('Xmlrss');
-$pathIcon16 = Xmf\Module\Admin::iconUrl('', 16);
-$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32);
+$pathIcon16 = Admin::iconUrl('', 16);
+$pathIcon32 = Admin::iconUrl('', 32);
//$pathModIcon16 = $helper->getModule()->getInfo('modicons16');
//$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
diff --git a/include/config.php b/include/config.php
index f9d9c787..2b420ec4 100644
--- a/include/config.php
+++ b/include/config.php
@@ -8,6 +8,7 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
+
/**
* animal module for xoops
*
@@ -18,87 +19,93 @@
* @since 1.03
* @author XOOPS Development Team - ( https://xoops.org )
*/
+
+use Xmf\Module\Admin;
+
$moduleDirName = basename(dirname(__DIR__));
/**
* @return object
*/
-function getConfig()
-{
- $moduleDirName = basename(dirname(__DIR__));
- $moduleDirNameUpper = mb_strtoupper($moduleDirName);
- return (object)[
- 'name' => mb_strtoupper($moduleDirName) . ' Module Configurator',
- 'paths' => [
- 'dirname' => $moduleDirName,
- 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
- 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
- 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName,
- 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
- 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
- ],
- 'uploadFolders' => [
- XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
- XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs',
+$moduleDirName = basename(dirname(__DIR__));
+$moduleDirNameUpper = mb_strtoupper($moduleDirName);
+
+return (object)[
+ 'name' => $moduleDirNameUpper . ' Module Configurator',
+ 'paths' => [
+ 'dirname' => $moduleDirName,
+ 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
+ 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
+ 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName,
+ 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName,
+ ],
+ 'uploadFolders' => [
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs',
- //XOOPS_UPLOAD_PATH . '/flags'
- ],
- 'copyBlankFiles' => [
- XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
- XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs',
- //XOOPS_UPLOAD_PATH . '/flags'
- ],
+ //XOOPS_UPLOAD_PATH . '/flags'
+ ],
+ 'copyBlankFiles' => [
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName,
+ XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/thumbs',
+ //XOOPS_UPLOAD_PATH . '/flags'
+ ],
- 'copyTestFolders' => [
- //[
- // constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
- // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images',
- //]
- ],
+ 'copyTestFolders' => [
+ //[
+ // constant($moduleDirNameUpper . '_PATH') . '/testdata/images',
+ // XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/images',
+ //]
+ ],
- 'templateFolders' => [
- '/templates/',
- '/templates/blocks/',
- '/templates/admin/',
- ],
- 'oldFiles' => [
- '/class/request.php',
- '/class/registry.php',
- '/class/utilities.php',
- '/class/util.php',
- // '/include/constants.php',
- // '/include/functions.php',
- '/ajaxrating.txt',
- ],
- 'oldFolders' => [
- '/images',
- '/css',
- '/js',
- '/tcpdf',
- '/images',
- ],
- 'renameTables' => [
- 'bb_archive' => 'newbb_archive',
- 'bb_attachments' => 'newbb_attachments',
- 'bb_categories' => 'newbb_categories',
- 'bb_digest' => 'newbb_digest',
- 'bb_forums' => 'newbb_forums',
- 'bb_moderates' => 'newbb_moderates',
- 'bb_online' => 'newbb_online',
- 'bb_posts' => 'newbb_posts',
- 'bb_posts_text' => 'newbb_posts_text',
- 'bb_reads_forum' => 'newbb_reads_forum',
- 'bb_reads_topic' => 'newbb_reads_topic',
- 'bb_report' => 'newbb_report',
- 'bb_stats' => 'newbb_stats',
- 'bb_topics' => 'newbb_topics',
- 'bb_type' => 'newbb_type',
- 'bb_type_forum' => 'newbb_type_forum',
- 'bb_user_stats' => 'newbb_user_stats',
- 'bb_votedata' => 'newbb_votedata',
- ],
- 'modCopyright' => "
- ',
- ];
-}
+ 'templateFolders' => [
+ '/templates/',
+ '/templates/blocks/',
+ '/templates/admin/',
+ ],
+ 'oldFiles' => [
+ '/class/request.php',
+ '/class/registry.php',
+ '/class/utilities.php',
+ '/class/util.php',
+ // '/include/constants.php',
+ // '/include/functions.php',
+ '/ajaxrating.txt',
+ ],
+ 'oldFolders' => [
+ '/images',
+ '/css',
+ '/js',
+ '/tcpdf',
+ '/images',
+ ],
+ 'renameTables' => [
+ 'bb_archive' => 'newbb_archive',
+ 'bb_attachments' => 'newbb_attachments',
+ 'bb_categories' => 'newbb_categories',
+ 'bb_digest' => 'newbb_digest',
+ 'bb_forums' => 'newbb_forums',
+ 'bb_moderates' => 'newbb_moderates',
+ 'bb_online' => 'newbb_online',
+ 'bb_posts' => 'newbb_posts',
+ 'bb_posts_text' => 'newbb_posts_text',
+ 'bb_reads_forum' => 'newbb_reads_forum',
+ 'bb_reads_topic' => 'newbb_reads_topic',
+ 'bb_report' => 'newbb_report',
+ 'bb_stats' => 'newbb_stats',
+ 'bb_topics' => 'newbb_topics',
+ 'bb_type' => 'newbb_type',
+ 'bb_type_forum' => 'newbb_type_forum',
+ 'bb_user_stats' => 'newbb_user_stats',
+ 'bb_votedata' => 'newbb_votedata',
+ ],
+ 'moduleStats' => [
+ // 'totalcategories' => $helper->getHandler('Category')->getCategoriesCount(-1),
+ // 'totalitems' => $helper->getHandler('Item')->getItemsCount(),
+ // 'totalsubmitted' => $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]),
+ ],
+ 'modCopyright' => "
+ ",
+];
diff --git a/include/display.php b/include/display.php
index 9b00a07a..a0350caf 100644
--- a/include/display.php
+++ b/include/display.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.) , irmtfan
* @since 4.3
* @package module::newbb
diff --git a/include/form.forum.php b/include/form.forum.php
index a02acb30..4379bb92 100644
--- a/include/form.forum.php
+++ b/include/form.forum.php
@@ -10,15 +10,15 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
*/
-use XoopsModules\Newbb;
-
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+use XoopsModules\Newbb\{
+ Tree
+};
if (!is_object($forumObject)) {
xoops_error('forum object IS null');
@@ -30,7 +30,7 @@
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
// The forum instanciation
-$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM . ' ' . $forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('PHP_SELF'));
+$form_forum = new \XoopsThemeForm(_AM_NEWBB_EDITTHISFORUM . ' ' . $forumObject->getVar('forum_name'), 'form_forum', xoops_getenv('SCRIPT_NAME'));
// Forum name
$form_forum->addElement(new \XoopsFormText(_AM_NEWBB_FORUMNAME, 'forum_name', 50, 80, $forumObject->getVar('forum_name', 'E')), true);
@@ -43,7 +43,7 @@
// Parent forums
ob_start();
-$mytree = new Newbb\Tree($GLOBALS['xoopsDB']->prefix('newbb_forums'), 'forum_id', 'parent_forum');
+$mytree = new Tree($GLOBALS['xoopsDB']->prefix('newbb_forums'), 'forum_id', 'parent_forum');
$mytree->makeMySelBox('forum_name', 'parent_forum', $forumObject->getVar('parent_forum'), 1, 'parent_forum');
$form_forum->addElement(new \XoopsFormLabel(_AM_NEWBB_MAKE_SUBFORUM_OF, ob_get_contents()));
ob_end_clean();
diff --git a/include/form.post.php b/include/form.post.php
index 3cbfa9bf..f3019cb4 100644
--- a/include/form.post.php
+++ b/include/form.post.php
@@ -10,22 +10,26 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
*/
use Xmf\Request;
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper,
+ ModerateHandler
+};
+use XoopsModules\Tag\FormTag;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
+/** @var ModerateHandler $moderateHandler */
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
$xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)));
-$categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+$categoryHandler = Helper::getInstance()->getHandler('Category');
$categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']);
//check banning
@@ -33,8 +37,7 @@
&& $GLOBALS['xoopsUser']->uid() > 0) ? $GLOBALS['xoopsUser']->uid() : 0;
$moderated_ip = Request::getString('REMOTE_ADDR', '', 'SERVER');
$moderated_forum = $forumObject->getVar('forum_id');
-/** @var Newbb\ModerateHandler $moderateHandler */
-$moderateHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate');
+$moderateHandler = Helper::getInstance()->getHandler('Moderate');
if (!$moderateHandler->verifyUser($moderated_id, '', $moderated_forum)) {
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('uid', $moderated_id, '='));
@@ -50,10 +53,12 @@
$xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]);
$xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject));
-$xoopsTpl->assign([
- 'forum_id' => $forumObject->getVar('forum_id'),
- 'forum_name' => $forumObject->getVar('forum_name'),
- ]);
+$xoopsTpl->assign(
+ [
+ 'forum_id' => $forumObject->getVar('forum_id'),
+ 'forum_name' => $forumObject->getVar('forum_name'),
+ ]
+);
if (!is_object($topicObject)) {
$topicObject = $topicHandler->create();
@@ -73,30 +78,34 @@
}
$xoopsTpl->assign('form_title', $form_title);
-foreach ([
- 'start',
- 'topic_id',
- 'post_id',
- 'pid',
- 'isreply',
- 'isedit',
- 'contents_preview',
- ] as $getint) {
+foreach (
+ [
+ 'start',
+ 'topic_id',
+ 'post_id',
+ 'pid',
+ 'isreply',
+ 'isedit',
+ 'contents_preview',
+ ] as $getint
+) {
${$getint} = Request::getInt($getint, (!empty(${$getint}) ? ${$getint} : 0), 'GET'); // isset($_GET[$getint]) ? (int)($_GET[$getint]) : ((!empty(${$getint})) ? ${$getint} : 0);
}
-foreach ([
- 'order',
- 'viewmode',
- 'hidden',
- 'newbb_form',
- 'icon',
- 'op',
- ] as $getstr) {
+foreach (
+ [
+ 'order',
+ 'viewmode',
+ 'hidden',
+ 'newbb_form',
+ 'icon',
+ 'op',
+ ] as $getstr
+) {
${$getstr} = Request::getString($getstr, (!empty(${$getstr}) ? ${$getstr} : ''), 'GET'); //isset($_GET[$getstr]) ? $_GET[$getstr] : ((!empty(${$getstr})) ? ${$getstr} : '');
}
/** @var Newbb\TopicHandler $topicHandler */
-$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+$topicHandler = Helper::getInstance()->getHandler('Topic');
$topic_status = $topicHandler->get(@$topic_id, 'topic_status');
//$filname = XOOPS_URL.$_SERVER['REQUEST_URI'];
@@ -115,7 +124,7 @@
|| $uid == $topicHandler->get(@$topic_id, 'topic_poster')))) {
$type_id = $topicHandler->get(@$topic_id, 'type_id');
/** @var Newbb\TypeHandler $typeHandler */
- $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
+ $typeHandler = Helper::getInstance()->getHandler('Type');
$types = $typeHandler->getByForum($forumObject->getVar('forum_id'));
if (!empty($types)) {
$type_element = new \XoopsFormSelect(_MD_NEWBB_TYPE, 'type_id', $type_id);
@@ -180,12 +189,12 @@
if (!empty($GLOBALS['xoopsModuleConfig']['do_tag']) && (empty($postObject) || $postObject->isTopic())) {
$topic_tags = '';
if (Request::getString('topic_tags', '', 'POST')) {
- $topic_tags = $myts->htmlSpecialChars(Request::getString('topic_tags', '', 'POST'));
+ $topic_tags = htmlspecialchars(Request::getString('topic_tags', '', 'POST'));
} elseif (!empty($topic_id)) {
$topic_tags = $topicHandler->get($topic_id, 'topic_tags');
}
- if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')) {
- $forum_form->addElement(new \XoopsModules\Tag\FormTag('topic_tags', 60, 255, $topic_tags));
+ if (!empty($newbbConfig['do_tag']) && class_exists('TagFormTag')) {
+ $forum_form->addElement(new FormTag('topic_tags', 60, 255, $topic_tags));
}
}
@@ -289,7 +298,7 @@
$radiobox->addOption('require_reply', _MD_NEWBB_REQUIRE_REPLY);
}
if ($GLOBALS['xoopsModuleConfig']['enable_karma']) {
- $karmas = array_map('trim', explode(',', $GLOBALS['xoopsModuleConfig']['karma_options']));
+ $karmas = array_map('\trim', explode(',', $GLOBALS['xoopsModuleConfig']['karma_options']));
if (count($karmas) > 1) {
foreach ($karmas as $karma) {
$karma_array[(string)$karma] = (int)$karma;
diff --git a/include/functions.config.php b/include/functions.config.php
index 90d81cb4..92fa7e77 100644
--- a/include/functions.config.php
+++ b/include/functions.config.php
@@ -3,15 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+use XoopsModules\Newbb\{Helper
+};
-use XoopsModules\Newbb;
+/** @var Helper $helper */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_CONFIG_LOADED', true);
@@ -30,8 +31,7 @@ function newbbLoadConfig()
// require_once dirname(__DIR__) . '/class/Helper.php';
//$helper = NewBB::getInstance();
- /** @var \XoopsModules\Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
static $configs = null;
if (null !== $configs) {
diff --git a/include/functions.forum.php b/include/functions.forum.php
index efbafb07..138421c0 100644
--- a/include/functions.forum.php
+++ b/include/functions.forum.php
@@ -3,15 +3,18 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use Xmf\Module\Helper\Cache;
+use XoopsModules\Newbb\{Helper,
+ ObjectTree
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_FORUM_LOADED', true);
@@ -20,20 +23,20 @@
define('NEWBB_FUNCTIONS_FORUM', 1);
/**
- * @param null|array $value selected forum id
- * @param string $permission permission (access, all, etc.)
- * @param bool $categoryDelimiter show delimiter between categories
- * @param bool $see
+ * @param null|array $value selected forum id
+ * @param string $permission permission (access, all, etc.)
+ * @param bool $categoryDelimiter show delimiter between categories
+ * @param bool $see
* @return string
*/
function newbbForumSelectBox($value = null, $permission = 'access', $categoryDelimiter = true, $see = false)
{
global $xoopsUser;
/** @var Newbb\CategoryHandler $categoryHandler */
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
$categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$groups = [XOOPS_GROUP_ANONYMOUS];
if (is_object($xoopsUser)) {
@@ -41,17 +44,21 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel
}
sort($groups);
$groupKey = 'forumselect_' . $permission . '_' . md5(implode(',', $groups));
- $forums = $cacheHelper->cacheRead($groupKey, function () use ($categories, $permission) {
- /** @var Newbb\CategoryHandler $categoryHandler */
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
- $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
-
- /** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
- $forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
-
- return $forums;
- }, 300);
+ $forums = $cacheHelper->cacheRead(
+ $groupKey,
+ static function () use ($categories, $permission) {
+ /** @var Newbb\CategoryHandler $categoryHandler */
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
+ $categories = $categoryHandler->getByPermission($permission, ['cat_id', 'cat_order', 'cat_title'], false);
+
+ /** @var Newbb\ForumHandler $forumHandler */
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
+ $forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
+
+ return $forums;
+ },
+ 300
+ );
$value = is_array($value) ? $value : [$value];
//$see = is_array($see) ? $see : array($see);
@@ -81,7 +88,7 @@ function newbbForumSelectBox($value = null, $permission = 'access', $categoryDel
}
/**
- * @param int $forum_id
+ * @param int $forum_id
* @return string
*/
function newbbMakeJumpbox($forum_id = 0)
@@ -91,7 +98,7 @@ function newbbMakeJumpbox($forum_id = 0)
$box .= '-- ' . _MD_NEWBB_SELFORUM . ' -- ';
$box .= newbbForumSelectBox($forum_id);
$box .= " ";
- unset($forums, $categories);
+// unset($forums, $categories);
return $box;
}
@@ -104,15 +111,15 @@ function newbbMakeJumpbox($forum_id = 0)
*
* @int integer $pid parent forum ID
*
- * @param int $pid
- * @param bool $refresh
+ * @param int $pid
+ * @param bool $refresh
* @return array
*/
function newbbGetSubForum($pid = 0, $refresh = false)
{
static $list;
if (null === $list) {
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$list = $cacheHelper->read('forum_sub');
}
@@ -133,13 +140,13 @@ function newbbCreateSubForumList()
{
/** @var Newbb\ForumHandler $forumHandler */
// $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$criteria = new \CriteriaCompo(null, 1);
$criteria->setSort('cat_id ASC, parent_forum ASC, forum_order');
$criteria->setOrder('ASC');
$forumsObject = $forumHandler->getObjects($criteria);
// require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php');
- $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
+ $tree = new ObjectTree($forumsObject, 'forum_id', 'parent_forum');
$forum_array = [];
foreach (array_keys($forumsObject) as $key) {
if (!$child = array_keys($tree->getAllChild($forumsObject[$key]->getVar('forum_id')))) {
@@ -149,15 +156,15 @@ function newbbCreateSubForumList()
}
unset($forumsObject, $tree, $criteria);
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$cacheHelper->write('forum_sub', $forum_array);
return $forum_array;
}
/**
- * @param int $forum_id
- * @param bool $refresh
+ * @param int $forum_id
+ * @param bool $refresh
* @return array|mixed|null
*/
function newbbGetParentForum($forum_id = 0, $refresh = false)
@@ -165,7 +172,7 @@ function newbbGetParentForum($forum_id = 0, $refresh = false)
static $list = null;
if (null === $list) {
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$list = $cacheHelper->read('forum_parent');
}
if (!is_array($list) || $refresh) {
@@ -184,13 +191,13 @@ function newbbGetParentForum($forum_id = 0, $refresh = false)
function newbbCreateParentForumList()
{
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$criteria = new \Criteria('forum_id');
$criteria->setSort('parent_forum');
$criteria->setOrder('ASC');
$forumsObject = $forumHandler->getObjects($criteria);
// require_once $GLOBALS['xoops']->path('modules/newbb/class/Tree.php');
- $tree = new Newbb\ObjectTree($forumsObject, 'forum_id', 'parent_forum');
+ $tree = new ObjectTree($forumsObject, 'forum_id', 'parent_forum');
$forum_array = [];
foreach (array_keys($forumsObject) as $key) {
$parent_forum = $forumsObject[$key]->getVar('parent_forum');
@@ -206,7 +213,7 @@ function newbbCreateParentForumList()
}
unset($forumsObject, $tree, $criteria);
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$cacheHelper->write('forum_parent', $forum_array);
return $forum_array;
diff --git a/include/functions.image.php b/include/functions.image.php
index bcbdffba..00fe447b 100644
--- a/include/functions.image.php
+++ b/include/functions.image.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -47,9 +47,12 @@ function newbbAttachmentImage($source)
$image = $img_path . '/' . $source;
$thumb_url = $thumb_url . '/' . $source;
$image_url = $img_url . '/' . $source;
+ $img_info = '';
$imginfo = @getimagesize($image);
- $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : '';
+ if (is_array($image)) {
+ $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : '';
+ }
if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0
&& $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) {
diff --git a/include/functions.ini.php b/include/functions.ini.php
index 9ffa4a54..f342e2f7 100644
--- a/include/functions.ini.php
+++ b/include/functions.ini.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -28,7 +28,6 @@
// URL: https://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
if (defined('NEWBB_FUNCTIONS_INI')) {
return;
diff --git a/include/functions.language.php b/include/functions.language.php
index 5c3b0d2a..8f88b918 100644
--- a/include/functions.language.php
+++ b/include/functions.language.php
@@ -3,14 +3,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_LANGUAGE_LOADED', true);
@@ -19,7 +17,7 @@
/**
* @param $page
- * @param string $dirname
+ * @param string $dirname
* @return bool
*/
function newbbLoadLanguage($page, $dirname = 'newbb')
diff --git a/include/functions.php b/include/functions.php
index 6f85b6ad..af7e5524 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -3,14 +3,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_LOADED', true);
diff --git a/include/functions.read.php b/include/functions.read.php
index 8a8d24a7..4dd4ce35 100644
--- a/include/functions.read.php
+++ b/include/functions.read.php
@@ -3,15 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_READ_LOADED', true);
@@ -23,13 +24,13 @@
* @param $type
* @param $item_id
* @param $post_id
- * @param null $uid
+ * @param null $uid
* @return mixed
*/
function newbbSetRead($type, $item_id, $post_id, $uid = null)
{
/** @var Newbb\ReadHandler $readHandler */
- $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type);
+ $readHandler = Helper::getInstance()->getHandler('Read' . $type);
return $readHandler->setRead($item_id, $post_id, $uid);
}
@@ -37,40 +38,40 @@ function newbbSetRead($type, $item_id, $post_id, $uid = null)
/**
* @param $type
* @param $item_id
- * @param null $uid
+ * @param null $uid
* @return mixed
*/
function newbbGetRead($type, $item_id, $uid = null)
{
/** @var Newbb\ReadHandler $readHandler */
- $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type);
+ $readHandler = Helper::getInstance()->getHandler('Read' . $type);
return $readHandler->getRead($item_id, $uid);
}
/**
- * @param int $status
- * @param null $uid
+ * @param int $status
+ * @param null $uid
* @return mixed
*/
function newbbSetReadforum($status = 0, $uid = null)
{
/** @var Newbb\ReadforumHandler $readHandler */
- $ReadforumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Readforum');
+ $ReadforumHandler = Helper::getInstance()->getHandler('Readforum');
return $ReadforumHandler->setReadItems($status, $uid);
}
/**
- * @param int $status
- * @param int $forum_id
- * @param null $uid
+ * @param int $status
+ * @param int $forum_id
+ * @param null $uid
* @return mixed
*/
function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null)
{
/** @var Newbb\ReadtopicHandler $readHandler */
- $readTopicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Readtopic');
+ $readTopicHandler = Helper::getInstance()->getHandler('Readtopic');
return $readTopicHandler->setReadItems($status, $forum_id, $uid);
}
@@ -78,13 +79,13 @@ function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null)
/**
* @param $type
* @param $items
- * @param null $uid
+ * @param null $uid
* @return mixed
*/
- function newbbIsRead($type, &$items, $uid = null)
+ function newbbIsRead($type, $items, $uid = null)
{
/** @var Newbb\ReadHandler $readHandler */
- $readHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Read' . $type);
+ $readHandler = Helper::getInstance()->getHandler('Read' . $type);
return $readHandler->isReadItems($items, $uid);
}
diff --git a/include/functions.recon.php b/include/functions.recon.php
index 9c92b620..1ac8dba9 100644
--- a/include/functions.recon.php
+++ b/include/functions.recon.php
@@ -3,15 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_RECON_LOADED', true);
@@ -20,7 +21,7 @@
define('NEWBB_FUNCTIONS_RECON', 1);
/**
- * @param null $type
+ * @param null $type
* @return bool
*/
function newbbSynchronization($type = null)
@@ -40,7 +41,8 @@ function newbbSynchronization($type = null)
$type = [];
$type = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]);
foreach ($type as $item) {
- $handler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($item);
+ /** @var \XoopsPersistableObjectHandler $handler */
+ $handler = Helper::getInstance()->getHandler($item);
if ('stats' !== $item) {
$handler->synchronization();
} else {
diff --git a/include/functions.render.php b/include/functions.render.php
index 002c7b2e..65be18d0 100644
--- a/include/functions.render.php
+++ b/include/functions.render.php
@@ -3,15 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{IconHandler
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var IconHandler $iconHandler */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_RENDER_LOADED', true);
@@ -26,18 +27,18 @@
* @param $text
* @return mixed
*/
- function newbbHtmlspecialchars(&$text)
+ function newbbHtmlspecialchars($text)
{
return preg_replace(['/&/i', '/ /i'], ['&', ' '], htmlspecialchars($text, ENT_QUOTES | ENT_HTML5));
}
/**
* @param $text
- * @param int $html
- * @param int $smiley
- * @param int $xcode
- * @param int $image
- * @param int $br
+ * @param int $html
+ * @param int $smiley
+ * @param int $xcode
+ * @param int $image
+ * @param int $br
* @return mixed
*/
function &newbbDisplayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
@@ -88,9 +89,9 @@ function newbbHtml2text($document)
*
* @param $link
* @param $button
- * @param string $alt alt message
- * @param bool $asImage true for image mode; false for text mode
- * @param string $extra extra attribute for the button
+ * @param string $alt alt message
+ * @param bool $asImage true for image mode; false for text mode
+ * @param string $extra extra attribute for the button
* @return mixed
* @internal param string $image image/button name, without extension
*/
@@ -107,10 +108,10 @@ function newbbGetButton($link, $button, $alt = '', $asImage = true, $extra = "cl
/**
* Display forrum images
*
- * @param string $image image name, without extension
- * @param string $alt alt message
- * @param bool $display true for return image anchor; faulse for assign to $xoopsTpl
- * @param string $extra extra attribute for the image
+ * @param string $image image name, without extension
+ * @param string $alt alt message
+ * @param bool $display true for return image anchor; faulse for assign to $xoopsTpl
+ * @param string $extra extra attribute for the image
* @return mixed
*/
function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class='forum_icon'")
@@ -138,7 +139,7 @@ function newbbDisplayImage($image, $alt = '', $display = true, $extra = "class='
}
/**
- * @return Newbb\IconHandler
+ * @return IconHandler
*/
function newbbGetIconHandler()
{
@@ -153,7 +154,7 @@ function newbbGetIconHandler()
// require_once dirname(__DIR__) . '/class/icon.php';
// }
- $iconHandler = Newbb\IconHandler::getInstance();
+ $iconHandler = IconHandler::getInstance();
$iconHandler->template = $xoTheme->template;
$iconHandler->init($GLOBALS['xoopsConfig']['language']);
diff --git a/include/functions.rpc.php b/include/functions.rpc.php
index 9efa89d9..59b5d634 100644
--- a/include/functions.rpc.php
+++ b/include/functions.rpc.php
@@ -3,14 +3,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_RPC_LOADED', true);
diff --git a/include/functions.session.php b/include/functions.session.php
index bead0e3a..9df4f736 100644
--- a/include/functions.session.php
+++ b/include/functions.session.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
@@ -11,8 +11,6 @@
use Xmf\Request;
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_SESSION_LOADED', true);
@@ -43,7 +41,7 @@ function newbbSetSession($name, $string = '')
/**
* @param $name
- * @param bool $isArray
+ * @param bool $isArray
* @return array|bool
*/
function newbbGetSession($name, $isArray = false)
@@ -85,7 +83,7 @@ function newbbSetCookie($name, $string = '', $expire = 0)
/**
* @param $name
- * @param bool $isArray
+ * @param bool $isArray
* @return array|null|string
*/
function newbbGetCookie($name, $isArray = false)
diff --git a/include/functions.stats.php b/include/functions.stats.php
index 0975a64f..940b48fe 100644
--- a/include/functions.stats.php
+++ b/include/functions.stats.php
@@ -3,15 +3,21 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper,
+ PostHandler,
+ StatsHandler,
+ TopicHandler
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
+/** @var TopicHandler $topicHandler */
+/** @var PostHandler $postHandler */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_STATS_LOADED', true);
@@ -24,8 +30,8 @@
*/
function newbbGetStats()
{
- /** @var Newbb\StatsHandler $statsHandler */
- $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats');
+ /** @var StatsHandler $statsHandler */
+ $statsHandler = Helper::getInstance()->getHandler('Stats');
$stats = $statsHandler->getStats();
return $stats;
@@ -34,13 +40,13 @@ function newbbGetStats()
/**
* @param $id
* @param $type
- * @param int $increment
+ * @param int $increment
* @return mixed
*/
function newbbUpdateStats($id, $type, $increment = 1)
{
- /** @var Newbb\StatsHandler $statsHandler */
- $statsHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Stats');
+ /** @var StatsHandler $statsHandler */
+ $statsHandler = Helper::getInstance()->getHandler('Stats');
return $statsHandler->update($id, $type, $increment);
}
@@ -49,13 +55,12 @@ function newbbUpdateStats($id, $type, $increment = 1)
* Gets the total number of topics in a form
*/
/**
- * @param string $forum_id
+ * @param string $forum_id
* @return mixed
*/
function getTotalTopics($forum_id = '')
{
- /** @var Newbb\TopicHandler $topicHandler */
- $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
+ $topicHandler = Helper::getInstance()->getHandler('Topic');
$criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>'));
if ($forum_id) {
$criteria->add(new \Criteria('forum_id', (int)$forum_id));
@@ -69,14 +74,13 @@ function getTotalTopics($forum_id = '')
* Also can return the number of users on the system.
*/
/**
- * @param int $id
- * @param string $type
+ * @param int $id
+ * @param string $type
* @return mixed
*/
function getTotalPosts($id = 0, $type = 'all')
{
- /** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$criteria = new \CriteriaCompo(new \Criteria('approved', 0, '>'));
switch ($type) {
case 'forum':
@@ -106,7 +110,7 @@ function getTotalViews()
if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
return null;
}
- list($total) = $GLOBALS['xoopsDB']->fetchRow($result);
+ [$total] = $GLOBALS['xoopsDB']->fetchRow($result);
return $total;
}
diff --git a/include/functions.text.php b/include/functions.text.php
index deb71d8c..09dd4703 100644
--- a/include/functions.text.php
+++ b/include/functions.text.php
@@ -2,15 +2,13 @@
/**
* NewBB 4.3x, the forum module for XOOPS project
*
- * @copyright XOOPS Project (http://xoops.org)
+ * @copyright XOOPS Project (https://xoops.org)
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.) , irmtfan
* @since 4.3
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
-
define('NEWBB_FUNCTIONS_TEXT_LOADED', true);
if (!defined('NEWBB_FUNCTIONS_TEXT')) {
@@ -18,15 +16,15 @@
/**
* function for select from a text where it have some keywords
*
- * @param text $text , array text $queryarray, int $selectlength = 200, int $selectstartlag = 100, int $highlight = true
- * @param $queryarray
- * @param int $selectstartlag
- * @param int $selectlength
- * @param bool $striptags
- * @param string $excludetags
- * @param string $start_trimmarker
- * @param string $end_trimmarker
- * @return text $select_text
+ * @param string $text
+ * @param array|string $queryarray
+ * @param int $selectstartlag
+ * @param int $selectlength
+ * @param bool $striptags
+ * @param string $excludetags
+ * @param string $start_trimmarker
+ * @param string $end_trimmarker
+ * @return string $select_text
*/
function newbb_selectText(
@@ -42,8 +40,8 @@ function newbb_selectText(
$sanitized_text = $striptags ? strip_tags($text, $excludetags) : $text;
$queryarray = newbb_str2array($queryarray);
$text_i = strtolower($sanitized_text);
- $queryarray = array_map('strtolower', $queryarray);
- $lengtharray = array_map('strlen', $queryarray);
+ $queryarray = array_map('\strtolower', $queryarray);
+ $lengtharray = array_map('\strlen', $queryarray);
$maxlengthquery = max($lengtharray);
$lengthend_trimmarker = strlen($end_trimmarker);
$select_text = '';
@@ -59,12 +57,12 @@ function newbb_selectText(
if ($pos == $endpos) {
break;
}
- $start = max($pos - $selectstartlag, $startpos - $maxlengthquery, 0); // $startpos is the last position in the previous select text
- $length = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200;
+ $start = max($pos - $selectstartlag, $startpos - $maxlengthquery, 0); // $startpos is the last position in the previous select text
+ $length = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200;
$select_text .= '';
$select_text .= ($start > 0) ? $start_trimmarker . ' ' : ' ';
$select_text .= xoops_substr($sanitized_text, $start, $length + $lengthend_trimmarker + 1, ' ' . $end_trimmarker) . '
';
- $startpos = $start + $length + 1; // start searching from next position.
+ $startpos = $start + $length + 1; // start searching from next position.
}
if (empty($select_text)) {
return '';
@@ -75,9 +73,9 @@ function newbb_selectText(
/**
* function for highlight a text when it have some keywords
*
- * @param text $text , array text $queryarray
- * @param $queryarray
- * @return text $highlight_text
+ * @param string $text
+ * @param array|string $queryarray
+ * @return string $highlight_text
*/
function newbb_highlightText($text, $queryarray)
@@ -90,7 +88,7 @@ function newbb_highlightText($text, $queryarray)
$highlight_text = $text;
foreach ($queryarray as $key => $query) {
// use preg_replace instead of str_replace to exclude all $queries inside html span tag
- $highlight_text = preg_replace("/(?!(?:[^<]+>|[^>]+<\/a>))(" . preg_quote($query) . ')/si', newbb_highlighter($query, $key), $highlight_text);
+ $highlight_text = preg_replace("/(?!(?:[^<]+>|[^>]+<\/a>))(" . preg_quote($query, '/') . ')/si', newbb_highlighter($query, $key), $highlight_text);
}
return $highlight_text;
@@ -99,8 +97,8 @@ function newbb_highlightText($text, $queryarray)
/**
* function for highlighting search results
*
- * @param text $query , int $i
- * @param $i
+ * @param string $query
+ * @param int $i
* @return mixed
*/
function newbb_highlighter($query, $i)
@@ -111,7 +109,7 @@ function newbb_highlighter($query, $i)
/**
* function for convert string to array
*
- * @param text /array $str
+ * @param string|array $str
* @return mixed
*/
diff --git a/include/functions.time.php b/include/functions.time.php
index 99bc37c4..2aed10c8 100644
--- a/include/functions.time.php
+++ b/include/functions.time.php
@@ -3,14 +3,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_TIME_LOADED', true);
@@ -20,8 +18,8 @@
/**
* Function to convert UNIX time to formatted time string
* @param $time
- * @param string $format
- * @param string $timeoffset
+ * @param string $format
+ * @param string $timeoffset
* @return string
*/
function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '')
@@ -41,7 +39,7 @@ function newbbFormatTimestamp($time, $format = 'c', $timeoffset = '')
}
/**
- * @param int $selected
+ * @param int $selected
* @return string
*/
function newbbSinceSelectBox($selected = 100)
@@ -104,7 +102,7 @@ function newbbSinceSelectBox($selected = 100)
}
/**
- * @param int $since
+ * @param int $since
* @return int
*/
function newbbGetSinceTime($since = 100)
diff --git a/include/functions.topic.php b/include/functions.topic.php
index ded5c4d9..f25751e3 100644
--- a/include/functions.topic.php
+++ b/include/functions.topic.php
@@ -3,14 +3,12 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_TOPIC_LOADED', true);
@@ -22,8 +20,8 @@
*
* the title is composed of [type_name] if type_id is greater than 0 plus topic Title
* @param $topicTitle
- * @param null $prefixName
- * @param null $prefixColor
+ * @param null $prefixName
+ * @param null $prefixColor
* @return string
*/
function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null)
@@ -33,8 +31,8 @@ function newbbGetTopicTitle($topicTitle, $prefixName = null, $prefixColor = null
/**
* @param $topicTitle
- * @param null $prefixName
- * @param null $prefixColor
+ * @param null $prefixName
+ * @param null $prefixColor
* @return string
*/
function getTopicTitle($topicTitle, $prefixName = null, $prefixColor = null)
diff --git a/include/functions.user.php b/include/functions.user.php
index 2069a8c4..1273c28a 100644
--- a/include/functions.user.php
+++ b/include/functions.user.php
@@ -10,21 +10,23 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper,
+ Forum
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
/**
* Function to a list of user names associated with their user IDs
- * @param $uid
- * @param int $usereal
- * @param bool $linked
+ * @param int $uid
+ * @param int $usereal
+ * @param bool $linked
* @return array
*/
function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false)
@@ -36,9 +38,9 @@ function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false)
}
/**
- * @param $uid
- * @param int $usereal
- * @param bool $linked
+ * @param int $uid
+ * @param int $usereal
+ * @param bool $linked
* @return string
*/
function newbbGetUnameFromId($uid, $usereal = 0, $linked = false)
@@ -51,8 +53,8 @@ function newbbGetUnameFromId($uid, $usereal = 0, $linked = false)
/**
* Function to check if a user is an administrator of the module
*
- * @param int|string|array|\XoopsUser $user
- * @param int $mid
+ * @param int|string|array|\XoopsUser $user
+ * @param int $mid
* @return bool
*/
function newbbIsAdministrator($user = -1, $mid = 0)
@@ -98,7 +100,7 @@ function newbbIsAdministrator($user = -1, $mid = 0)
* Function to check if a user is a moderator of a forum
*
* @param $forum
- * @param int|array |string|\XoopsUser $user
+ * @param int|array |string|\XoopsUser $user
* @return bool
*/
function newbbIsModerator(&$forum, $user = -1)
@@ -108,7 +110,7 @@ function newbbIsModerator(&$forum, $user = -1)
if (0 == $forum_id) {
return false;
}
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forum = $forumHandler->get($forum_id);
}
@@ -126,7 +128,7 @@ function newbbIsModerator(&$forum, $user = -1)
/**
* Function to check if a user has moderation permission over a forum
*
- * @param Newbb\Forum|int $forum
+ * @param Forum|int $forum
* @return bool
*/
function newbbIsAdmin($forum = 0)
@@ -149,7 +151,7 @@ function newbbIsAdmin($forum = 0)
$cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum;
if (!isset($_cachedModerators[$cache_id])) {
if (!is_object($forum)) {
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forum = $forumHandler->get((int)$forum);
}
$_cachedModerators[$cache_id] = $forum->getVar('forum_moderator');
@@ -160,7 +162,7 @@ function newbbIsAdmin($forum = 0)
/* use hardcoded DB query to save queries */
/**
- * @param array $uid
+ * @param array $uid
* @return array
*/
function newbbIsModuleAdministrators(array $uid = [])
@@ -190,14 +192,15 @@ function newbbIsModuleAdministrators(array $uid = [])
. $xoopsGroupPermTable
. ' AS p ON p.gperm_groupid=l.groupid'
. ' WHERE l.uid IN ('
- . implode(', ', array_map('intval', $uid))
+ . implode(', ', array_map('\intval', $uid))
. ')'
. " AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '"
. (int)$mid
. "'"
. ' GROUP BY l.uid';
- if ($result = $GLOBALS['xoopsDB']->query($sql)) {
+ $result = $GLOBALS['xoopsDB']->query($sql);
+ if ($result) {
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
if (!empty($myrow['count'])) {
$module_administrators[] = $myrow['uid'];
@@ -210,8 +213,8 @@ function newbbIsModuleAdministrators(array $uid = [])
/* use hardcoded DB query to save queries */
/**
- * @param array $uid
- * @param int $mid
+ * @param array $uid
+ * @param int $mid
* @return array
*/
function newbbIsForumModerators(array $uid = [], $mid = 0)
@@ -222,8 +225,9 @@ function newbbIsForumModerators(array $uid = [], $mid = 0)
return $forum_moderators;
}
- $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums');
- if ($result = $GLOBALS['xoopsDB']->query($sql)) {
+ $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums');
+ $result = $GLOBALS['xoopsDB']->query($sql);
+ if ($result) {
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
if (empty($myrow['forum_moderator'])) {
continue;
diff --git a/include/functions.welcome.inc.php b/include/functions.welcome.inc.php
index 8078cd76..48a3c15f 100644
--- a/include/functions.welcome.inc.php
+++ b/include/functions.welcome.inc.php
@@ -3,13 +3,17 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use Xmf\IPAddress;
+use XoopsModules\Newbb\{Helper
+};
+
+/** @var Helper $helper */
global $xoopsModule, $myts, $xoopsUser, $forumObject;
@@ -19,9 +23,9 @@
}
$forum_id = $forumObject->getVar('forum_id');
-$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+$postHandler = Helper::getInstance()->getHandler('Post');
$postObject = $postHandler->create();
-$postObject->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable());
+$postObject->setVar('poster_ip', IPAddress::fromRequest()->asReadable());
$postObject->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid'));
$postObject->setVar('approved', 1);
$postObject->setVar('forum_id', $forum_id);
@@ -40,7 +44,10 @@
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
-if ($mod = @$moduleHandler->getByDirname('profile', true)) {
+
+$mod = @$moduleHandler->getByDirname('profile', true);
+if ($mod) {
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
$groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS];
@@ -48,19 +55,23 @@
$mod->loadLanguage();
}
/** var Newbb\PermissionHandler $permHandler */
- $permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission');
+ $permHandler = Helper::getInstance()->getHandler('Permission');
$show_ids = $permHandler->getItemIds('profile_show', $groups, $mod->getVar('mid'));
$visible_ids = $permHandler->getItemIds('profile_visible', $groups, $mod->getVar('mid'));
unset($mod);
$fieldids = array_intersect($show_ids, $visible_ids);
+
/** @var \ProfileProfileHandler $profileHandler */
- $profileHandler = $helper->getHandler('Profile', 'profile');
+ // $profileHandler = $helper->getHandler('Profile', 'profile');
+ $profileHandler = xoops_getModuleHandler('profile', 'profile');
$fields = $profileHandler->loadFields();
/** @var \ProfileCategoryHandler $catHandler */
- $catHandler = $helper->getHandler('Category', 'profile');
+ // $catHandler = $helper->getHandler('Category', 'profile');
+ $catHandler = xoops_getModuleHandler('category', 'profile');
$categories = $catHandler->getObjects(null, true, false);
/** @var \ProfileFieldHandler $fieldcatHandler */
- $fieldcatHandler = $helper->getHandler('Field', 'profile');
+ // $fieldcatHandler = $helper->getHandler('Field', 'profile');
+ $fieldcatHandler = xoops_getModuleHandler('field', 'profile');
$fieldcats = $fieldcatHandler->getObjects(null, true, false);
// Add core fields
diff --git a/include/functions.welcome.php b/include/functions.welcome.php
index 9b4ba4f8..1d2fa7fb 100644
--- a/include/functions.welcome.php
+++ b/include/functions.welcome.php
@@ -3,15 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+/** @var Helper $helper */
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
define('NEWBB_FUNCTIONS_WELCOME_LOADED', true);
@@ -32,7 +33,7 @@ function newbbWelcome()
return false;
}
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forumObject = $forumHandler->get($forumId);
if (!$forumObject || !$forumHandler->getPermission($forumObject)) {
unset($forumObject);
diff --git a/include/images.php b/include/images.php
index 0ba25f2f..3d5960a8 100644
--- a/include/images.php
+++ b/include/images.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
diff --git a/include/index.html b/include/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/include/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/include/index.php b/include/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/include/index.php
@@ -0,0 +1,3 @@
+ //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -28,9 +28,13 @@
// URL: https://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
-use XoopsModules\Newbb;
+use Xmf\IPAddress;
+use Xmf\Module\Helper\Cache;
+use XoopsModules\Newbb\{Common\Configurator,
+ Common\Migrate,
+ Helper
+};
if (defined('XOOPS_MODULE_NEWBB_FUCTIONS')) {
exit();
@@ -40,13 +44,13 @@
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
- * @param XoopsModule $module
- * @param null $oldversion
+ * @param XoopsModule $module
+ * @param null $oldversion
* @return bool
*/
function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null)
{
- $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
+ $cacheHelper = new Cache('newbb');
$cacheHelper->delete('config');
$newbbConfig = newbbLoadConfig();
@@ -78,7 +82,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null)
$folderHandler->delete($imagesDirectory);
//remove old changelogs
- array_map('unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt'));
+ array_map('\unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt', GLOB_NOSORT));
if (!empty($newbbConfig['syncOnUpdate'])) {
require_once dirname(__DIR__) . '/include/functions.recon.php';
@@ -89,23 +93,22 @@ function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null)
}
/**
- * @param XoopsModule $module
+ * @param XoopsModule $module
* @return bool
*/
function xoops_module_pre_update_newbb(\XoopsModule $module)
{
// XoopsLoad::load('migrate', 'newbb');
- /** @var \XoopsModules\Newbb\Common\Configurator $configurator */
- $configurator = new \XoopsModules\Newbb\Common\Configurator();
+ $configurator = new Configurator();
- $migrator = new \XoopsModules\Newbb\Common\Migrate($configurator);
+ $migrator = new Migrate($configurator);
$migrator->synchronizeSchema();
return true;
}
/**
- * @param XoopsModule $module
+ * @param XoopsModule $module
* @return bool
*/
function xoops_module_pre_install_newbb(\XoopsModule $module)
@@ -119,14 +122,14 @@ function xoops_module_pre_install_newbb(\XoopsModule $module)
}
/**
- * @param XoopsModule $module
+ * @param XoopsModule $module
* @return bool
*/
function xoops_module_install_newbb(\XoopsModule $module)
{
/* Create a test category */
/** @var Newbb\CategoryHandler $categoryHandler */
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
$category = $categoryHandler->create();
$category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true);
$category->setVar('cat_image', '', true);
@@ -138,7 +141,7 @@ function xoops_module_install_newbb(\XoopsModule $module)
/* Create a forum for test */
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$forum = $forumHandler->create();
$forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true);
$forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true);
@@ -186,10 +189,10 @@ function xoops_module_install_newbb(\XoopsModule $module)
/* Create a test post */
require_once __DIR__ . '/functions.user.php';
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
/** @var $forumpost */
$forumpost = $postHandler->create();
- $forumpost->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable());
+ $forumpost->setVar('poster_ip', IPAddress::fromRequest()->asReadable());
$forumpost->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid'));
$forumpost->setVar('approved', 1);
$forumpost->setVar('forum_id', $forum_id);
diff --git a/include/module.v100.php b/include/module.v100.php
index 6b49bb61..acef1fb8 100644
--- a/include/module.v100.php
+++ b/include/module.v100.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -25,7 +25,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J., infomax@gmail.com) //
-// URL: http://xoops.org //
+// URL: https://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
@@ -35,16 +35,19 @@
*/
function xoops_module_update_newbb_v100(XoopsObject $module)
{
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_archive') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_archive') . "(
`topic_id` tinyint(8) NOT NULL default '0',
`post_id` tinyint(8) NOT NULL default '0',
`post_text` text NOT NULL
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_archive');
}
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_attachments') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_attachments') . "(
`attach_id` int(8) unsigned NOT NULL auto_increment,
`post_id` int(10) default NULL,
`name_saved` varchar(255) default NULL,
@@ -55,35 +58,41 @@ function xoops_module_update_newbb_v100(XoopsObject $module)
`download` int(10) NOT NULL default '0',
PRIMARY KEY (`attach_id`),
KEY `post_id` (`post_id`)
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_attachments');
}
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_digest') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_digest') . "(
`digest_id` int(8) unsigned NOT NULL auto_increment,
`digest_time` int(10) NOT NULL default '0',
`digest_content` text,
PRIMARY KEY (`digest_id`),
KEY `digest_time` (`digest_time`)
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_digest');
}
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_online') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_online') . "(
`online_forum` int(10) NOT NULL default '0',
`online_topic` int(10) NOT NULL default '0',
`online_uid` int(10) default NULL,
`online_uname` varchar(255) default NULL,
`online_ip` varchar(32) default NULL,
`online_updated` int(14) default NULL
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_online');
}
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_report') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_report') . "(
`report_id` int(8) unsigned NOT NULL auto_increment,
`post_id` int(10) default NULL,
`reporter_uid` int(10) default NULL,
@@ -94,12 +103,14 @@ function xoops_module_update_newbb_v100(XoopsObject $module)
`report_memo` varchar(255) default NULL,
PRIMARY KEY (`report_id`),
KEY `post_id` (`post_id`)
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_report');
}
- $result = $GLOBALS['xoopsDB']->queryF('CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_votedata') . "(
+ $result = $GLOBALS['xoopsDB']->queryF(
+ 'CREATE TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_votedata') . "(
`ratingid` int(11) unsigned NOT NULL auto_increment,
`topic_id` int(11) unsigned NOT NULL default '0',
`ratinguser` int(11) NOT NULL default '0',
@@ -110,7 +121,8 @@ function xoops_module_update_newbb_v100(XoopsObject $module)
KEY ratinguser (ratinguser),
KEY ratinghostname (ratinghostname),
KEY topic_id (topic_id)
- ) TYPE=MyISAM");
+ ) ENGINE=MyISAM"
+ );
if (!$result) {
$module->setErrors('Could not create bb_votedata');
}
diff --git a/include/module.v220.php b/include/module.v220.php
index c6191a2c..8a6b6c21 100644
--- a/include/module.v220.php
+++ b/include/module.v220.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -25,12 +25,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J., infomax@gmail.com) //
-// URL: http://xoops.org //
+// URL: https://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
/**
- * @param XoopsModule $module
+ * @param XoopsModule $module
* @return bool
*/
function xoops_module_update_newbb_v220(XoopsModule $module)
diff --git a/include/module.v400.php b/include/module.v400.php
index 37bbd640..61e4d023 100644
--- a/include/module.v400.php
+++ b/include/module.v400.php
@@ -2,12 +2,12 @@
/**
* NewBB 4.3x, the forum module for XOOPS project
*
- * @copyright XOOPS Project (http://xoops.org)
+ * @copyright XOOPS Project (https://xoops.org)
* @license http://www.fsf.org/copyleft/gpl.html GNU public license
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
- * @param XoopsModule $module
+ * @param XoopsModule $module
* @return bool
*/
@@ -77,19 +77,13 @@ function xoops_module_update_newbb_v400(XoopsModule $module)
. ' t.dobr = p.dobr'
. ' WHERE p.post_id =t.post_id ';
if ($GLOBALS['xoopsDB']->queryF($sql)) {
- $sql = ' ALTER TABLE '
- . $GLOBALS['xoopsDB']->prefix('bb_posts')
- . ' DROP `dohtml`,'
- . ' DROP `dosmiley`,'
- . ' DROP `doxcode`,'
- . ' DROP `doimage`,'
- . ' DROP `dobr`';
+ $sql = ' ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' DROP `dohtml`,' . ' DROP `dosmiley`,' . ' DROP `doxcode`,' . ' DROP `doimage`,' . ' DROP `dobr`';
$GLOBALS['xoopsDB']->queryF($sql);
} else {
xoops_error($GLOBALS['xoopsDB']->error() . ' ' . $sql);
}
- @include_once $GLOBALS['xoops']->path('modules/tag/include/functions.php');
+ @require_once $GLOBALS['xoops']->path('modules/tag/include/functions.php');
if (function_exists('tag_getTagHandler') && $tag_handler = tag_getTagHandler()) {
$table_topic = $GLOBALS['xoopsDB']->prefix('bb_topics');
@@ -105,12 +99,13 @@ function xoops_module_update_newbb_v400(XoopsModule $module)
}
}
- if (!$GLOBALS['xoopsDB']->query('
+ if (!$GLOBALS['xoopsDB']->query(
+ '
SELECT COUNT(*)
FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp') . ' AS a, ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp') . ' AS b
WHERE a.type_id = b.type_id AND a.type_id >0;
- ')
- ) {
+ '
+ )) {
//xoops_error($GLOBALS['xoopsDB']->error());
$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp'));
$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp'));
@@ -118,18 +113,12 @@ function xoops_module_update_newbb_v400(XoopsModule $module)
return true;
}
- $GLOBALS['xoopsDB']->queryF(' INSERT INTO '
- . $GLOBALS['xoopsDB']->prefix('bb_type')
- . ' (`type_id`, `type_name`, `type_color`)'
- . ' SELECT `type_id`, `type_name`, `type_color`'
- . ' FROM '
- . $GLOBALS['xoopsDB']->prefix('bb_type_tmp'));
- $GLOBALS['xoopsDB']->queryF(' INSERT INTO '
- . $GLOBALS['xoopsDB']->prefix('bb_type_forum')
- . ' (`type_id`, `forum_id`, `type_order`)'
- . ' SELECT `type_id`, `forum_id`, `type_order`'
- . ' FROM '
- . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp'));
+ $GLOBALS['xoopsDB']->queryF(
+ ' INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type') . ' (`type_id`, `type_name`, `type_color`)' . ' SELECT `type_id`, `type_name`, `type_color`' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp')
+ );
+ $GLOBALS['xoopsDB']->queryF(
+ ' INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum') . ' (`type_id`, `forum_id`, `type_order`)' . ' SELECT `type_id`, `forum_id`, `type_order`' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp')
+ );
$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp'));
$GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp'));
diff --git a/include/notification.inc.php b/include/notification.inc.php
index d1d16fef..cf2fd10e 100644
--- a/include/notification.inc.php
+++ b/include/notification.inc.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -28,7 +28,7 @@
// URL: https://xoops.org //
// Project: Article Project //
// ------------------------------------------------------------------------ //
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.php');
if (!defined('NEWBB_NOTIFY_ITEMINFO')) {
define('NEWBB_NOTIFY_ITEMINFO', 1);
diff --git a/include/oninstall.php b/include/oninstall.php
index 01e8adeb..4e893ad3 100644
--- a/include/oninstall.php
+++ b/include/oninstall.php
@@ -11,13 +11,18 @@
/**
* @copyright XOOPS Project https://xoops.org/
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package
* @since
* @author XOOPS Development Team
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{
+ Common\Configurator,
+ Helper,
+ Utility};
+
+/** @var Helper $helper */
//require_once __DIR__ . '/setup.php';
@@ -31,7 +36,7 @@ function xoops_module_pre_install_newbb(\XoopsModule $module)
{
require_once dirname(__DIR__) . '/preloads/autoloader.php';
/** @var Newbb\Utility $utility */
- $utility = new \XoopsModules\Newbb\Utility();
+ $utility = new Utility();
$xoopsSuccess = $utility::checkVerXoops($module);
$phpSuccess = $utility::checkVerPhp($module);
@@ -54,22 +59,22 @@ function xoops_module_pre_install_newbb(\XoopsModule $module)
function xoops_module_install_newbb(\XoopsModule $module)
{
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
- require_once dirname(__DIR__) . '/include/config.php';
$moduleDirName = basename(dirname(__DIR__));
/** @var Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
- $utility = new Newbb\Utility();
- $configurator = new Newbb\Common\Configurator();
+ $helper = Helper::getInstance();
+ $utility = new Utility();
+ $configurator = new Configurator();
// Load language files
$helper->loadLanguage('admin');
$helper->loadLanguage('modinfo');
// default Permission Settings ----------------------
global $xoopsModule, $xoopsDB;
- $moduleId = $xoopsModule->getVar('mid');
+ $moduleId = $xoopsModule->getVar('mid');
// $moduleId2 = $helper->getModule()->mid();
+ /** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
// access rights ------------------------------------------
$grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId);
diff --git a/include/onuninstall.php b/include/onuninstall.php
index b78dd852..2c8a6310 100644
--- a/include/onuninstall.php
+++ b/include/onuninstall.php
@@ -8,7 +8,9 @@
* @link https://xoops.org XOOPS
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper, Utility};
+
+/** @var Helper $helper */
/**
* Prepares system prior to attempting to uninstall module
@@ -34,11 +36,10 @@ function xoops_module_uninstall_newbb(\XoopsModule $module)
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
- /** @var \XoopsModules\Newbb\Helper $helper */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
+ $helper = Helper::getInstance();
/** @var Newbb\Utility $utility */
- $utility = new \XoopsModules\Newbb\Utility();
+ $utility = new Utility();
$success = true;
$helper->loadLanguage('admin');
diff --git a/include/onupdate.php b/include/onupdate.php
index 1ed75cb4..b119f2ff 100644
--- a/include/onupdate.php
+++ b/include/onupdate.php
@@ -11,13 +11,18 @@
/**
* @copyright XOOPS Project https://xoops.org/
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package
* @since
* @author XOOPS Development Team
*/
+
+use XoopsModules\Newbb\{Common\Configurator, Common\Migrate, Helper, Utility};
+
+/** @var Helper $helper */
+
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
- || !$GLOBALS['xoopsUser']->IsAdmin()) {
+ || !$GLOBALS['xoopsUser']->isAdmin()) {
exit('Restricted access' . PHP_EOL);
}
@@ -45,15 +50,13 @@ function xoops_module_pre_update_newbb(\XoopsModule $module)
{
$moduleDirName = basename(dirname(__DIR__));
- /** @var \XoopsModules\Newbb\Utility $utility */
- $utility = new \XoopsModules\Newbb\Utility();
- /** @var \XoopsModules\Newbb\Common\Configurator $configurator */
- $configurator = new \XoopsModules\Newbb\Common\Configurator();
+ $utility = new Utility();
+ $configurator = new Configurator();
$xoopsSuccess = $utility::checkVerXoops($module);
$phpSuccess = $utility::checkVerPhp($module);
- $migrator = new \XoopsModules\Newbb\Common\Migrate($configurator);
+ $migrator = new Migrate($configurator);
$migrator->synchronizeSchema();
return $xoopsSuccess && $phpSuccess;
@@ -62,7 +65,7 @@ function xoops_module_pre_update_newbb(\XoopsModule $module)
/**
* Performs tasks required during update of the module
* @param \XoopsModule $module {@link XoopsModule}
- * @param null $previousVersion
+ * @param null $previousVersion
*
* @return bool true if update successful, false if not
*/
@@ -71,12 +74,11 @@ function xoops_module_update_newbb(\XoopsModule $module, $previousVersion = null
$moduleDirName = basename(dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
- /** @var \XoopsModules\Newbb\Helper $helper */
- /** @var \XoopsModules\Newbb\Utility $utility */
+ /** @var \XoopsModules\Newbb\Helper $helper */ /** @var \XoopsModules\Newbb\Utility $utility */
/** @var \XoopsModules\Newbb\Common\Configurator $configurator */
- $helper = \XoopsModules\Newbb\Helper::getInstance();
- $utility = new \XoopsModules\Newbb\Utility();
- $configurator = new \XoopsModules\Newbb\Common\Configurator();
+ $helper = Helper::getInstance();
+ $utility = new Utility();
+ $configurator = new Configurator();
if ($previousVersion < 510) {
//delete old HTML templates
@@ -88,7 +90,7 @@ function xoops_module_update_newbb(\XoopsModule $module, $previousVersion = null
foreach ($templateList as $k => $v) {
$fileInfo = new \SplFileInfo($templateFolder . $v);
if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) {
- if (file_exists($templateFolder . $v)) {
+ if (is_file($templateFolder . $v)) {
unlink($templateFolder . $v);
}
}
diff --git a/include/plugin.dist.php b/include/plugin.dist.php
index 02fb16cc..f05b39e9 100644
--- a/include/plugin.dist.php
+++ b/include/plugin.dist.php
@@ -1,18 +1,18 @@
* @since 4.00
* @package module::newbb
*/
xoops_loadLanguage('main', 'newbb');
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
/* some static xoopsModuleConfig */
$customConfig = [];
diff --git a/include/plugin.php b/include/plugin.php
index 41ee76ae..da638cbe 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -1,16 +1,16 @@
* @since 4.00
* @package module::newbb
*/
xoops_loadLanguage('main', 'newbb');
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
/* some static xoopsModuleConfig */
$customConfig = [];
diff --git a/include/search.inc.php b/include/search.inc.php
index 533e129b..2f8af0f4 100644
--- a/include/search.inc.php
+++ b/include/search.inc.php
@@ -3,28 +3,31 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.) , irmtfan
* @since 4.3
* @package module::newbb
*/
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
+
+/** @var Helper $helper */
// completely rewrite by irmtfan - remove hardcode database access, solve order issues, add post_text & topic_id, add highlight and reduce queries
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
/**
- * @param $queryarray
- * @param $andor
- * @param $limit
- * @param $offset
- * @param $userid
- * @param int $forums
- * @param int|string $sortby
- * @param string $searchin
- * @param \CriteriaCompo $criteriaExtra
+ * @param $queryarray
+ * @param $andor
+ * @param $limit
+ * @param $offset
+ * @param $userid
+ * @param int $forums
+ * @param int|string $sortby
+ * @param string $searchin
+ * @param \CriteriaCompo|null $criteriaExtra
* @return array
*/
function newbb_search(
@@ -36,8 +39,8 @@ function newbb_search(
$forums = 0,
$sortby = 0,
$searchin = 'both',
- \CriteriaCompo $criteriaExtra = null)
-{
+ \CriteriaCompo $criteriaExtra = null
+) {
global $myts, $xoopsDB;
// irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
if (!isset($GLOBALS['xoopsModuleConfig'])) {
@@ -49,7 +52,7 @@ function newbb_search(
$GLOBALS['xoopsModule'] = $GLOBALS['module'];
}
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
$validForums = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
$criteriaPost = new \CriteriaCompo();
@@ -66,7 +69,7 @@ function newbb_search(
$criteriaUser = new \CriteriaCompo();
$criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
} elseif ($userid && is_array($userid)) {
- $userid = array_map('intval', $userid);
+ $userid = array_map('\intval', $userid);
$criteriaUser = new \CriteriaCompo();
$criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
}
@@ -121,7 +124,7 @@ function newbb_search(
$criteria->setOrder($order);
/** @var Newbb\PostHandler $postHandler */
- $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
+ $postHandler = Helper::getInstance()->getHandler('Post');
$posts = $postHandler->getPostsByLimit($criteria, $limit, $offset);
$ret = [];
@@ -134,7 +137,7 @@ function newbb_search(
$ret[$i]['link'] = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
$ret[$i]['title'] = $post_data['subject'];
$ret[$i]['time'] = $post_data['date'];
- $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
+ $ret[$i]['forum_name'] = htmlspecialchars($forum_list[$post->getVar('forum_id')]['forum_name']);
$ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
$ret[$i]['post_text'] = $post_data['text'];
$ret[$i]['uid'] = $post->getVar('uid');
diff --git a/include/sitemap.plugin.php b/include/sitemap.plugin.php
index 02857e07..19b2098f 100644
--- a/include/sitemap.plugin.php
+++ b/include/sitemap.plugin.php
@@ -2,11 +2,14 @@
//
// FILE :: newbb.php
// AUTHOR :: Ryuji AMANO
-// WEB :: Ryu's Planning
+// WEB :: Ryu's Planning
// NewBB plugin: D.J., https://xoops.org.cn
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper
+};
+
+/** @var Helper $helper */
/**
* @return array
@@ -17,7 +20,7 @@ function b_sitemap_newbb()
$sitemap = [];
/** @var Newbb\ForumHandler $forumHandler */
- $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+ $forumHandler = Helper::getInstance()->getHandler('Forum');
/* Allowed forums */
$forums_allowed = $forumHandler->getIdsByPermission();
@@ -67,7 +70,7 @@ function b_sitemap_newbb()
if ($sitemap_configs['show_subcategoris']) {
/** @var Newbb\CategoryHandler $categoryHandler */
- $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category');
+ $categoryHandler = Helper::getInstance()->getHandler('Category');
$categories = [];
$categories = $categoryHandler->getByPermission('access', ['cat_id', 'cat_title'], false);
diff --git a/include/vars.php b/include/vars.php
index be2e6e01..2f2c4fce 100644
--- a/include/vars.php
+++ b/include/vars.php
@@ -3,13 +3,14 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
-// defined('XOOPS_ROOT_PATH') || die('Restricted access');
+use Xmf\IPAddress;
+
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
require_once __DIR__ . '/functions.session.php';
@@ -33,7 +34,7 @@
$forumCookie['path'] = '/';
$forumCookie['secure'] = false;
$forumCookie['expire'] = time() + 3600 * 24 * 30; // one month
-$forumCookie['prefix'] = 'newbb_' . (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP' . \Xmf\IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"]
+$forumCookie['prefix'] = 'newbb_' . (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : '0IP' . IPAddress::fromRequest()->asReadable()); // irmtfan IP for anons - use $GLOBALS["xoopsUser"]
// set LastVisitTemp cookie, which only gets the time from the LastVisit cookie if it does not exist yet
// otherwise, it gets the time from the LastVisitTemp cookie
diff --git a/index.php b/index.php
index e5ba50f8..494007a2 100644
--- a/index.php
+++ b/index.php
@@ -3,14 +3,18 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
use Xmf\Request;
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{Helper,
+ ObjectTree
+};
+
+/** @var Helper $helper */
require_once __DIR__ . '/header.php';
@@ -61,9 +65,12 @@
/* rss feed */
// irmtfan new method
if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
- $xoopsTpl->assign('xoops_module_header', '
+ $xoopsTpl->assign(
+ 'xoops_module_header',
+ '
- ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
+ ' . @$xoopsTpl->get_template_vars('xoops_module_header')
+ );
}
$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
// irmtfan remove and move to footer.php
@@ -77,7 +84,7 @@
$xoopsTpl->assign('online', $onlineHandler->showOnline());
}
/** @var Newbb\ForumHandler $forumHandler */
-$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
+$forumHandler = Helper::getInstance()->getHandler('Forum');
///** @var Newbb\PostHandler $postHandler */
//$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
@@ -187,18 +194,18 @@
}
$cat_sponsor = [];
- @list($url, $title) = array_map('trim', explode(' ', $onecat['cat_url'], 2));
+ @list($url, $title) = array_map('\trim', explode(' ', $onecat['cat_url'], 2));
if ('' === $title) {
$title = $url;
}
- $title = $myts->htmlSpecialChars($title);
+ $title = htmlspecialchars($title);
if ('' !== $url) {
$cat_sponsor = ['title' => $title, 'link' => formatURL($url)];
}
//$cat_image = $onecat['cat_image'];
$cat_image = '';
$cat_image = $onecat['cat_image'];
- if ('' !== $cat_image && 'blank.gif' !== $cat_image && $cat_image) {
+ if ('' !== $cat_image && $cat_image) {
$cat_image = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/assets/images/category/' . $cat_image;
}
$category_array[] = [
@@ -219,10 +226,12 @@
$xoopsTpl->assign_by_ref('categories', $category_array);
$xoopsTpl->assign('notifyicon', $category_icon);
-$xoopsTpl->assign([
- 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
- 'index_desc' => _MD_NEWBB_TOSTART,
- ]);
+$xoopsTpl->assign(
+ [
+ 'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
+ 'index_desc' => _MD_NEWBB_TOSTART,
+ ]
+);
/* display user stats */
if (!empty($GLOBALS['xoopsModuleConfig']['statistik_enabled'])) {
@@ -279,11 +288,13 @@
$xoopsTpl->assign('rss_enable', 1);
$xoopsTpl->assign('rss_button', newbbDisplayImage('rss', 'RSS feed'));
}
-$xoopsTpl->assign([
- 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS),
- 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS),
- 'img_subforum' => newbbDisplayImage('subforum'),
- ]);
+$xoopsTpl->assign(
+ [
+ 'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS),
+ 'img_forum' => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS),
+ 'img_subforum' => newbbDisplayImage('subforum'),
+ ]
+);
// irmtfan move to footer.php
require_once __DIR__ . '/footer.php';
diff --git a/language/english/admin.php b/language/english/admin.php
index dda4b572..873e7e8c 100644
--- a/language/english/admin.php
+++ b/language/english/admin.php
@@ -74,8 +74,10 @@
define('_AM_NEWBB_DIGEST_HELP_2', 'Create a newsletter is possible only after the topic is marked as \'Digest\'.');
define('_AM_NEWBB_DIGEST_HELP_3', 'The dispatch is made only to users signed up for notification of digest topics.');
define('_AM_NEWBB_DIGEST_HELP_4', 'After creating and sending, do not delete the created messages. Otherwise they will be generated again.');
-define('_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST',
- 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server. For example: * NIX systems: 0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done. If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above. Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.');
+define(
+ '_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST',
+ 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server. For example: * NIX systems: 0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done. If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above. Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.'
+);
//define('_AM_NEWBB_DIGEST_PAST', 'Should be sent out %d minutes ago ');
//define('_AM_NEWBB_DIGEST_NEXT', 'Need to send out in %d minutes');
//define('_AM_NEWBB_DIGEST_ARCHIVE', 'Digest archive');
@@ -321,21 +323,33 @@
define('_AM_NEWBB_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module');
// Help tab
-define('_AM_NEWBB_HELP_CATEGORY_TAB',
- 'To create a category, use the button above and fill in all the fields on the form. By default, category images are located: /modules/newbb/assets/images/category/ Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.');
-define('_AM_NEWBB_HELP_FORUM_TAB',
- 'To create and manage the forums use the buttons with the right To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum. To move the forum between categories, use the \'Move\' button. Follow the further instructions. To merge forums, use the \'Merge\' button. Follow the further instructions. If you have an access rights template, then you can apply it to the forum you are creating.');
-define('_AM_NEWBB_HELP_PERMISSION_TAB',
- 'When setting permissions, be careful. After you install and apply the settings, you will automatically go to the next permissions tab. Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.');
+define(
+ '_AM_NEWBB_HELP_CATEGORY_TAB',
+ 'To create a category, use the button above and fill in all the fields on the form. By default, category images are located: /modules/newbb/assets/images/category/ Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.'
+);
+define(
+ '_AM_NEWBB_HELP_FORUM_TAB',
+ 'To create and manage the forums use the buttons with the right To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum. To move the forum between categories, use the \'Move\' button. Follow the further instructions. To merge forums, use the \'Merge\' button. Follow the further instructions. If you have an access rights template, then you can apply it to the forum you are creating.'
+);
+define(
+ '_AM_NEWBB_HELP_PERMISSION_TAB',
+ 'When setting permissions, be careful. After you install and apply the settings, you will automatically go to the next permissions tab. Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.'
+);
define('_AM_NEWBB_HELP_ORDER_TAB', 'Allows you to set the order of categories and forums relative to each other. The order (Weight) is set to 0 - top, 99 (and further) - bottom.');
define('_AM_NEWBB_HELP_PRUNE_TAB', 'Allows you to clear forums from empty themes, obsolete themes, etc. Also you can not delete topics that you want to clear, but transfer them to a specially created category \'Archive\' or any other.');
-define('_AM_NEWBB_HELP_REPORT_TAB',
- 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules. You can review the report and take action in relation to the message, the author, etc. When a user sends a message, moderators and administrators are notified by e-mail.');
+define(
+ '_AM_NEWBB_HELP_REPORT_TAB',
+ 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules. You can review the report and take action in relation to the message, the author, etc. When a user sends a message, moderators and administrators are notified by e-mail.'
+);
define('_AM_NEWBB_HELP_VOTE_TAB', 'If you have the voting function enabled, here you can see the results of the voting. This vote is not associated with other XOOPS modules.');
-define('_AM_NEWBB_HELP_TYPE_TAB',
- 'Allows you to create tags for highlighting themes. For example:[Important] Topic Title [ATTENTION] Topic Title You can set theme types when creating a theme on the user side.');
-define('_AM_NEWBB_HELP_GROUPMOD_TAB',
- 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums. It is recommended to create separate groups of moderators, for more convenient management of moderators. You can also assign specific users to moderators when creating a forum.');
+define(
+ '_AM_NEWBB_HELP_TYPE_TAB',
+ 'Allows you to create tags for highlighting themes. For example:[Important] Topic Title [ATTENTION] Topic Title You can set theme types when creating a theme on the user side.'
+);
+define(
+ '_AM_NEWBB_HELP_GROUPMOD_TAB',
+ 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums. It is recommended to create separate groups of moderators, for more convenient management of moderators. You can also assign specific users to moderators when creating a forum.'
+);
define('_AM_NEWBB_HELP_SYNC_TAB', 'If you notice a problem with the message dates, the appearance of blank messages, etc. Here you can synchronize and correct forum data and topics');
define('_AM_NEWBB_FORUM_DESC_LENGTH', 'Forum Description Length');
diff --git a/language/english/common.php b/language/english/common.php
index 803f1f63..e266c432 100644
--- a/language/english/common.php
+++ b/language/english/common.php
@@ -8,11 +8,12 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
+
/**
* Wfdownloads module
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package wfdownload
* @since 3.23
* @author Xoops Development Team
diff --git a/language/english/help/index.html b/language/english/help/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/language/english/help/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/language/english/help/index.php b/language/english/help/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/language/english/help/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
diff --git a/language/english/index.php b/language/english/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/language/english/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/language/english/mail_template/index.php b/language/english/mail_template/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/language/english/mail_template/index.php
@@ -0,0 +1,3 @@
+(If a reason is provided, the user will receive a message) :');
define('_MD_NEWBB_DELEDEDMSG_SUBJECT', 'Deletion of your article');
-define('_MD_NEWBB_DELEDEDMSG_BODY', 'Hello %s,
+define(
+ '_MD_NEWBB_DELEDEDMSG_BODY',
+ 'Hello %s,
your post in the forum
%s
@@ -478,7 +480,8 @@
-------------------------
Please do not reply to this message!
%s
-%s');
+%s'
+);
define('_MD_NEWBB_FORUMHOME', 'Board index');
define('_MD_NEWBB_SEEWAITREPORT', "There were %s Contributions reported ");
define('_MD_NEWBB_PDF_SUBJECT', 'Title: ');
@@ -550,3 +553,9 @@
define('_MD_NEWBB_PDF_PAGE2', 'page');
define('_MD_NEWBB_PDF_META_DIR', 'ltr');
+
+//Facebook UI Style Rating
+define('THEME_LIKE', 'Like');
+define('_AM_NEWBB_NOTOPIC', 'No Posts'); //TODO delete in next XOOPS release
+
+define('_MD_NEWBB_ERROR_POLL_MODULE_NOT_FOUND', "Error: Cannot find poll module that is in used in newbb!!! You should select the correct poll module yourself in newbb > preferences > poll module setting.");
diff --git a/language/english/modinfo.php b/language/english/modinfo.php
index 977fc784..9b4e8ab0 100644
--- a/language/english/modinfo.php
+++ b/language/english/modinfo.php
@@ -41,8 +41,10 @@
//define('_MI_NEWBB_THEMESET', 'Theme set');
//define('_MI_NEWBB_THEMESET_DESC', "Module-wide, select '' . _NONE . '' will use site-wide theme");
define('_MI_NEWBB_DIR_ATTACHMENT', 'Attachments physical path.');
-define('_MI_NEWBB_DIR_ATTACHMENT_DESC',
- "Physical path only needs to be set from your xoops root and not before, for example you may have attachments uploaded to www.yoururl.com/uploads/newbb the path entered would then be '/uploads/newbb' never include a trailing slash '/' the thumbnails path becomes '/uploads/newbb/thumbs'");
+define(
+ '_MI_NEWBB_DIR_ATTACHMENT_DESC',
+ "Physical path only needs to be set from your xoops root and not before, for example you may have attachments uploaded to www.yoururl.com/uploads/newbb the path entered would then be '/uploads/newbb' never include a trailing slash '/' the thumbnails path becomes '/uploads/newbb/thumbs'"
+);
define('_MI_NEWBB_PATH_MAGICK', 'Path for ImageMagick');
define('_MI_NEWBB_PATH_MAGICK_DESC', "Usually it is '/usr/bin/X11'. Leave it BLANK if you do not have ImageMagicK installed or for autodetecting.");
define('_MI_NEWBB_SUBFORUM_DISPLAY', 'Display Mode of subforums on index page');
@@ -78,8 +80,10 @@
define('_MI_NEWBB_TEXT', 'text');
define('_MI_NEWBB_GRAPHIC', 'graphic');
define('_MI_NEWBB_USERLEVEL', 'HP/MP/EXP Level Mode');
-define('_MI_NEWBB_USERLEVEL_DESC',
- 'HP is determined by your average posts per day.MP is determined by your join date related to your post count.EXP goes up each time you post, and when you get to 100%, you gain a level and the EXP drops to 0 again.');
+define(
+ '_MI_NEWBB_USERLEVEL_DESC',
+ 'HP is determined by your average posts per day.MP is determined by your join date related to your post count.EXP goes up each time you post, and when you get to 100%, you gain a level and the EXP drops to 0 again.'
+);
define('_MI_NEWBB_RSS_ENABLE', 'Enable RSS Feed');
define('_MI_NEWBB_RSS_ENABLE_DESC', 'Enable RSS Feed, edit options below for maximum Items and Description length');
define('_MI_NEWBB_RSS_MAX_ITEMS', 'RSS Max. Items');
@@ -211,7 +215,9 @@
define('_MI_NEWBB_INSTALL_FORUM_NAME', 'Forum Test');
define('_MI_NEWBB_INSTALL_FORUM_DESC', 'Forum for test.');
define('_MI_NEWBB_INSTALL_POST_SUBJECT', 'Congratulations! The forum is working.');
-define('_MI_NEWBB_INSTALL_POST_TEXT', '
+define(
+ '_MI_NEWBB_INSTALL_POST_TEXT',
+ '
Welcome to ' . htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES) . ' forum.
Feel free to register and login to start your topics.
@@ -279,7 +285,8 @@
The forum automatically uses cookies to store information on your computer. These cookies do not contain any information from your input and serve only to improve the quality of the forums. Your e-mail address is used only to confirm your registration, inform you of new messages and password (and to send a new password if you forget the current one).
The use of the Forum is evidence of your consent to these Rules.
- ');
+ '
+);
define('_MI_NEWBB_ADMENU_GROUPMOD', 'Group moderate');
//define('_MI_NEWBB_SUBJECT_PREFIX', 'Add a prefix to the topic subject');
//define('_MI_NEWBB_SUBJECT_PREFIX_DESC', 'Sets a prefix, such as [SOLVED] at the beginning of the subject. For more options please use one ', ' as the separator. NONE is no prefix.');
@@ -335,12 +342,19 @@
// Message when you first log in to the forum
define('_MI_NEWBB_WELCOMEFORUM_MESSAGE', 'Enter a message for the first time you logged in');
define('_MI_NEWBB_WELCOMEFORUM_MESSAGE_DESC', 'The message will be published in the first user message when the user first logs on to the Forum');
-define('_MI_NEWBB_WELCOMEFORUM_DESC_MESSAGE', '
+define(
+ '_MI_NEWBB_WELCOMEFORUM_DESC_MESSAGE',
+ '
Since the forum works in real time, it is impossible to verify or confirm the accuracy of the information placed here. Remember that the forum administration does not actively monitor and is not responsible for the messages sent. Administration does not guarantee the accuracy, completeness and correctness of the content of any message. Any communication reflects the author\'s point of view, which does not necessarily coincide with the point of view of the administration of the forum or organization associated with this forum. Any user who finds a provocative message can inform the forum administration about this. In this case, the message will be reviewed and, if the administration deems it necessary, deleted. However, do not forget that this process takes time and treat it with understanding.
-');
+'
+);
define('_MI_NEWBB_FORUM_DESC_LENGTH', 'Forum Description Length');
define('_MI_NEWBB_FORUM_DESC_LENGTH_DESC', 'The Forum description shown on the main page will be truncated to # of characters you set here. A full description will be shown on the forum page.');
define('_MI_NEWBB_ADMENU_MIGRATE', 'Migrate');
define('_MI_NEWBB_SHOW_DEV_TOOLS', 'Show Development Tools Button?');
define('_MI_NEWBB_SHOW_DEV_TOOLS_DESC', 'If yes, the "Migrate" Tab and other Development tools will be visible to the Admin.');
+
+//5.01
+define('_MI_NEWBB_FACEBOOK_STYLE_RATING', 'Facebook UI Rating?');
+define('_MI_NEWBB_FACEBOOK_STYLE_RATING_DESC', 'Show Facebook UI Style Rating');
diff --git a/language/index.html b/language/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/language/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/language/index.php b/language/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/language/index.php
@@ -0,0 +1,3 @@
+
* @since 4.00
* @package module::newbb
diff --git a/list.topic.php b/list.topic.php
index e9ef602e..37314ae5 100644
--- a/list.topic.php
+++ b/list.topic.php
@@ -3,14 +3,16 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
use Xmf\Request;
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{
+ TopicRenderer
+};
require_once __DIR__ . '/header.php';
@@ -20,9 +22,12 @@
require_once $GLOBALS['xoops']->path('header.php');
// irmtfan new method
if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
- $xoopsTpl->assign('xoops_module_header', '
+ $xoopsTpl->assign(
+ 'xoops_module_header',
+ '
- ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
+ ' . @$xoopsTpl->get_template_vars('xoops_module_header')
+ );
}
//$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
@@ -31,7 +36,7 @@
// irmtfan use require_once because it will redeclared in newbb/blocks/list_topic.php
//require_once __DIR__ . '/./class/TopicRenderer.php';
-$topic_renderer = Newbb\TopicRenderer::getInstance();
+$topic_renderer = TopicRenderer::getInstance();
$topic_renderer->userlevel = $GLOBALS['xoopsUserIsAdmin'] ? 2 : is_object($GLOBALS['xoopsUser']);
// irmtfan if list topic block is in the page then force to parse
if (defined('LIST_TOPIC_DEFINED')) {
diff --git a/makepdf.php b/makepdf.php
index ba596067..d69df48f 100644
--- a/makepdf.php
+++ b/makepdf.php
@@ -18,6 +18,7 @@
*/
use Xmf\Request;
+use XoopsModules\Xlanguage\Utility as XlanguageUtility;
//use tecnickcom\TCPDF;
@@ -101,8 +102,8 @@
$pdf_data = easiestml($pdf_data);
// END irmtfan to implement EMLH by GIJ
// START irmtfan to implement Xlanguage by phppp(DJ)
-} elseif (function_exists('xlanguage_ml')) {
- $pdf_data = xlanguage_ml($pdf_data);
+} elseif (class_exists('XlanguageUtility')) {
+ $pdf_data = XlanguageUtility::cleanMultiLang($pdf_data);
}
// END irmtfan to implement Xlanguage by phppp(DJ)
diff --git a/moderate.php b/moderate.php
index 7389aff9..a80afd39 100644
--- a/moderate.php
+++ b/moderate.php
@@ -3,12 +3,13 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
*/
+use Xmf\IPAddress;
use Xmf\Request;
require_once __DIR__ . '/header.php';
@@ -33,7 +34,7 @@
$ipWithMask = Request::getString('ip', null, 'POST');
$mask = '';
$ipParts = explode('/', $ipWithMask);
- $ip = new \Xmf\IPAddress($ipParts[0]);
+ $ip = new IPAddress($ipParts[0]);
if (false === $ip->asReadable()) {
$ipWithMask = '';
} else {
diff --git a/newtopic.php b/newtopic.php
index 6186a135..0abd5bd6 100644
--- a/newtopic.php
+++ b/newtopic.php
@@ -3,7 +3,7 @@
* NewBB 5.0x, the forum module for XOOPS project
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @author Taiwen Jiang (phppp or D.J.)
* @since 4.00
* @package module::newbb
diff --git a/notification_update.php b/notification_update.php
index ad3eba93..87e5f282 100644
--- a/notification_update.php
+++ b/notification_update.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
diff --git a/polls.php b/polls.php
index 0bd9198b..551546f7 100644
--- a/polls.php
+++ b/polls.php
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
@@ -19,11 +19,13 @@
use Xmf\Request;
use XoopsModules\Newbb;
use XoopsModules\Xoopspoll;
-
-//use XoopsModules\Xoopspoll\Constants;
+use XoopsModules\Xoopspoll\Constants;
+use XoopsModules\Xoopspoll\Helper;
// rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones
+global $xoopsModule;
+
require_once __DIR__ . '/header.php';
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
require_once $GLOBALS['xoops']->path('class/xoopslists.php');
@@ -71,18 +73,24 @@
redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
}
// poll module
+/** @var \XoopsModuleHandler $moduleHandler */
+$moduleHandler = xoops_getHandler('module');
$pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) {
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
- xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']);
- xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']);
- xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']);
- xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ if ($pollModuleHandler->getVar('version') >= 201) {
/** @var \XoopsModules\Xoopspoll\PollHandler $xpPollHandler */
$xpPollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll');
/** @var \XoopsModules\XoopsPoll $pollObject */
$pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist
+
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ xoops_load('constants', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ xoops_load('pollUtility', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ xoops_load('request', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ xoops_loadLanguage('admin', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpPollHandler = xoops_getModuleHandler('poll', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $poll_obj = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist
// old xoopspoll or umfrage or any clone from them
} else {
require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php');
@@ -114,24 +122,30 @@
switch ($op) {
case 'add':
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
echo '' . _MD_NEWBB_POLL_CREATNEWPOLL . " \n";
- $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
+ $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ echo '' . _MD_NEWBB_POLL_CREATNEWPOLL . " \n";
+ $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
// old xoopspoll or umfrage or any clone from them
} else {
$classOption = $classPoll . 'Option';
$poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
- $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("getVar('uid')
- . "'>"
- . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
- . ' ') : $GLOBALS['xoopsConfig']['anonymous']);
+ $author_label = new \XoopsFormLabel(
+ _MD_NEWBB_POLL_AUTHOR,
+ is_object($GLOBALS['xoopsUser']) ? ("getVar('uid')
+ . "'>"
+ . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
+ . ' ') : $GLOBALS['xoopsConfig']['anonymous']
+ );
$poll_form->addElement($author_label);
$question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255);
$poll_form->addElement($question_text);
- $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description');
+ $desc_tarea = new \XoopsFormTextArea(_MD_NEWBB_POLL_POLLDESC, 'description');
$poll_form->addElement($desc_tarea);
$currenttime = formatTimestamp(time(), 'Y-m-d H:i:s');
$endtime = formatTimestamp(time() + 604800, 'Y-m-d H:i:s');
@@ -156,13 +170,9 @@
$color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
$color_select->addOptionArray($barcolor_array);
$color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'");
- $color_label = new \XoopsFormLabel('', " ");
+ $color_label = new \XoopsFormLabel(
+ '', " "
+ );
$option_tray->addElement($color_select);
$option_tray->addElement($color_label);
if (!next($barcolor_array)) {
@@ -183,9 +193,12 @@
break; // op: add
case 'edit':
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
+ echo '' . _MD_NEWBB_POLL_EDITPOLL . " \n";
+ $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
echo '' . _MD_NEWBB_POLL_EDITPOLL . " \n";
- $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
+ $pollObject->renderForm(Request::getString('SCRIPT_NAME', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
// old xoopspoll or umfrage or any clone from them
} else {
$classOption = $classPoll . 'Option';
@@ -194,7 +207,7 @@
$poll_form->addElement($author_label);
$question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E'));
$poll_form->addElement($question_text);
- $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E'));
+ $desc_tarea = new \XoopsFormTextArea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E'));
$poll_form->addElement($desc_tarea);
$date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function
if (!$pollObject->hasExpired()) {
@@ -202,8 +215,9 @@
$poll_form->addElement($expire_text);
} else {
// irmtfan full URL - add topic_id
- $restart_label = new \XoopsFormLabel(_MD_NEWBB_POLL_EXPIRATION,
- sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . ' ');
+ $restart_label = new \XoopsFormLabel(
+ _MD_NEWBB_POLL_EXPIRATION, sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "getVar('dirname') . "/polls.php?op=restart&poll_id={$poll_id}&topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . ' '
+ );
$poll_form->addElement($restart_label);
}
$weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight'));
@@ -227,9 +241,12 @@
$color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color'));
$color_select->addOptionArray($barcolor_array);
$color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
- $color_label = new \XoopsFormLabel('', " url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
- . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' > ");
+ $color_label = new \XoopsFormLabel(
+ '',
+ " url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
+ . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' > "
+ );
$option_tray->addElement($color_select);
$option_tray->addElement($color_label);
unset($color_select, $color_label);
@@ -253,7 +270,7 @@
if ($pollModuleHandler->getVar('version') < 140) {
// check security token
if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
+ redirect_header(Request::getString('SCRIPT_NAME', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
}
/*
* The option check should be done before submitting
@@ -279,7 +296,7 @@
$end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time'];
if ('' !== $end_time) {
$timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
- $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
+ $pollObject->setVar('end_time', userTimeToServerTime(strtotime($end_time), $timezone));
} else {
// if expiration date is not set, set it to 10 days from now
$pollObject->setVar('end_time', time() + (86400 * 10));
@@ -336,7 +353,7 @@
case 'update':
// check security token
if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
+ redirect_header(Request::getString('SCRIPT_NAME', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
}
/* make sure there's at least one option */
$option_text = Request::getString('option_text', '', 'POST');
@@ -347,23 +364,27 @@
}
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
/** @var \XoopsModules\Xoopspoll\OptionHandler $xpOptHandler */
$xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
/** @var \XoopsModules\Xoopspoll\LogHandler $xpLogHandler */
$xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']);
// $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request";
- $classConstants = new XoopsModules\Xoopspoll\Constants();
- $notify = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST');
+ $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
+ $notify = XoopsRequest::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST');
$currentTimestamp = time();
+
//$xuEndTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST'))
// : strtotime(Request::getString('xu_end_time', null, 'POST'));
$xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST'));
- $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
+ $endTimestamp = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
//$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST'))
// : strtotime(Request::getString('xu_start_time', null, 'POST'));
$xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST'));
- $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
+ $startTimestamp = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
// don't allow changing start time if there are votes in the log
if (($startTimestamp < $pollObject->getVar('start_time'))
@@ -375,16 +396,16 @@
'user_id' => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
'question' => Request::getString('question', null, 'POST'),
'description' => Request::getText('description', null, 'POST'),
- 'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED,
- 'mail_voter' => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'),
+ 'mail_status' => (Constants::NOTIFICATION_ENABLED == $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
+ 'mail_voter' => Request::getInt('mail_voter', Constants::NOT_MAIL_POLL_TO_VOTER, 'POST'),
'start_time' => $startTimestamp,
'end_time' => $endTimestamp,
- 'display' => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'),
- 'visibility' => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'),
- 'weight' => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'),
- 'multiple' => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'),
- 'multilimit' => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'),
- 'anonymous' => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST'),
+ 'display' => Request::getInt('display', Constants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'),
+ 'visibility' => Request::getInt('visibility', Constants::HIDE_NEVER, 'POST'),
+ 'weight' => Request::getInt('weight', Constants::DEFAULT_WEIGHT, 'POST'),
+ 'multiple' => Request::getInt('multiple', Constants::NOT_MULTIPLE_SELECT_POLL, 'POST'),
+ 'multilimit' => Request::getInt('multilimit', Constants::MULTIPLE_SELECT_LIMITLESS, 'POST'),
+ 'anonymous' => Request::getInt('anonymous', Constants::ANONYMOUS_VOTING_DISALLOWED, 'POST'),
];
$pollObject->setVars($poll_vars);
$poll_id = $xpPollHandler->insert($pollObject);
@@ -395,7 +416,7 @@
// now get the options
$optionIdArray = Request::getArray('option_id', [], 'POST');
- $optionIdArray = array_map('intval', $optionIdArray);
+ $optionIdArray = array_map('\intval', $optionIdArray);
$optionTextArray = Request::getArray('option_text', [], 'POST');
$optionColorArray = Request::getArray('option_color', [], 'POST');
@@ -441,7 +462,7 @@
$end_time = Request::getString('end_time', '', 'POST');
if ('' !== $end_time) {
$timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
- $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
+ $pollObject->setVar('end_time', userTimeToServerTime(strtotime($end_time), $timezone));
}
$pollObject->setVar('display', 0);
$pollObject->setVar('weight', Request::getInt('weight', 0, 'POST'));
@@ -449,10 +470,10 @@
$pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST'));
if (Request::getInt('notify', 0, 'POST') && $end_time > time()) {
// if notify, set mail status to "not mailed"
- $pollObject->setVar('mail_status', $classConstants::POLL_NOT_MAILED);
+ $pollObject->setVar('mail_status', Constants::POLL_NOT_MAILED);
} else {
// if not notify, set mail status to already "mailed"
- $pollObject->setVar('mail_status', $classConstants::POLL_MAILED);
+ $pollObject->setVar('mail_status', Constants::POLL_MAILED);
}
if (!$pollObject->store()) {
@@ -471,10 +492,8 @@
$optionObject->setVar('option_text', $option_text[$i]);
$optionObject->setVar('option_color', $option_color[$i]);
$optionObject->store();
- } else {
- if (false !== $optionObject->delete()) {
- $classLog::deleteByOptionId($option->getVar('option_id'));
- }
+ } elseif (false !== $optionObject->delete()) {
+ $classLog::deleteByOptionId($option->getVar('option_id'));
}
++$i;
}
@@ -501,9 +520,12 @@
$poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true);
$poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question));
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
$xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
$option_tray = $xpOptHandler->renderOptionFormTray($poll_id);
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $option_tray = $xpOptHandler->renderOptionFormTray($poll_id);
// old xoopspoll or umfrage or any clone from them
} else {
$option_tray = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
@@ -515,9 +537,9 @@
$color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
$color_select->addOptionArray($barcolor_array);
$color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
- $color_label = new \XoopsFormLabel('', " url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
- . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' > ");
+ $color_label = new \XoopsFormLabel(
+ '', " url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}") . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' > "
+ );
$option_tray->addElement($color_select);
$option_tray->addElement($color_label);
unset($color_select, $color_label, $option_text);
@@ -538,7 +560,7 @@
case 'savemore':
// check security token
if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
+ redirect_header(Request::getString('SCRIPT_NAME', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
}
$option_text = Request::getString('option_text', '', 'POST');
@@ -554,13 +576,20 @@
$optxt = trim($optxt);
if ('' !== $optxt) {
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
$xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
$optionObject = $xpOptHandler->create();
$optionObject->setVar('option_text', $optxt);
$optionObject->setVar('poll_id', $poll_id);
$optionObject->setVar('option_color', $option_color[$i]);
$xpOptHandler->insert($optionObject);
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $optionObject = $xpOptHandler->create();
+ $optionObject->setVar('option_text', $optxt);
+ $optionObject->setVar('poll_id', $poll_id);
+ $optionObject->setVar('option_color', $option_color[$i]);
+ $xpOptHandler->insert($optionObject);
// old xoopspoll or umfrage or any clone from them
} else {
$classOption = $classPoll . 'Option';
@@ -586,11 +615,11 @@
case 'delete_ok':
// check security token
if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
+ redirect_header(Request::getString('SCRIPT_NAME', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
}
//try and delete the poll
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
$status = $xpPollHandler->delete($pollObject);
if (false !== $status) {
$xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
@@ -600,6 +629,16 @@
} else {
$msg = $xpPollHandler->getHtmlErrors();
}
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $status = $xpPollHandler->delete($poll_obj);
+ if (false !== $status) {
+ $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpOptHandler->deleteByPollId($poll_id);
+ $xpLogHandler->deleteByPollId($poll_id);
+ } else {
+ $msg = $xpPollHandler->getHtmlErrors();
+ }
// old xoopspoll or umfrage or any clone from them
} else {
$status = $pollObject->delete();
@@ -635,17 +674,22 @@
break;
case 'restart':
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
- $classConstants = new XoopsModules\Xoopspoll\Constants();
+ if ($pollModuleHandler->getVar('version') >= 201) {
+ $default_poll_duration = Constants::DEFAULT_POLL_DURATION;
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
$default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
// old xoopspoll or umfrage or any clone from them
} else {
$default_poll_duration = (86400 * 10);
}
$poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true);
- $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '' . _MD_NEWBB_POLL_FORMAT . ' ' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . ' ' . sprintf(_MD_NEWBB_POLL_EXPIREDAT,
- formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')) . ' ',
- 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s'));
+ $expire_text = new \XoopsFormText(
+ _MD_NEWBB_POLL_EXPIRATION . '' . _MD_NEWBB_POLL_FORMAT . ' ' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . ' ' . sprintf(
+ _MD_NEWBB_POLL_EXPIREDAT,
+ formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
+ ) . ' ', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s')
+ );
$poll_form->addElement($expire_text);
$poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1));
$poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0));
@@ -660,12 +704,17 @@
case 'restart_ok':
// check security token
if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
+ redirect_header(Request::getString('SCRIPT_NAME', '', 'SERVER'), 2, implode(' ', $GLOBALS['xoopsSecurity']->getErrors()));
}
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
- $classConstants = new XoopsModules\Xoopspoll\Constants();
+ if ($pollModuleHandler->getVar('version') >= 201) {
+ // $classConstants = new XoopsModules\Xoopspoll\Constants();
+ $default_poll_duration = Constants::DEFAULT_POLL_DURATION;
+ $poll_not_mailed = Constants::POLL_NOT_MAILED;
+ $poll_mailed = Constants::POLL_MAILED;
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ $classConstants = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
$default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
$poll_not_mailed = $classConstants::POLL_NOT_MAILED;
$poll_mailed = $classConstants::POLL_MAILED;
@@ -679,7 +728,7 @@
$end_time = !Request::getInt('end_time', 0, 'POST');
if (0 !== $end_time) {
$timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
- $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
+ $pollObject->setVar('end_time', userTimeToServerTime(strtotime($end_time), $timezone));
} else {
$pollObject->setVar('end_time', time() + $default_poll_duration);
}
@@ -694,7 +743,7 @@
}
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
if (!$xpPollHandler->insert($pollObject)) { // update the poll
xoops_error($pollObject->getHtmlErrors());
exit();
@@ -708,6 +757,18 @@
$xpOptHandler->resetCountByPollId($poll_id);
$xpPollHandler->updateCount($pollObject);
}
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
+ if (!$xpPollHandler->insert($poll_obj)) { // update the poll
+ xoops_error($poll_obj->getHtmlErrors());
+ exit();
+ }
+ if (XoopsRequest::getInt('reset', 0, 'POST')) { // reset all vote/voter counters
+ $xpOptHandler = xoops_getModuleHandler('option', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpLogHandler = xoops_getModuleHandler('log', $GLOBALS['xoopsModuleConfig']['poll_module']);
+ $xpLogHandler->deleteByPollId($poll_id);
+ $xpOptHandler->resetCountByPollId($poll_id);
+ $xpPollHandler->updateCount($poll_obj);
+ }
// old xoopspoll or umfrage or any clone from them
} else {
if (!$pollObject->store()) { // update the poll
@@ -729,7 +790,9 @@
break;
case 'log':
// new xoopspoll module
- if ($pollModuleHandler->getVar('version') >= 140) {
+ if ($pollModuleHandler->getVar('version') >= 201) {
+ Helper::getInstance()->redirect('admin/main.php?op=log&poll_id={$poll_id}', 2, _MD_NEWBB_POLL_VIEWLOG);
+ } elseif ($pollModuleHandler->getVar('version') >= 140) {
redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
// old xoopspoll or umfrage or any clone from them
} else {
diff --git a/post.php b/post.php
index d92c13ff..23f819c7 100644
--- a/post.php
+++ b/post.php
@@ -10,27 +10,31 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package newbb
* @since 4.0
* @author Taiwen Jiang
*/
use Xmf\Request;
-use XoopsModules\Newbb;
+use XoopsModules\Newbb\{
+ Uploader
+};
require_once __DIR__ . '/header.php';
-foreach ([
- 'forum',
- 'topic_id',
- 'post_id',
- 'order',
- 'pid',
- 'start',
- 'isreply',
- 'isedit',
- ] as $getint) {
+foreach (
+ [
+ 'forum',
+ 'topic_id',
+ 'post_id',
+ 'order',
+ 'pid',
+ 'start',
+ 'isreply',
+ 'isedit',
+ ] as $getint
+) {
${$getint} = Request::getInt($getint, 0, 'POST');
}
$token_valid = false;
@@ -40,11 +44,11 @@
redirect_header('index.php', 2, _MD_NEWBB_ERRORFORUM);
}
-///** @var Newbb\ForumHandler $forumHandler */
+/** @var Newbb\ForumHandler $forumHandler */
//$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
-///** @var Newbb\TopicHandler $topicHandler */
+/** @var Newbb\TopicHandler $topicHandler */
//$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
-///** @var Newbb\PostHandler $postHandler */
+/** @var Newbb\PostHandler $postHandler */
//$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
if (!empty($isedit) && $post_id > 0) {
@@ -62,7 +66,7 @@
}
if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
- // /** @var Newbb\OnlineHandler $onlineHandler */
+ /** @var Newbb\OnlineHandler $onlineHandler */
// $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online');
$onlineHandler->init($forumObject);
}
@@ -228,7 +232,7 @@
$postObject->setPostEdit($poster_name, $editwhy);
} // is reply
- // $attachments_tmp = array();
+ // $attachments_tmp = [];
// if (!empty($_POST["attachments_tmp"])) {
if (Request::getString('attachments_tmp', '', 'POST')) {
$attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true));
@@ -254,7 +258,7 @@
$maxfilesize = $forumObject->getVar('attach_maxkb') * 1024;
$uploaddir = XOOPS_CACHE_PATH;
- $uploader = new Newbb\Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']);
+ $uploader = new Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']);
if ($_FILES['userfile']['error'] > 0) {
switch ($_FILES['userfile']['error']) {
@@ -272,15 +276,13 @@
$uploader->setCheckMediaTypeByExt();
$temp = Request::getArray('xoops_upload_file', [], 'POST');
if ($uploader->fetchMedia($temp[0])) {
- $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid() . '_' : 'newbb_';
+ $prefix = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() . '_' : 'newbb_';
$uploader->setPrefix($prefix);
if (!$uploader->upload()) {
$error_message[] = $error_upload = $uploader->getErrors();
- } else {
- if (is_file($uploader->getSavedDestination())) {
- if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) {
- $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType());
- }
+ } elseif (is_file($uploader->getSavedDestination())) {
+ if (rename(XOOPS_CACHE_PATH . '/' . $uploader->getSavedFileName(), $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $uploader->getSavedFileName()))) {
+ $postObject->setAttachment($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType());
}
}
} else {
@@ -356,6 +358,7 @@
// If user checked notification box, subscribe them to the
// appropriate event; if unchecked, then unsubscribe
if (!empty($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) {
+ /** @var \XoopsNotificationHandler $notificationHandler */
$notificationHandler = xoops_getHandler('notification');
if (!Request::getInt('notify', 0, 'POST')) {
$notificationHandler->unsubscribe('thread', $postObject->getVar('topic_id'), 'new_post');
@@ -373,15 +376,15 @@
if ($uid > 0) {
$sql = 'SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_poster =' . $uid;
$ret = $GLOBALS['xoopsDB']->query($sql);
- list($topics) = $GLOBALS['xoopsDB']->fetchRow($ret);
+ [$topics] = $GLOBALS['xoopsDB']->fetchRow($ret);
$sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE approved=1 AND topic_digest > 0 AND topic_poster =' . $uid;
$ret = $GLOBALS['xoopsDB']->query($sql);
- list($digests) = $GLOBALS['xoopsDB']->fetchRow($ret);
+ [$digests] = $GLOBALS['xoopsDB']->fetchRow($ret);
$sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE approved=1 AND uid =' . $uid;
$ret = $GLOBALS['xoopsDB']->query($sql);
- list($posts, $lastpost) = $GLOBALS['xoopsDB']->fetchRow($ret);
+ [$posts, $lastpost] = $GLOBALS['xoopsDB']->fetchRow($ret);
$GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'");
}
@@ -433,7 +436,7 @@
$maxfilesize = $forumObject->getVar('attach_maxkb') * 1024;
$uploaddir = XOOPS_CACHE_PATH;
- $uploader = new Newbb\Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']);
+ $uploader = new Uploader($uploaddir, $forumObject->getVar('attach_ext'), (int)$maxfilesize, (int)$GLOBALS['xoopsModuleConfig']['max_img_width'], (int)$GLOBALS['xoopsModuleConfig']['max_img_height']);
if ($_FILES['userfile']['error'] > 0) {
switch ($_FILES['userfile']['error']) {
case 1:
@@ -450,18 +453,16 @@
$uploader->setCheckMediaTypeByExt();
$temp = Request::getArray('xoops_upload_file', [], 'POST');
if ($uploader->fetchMedia($temp[0])) {
- $prefix = is_object($GLOBALS['xoopsUser']) ? (string)$GLOBALS['xoopsUser']->uid() . '_' : 'newbb_';
+ $prefix = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() . '_' : 'newbb_';
$uploader->setPrefix($prefix);
if (!$uploader->upload()) {
$error_message[] = $error_upload = $uploader->getErrors();
- } else {
- if (is_file($uploader->getSavedDestination())) {
- $attachments_tmp[(string)time()] = [
- $uploader->getSavedFileName(),
- $uploader->getMediaName(),
- $uploader->getMediaType(),
- ];
- }
+ } elseif (is_file($uploader->getSavedDestination())) {
+ $attachments_tmp[(string)time()] = [
+ $uploader->getSavedFileName(),
+ $uploader->getMediaName(),
+ $uploader->getMediaType(),
+ ];
}
} else {
$error_message[] = $error_upload = $uploader->getErrors();
@@ -475,7 +476,7 @@
$attachments_tmp = unserialize(base64_decode(Request::getString('attachments_tmp', '', 'POST'), true));
}
- $p_subject = $myts->htmlSpecialChars(Request::getString('subject', '', 'POST'));
+ $p_subject = htmlspecialchars(Request::getString('subject', '', 'POST'));
$dosmiley = Request::getInt('dosmiley', 0, 'POST');
$dohtml = Request::getInt('dohtml', 0, 'POST');
$doxcode = Request::getInt('doxcode', 0, 'POST');
diff --git a/preloads/autoloader.php b/preloads/autoloader.php
index 8b8e4bd6..b0c8e17b 100644
--- a/preloads/autoloader.php
+++ b/preloads/autoloader.php
@@ -3,30 +3,32 @@
/**
* @see http://www.php-fig.org/psr/psr-4/examples/
*/
-spl_autoload_register(static function ($class) {
- // project-specific namespace prefix
- $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__)));
+spl_autoload_register(
+ static function ($class) {
+ // project-specific namespace prefix
+ $prefix = 'XoopsModules\\' . ucfirst(basename(dirname(__DIR__)));
- // base directory for the namespace prefix
- $baseDir = dirname(__DIR__) . '/class/';
+ // base directory for the namespace prefix
+ $baseDir = dirname(__DIR__) . '/class/';
- // does the class use the namespace prefix?
- $len = mb_strlen($prefix);
+ // does the class use the namespace prefix?
+ $len = mb_strlen($prefix);
- if (0 !== strncmp($prefix, $class, $len)) {
- return;
- }
+ if (0 !== strncmp($prefix, $class, $len)) {
+ return;
+ }
- // get the relative class name
- $relativeClass = mb_substr($class, $len);
+ // get the relative class name
+ $relativeClass = mb_substr($class, $len);
- // replace the namespace prefix with the base directory, replace namespace
- // separators with directory separators in the relative class name, append
- // with .php
- $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
+ // replace the namespace prefix with the base directory, replace namespace
+ // separators with directory separators in the relative class name, append
+ // with .php
+ $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
- // if the file exists, require it
- if (file_exists($file)) {
- require_once $file;
+ // if the file exists, require it
+ if (is_file($file)) {
+ require_once $file;
+ }
}
-});
+);
diff --git a/preloads/core.php b/preloads/core.php
index 1582d52f..749b690f 100644
--- a/preloads/core.php
+++ b/preloads/core.php
@@ -8,12 +8,12 @@
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
+
/**
* @copyright XOOPS Project (https://xoops.org)
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @author XOOPS Project
*/
-defined('XOOPS_ROOT_PATH') || die('Restricted access');
/**
* Class NewbbCorePreload
@@ -21,7 +21,6 @@
class NewbbCorePreload extends \XoopsPreloadItem
{
// to add PSR-4 autoloader
-
/**
* @param $args
*/
diff --git a/preloads/index.html b/preloads/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/preloads/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/preloads/index.php b/preloads/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/preloads/index.php
@@ -0,0 +1,3 @@
+ //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
diff --git a/ratethread.php b/ratethread.php
index a13f1b65..baac04ba 100644
--- a/ratethread.php
+++ b/ratethread.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -29,13 +29,14 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
+use Xmf\IPAddress;
use Xmf\Request;
require_once __DIR__ . '/header.php';
$ratinguser = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
$anonwaitdays = 1;
-$ip = \Xmf\IPAddress::fromRequest()->asReadable();
+$ip = IPAddress::fromRequest()->asReadable();
foreach (['topic_id', 'rate', 'forum'] as $var) {
// ${$var} = isset($_POST[$var]) ? (int)($_POST[$var]) : (isset($_GET[$var])?(int)($_GET[$var]):0);
${$var} = Request::getInt($var, Request::getInt($var, 0, 'POST'), 'GET');
diff --git a/reply.php b/reply.php
index b08b87ce..f9ac129e 100644
--- a/reply.php
+++ b/reply.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -118,16 +118,18 @@
$xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject));
-$xoopsTpl->assign([
- 'forum_id' => $forumObject->getVar('forum_id'),
- 'forum_name' => $forumObject->getVar('forum_name'),
- ]);
+$xoopsTpl->assign(
+ [
+ 'forum_id' => $forumObject->getVar('forum_id'),
+ 'forum_name' => $forumObject->getVar('forum_name'),
+ ]
+);
if ($postParentObject->getVar('uid')) {
$r_name = newbbGetUnameFromId($postParentObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']);
} else {
$poster_name = $postParentObject->getVar('poster_name');
- $r_name = empty($poster_name) ? $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']) : $poster_name;
+ $r_name = empty($poster_name) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']) : $poster_name;
}
$r_subject = $postParentObject->getVar('subject', 'E');
diff --git a/report.php b/report.php
index e80f2e5a..f4dd860c 100644
--- a/report.php
+++ b/report.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -29,6 +29,7 @@
// Project: Article Project //
// ------------------------------------------------------------------------ //
+use Xmf\IPAddress;
use Xmf\Request;
require_once __DIR__ . '/header.php';
@@ -78,11 +79,12 @@
$report->setVar('post_id', Request::getInt('post_id', 0, 'POST'));
$report->setVar('report_time', time());
$report->setVar('reporter_uid', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
- $report->setVar('reporter_ip', \Xmf\IPAddress::fromRequest()->asReadable());
+ $report->setVar('reporter_ip', IPAddress::fromRequest()->asReadable());
$report->setVar('report_result', 0);
$report->setVar('report_memo', '');
- if ($reportId = $reportHandler->insert($report)) {
+ $reportId = $reportHandler->insert($report);
+ if ($reportId) {
// $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
if (empty($forum)) {
}
@@ -159,7 +161,7 @@
$r_name = newbbGetUnameFromId($postObject->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname']);
} else {
$poster_name = $postObject->getVar('poster_name');
- $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : $myts->htmlSpecialChars($poster_name);
+ $r_name = empty($poster_name) ? $GLOBALS['xoopsConfig']['anonymous'] : htmlspecialchars($poster_name);
}
$r_content = _MD_NEWBB_SUBJECTC . ' ' . $r_subject . ' ';
$r_content .= _MD_NEWBB_BY . ' ' . $r_name . ' ' . _MD_NEWBB_ON . ' ' . $r_date . ' ';
diff --git a/rss.php b/rss.php
index 1be0e969..9e733190 100644
--- a/rss.php
+++ b/rss.php
@@ -2,8 +2,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -47,7 +47,7 @@
$category = Request::getInt('c', 0, 'GET');
$forumSet = Request::getString('f', '', 'GET');
if ('' !== $forumSet) {
- $forums = array_map('intval', array_map('trim', explode('|', $forumSet)));
+ $forums = array_map('\intval', array_map('\trim', explode('|', $forumSet)));
}
///** @var Newbb\ForumHandler $forumHandler */
@@ -182,7 +182,7 @@
if (!empty($users[$topic['uid']])) {
$topic['uname'] = $users[$topic['uid']];
} else {
- $topic['uname'] = $topic['poster_name'] ? $myts->htmlSpecialChars($topic['poster_name']) : $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
+ $topic['uname'] = $topic['poster_name'] ? htmlspecialchars($topic['poster_name']) : htmlspecialchars($GLOBALS['xoopsConfig']['anonymous']);
}
$description = $topic['forum_name'] . '::';
$topic['topic_subject'] = empty($type_list[$topic['type_id']]) ? '' : '[' . $type_list[$topic['type_id']] . '] ';
diff --git a/search.php b/search.php
index 91bef170..e3b5c666 100644
--- a/search.php
+++ b/search.php
@@ -7,8 +7,8 @@
//
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
-// Copyright (c) 2000-2016 XOOPS.org //
-// //
+// Copyright (c) 2000-2020 XOOPS.org //
+// //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -94,7 +94,7 @@
if (empty($forum) || 'all' === $forum || (is_array($forum) && in_array('all', $forum))) {
$forum = [];
} elseif (!is_array($forum)) {
- $forum = array_map('intval', explode('|', $forum));
+ $forum = array_map('\intval', explode('|', $forum));
}
$next_search['forum'] = implode('|', $forum);
// START irmtfan topic search
@@ -179,7 +179,7 @@
$results = newbb_search($queries, $andor, $limit, $start, $uid, $forum, $sortby, $searchin, $criteriaExtra);
} // irmtfan $criteriaExtra
- $search_info_keywords = Highlighter::apply($myts->htmlSpecialChars($term, ENT_QUOTES), implode(' ', $queries), '', ' ');
+ $search_info_keywords = Highlighter::apply(htmlspecialchars($term, ENT_QUOTES), implode(' ', $queries), '', ' ');
$num_results = count($results);
if ($num_results < 1) {
$xoopsTpl->assign('lang_nomatch', _SR_NOMATCH);
@@ -197,15 +197,18 @@
++$skipresults;
continue;
}
- $xoopsTpl->append('results', [
- 'forum_name' => $row['forum_name'],
- 'forum_link' => $row['forum_link'],
- 'link' => $row['link'],
- 'title' => $post_subject_select,
- 'poster' => $row['poster'],
- 'post_time' => formatTimestamp($row['time'], 'm'),
- 'post_text' => $post_text_select,
- ]);
+ $xoopsTpl->append(
+ 'results',
+ [
+ 'forum_name' => $row['forum_name'],
+ 'forum_link' => $row['forum_link'],
+ 'link' => $row['link'],
+ 'title' => $post_subject_select,
+ 'poster' => $row['poster'],
+ 'post_time' => formatTimestamp($row['time'], 'm'),
+ 'post_text' => $post_text_select,
+ ]
+ );
}
unset($results);
@@ -255,7 +258,7 @@
if ($search_info) {
$search_info .= ' ';
}
- $search_info .= _MD_NEWBB_USERNAME . ': ' . $myts->htmlSpecialChars($search_username);
+ $search_info .= _MD_NEWBB_USERNAME . ': ' . htmlspecialchars($search_username);
}
// add num_results
$search_info .= ' ' . sprintf(_SR_SHOWING, $start + 1, $start + $num_results);
diff --git a/seo.php b/seo.php
index 59dd80a5..6012c7d3 100644
--- a/seo.php
+++ b/seo.php
@@ -29,12 +29,12 @@
if (!empty($seoOp) && !empty($seoMap[$seoOp]) && in_array($seoOp, $seos)) {
// module specific dispatching logic, other module must implement as
// per their requirements.
- $ori_self = Request::getString('PHP_SELF', '', 'SERVER');
+ $ori_self = Request::getString('SCRIPT_NAME', '', 'SERVER');
$ori_self = explode('modules/newbb', $ori_self);
$newUrl = $ori_self[0] . 'modules/newbb/' . $seoMap[$seoOp];
- $_ENV['PHP_SELF'] = $newUrl;
+ $_ENV['SCRIPT_NAME'] = $newUrl;
+ $_SERVER['SCRIPT_NAME'] = $newUrl;
$_SERVER['SCRIPT_NAME'] = $newUrl;
- $_SERVER['PHP_SELF'] = $newUrl;
switch ($seoOp) {
case 'c':
$_SERVER['REQUEST_URI'] = $newUrl . '?cat=' . $seoArg;
diff --git a/seo_url.php b/seo_url.php
index ced2036a..c9361b94 100644
--- a/seo_url.php
+++ b/seo_url.php
@@ -1,7 +1,9 @@
getHandler('Topic');
+ $topicsHandler = Helper::getInstance()->getHandler('Topic');
$criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '='));
$fields = ['topic_title'];
$ret0 = $topicsHandler->getAll($criteria, $fields, false);
@@ -266,8 +270,8 @@ function forum_seo_post($_cat_id)
}
/**
- * @param string $title
- * @param bool $withExt
+ * @param string $title
+ * @param bool $withExt
* @return mixed|string
*/
function forum_seo_title($title = '', $withExt = true)
diff --git a/sql/index.html b/sql/index.html
deleted file mode 100644
index 2c5cdd3f..00000000
--- a/sql/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/sql/index.php b/sql/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/sql/index.php
@@ -0,0 +1,3 @@
+history.go(-1);
\ No newline at end of file
diff --git a/templates/blocks/index.php b/templates/blocks/index.php
new file mode 100644
index 00000000..2ea9b7d9
--- /dev/null
+++ b/templates/blocks/index.php
@@ -0,0 +1,3 @@
+
<{foreach item=topic from=$block.topics}>
">
-
+ <{* irmtfan remove hardcoded html in URLs *}>
<{$topic.forum_name}>
<{$topic.title}>
<{$topic.replies}>
<{$topic.views}>
-
+ <{* irmtfan hardcode removed align="right" *}>
<{$topic.time}> <{$topic.topic_poster}> <{$topic.topic_page_jump}>
<{/foreach}>
@@ -27,10 +27,10 @@
<{foreach item=topic from=$block.topics}>
">
-
+ <{* irmtfan remove hardcoded html in URLs *}>
<{$topic.title}>
<{$topic.replies}>
-
+ <{* irmtfan hardcode removed align="right" *}>
<{$topic.time}> <{$topic.topic_poster}> <{$topic.topic_page_jump}>
<{/foreach}>
@@ -39,7 +39,7 @@
<{foreach item=topic from=$block.topics}>
">
-
+ <{* irmtfan remove hardcoded html in URLs *}>
<{$topic.title}>
<{/foreach}>
@@ -49,9 +49,9 @@
<{if $block.indexNav}>
-
+ <{* irmtfan hardcode removed style="text-align:right; padding: 5px;" *}>