@@ -17,75 +17,75 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_READ_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_READ')) { |
20 | - define('NEWBB_FUNCTIONS_READ', 1); |
|
20 | + define('NEWBB_FUNCTIONS_READ', 1); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param $type |
|
24 | - * @param $item_id |
|
25 | - * @param $post_id |
|
26 | - * @param null $uid |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - function newbbSetRead($type, $item_id, $post_id, $uid = null) |
|
30 | - { |
|
31 | - /** @var Newbb\ReadHandler $readHandler */ |
|
32 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
22 | + /** |
|
23 | + * @param $type |
|
24 | + * @param $item_id |
|
25 | + * @param $post_id |
|
26 | + * @param null $uid |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + function newbbSetRead($type, $item_id, $post_id, $uid = null) |
|
30 | + { |
|
31 | + /** @var Newbb\ReadHandler $readHandler */ |
|
32 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
33 | 33 | |
34 | - return $readHandler->setRead($item_id, $post_id, $uid); |
|
35 | - } |
|
34 | + return $readHandler->setRead($item_id, $post_id, $uid); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param $type |
|
39 | - * @param $item_id |
|
40 | - * @param null $uid |
|
41 | - * @return mixed |
|
42 | - */ |
|
43 | - function newbbGetRead($type, $item_id, $uid = null) |
|
44 | - { |
|
45 | - /** @var Newbb\ReadHandler $readHandler */ |
|
46 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
37 | + /** |
|
38 | + * @param $type |
|
39 | + * @param $item_id |
|
40 | + * @param null $uid |
|
41 | + * @return mixed |
|
42 | + */ |
|
43 | + function newbbGetRead($type, $item_id, $uid = null) |
|
44 | + { |
|
45 | + /** @var Newbb\ReadHandler $readHandler */ |
|
46 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
47 | 47 | |
48 | - return $readHandler->getRead($item_id, $uid); |
|
49 | - } |
|
48 | + return $readHandler->getRead($item_id, $uid); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param int $status |
|
53 | - * @param null $uid |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - function newbbSetReadForum($status = 0, $uid = null) |
|
57 | - { |
|
58 | - /** @var Newbb\ReadForumHandler $readHandler */ |
|
59 | - $readForumHandler = Newbb\Helper::getInstance()->getHandler('Readforum'); |
|
51 | + /** |
|
52 | + * @param int $status |
|
53 | + * @param null $uid |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + function newbbSetReadForum($status = 0, $uid = null) |
|
57 | + { |
|
58 | + /** @var Newbb\ReadForumHandler $readHandler */ |
|
59 | + $readForumHandler = Newbb\Helper::getInstance()->getHandler('Readforum'); |
|
60 | 60 | |
61 | - return $readForumHandler->setReadItems($status, $uid); |
|
62 | - } |
|
61 | + return $readForumHandler->setReadItems($status, $uid); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param int $status |
|
66 | - * @param int $forum_id |
|
67 | - * @param null $uid |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) |
|
71 | - { |
|
72 | - /** @var Newbb\ReadtopicHandler $readHandler */ |
|
73 | - $readTopicHandler = Newbb\Helper::getInstance()->getHandler('Readtopic'); |
|
64 | + /** |
|
65 | + * @param int $status |
|
66 | + * @param int $forum_id |
|
67 | + * @param null $uid |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + function newbbSetReadTopic($status = 0, $forum_id = 0, $uid = null) |
|
71 | + { |
|
72 | + /** @var Newbb\ReadtopicHandler $readHandler */ |
|
73 | + $readTopicHandler = Newbb\Helper::getInstance()->getHandler('Readtopic'); |
|
74 | 74 | |
75 | - return $readTopicHandler->setReadItems($status, $forum_id, $uid); |
|
76 | - } |
|
75 | + return $readTopicHandler->setReadItems($status, $forum_id, $uid); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param $type |
|
80 | - * @param $items |
|
81 | - * @param null $uid |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - function newbbIsRead($type, &$items, $uid = null) |
|
85 | - { |
|
86 | - /** @var Newbb\ReadHandler $readHandler */ |
|
87 | - $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
78 | + /** |
|
79 | + * @param $type |
|
80 | + * @param $items |
|
81 | + * @param null $uid |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + function newbbIsRead($type, &$items, $uid = null) |
|
85 | + { |
|
86 | + /** @var Newbb\ReadHandler $readHandler */ |
|
87 | + $readHandler = Newbb\Helper::getInstance()->getHandler('Read'.$type); |
|
88 | 88 | |
89 | - return $readHandler->isReadItems($items, $uid); |
|
90 | - } |
|
89 | + return $readHandler->isReadItems($items, $uid); |
|
90 | + } |
|
91 | 91 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_READ_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_READ')) { |
@@ -15,12 +15,12 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS')) { |
18 | - define('NEWBB_FUNCTIONS', 1); |
|
18 | + define('NEWBB_FUNCTIONS', 1); |
|
19 | 19 | |
20 | - require_once __DIR__ . '/functions.image.php'; |
|
21 | - require_once __DIR__ . '/functions.user.php'; |
|
22 | - require_once __DIR__ . '/functions.render.php'; |
|
23 | - require_once __DIR__ . '/functions.forum.php'; |
|
24 | - require_once __DIR__ . '/functions.session.php'; |
|
25 | - require_once __DIR__ . '/functions.stats.php'; |
|
20 | + require_once __DIR__ . '/functions.image.php'; |
|
21 | + require_once __DIR__ . '/functions.user.php'; |
|
22 | + require_once __DIR__ . '/functions.render.php'; |
|
23 | + require_once __DIR__ . '/functions.forum.php'; |
|
24 | + require_once __DIR__ . '/functions.session.php'; |
|
25 | + require_once __DIR__ . '/functions.stats.php'; |
|
26 | 26 | } |
@@ -11,16 +11,16 @@ |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS')) { |
18 | 18 | define('NEWBB_FUNCTIONS', 1); |
19 | 19 | |
20 | - require_once __DIR__ . '/functions.image.php'; |
|
21 | - require_once __DIR__ . '/functions.user.php'; |
|
22 | - require_once __DIR__ . '/functions.render.php'; |
|
23 | - require_once __DIR__ . '/functions.forum.php'; |
|
24 | - require_once __DIR__ . '/functions.session.php'; |
|
25 | - require_once __DIR__ . '/functions.stats.php'; |
|
20 | + require_once __DIR__.'/functions.image.php'; |
|
21 | + require_once __DIR__.'/functions.user.php'; |
|
22 | + require_once __DIR__.'/functions.render.php'; |
|
23 | + require_once __DIR__.'/functions.forum.php'; |
|
24 | + require_once __DIR__.'/functions.session.php'; |
|
25 | + require_once __DIR__.'/functions.stats.php'; |
|
26 | 26 | } |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function newbbGetUnameFromIds($uid, $usereal = 0, $linked = false) |
31 | 31 | { |
32 | - xoops_load('xoopsuserutility'); |
|
33 | - $ids = \XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); |
|
32 | + xoops_load('xoopsuserutility'); |
|
33 | + $ids = \XoopsUserUtility::getUnameFromIds($uid, $usereal, $linked); |
|
34 | 34 | |
35 | - return $ids; |
|
35 | + return $ids; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | function newbbGetUnameFromId($uid, $usereal = 0, $linked = false) |
45 | 45 | { |
46 | - xoops_load('xoopsuserutility'); |
|
46 | + xoops_load('xoopsuserutility'); |
|
47 | 47 | |
48 | - return \XoopsUserUtility::getUnameFromId($uid, $usereal, $linked); |
|
48 | + return \XoopsUserUtility::getUnameFromId($uid, $usereal, $linked); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -57,41 +57,41 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function newbbIsAdministrator($user = -1, $mid = 0) |
59 | 59 | { |
60 | - global $xoopsModule; |
|
61 | - |
|
62 | - if (is_numeric($user) && -1 == $user) { |
|
63 | - $user = $GLOBALS['xoopsUser']; |
|
64 | - } |
|
65 | - if (!is_object($user) && (int)$user < 1) { |
|
66 | - return false; |
|
67 | - } |
|
68 | - $uid = is_object($user) ? $user->getVar('uid') : (int)$user; |
|
69 | - |
|
70 | - if (!$mid) { |
|
71 | - if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname', 'n')) { |
|
72 | - $mid = $xoopsModule->getVar('mid', 'n'); |
|
73 | - } else { |
|
74 | - /** @var \XoopsModuleHandler $moduleHandler */ |
|
75 | - $moduleHandler = xoops_getHandler('module'); |
|
76 | - $newbb_module = $moduleHandler->getByDirname('newbb'); |
|
77 | - $mid = $newbb_module->getVar('mid', 'n'); |
|
78 | - unset($newbb_module); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - if (is_object($xoopsModule) && is_object($GLOBALS['xoopsUser']) && $mid == $xoopsModule->getVar('mid', 'n') |
|
83 | - && $uid == $GLOBALS['xoopsUser']->getVar('uid', 'n')) { |
|
84 | - return $GLOBALS['xoopsUserIsAdmin']; |
|
85 | - } |
|
86 | - |
|
87 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
88 | - $memberHandler = xoops_getHandler('member'); |
|
89 | - $groups = $memberHandler->getGroupsByUser($uid); |
|
90 | - |
|
91 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
92 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
93 | - |
|
94 | - return $grouppermHandler->checkRight('module_admin', $mid, $groups); |
|
60 | + global $xoopsModule; |
|
61 | + |
|
62 | + if (is_numeric($user) && -1 == $user) { |
|
63 | + $user = $GLOBALS['xoopsUser']; |
|
64 | + } |
|
65 | + if (!is_object($user) && (int)$user < 1) { |
|
66 | + return false; |
|
67 | + } |
|
68 | + $uid = is_object($user) ? $user->getVar('uid') : (int)$user; |
|
69 | + |
|
70 | + if (!$mid) { |
|
71 | + if (is_object($xoopsModule) && 'newbb' === $xoopsModule->getVar('dirname', 'n')) { |
|
72 | + $mid = $xoopsModule->getVar('mid', 'n'); |
|
73 | + } else { |
|
74 | + /** @var \XoopsModuleHandler $moduleHandler */ |
|
75 | + $moduleHandler = xoops_getHandler('module'); |
|
76 | + $newbb_module = $moduleHandler->getByDirname('newbb'); |
|
77 | + $mid = $newbb_module->getVar('mid', 'n'); |
|
78 | + unset($newbb_module); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + if (is_object($xoopsModule) && is_object($GLOBALS['xoopsUser']) && $mid == $xoopsModule->getVar('mid', 'n') |
|
83 | + && $uid == $GLOBALS['xoopsUser']->getVar('uid', 'n')) { |
|
84 | + return $GLOBALS['xoopsUserIsAdmin']; |
|
85 | + } |
|
86 | + |
|
87 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
88 | + $memberHandler = xoops_getHandler('member'); |
|
89 | + $groups = $memberHandler->getGroupsByUser($uid); |
|
90 | + |
|
91 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
92 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
93 | + |
|
94 | + return $grouppermHandler->checkRight('module_admin', $mid, $groups); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,24 +103,24 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function newbbIsModerator(&$forum, $user = -1) |
105 | 105 | { |
106 | - if (!is_object($forum)) { |
|
107 | - $forum_id = (int)$forum; |
|
108 | - if (0 == $forum_id) { |
|
109 | - return false; |
|
110 | - } |
|
111 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
112 | - $forum = $forumHandler->get($forum_id); |
|
113 | - } |
|
114 | - |
|
115 | - if (is_numeric($user) && -1 == $user) { |
|
116 | - $user = $GLOBALS['xoopsUser']; |
|
117 | - } |
|
118 | - if (!is_object($user) && (int)$user < 1) { |
|
119 | - return false; |
|
120 | - } |
|
121 | - $uid = is_object($user) ? $user->getVar('uid', 'n') : (int)$user; |
|
122 | - |
|
123 | - return in_array($uid, $forum->getVar('forum_moderator'), true); |
|
106 | + if (!is_object($forum)) { |
|
107 | + $forum_id = (int)$forum; |
|
108 | + if (0 == $forum_id) { |
|
109 | + return false; |
|
110 | + } |
|
111 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
112 | + $forum = $forumHandler->get($forum_id); |
|
113 | + } |
|
114 | + |
|
115 | + if (is_numeric($user) && -1 == $user) { |
|
116 | + $user = $GLOBALS['xoopsUser']; |
|
117 | + } |
|
118 | + if (!is_object($user) && (int)$user < 1) { |
|
119 | + return false; |
|
120 | + } |
|
121 | + $uid = is_object($user) ? $user->getVar('uid', 'n') : (int)$user; |
|
122 | + |
|
123 | + return in_array($uid, $forum->getVar('forum_moderator'), true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -131,31 +131,31 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function newbbIsAdmin($forum = 0) |
133 | 133 | { |
134 | - global $xoopsModule; |
|
135 | - static $_cachedModerators; |
|
136 | - |
|
137 | - if (empty($forum)) { |
|
138 | - return $GLOBALS['xoopsUserIsAdmin']; |
|
139 | - } |
|
140 | - |
|
141 | - if (!is_object($GLOBALS['xoopsUser'])) { |
|
142 | - return false; |
|
143 | - } |
|
144 | - |
|
145 | - if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $xoopsModule->getVar('dirname')) { |
|
146 | - return true; |
|
147 | - } |
|
148 | - |
|
149 | - $cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum; |
|
150 | - if (!isset($_cachedModerators[$cache_id])) { |
|
151 | - if (!is_object($forum)) { |
|
152 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
153 | - $forum = $forumHandler->get((int)$forum); |
|
154 | - } |
|
155 | - $_cachedModerators[$cache_id] = $forum->getVar('forum_moderator'); |
|
156 | - } |
|
157 | - |
|
158 | - return in_array($GLOBALS['xoopsUser']->getVar('uid'), $_cachedModerators[$cache_id]); |
|
134 | + global $xoopsModule; |
|
135 | + static $_cachedModerators; |
|
136 | + |
|
137 | + if (empty($forum)) { |
|
138 | + return $GLOBALS['xoopsUserIsAdmin']; |
|
139 | + } |
|
140 | + |
|
141 | + if (!is_object($GLOBALS['xoopsUser'])) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + |
|
145 | + if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $xoopsModule->getVar('dirname')) { |
|
146 | + return true; |
|
147 | + } |
|
148 | + |
|
149 | + $cache_id = is_object($forum) ? $forum->getVar('forum_id', 'n') : (int)$forum; |
|
150 | + if (!isset($_cachedModerators[$cache_id])) { |
|
151 | + if (!is_object($forum)) { |
|
152 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
153 | + $forum = $forumHandler->get((int)$forum); |
|
154 | + } |
|
155 | + $_cachedModerators[$cache_id] = $forum->getVar('forum_moderator'); |
|
156 | + } |
|
157 | + |
|
158 | + return in_array($GLOBALS['xoopsUser']->getVar('uid'), $_cachedModerators[$cache_id]); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /* use hardcoded DB query to save queries */ |
@@ -165,47 +165,47 @@ discard block |
||
165 | 165 | */ |
166 | 166 | function newbbIsModuleAdministrators(array $uid = []) |
167 | 167 | { |
168 | - global $xoopsModule; |
|
169 | - $module_administrators = []; |
|
170 | - |
|
171 | - // $xoopsMembershipHandler = xoops_getHandler('membership'); |
|
172 | - // $xoopsMembershipTable = $xoopsMembershipHandler->table; |
|
173 | - |
|
174 | - /** @var \XoopsMembershipHandler $xoopsMembershipHandler */ |
|
175 | - $xoopsMembershipHandler = xoops_getHandler('membership'); |
|
176 | - $xoopsMembershipTable = $xoopsMembershipHandler->table; |
|
177 | - /** @var \XoopsGroupPermHandler $xoopsGroupPermHandler */ |
|
178 | - $xoopsGroupPermHandler = xoops_getHandler('groupperm'); |
|
179 | - $xoopsGroupPermTable = $xoopsGroupPermHandler->table; |
|
180 | - |
|
181 | - if (!(bool)$uid) { |
|
182 | - return $module_administrators; |
|
183 | - } |
|
184 | - $mid = $xoopsModule->getVar('mid'); |
|
185 | - |
|
186 | - $sql = 'SELECT COUNT(l.groupid) AS count, l.uid FROM ' |
|
187 | - . $xoopsMembershipTable |
|
188 | - . ' AS l' |
|
189 | - . ' LEFT JOIN ' |
|
190 | - . $xoopsGroupPermTable |
|
191 | - . ' AS p ON p.gperm_groupid=l.groupid' |
|
192 | - . ' WHERE l.uid IN (' |
|
193 | - . implode(', ', array_map('intval', $uid)) |
|
194 | - . ')' |
|
195 | - . " AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '" |
|
196 | - . (int)$mid |
|
197 | - . "'" |
|
198 | - . ' GROUP BY l.uid'; |
|
199 | - |
|
200 | - if ($result = $GLOBALS['xoopsDB']->query($sql)) { |
|
201 | - while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
202 | - if (!empty($myrow['count'])) { |
|
203 | - $module_administrators[] = $myrow['uid']; |
|
204 | - } |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - return $module_administrators; |
|
168 | + global $xoopsModule; |
|
169 | + $module_administrators = []; |
|
170 | + |
|
171 | + // $xoopsMembershipHandler = xoops_getHandler('membership'); |
|
172 | + // $xoopsMembershipTable = $xoopsMembershipHandler->table; |
|
173 | + |
|
174 | + /** @var \XoopsMembershipHandler $xoopsMembershipHandler */ |
|
175 | + $xoopsMembershipHandler = xoops_getHandler('membership'); |
|
176 | + $xoopsMembershipTable = $xoopsMembershipHandler->table; |
|
177 | + /** @var \XoopsGroupPermHandler $xoopsGroupPermHandler */ |
|
178 | + $xoopsGroupPermHandler = xoops_getHandler('groupperm'); |
|
179 | + $xoopsGroupPermTable = $xoopsGroupPermHandler->table; |
|
180 | + |
|
181 | + if (!(bool)$uid) { |
|
182 | + return $module_administrators; |
|
183 | + } |
|
184 | + $mid = $xoopsModule->getVar('mid'); |
|
185 | + |
|
186 | + $sql = 'SELECT COUNT(l.groupid) AS count, l.uid FROM ' |
|
187 | + . $xoopsMembershipTable |
|
188 | + . ' AS l' |
|
189 | + . ' LEFT JOIN ' |
|
190 | + . $xoopsGroupPermTable |
|
191 | + . ' AS p ON p.gperm_groupid=l.groupid' |
|
192 | + . ' WHERE l.uid IN (' |
|
193 | + . implode(', ', array_map('intval', $uid)) |
|
194 | + . ')' |
|
195 | + . " AND p.gperm_modid = '1' AND p.gperm_name = 'module_admin' AND p.gperm_itemid = '" |
|
196 | + . (int)$mid |
|
197 | + . "'" |
|
198 | + . ' GROUP BY l.uid'; |
|
199 | + |
|
200 | + if ($result = $GLOBALS['xoopsDB']->query($sql)) { |
|
201 | + while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
202 | + if (!empty($myrow['count'])) { |
|
203 | + $module_administrators[] = $myrow['uid']; |
|
204 | + } |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + return $module_administrators; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /* use hardcoded DB query to save queries */ |
@@ -216,22 +216,22 @@ discard block |
||
216 | 216 | */ |
217 | 217 | function newbbIsForumModerators(array $uid = [], $mid = 0) |
218 | 218 | { |
219 | - $forum_moderators = []; |
|
220 | - |
|
221 | - if (!(bool)$uid) { |
|
222 | - return $forum_moderators; |
|
223 | - } |
|
224 | - |
|
225 | - $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
226 | - if ($result = $GLOBALS['xoopsDB']->query($sql)) { |
|
227 | - while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
228 | - if (empty($myrow['forum_moderator'])) { |
|
229 | - continue; |
|
230 | - } |
|
231 | - $forum_moderators = array_merge($forum_moderators, unserialize($myrow['forum_moderator'])); |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - return array_unique($forum_moderators); |
|
219 | + $forum_moderators = []; |
|
220 | + |
|
221 | + if (!(bool)$uid) { |
|
222 | + return $forum_moderators; |
|
223 | + } |
|
224 | + |
|
225 | + $sql = 'SELECT forum_moderator FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
226 | + if ($result = $GLOBALS['xoopsDB']->query($sql)) { |
|
227 | + while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
228 | + if (empty($myrow['forum_moderator'])) { |
|
229 | + continue; |
|
230 | + } |
|
231 | + $forum_moderators = array_merge($forum_moderators, unserialize($myrow['forum_moderator'])); |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + return array_unique($forum_moderators); |
|
236 | 236 | } |
237 | 237 | //ENDIF; |
@@ -17,45 +17,45 @@ |
||
17 | 17 | define('NEWBB_FUNCTIONS_RECON_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_RECON')) { |
20 | - define('NEWBB_FUNCTIONS_RECON', 1); |
|
20 | + define('NEWBB_FUNCTIONS_RECON', 1); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param null $type |
|
24 | - * @return bool |
|
25 | - */ |
|
26 | - function newbbSynchronization($type = null) |
|
27 | - { |
|
28 | - $allTypes = [ |
|
29 | - 'category', |
|
30 | - 'forum', |
|
31 | - 'topic', |
|
32 | - 'post', |
|
33 | - 'report', |
|
34 | - 'rate', |
|
35 | - 'moderate', |
|
36 | - 'readtopic', |
|
37 | - 'readforum', |
|
38 | - 'stats' |
|
39 | - ]; |
|
40 | - $type = []; |
|
41 | - $type = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]); |
|
42 | - foreach ($type as $item) { |
|
43 | - $handler = Newbb\Helper::getInstance()->getHandler($item); |
|
44 | - if ('stats' !== $item) { |
|
45 | - $handler->synchronization(); |
|
46 | - } else { |
|
47 | - $handler->reset(); |
|
48 | - } |
|
22 | + /** |
|
23 | + * @param null $type |
|
24 | + * @return bool |
|
25 | + */ |
|
26 | + function newbbSynchronization($type = null) |
|
27 | + { |
|
28 | + $allTypes = [ |
|
29 | + 'category', |
|
30 | + 'forum', |
|
31 | + 'topic', |
|
32 | + 'post', |
|
33 | + 'report', |
|
34 | + 'rate', |
|
35 | + 'moderate', |
|
36 | + 'readtopic', |
|
37 | + 'readforum', |
|
38 | + 'stats' |
|
39 | + ]; |
|
40 | + $type = []; |
|
41 | + $type = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]); |
|
42 | + foreach ($type as $item) { |
|
43 | + $handler = Newbb\Helper::getInstance()->getHandler($item); |
|
44 | + if ('stats' !== $item) { |
|
45 | + $handler->synchronization(); |
|
46 | + } else { |
|
47 | + $handler->reset(); |
|
48 | + } |
|
49 | 49 | |
50 | - if (method_exists($handler, 'cleanExpires')) { |
|
51 | - $handler->cleanExpires(); |
|
52 | - } |
|
53 | - if (method_exists($handler, 'clearGarbage')) { |
|
54 | - $handler->clearGarbage(); |
|
55 | - } |
|
56 | - unset($handler); |
|
57 | - } |
|
50 | + if (method_exists($handler, 'cleanExpires')) { |
|
51 | + $handler->cleanExpires(); |
|
52 | + } |
|
53 | + if (method_exists($handler, 'clearGarbage')) { |
|
54 | + $handler->clearGarbage(); |
|
55 | + } |
|
56 | + unset($handler); |
|
57 | + } |
|
58 | 58 | |
59 | - return true; |
|
60 | - } |
|
59 | + return true; |
|
60 | + } |
|
61 | 61 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
15 | 15 | |
16 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
16 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
17 | 17 | define('NEWBB_FUNCTIONS_RECON_LOADED', true); |
18 | 18 | |
19 | 19 | if (!defined('NEWBB_FUNCTIONS_RECON')) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | use XoopsModules\Newbb; |
34 | 34 | |
35 | 35 | if (defined('XOOPS_MODULE_NEWBB_FUCTIONS')) { |
36 | - exit(); |
|
36 | + exit(); |
|
37 | 37 | } |
38 | 38 | define('XOOPS_MODULE_NEWBB_FUCTIONS', 1); |
39 | 39 | |
@@ -46,46 +46,46 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function xoops_module_update_newbb(\XoopsModule $module, $oldversion = null) |
48 | 48 | { |
49 | - $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
50 | - $cacheHelper->delete('config'); |
|
51 | - |
|
52 | - $newbbConfig = newbbLoadConfig(); |
|
53 | - |
|
54 | - // remove old html template files |
|
55 | - // create an array with all folders, and then run this once |
|
56 | - |
|
57 | - $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/'); |
|
58 | - $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
59 | - foreach ($template_list as $k => $v) { |
|
60 | - $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
61 | - if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
62 | - @unlink($templateDirectory . $v); |
|
63 | - } |
|
64 | - } |
|
65 | - $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks'); |
|
66 | - $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
67 | - foreach ($template_list as $k => $v) { |
|
68 | - $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
69 | - if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
70 | - @unlink($templateDirectory . $v); |
|
71 | - } |
|
72 | - } |
|
73 | - // Load class XoopsFile |
|
74 | - xoops_load('xoopsfile'); |
|
75 | - //remove /images directory |
|
76 | - $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/'); |
|
77 | - $folderHandler = \XoopsFile::getHandler('folder', $imagesDirectory); |
|
78 | - $folderHandler->delete($imagesDirectory); |
|
79 | - |
|
80 | - //remove old changelogs |
|
81 | - array_map('unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt')); |
|
82 | - |
|
83 | - if (!empty($newbbConfig['syncOnUpdate'])) { |
|
84 | - require_once dirname(__DIR__) . '/include/functions.recon.php'; |
|
85 | - newbbSynchronization(); |
|
86 | - } |
|
87 | - |
|
88 | - return true; |
|
49 | + $cacheHelper = new \Xmf\Module\Helper\Cache('newbb'); |
|
50 | + $cacheHelper->delete('config'); |
|
51 | + |
|
52 | + $newbbConfig = newbbLoadConfig(); |
|
53 | + |
|
54 | + // remove old html template files |
|
55 | + // create an array with all folders, and then run this once |
|
56 | + |
|
57 | + $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/'); |
|
58 | + $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
59 | + foreach ($template_list as $k => $v) { |
|
60 | + $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
61 | + if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
62 | + @unlink($templateDirectory . $v); |
|
63 | + } |
|
64 | + } |
|
65 | + $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks'); |
|
66 | + $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
|
67 | + foreach ($template_list as $k => $v) { |
|
68 | + $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
69 | + if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
|
70 | + @unlink($templateDirectory . $v); |
|
71 | + } |
|
72 | + } |
|
73 | + // Load class XoopsFile |
|
74 | + xoops_load('xoopsfile'); |
|
75 | + //remove /images directory |
|
76 | + $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/'); |
|
77 | + $folderHandler = \XoopsFile::getHandler('folder', $imagesDirectory); |
|
78 | + $folderHandler->delete($imagesDirectory); |
|
79 | + |
|
80 | + //remove old changelogs |
|
81 | + array_map('unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt')); |
|
82 | + |
|
83 | + if (!empty($newbbConfig['syncOnUpdate'])) { |
|
84 | + require_once dirname(__DIR__) . '/include/functions.recon.php'; |
|
85 | + newbbSynchronization(); |
|
86 | + } |
|
87 | + |
|
88 | + return true; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function xoops_module_pre_update_newbb(\XoopsModule $module) |
96 | 96 | { |
97 | - XoopsLoad::load('migrate', 'newbb'); |
|
98 | - $newbbMigrate = new Newbb\Migrate(); |
|
99 | - $newbbMigrate->synchronizeSchema(); |
|
97 | + XoopsLoad::load('migrate', 'newbb'); |
|
98 | + $newbbMigrate = new Newbb\Migrate(); |
|
99 | + $newbbMigrate->synchronizeSchema(); |
|
100 | 100 | |
101 | - return true; |
|
101 | + return true; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function xoops_module_pre_install_newbb(\XoopsModule $module) |
109 | 109 | { |
110 | - $mod_tables =& $module->getInfo('tables'); |
|
111 | - foreach ($mod_tables as $table) { |
|
112 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
113 | - } |
|
110 | + $mod_tables =& $module->getInfo('tables'); |
|
111 | + foreach ($mod_tables as $table) { |
|
112 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
113 | + } |
|
114 | 114 | |
115 | - return true; |
|
115 | + return true; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -121,85 +121,85 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function xoops_module_install_newbb(\XoopsModule $module) |
123 | 123 | { |
124 | - /* Create a test category */ |
|
125 | - /** @var Newbb\CategoryHandler $categoryHandler */ |
|
126 | - $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
127 | - $category = $categoryHandler->create(); |
|
128 | - $category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true); |
|
129 | - $category->setVar('cat_image', '', true); |
|
130 | - $category->setVar('cat_description', _MI_NEWBB_INSTALL_CAT_DESC, true); |
|
131 | - $category->setVar('cat_url', 'https://xoops.org XOOPS Project', true); |
|
132 | - if (!$cat_id = $categoryHandler->insert($category)) { |
|
133 | - return true; |
|
134 | - } |
|
135 | - |
|
136 | - /* Create a forum for test */ |
|
137 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
138 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
139 | - $forum = $forumHandler->create(); |
|
140 | - $forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true); |
|
141 | - $forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true); |
|
142 | - $forum->setVar('forum_moderator', []); |
|
143 | - $forum->setVar('parent_forum', 0); |
|
144 | - $forum->setVar('cat_id', $cat_id); |
|
145 | - $forum->setVar('attach_maxkb', 100); |
|
146 | - $forum->setVar('attach_ext', 'zip|jpg|gif|png'); |
|
147 | - $forum->setVar('hot_threshold', 20); |
|
148 | - $forum_id = $forumHandler->insert($forum); |
|
149 | - |
|
150 | - /* Set corresponding permissions for the category and the forum */ |
|
151 | - $module_id = $module->getVar('mid'); |
|
152 | - /** @var XoopsGroupPermHandler $grouppermHandler */ |
|
153 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
154 | - $groups_view = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; |
|
155 | - $groups_post = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; |
|
156 | - // irmtfan bug fix: html and signature permissions, add: pdf and print permissions |
|
157 | - $post_items = [ |
|
158 | - 'post', |
|
159 | - 'reply', |
|
160 | - 'edit', |
|
161 | - 'delete', |
|
162 | - 'addpoll', |
|
163 | - 'vote', |
|
164 | - 'attach', |
|
165 | - 'noapprove', |
|
166 | - 'type', |
|
167 | - 'html', |
|
168 | - 'signature', |
|
169 | - 'pdf', |
|
170 | - 'print' |
|
171 | - ]; |
|
172 | - foreach ($groups_view as $group_id) { |
|
173 | - $grouppermHandler->addRight('category_access', $cat_id, $group_id, $module_id); |
|
174 | - $grouppermHandler->addRight('forum_access', $forum_id, $group_id, $module_id); |
|
175 | - $grouppermHandler->addRight('forum_view', $forum_id, $group_id, $module_id); |
|
176 | - } |
|
177 | - foreach ($groups_post as $group_id) { |
|
178 | - foreach ($post_items as $item) { |
|
179 | - $grouppermHandler->addRight('forum_' . $item, $forum_id, $group_id, $module_id); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - /* Create a test post */ |
|
184 | - require_once __DIR__ . '/functions.user.php'; |
|
185 | - /** @var Newbb\PostHandler $postHandler */ |
|
186 | - $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
187 | - /** @var $forumpost */ |
|
188 | - $forumpost = $postHandler->create(); |
|
189 | - $forumpost->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
|
190 | - $forumpost->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); |
|
191 | - $forumpost->setVar('approved', 1); |
|
192 | - $forumpost->setVar('forum_id', $forum_id); |
|
193 | - $forumpost->setVar('subject', _MI_NEWBB_INSTALL_POST_SUBJECT, true); |
|
194 | - $forumpost->setVar('dohtml', 1); |
|
195 | - $forumpost->setVar('dosmiley', 1); |
|
196 | - $forumpost->setVar('doxcode', 1); |
|
197 | - $forumpost->setVar('dobr', 1); |
|
198 | - $forumpost->setVar('icon', '', true); |
|
199 | - $forumpost->setVar('attachsig', 1); |
|
200 | - $forumpost->setVar('post_time', time()); |
|
201 | - $forumpost->setVar('post_text', _MI_NEWBB_INSTALL_POST_TEXT, true); |
|
202 | - $postid = $postHandler->insert($forumpost); |
|
203 | - |
|
204 | - return true; |
|
124 | + /* Create a test category */ |
|
125 | + /** @var Newbb\CategoryHandler $categoryHandler */ |
|
126 | + $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
|
127 | + $category = $categoryHandler->create(); |
|
128 | + $category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true); |
|
129 | + $category->setVar('cat_image', '', true); |
|
130 | + $category->setVar('cat_description', _MI_NEWBB_INSTALL_CAT_DESC, true); |
|
131 | + $category->setVar('cat_url', 'https://xoops.org XOOPS Project', true); |
|
132 | + if (!$cat_id = $categoryHandler->insert($category)) { |
|
133 | + return true; |
|
134 | + } |
|
135 | + |
|
136 | + /* Create a forum for test */ |
|
137 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
138 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
139 | + $forum = $forumHandler->create(); |
|
140 | + $forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true); |
|
141 | + $forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true); |
|
142 | + $forum->setVar('forum_moderator', []); |
|
143 | + $forum->setVar('parent_forum', 0); |
|
144 | + $forum->setVar('cat_id', $cat_id); |
|
145 | + $forum->setVar('attach_maxkb', 100); |
|
146 | + $forum->setVar('attach_ext', 'zip|jpg|gif|png'); |
|
147 | + $forum->setVar('hot_threshold', 20); |
|
148 | + $forum_id = $forumHandler->insert($forum); |
|
149 | + |
|
150 | + /* Set corresponding permissions for the category and the forum */ |
|
151 | + $module_id = $module->getVar('mid'); |
|
152 | + /** @var XoopsGroupPermHandler $grouppermHandler */ |
|
153 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
154 | + $groups_view = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS]; |
|
155 | + $groups_post = [XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS]; |
|
156 | + // irmtfan bug fix: html and signature permissions, add: pdf and print permissions |
|
157 | + $post_items = [ |
|
158 | + 'post', |
|
159 | + 'reply', |
|
160 | + 'edit', |
|
161 | + 'delete', |
|
162 | + 'addpoll', |
|
163 | + 'vote', |
|
164 | + 'attach', |
|
165 | + 'noapprove', |
|
166 | + 'type', |
|
167 | + 'html', |
|
168 | + 'signature', |
|
169 | + 'pdf', |
|
170 | + 'print' |
|
171 | + ]; |
|
172 | + foreach ($groups_view as $group_id) { |
|
173 | + $grouppermHandler->addRight('category_access', $cat_id, $group_id, $module_id); |
|
174 | + $grouppermHandler->addRight('forum_access', $forum_id, $group_id, $module_id); |
|
175 | + $grouppermHandler->addRight('forum_view', $forum_id, $group_id, $module_id); |
|
176 | + } |
|
177 | + foreach ($groups_post as $group_id) { |
|
178 | + foreach ($post_items as $item) { |
|
179 | + $grouppermHandler->addRight('forum_' . $item, $forum_id, $group_id, $module_id); |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + /* Create a test post */ |
|
184 | + require_once __DIR__ . '/functions.user.php'; |
|
185 | + /** @var Newbb\PostHandler $postHandler */ |
|
186 | + $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
|
187 | + /** @var $forumpost */ |
|
188 | + $forumpost = $postHandler->create(); |
|
189 | + $forumpost->setVar('poster_ip', \Xmf\IPAddress::fromRequest()->asReadable()); |
|
190 | + $forumpost->setVar('uid', $GLOBALS['xoopsUser']->getVar('uid')); |
|
191 | + $forumpost->setVar('approved', 1); |
|
192 | + $forumpost->setVar('forum_id', $forum_id); |
|
193 | + $forumpost->setVar('subject', _MI_NEWBB_INSTALL_POST_SUBJECT, true); |
|
194 | + $forumpost->setVar('dohtml', 1); |
|
195 | + $forumpost->setVar('dosmiley', 1); |
|
196 | + $forumpost->setVar('doxcode', 1); |
|
197 | + $forumpost->setVar('dobr', 1); |
|
198 | + $forumpost->setVar('icon', '', true); |
|
199 | + $forumpost->setVar('attachsig', 1); |
|
200 | + $forumpost->setVar('post_time', time()); |
|
201 | + $forumpost->setVar('post_text', _MI_NEWBB_INSTALL_POST_TEXT, true); |
|
202 | + $postid = $postHandler->insert($forumpost); |
|
203 | + |
|
204 | + return true; |
|
205 | 205 | } |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | // remove old html template files |
55 | 55 | // create an array with all folders, and then run this once |
56 | 56 | |
57 | - $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/'); |
|
57 | + $templateDirectory = $GLOBALS['xoops']->path('modules/'.$module->getVar('dirname', 'n').'/templates/'); |
|
58 | 58 | $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
59 | 59 | foreach ($template_list as $k => $v) { |
60 | - $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
60 | + $fileinfo = new \SplFileInfo($templateDirectory.$v); |
|
61 | 61 | if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
62 | - @unlink($templateDirectory . $v); |
|
62 | + @unlink($templateDirectory.$v); |
|
63 | 63 | } |
64 | 64 | } |
65 | - $templateDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/templates/blocks'); |
|
65 | + $templateDirectory = $GLOBALS['xoops']->path('modules/'.$module->getVar('dirname', 'n').'/templates/blocks'); |
|
66 | 66 | $template_list = array_diff(scandir($templateDirectory, SCANDIR_SORT_NONE), ['..', '.']); |
67 | 67 | foreach ($template_list as $k => $v) { |
68 | - $fileinfo = new \SplFileInfo($templateDirectory . $v); |
|
68 | + $fileinfo = new \SplFileInfo($templateDirectory.$v); |
|
69 | 69 | if ('html' === $fileinfo->getExtension() && 'index.html' !== $fileinfo->getFilename()) { |
70 | - @unlink($templateDirectory . $v); |
|
70 | + @unlink($templateDirectory.$v); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | // Load class XoopsFile |
74 | 74 | xoops_load('xoopsfile'); |
75 | 75 | //remove /images directory |
76 | - $imagesDirectory = $GLOBALS['xoops']->path('modules/' . $module->getVar('dirname', 'n') . '/images/'); |
|
76 | + $imagesDirectory = $GLOBALS['xoops']->path('modules/'.$module->getVar('dirname', 'n').'/images/'); |
|
77 | 77 | $folderHandler = \XoopsFile::getHandler('folder', $imagesDirectory); |
78 | 78 | $folderHandler->delete($imagesDirectory); |
79 | 79 | |
80 | 80 | //remove old changelogs |
81 | - array_map('unlink', glob(dirname(__DIR__) . '/docs/changelog-rev*.txt')); |
|
81 | + array_map('unlink', glob(dirname(__DIR__).'/docs/changelog-rev*.txt')); |
|
82 | 82 | |
83 | 83 | if (!empty($newbbConfig['syncOnUpdate'])) { |
84 | - require_once dirname(__DIR__) . '/include/functions.recon.php'; |
|
84 | + require_once dirname(__DIR__).'/include/functions.recon.php'; |
|
85 | 85 | newbbSynchronization(); |
86 | 86 | } |
87 | 87 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function xoops_module_pre_install_newbb(\XoopsModule $module) |
109 | 109 | { |
110 | - $mod_tables =& $module->getInfo('tables'); |
|
110 | + $mod_tables = & $module->getInfo('tables'); |
|
111 | 111 | foreach ($mod_tables as $table) { |
112 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
112 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS '.$GLOBALS['xoopsDB']->prefix($table).';'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return true; |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | } |
177 | 177 | foreach ($groups_post as $group_id) { |
178 | 178 | foreach ($post_items as $item) { |
179 | - $grouppermHandler->addRight('forum_' . $item, $forum_id, $group_id, $module_id); |
|
179 | + $grouppermHandler->addRight('forum_'.$item, $forum_id, $group_id, $module_id); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | 183 | /* Create a test post */ |
184 | - require_once __DIR__ . '/functions.user.php'; |
|
184 | + require_once __DIR__.'/functions.user.php'; |
|
185 | 185 | /** @var Newbb\PostHandler $postHandler */ |
186 | 186 | $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
187 | 187 | /** @var $forumpost */ |
@@ -74,9 +74,9 @@ |
||
74 | 74 | // MENU handler |
75 | 75 | /* You could remove anyone by commenting out in order to disable it */ |
76 | 76 | $customConfig['valid_menumodes'] = [ |
77 | - 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
78 | - //1 => _MD_NEWBB_MENU_CLICK, // for "click to expand" |
|
79 | - //2 => _MD_NEWBB_MENU_HOVER // for "mouse hover to expand" |
|
77 | + 0 => _MD_NEWBB_MENU_SELECT, // for selectbox |
|
78 | + //1 => _MD_NEWBB_MENU_CLICK, // for "click to expand" |
|
79 | + //2 => _MD_NEWBB_MENU_HOVER // for "mouse hover to expand" |
|
80 | 80 | ]; |
81 | 81 | |
82 | 82 | // view latest edit |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | $moduleDirName = basename(dirname(__DIR__)); |
24 | 24 | $uploadFolders = [ |
25 | - NEWBB_UPLOAD_PATH, |
|
26 | - NEWBB_UPLOAD_PATH . '/thumbs' |
|
25 | + NEWBB_UPLOAD_PATH, |
|
26 | + NEWBB_UPLOAD_PATH . '/thumbs' |
|
27 | 27 | ]; |
28 | 28 | |
29 | 29 | /** |
@@ -31,61 +31,61 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function getConfig() |
33 | 33 | { |
34 | - $moduleDirName = basename(dirname(__DIR__)); |
|
35 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
36 | - return (object)[ |
|
37 | - 'name' => strtoupper($moduleDirName) . ' Module Configurator', |
|
38 | - 'paths' => [ |
|
39 | - 'dirname' => $moduleDirName, |
|
40 | - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', |
|
41 | - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, |
|
42 | - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, |
|
43 | - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
44 | - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, |
|
45 | - ], |
|
46 | - 'uploadFolders' => [ |
|
47 | - constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
48 | - constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
34 | + $moduleDirName = basename(dirname(__DIR__)); |
|
35 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
36 | + return (object)[ |
|
37 | + 'name' => strtoupper($moduleDirName) . ' Module Configurator', |
|
38 | + 'paths' => [ |
|
39 | + 'dirname' => $moduleDirName, |
|
40 | + 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', |
|
41 | + 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, |
|
42 | + 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, |
|
43 | + 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
44 | + 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, |
|
45 | + ], |
|
46 | + 'uploadFolders' => [ |
|
47 | + constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
48 | + constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
49 | 49 | |
50 | - //XOOPS_UPLOAD_PATH . '/flags' |
|
51 | - ], |
|
52 | - 'copyBlankFiles' => [ |
|
53 | - constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
54 | - constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
55 | - //XOOPS_UPLOAD_PATH . '/flags' |
|
56 | - ], |
|
50 | + //XOOPS_UPLOAD_PATH . '/flags' |
|
51 | + ], |
|
52 | + 'copyBlankFiles' => [ |
|
53 | + constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
54 | + constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
55 | + //XOOPS_UPLOAD_PATH . '/flags' |
|
56 | + ], |
|
57 | 57 | |
58 | - 'copyTestFolders' => [ |
|
59 | - // constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
60 | - //[ |
|
61 | - // constant($moduleDirNameUpper . '_PATH') . '/testdata/images', |
|
62 | - // constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/images', |
|
63 | - //] |
|
64 | - ], |
|
58 | + 'copyTestFolders' => [ |
|
59 | + // constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
60 | + //[ |
|
61 | + // constant($moduleDirNameUpper . '_PATH') . '/testdata/images', |
|
62 | + // constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/images', |
|
63 | + //] |
|
64 | + ], |
|
65 | 65 | |
66 | - 'templateFolders' => [ |
|
67 | - '/templates/', |
|
68 | - '/templates/blocks/', |
|
69 | - '/templates/admin/' |
|
66 | + 'templateFolders' => [ |
|
67 | + '/templates/', |
|
68 | + '/templates/blocks/', |
|
69 | + '/templates/admin/' |
|
70 | 70 | |
71 | - ], |
|
72 | - 'oldFiles' => [ |
|
73 | - '/class/request.php', |
|
74 | - '/class/registry.php', |
|
75 | - '/class/utilities.php', |
|
76 | - '/class/util.php', |
|
77 | - // '/include/constants.php', |
|
78 | - // '/include/functions.php', |
|
79 | - '/ajaxrating.txt', |
|
80 | - ], |
|
81 | - 'oldFolders' => [ |
|
82 | - '/images', |
|
83 | - '/css', |
|
84 | - '/js', |
|
85 | - '/tcpdf', |
|
86 | - '/images', |
|
87 | - ], |
|
88 | - 'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'> |
|
71 | + ], |
|
72 | + 'oldFiles' => [ |
|
73 | + '/class/request.php', |
|
74 | + '/class/registry.php', |
|
75 | + '/class/utilities.php', |
|
76 | + '/class/util.php', |
|
77 | + // '/include/constants.php', |
|
78 | + // '/include/functions.php', |
|
79 | + '/ajaxrating.txt', |
|
80 | + ], |
|
81 | + 'oldFolders' => [ |
|
82 | + '/images', |
|
83 | + '/css', |
|
84 | + '/js', |
|
85 | + '/tcpdf', |
|
86 | + '/images', |
|
87 | + ], |
|
88 | + 'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'> |
|
89 | 89 | <img src='" . constant($moduleDirNameUpper . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>', |
90 | - ]; |
|
90 | + ]; |
|
91 | 91 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $moduleDirName = basename(dirname(__DIR__)); |
24 | 24 | $uploadFolders = [ |
25 | 25 | NEWBB_UPLOAD_PATH, |
26 | - NEWBB_UPLOAD_PATH . '/thumbs' |
|
26 | + NEWBB_UPLOAD_PATH.'/thumbs' |
|
27 | 27 | ]; |
28 | 28 | |
29 | 29 | /** |
@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | $moduleDirName = basename(dirname(__DIR__)); |
35 | 35 | $moduleDirNameUpper = strtoupper($moduleDirName); |
36 | 36 | return (object)[ |
37 | - 'name' => strtoupper($moduleDirName) . ' Module Configurator', |
|
37 | + 'name' => strtoupper($moduleDirName).' Module Configurator', |
|
38 | 38 | 'paths' => [ |
39 | 39 | 'dirname' => $moduleDirName, |
40 | - 'admin' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin', |
|
41 | - 'modPath' => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName, |
|
42 | - 'modUrl' => XOOPS_URL . '/modules/' . $moduleDirName, |
|
43 | - 'uploadPath' => XOOPS_UPLOAD_PATH . '/' . $moduleDirName, |
|
44 | - 'uploadUrl' => XOOPS_UPLOAD_URL . '/' . $moduleDirName, |
|
40 | + 'admin' => XOOPS_ROOT_PATH.'/modules/'.$moduleDirName.'/admin', |
|
41 | + 'modPath' => XOOPS_ROOT_PATH.'/modules/'.$moduleDirName, |
|
42 | + 'modUrl' => XOOPS_URL.'/modules/'.$moduleDirName, |
|
43 | + 'uploadPath' => XOOPS_UPLOAD_PATH.'/'.$moduleDirName, |
|
44 | + 'uploadUrl' => XOOPS_UPLOAD_URL.'/'.$moduleDirName, |
|
45 | 45 | ], |
46 | 46 | 'uploadFolders' => [ |
47 | - constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
48 | - constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
47 | + constant($moduleDirNameUpper.'_UPLOAD_PATH'), |
|
48 | + constant($moduleDirNameUpper.'_UPLOAD_PATH').'/thumbs', |
|
49 | 49 | |
50 | 50 | //XOOPS_UPLOAD_PATH . '/flags' |
51 | 51 | ], |
52 | 52 | 'copyBlankFiles' => [ |
53 | - constant($moduleDirNameUpper . '_UPLOAD_PATH'), |
|
54 | - constant($moduleDirNameUpper . '_UPLOAD_PATH') . '/thumbs', |
|
53 | + constant($moduleDirNameUpper.'_UPLOAD_PATH'), |
|
54 | + constant($moduleDirNameUpper.'_UPLOAD_PATH').'/thumbs', |
|
55 | 55 | //XOOPS_UPLOAD_PATH . '/flags' |
56 | 56 | ], |
57 | 57 | |
@@ -86,6 +86,6 @@ discard block |
||
86 | 86 | '/images', |
87 | 87 | ], |
88 | 88 | 'modCopyright' => "<a href='https://xoops.org' title='XOOPS Project' target='_blank'> |
89 | - <img src='" . constant($moduleDirNameUpper . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>', |
|
89 | + <img src='" . constant($moduleDirNameUpper.'_AUTHOR_LOGOIMG').'\' alt=\'XOOPS Project\' /></a>', |
|
90 | 90 | ]; |
91 | 91 | } |
@@ -15,36 +15,36 @@ |
||
15 | 15 | define('NEWBB_FUNCTIONS_RPC_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_RPC')) { |
18 | - define('NEWBB_FUNCTIONS_RPC', 1); |
|
18 | + define('NEWBB_FUNCTIONS_RPC', 1); |
|
19 | 19 | |
20 | - /** |
|
21 | - * Function to respond to a trackback |
|
22 | - * @param int $error |
|
23 | - * @param string $error_message |
|
24 | - */ |
|
25 | - function newbbTrackbackResponse($error = 0, $error_message = '') |
|
26 | - { |
|
27 | - $moduleConfig = newbbLoadConfig(); |
|
20 | + /** |
|
21 | + * Function to respond to a trackback |
|
22 | + * @param int $error |
|
23 | + * @param string $error_message |
|
24 | + */ |
|
25 | + function newbbTrackbackResponse($error = 0, $error_message = '') |
|
26 | + { |
|
27 | + $moduleConfig = newbbLoadConfig(); |
|
28 | 28 | |
29 | - if (!empty($moduleConfig['rss_utf8'])) { |
|
30 | - $charset = 'utf-8'; |
|
31 | - $error_message = xoops_utf8_encode($error_message); |
|
32 | - } else { |
|
33 | - $charset = _CHARSET; |
|
34 | - } |
|
35 | - header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
36 | - if ($error) { |
|
37 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
38 | - echo '<response>\n'; |
|
39 | - echo '<error>1</error>\n'; |
|
40 | - echo '<message>$error_message</message>\n'; |
|
41 | - echo '</response>'; |
|
42 | - exit(); |
|
43 | - } else { |
|
44 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
45 | - echo '<response>\n'; |
|
46 | - echo '<error>0</error>\n'; |
|
47 | - echo '</response>'; |
|
48 | - } |
|
49 | - } |
|
29 | + if (!empty($moduleConfig['rss_utf8'])) { |
|
30 | + $charset = 'utf-8'; |
|
31 | + $error_message = xoops_utf8_encode($error_message); |
|
32 | + } else { |
|
33 | + $charset = _CHARSET; |
|
34 | + } |
|
35 | + header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
36 | + if ($error) { |
|
37 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
38 | + echo '<response>\n'; |
|
39 | + echo '<error>1</error>\n'; |
|
40 | + echo '<message>$error_message</message>\n'; |
|
41 | + echo '</response>'; |
|
42 | + exit(); |
|
43 | + } else { |
|
44 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
45 | + echo '<response>\n'; |
|
46 | + echo '<error>0</error>\n'; |
|
47 | + echo '</response>'; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | // defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
13 | 13 | |
14 | -defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__ . '/functions.ini.php'; |
|
14 | +defined('NEWBB_FUNCTIONS_INI') || require_once __DIR__.'/functions.ini.php'; |
|
15 | 15 | define('NEWBB_FUNCTIONS_RPC_LOADED', true); |
16 | 16 | |
17 | 17 | if (!defined('NEWBB_FUNCTIONS_RPC')) { |
@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | } else { |
33 | 33 | $charset = _CHARSET; |
34 | 34 | } |
35 | - header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
35 | + header('Content-Type: text/xml; charset="'.$charset.'"'); |
|
36 | 36 | if ($error) { |
37 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
37 | + echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n"; |
|
38 | 38 | echo '<response>\n'; |
39 | 39 | echo '<error>1</error>\n'; |
40 | 40 | echo '<message>$error_message</message>\n'; |
41 | 41 | echo '</response>'; |
42 | 42 | exit(); |
43 | 43 | } else { |
44 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
44 | + echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n"; |
|
45 | 45 | echo '<response>\n'; |
46 | 46 | echo '<error>0</error>\n'; |
47 | 47 | echo '</response>'; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | global $xoopsModule, $myts, $xoopsUser, $forumObject; |
15 | 15 | |
16 | 16 | if (!defined('XOOPS_ROOT_PATH') || !is_object($forumObject) || !is_object($GLOBALS['xoopsUser']) |
17 | - || !is_object($xoopsModule)) { |
|
18 | - return; |
|
17 | + || !is_object($xoopsModule)) { |
|
18 | + return; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $forum_id = $forumObject->getVar('forum_id'); |
@@ -41,67 +41,67 @@ discard block |
||
41 | 41 | /** @var \XoopsModuleHandler $moduleHandler */ |
42 | 42 | $moduleHandler = xoops_getHandler('module'); |
43 | 43 | if ($mod = @$moduleHandler->getByDirname('profile', true)) { |
44 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
45 | - $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; |
|
44 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
45 | + $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; |
|
46 | 46 | |
47 | - if (!defined('_PROFILE_MA_ALLABOUT')) { |
|
48 | - $mod->loadLanguage(); |
|
49 | - } |
|
50 | - /** var Newbb\PermissionHandler $permHandler */ |
|
51 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
52 | - $show_ids = $permHandler->getItemIds('profile_show', $groups, $mod->getVar('mid')); |
|
53 | - $visible_ids = $permHandler->getItemIds('profile_visible', $groups, $mod->getVar('mid')); |
|
54 | - unset($mod); |
|
55 | - $fieldids = array_intersect($show_ids, $visible_ids); |
|
56 | - /** @var \ProfileProfileHandler $profileHandler */ |
|
57 | - $profileHandler = xoops_getModuleHandler('profile', 'profile'); |
|
58 | - $fields = $profileHandler->loadFields(); |
|
59 | - /** @var \ProfileCategoryHandler $catHandler */ |
|
60 | - $catHandler = xoops_getModuleHandler('category', 'profile'); |
|
61 | - $categories = $catHandler->getObjects(null, true, false); |
|
62 | - /** @var \ProfileFieldHandler $fieldcatHandler */ |
|
63 | - $fieldcatHandler = xoops_getModuleHandler('category', 'profile'); |
|
64 | - $fieldcats = $fieldcatHandler->getObjects(null, true, false); |
|
47 | + if (!defined('_PROFILE_MA_ALLABOUT')) { |
|
48 | + $mod->loadLanguage(); |
|
49 | + } |
|
50 | + /** var Newbb\PermissionHandler $permHandler */ |
|
51 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
52 | + $show_ids = $permHandler->getItemIds('profile_show', $groups, $mod->getVar('mid')); |
|
53 | + $visible_ids = $permHandler->getItemIds('profile_visible', $groups, $mod->getVar('mid')); |
|
54 | + unset($mod); |
|
55 | + $fieldids = array_intersect($show_ids, $visible_ids); |
|
56 | + /** @var \ProfileProfileHandler $profileHandler */ |
|
57 | + $profileHandler = xoops_getModuleHandler('profile', 'profile'); |
|
58 | + $fields = $profileHandler->loadFields(); |
|
59 | + /** @var \ProfileCategoryHandler $catHandler */ |
|
60 | + $catHandler = xoops_getModuleHandler('category', 'profile'); |
|
61 | + $categories = $catHandler->getObjects(null, true, false); |
|
62 | + /** @var \ProfileFieldHandler $fieldcatHandler */ |
|
63 | + $fieldcatHandler = xoops_getModuleHandler('category', 'profile'); |
|
64 | + $fieldcats = $fieldcatHandler->getObjects(null, true, false); |
|
65 | 65 | |
66 | - // Add core fields |
|
67 | - $categories[0]['cat_title'] = sprintf(_MD_NEWBB_AUTO_CREATE_ABOUT, $GLOBALS['xoopsUser']->getVar('uname')); |
|
68 | - $avatar = trim($GLOBALS['xoopsUser']->getVar('user_avatar')); |
|
69 | - if (!empty($avatar) && 'blank.gif' !== $avatar) { |
|
70 | - $categories[0]['fields'][] = [ |
|
71 | - 'title' => _MD_NEWBB_AUTO_CREATE_AVATARS, |
|
72 | - 'value' => "<img src='" . XOOPS_UPLOAD_URL . '/' . $GLOBALS['xoopsUser']->getVar('user_avatar') . "' alt='" . $GLOBALS['xoopsUser']->getVar('uname') . "' />" |
|
73 | - ]; |
|
74 | - $weights[0][] = 0; |
|
75 | - } |
|
76 | - if (1 == $GLOBALS['xoopsUser']->getVar('user_viewemail')) { |
|
77 | - $email = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
|
78 | - $categories[0]['fields'][] = ['title' => _MD_NEWBB_AUTO_CREATE_EMAIL, 'value' => $email]; |
|
79 | - $weights[0][] = 0; |
|
80 | - } |
|
66 | + // Add core fields |
|
67 | + $categories[0]['cat_title'] = sprintf(_MD_NEWBB_AUTO_CREATE_ABOUT, $GLOBALS['xoopsUser']->getVar('uname')); |
|
68 | + $avatar = trim($GLOBALS['xoopsUser']->getVar('user_avatar')); |
|
69 | + if (!empty($avatar) && 'blank.gif' !== $avatar) { |
|
70 | + $categories[0]['fields'][] = [ |
|
71 | + 'title' => _MD_NEWBB_AUTO_CREATE_AVATARS, |
|
72 | + 'value' => "<img src='" . XOOPS_UPLOAD_URL . '/' . $GLOBALS['xoopsUser']->getVar('user_avatar') . "' alt='" . $GLOBALS['xoopsUser']->getVar('uname') . "' />" |
|
73 | + ]; |
|
74 | + $weights[0][] = 0; |
|
75 | + } |
|
76 | + if (1 == $GLOBALS['xoopsUser']->getVar('user_viewemail')) { |
|
77 | + $email = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
|
78 | + $categories[0]['fields'][] = ['title' => _MD_NEWBB_AUTO_CREATE_EMAIL, 'value' => $email]; |
|
79 | + $weights[0][] = 0; |
|
80 | + } |
|
81 | 81 | |
82 | - // Add dynamic fields |
|
83 | - foreach (array_keys($fields) as $i) { |
|
84 | - if (in_array($fields[$i]->getVar('fieldid'), $fieldids)) { |
|
85 | - $catid = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? $fieldcats[$fields[$i]->getVar('fieldid')]['catid'] : 0; |
|
86 | - $value = $fields[$i]->getOutputValue($GLOBALS['xoopsUser']); |
|
87 | - if (is_array($value)) { |
|
88 | - $value = implode('<br>', array_values($value)); |
|
89 | - } |
|
82 | + // Add dynamic fields |
|
83 | + foreach (array_keys($fields) as $i) { |
|
84 | + if (in_array($fields[$i]->getVar('fieldid'), $fieldids)) { |
|
85 | + $catid = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? $fieldcats[$fields[$i]->getVar('fieldid')]['catid'] : 0; |
|
86 | + $value = $fields[$i]->getOutputValue($GLOBALS['xoopsUser']); |
|
87 | + if (is_array($value)) { |
|
88 | + $value = implode('<br>', array_values($value)); |
|
89 | + } |
|
90 | 90 | |
91 | - if (empty($value)) { |
|
92 | - continue; |
|
93 | - } |
|
94 | - $categories[$catid]['fields'][] = ['title' => $fields[$i]->getVar('field_title'), 'value' => $value]; |
|
95 | - $weights[$catid][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? (int)$fieldcats[$fields[$i]->getVar('fieldid')]['field_weight'] : 1; |
|
96 | - } |
|
97 | - } |
|
91 | + if (empty($value)) { |
|
92 | + continue; |
|
93 | + } |
|
94 | + $categories[$catid]['fields'][] = ['title' => $fields[$i]->getVar('field_title'), 'value' => $value]; |
|
95 | + $weights[$catid][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? (int)$fieldcats[$fields[$i]->getVar('fieldid')]['field_weight'] : 1; |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - foreach (array_keys($categories) as $i) { |
|
100 | - if (isset($categories[$i]['fields'])) { |
|
101 | - array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]['fields']), SORT_ASC, $categories[$i]['fields']); |
|
102 | - } |
|
103 | - } |
|
104 | - ksort($categories); |
|
99 | + foreach (array_keys($categories) as $i) { |
|
100 | + if (isset($categories[$i]['fields'])) { |
|
101 | + array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]['fields']), SORT_ASC, $categories[$i]['fields']); |
|
102 | + } |
|
103 | + } |
|
104 | + ksort($categories); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $message = sprintf(_MD_NEWBB_WELCOME_MESSAGE, $GLOBALS['xoopsUser']->getVar('uname')) . "\n\n"; |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | $post_id = $postHandler->insert($postObject); |
124 | 124 | |
125 | 125 | if (!empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
126 | - $tags = []; |
|
127 | - $tags['THREAD_NAME'] = $subject; |
|
128 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '&topic_id=' . $postObject->getVar('topic_id') . '&forum=' . $forum_id; |
|
129 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_id; |
|
130 | - require_once __DIR__ . '/notification.inc.php'; |
|
131 | - $forum_info = newbb_notify_iteminfo('forum', $forum_id); |
|
132 | - $tags['FORUM_NAME'] = $forum_info['name']; |
|
133 | - $tags['FORUM_URL'] = $forum_info['url']; |
|
134 | - /** @var \XoopsNotificationHandler $notificationHandler */ |
|
135 | - $notificationHandler = xoops_getHandler('notification'); |
|
136 | - $notificationHandler->triggerEvent('forum', $forum_id, 'new_thread', $tags); |
|
137 | - $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
138 | - $notificationHandler->triggerEvent('forum', $forum_id, 'new_post', $tags); |
|
139 | - $tags['POST_CONTENT'] = $message; |
|
140 | - $tags['POST_NAME'] = $subject; |
|
141 | - $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
126 | + $tags = []; |
|
127 | + $tags['THREAD_NAME'] = $subject; |
|
128 | + $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '&topic_id=' . $postObject->getVar('topic_id') . '&forum=' . $forum_id; |
|
129 | + $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_id; |
|
130 | + require_once __DIR__ . '/notification.inc.php'; |
|
131 | + $forum_info = newbb_notify_iteminfo('forum', $forum_id); |
|
132 | + $tags['FORUM_NAME'] = $forum_info['name']; |
|
133 | + $tags['FORUM_URL'] = $forum_info['url']; |
|
134 | + /** @var \XoopsNotificationHandler $notificationHandler */ |
|
135 | + $notificationHandler = xoops_getHandler('notification'); |
|
136 | + $notificationHandler->triggerEvent('forum', $forum_id, 'new_thread', $tags); |
|
137 | + $notificationHandler->triggerEvent('global', 0, 'new_post', $tags); |
|
138 | + $notificationHandler->triggerEvent('forum', $forum_id, 'new_post', $tags); |
|
139 | + $tags['POST_CONTENT'] = $message; |
|
140 | + $tags['POST_NAME'] = $subject; |
|
141 | + $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags); |
|
142 | 142 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $moduleHandler = xoops_getHandler('module'); |
43 | 43 | if ($mod = @$moduleHandler->getByDirname('profile', true)) { |
44 | 44 | $grouppermHandler = xoops_getHandler('groupperm'); |
45 | - $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; |
|
45 | + $groups = [XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS]; |
|
46 | 46 | |
47 | 47 | if (!defined('_PROFILE_MA_ALLABOUT')) { |
48 | 48 | $mod->loadLanguage(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | if (!empty($avatar) && 'blank.gif' !== $avatar) { |
70 | 70 | $categories[0]['fields'][] = [ |
71 | 71 | 'title' => _MD_NEWBB_AUTO_CREATE_AVATARS, |
72 | - 'value' => "<img src='" . XOOPS_UPLOAD_URL . '/' . $GLOBALS['xoopsUser']->getVar('user_avatar') . "' alt='" . $GLOBALS['xoopsUser']->getVar('uname') . "' />" |
|
72 | + 'value' => "<img src='".XOOPS_UPLOAD_URL.'/'.$GLOBALS['xoopsUser']->getVar('user_avatar')."' alt='".$GLOBALS['xoopsUser']->getVar('uname')."' />" |
|
73 | 73 | ]; |
74 | 74 | $weights[0][] = 0; |
75 | 75 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ksort($categories); |
105 | 105 | } |
106 | 106 | |
107 | -$message = sprintf(_MD_NEWBB_WELCOME_MESSAGE, $GLOBALS['xoopsUser']->getVar('uname')) . "\n\n"; |
|
107 | +$message = sprintf(_MD_NEWBB_WELCOME_MESSAGE, $GLOBALS['xoopsUser']->getVar('uname'))."\n\n"; |
|
108 | 108 | //$message .= _PROFILE . ": <a href='" . XOOPS_URL . '/userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid') . "'><strong>" . $GLOBALS['xoopsUser']->getVar('uname') . '</strong></a> '; |
109 | 109 | //$message .= " | <a target='_blank' href='".XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $GLOBALS['xoopsUser']->getVar('uid') . "'>" . _MD_NEWBB_PM . "</a>\n"; |
110 | 110 | $message .= sprintf($GLOBALS['xoopsModuleConfig']['welcome_forum_message']); |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | if (!empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) { |
126 | 126 | $tags = []; |
127 | 127 | $tags['THREAD_NAME'] = $subject; |
128 | - $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '&topic_id=' . $postObject->getVar('topic_id') . '&forum=' . $forum_id; |
|
129 | - $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $post_id; |
|
130 | - require_once __DIR__ . '/notification.inc.php'; |
|
128 | + $tags['THREAD_URL'] = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?post_id='.$post_id.'&topic_id='.$postObject->getVar('topic_id').'&forum='.$forum_id; |
|
129 | + $tags['POST_URL'] = $tags['THREAD_URL'].'#forumpost'.$post_id; |
|
130 | + require_once __DIR__.'/notification.inc.php'; |
|
131 | 131 | $forum_info = newbb_notify_iteminfo('forum', $forum_id); |
132 | 132 | $tags['FORUM_NAME'] = $forum_info['name']; |
133 | 133 | $tags['FORUM_URL'] = $forum_info['url']; |