@@ -19,80 +19,80 @@ |
||
19 | 19 | */ |
20 | 20 | class Uploader extends \XoopsMediaUploader |
21 | 21 | { |
22 | - /** |
|
23 | - * No admin check for uploads |
|
24 | - */ |
|
25 | - /** |
|
26 | - * Constructor |
|
27 | - * |
|
28 | - * @param string $uploadDir |
|
29 | - * @param array|int|string $allowedMimeTypes |
|
30 | - * @param int $maxFileSize |
|
31 | - * @param int $maxWidth |
|
32 | - * @param int $maxHeight |
|
33 | - */ |
|
34 | - public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize = 0, $maxWidth = 0, $maxHeight = 0) |
|
35 | - { |
|
36 | - // $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
22 | + /** |
|
23 | + * No admin check for uploads |
|
24 | + */ |
|
25 | + /** |
|
26 | + * Constructor |
|
27 | + * |
|
28 | + * @param string $uploadDir |
|
29 | + * @param array|int|string $allowedMimeTypes |
|
30 | + * @param int $maxFileSize |
|
31 | + * @param int $maxWidth |
|
32 | + * @param int $maxHeight |
|
33 | + */ |
|
34 | + public function __construct($uploadDir, $allowedMimeTypes = 0, $maxFileSize = 0, $maxWidth = 0, $maxHeight = 0) |
|
35 | + { |
|
36 | + // $this->XoopsMediaUploader($uploadDir, $allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
37 | 37 | |
38 | - if (!is_array($allowedMimeTypes)) { |
|
39 | - if (empty($allowedMimeTypes) || '*' === $allowedMimeTypes) { |
|
40 | - $allowedMimeTypes = []; |
|
41 | - } else { |
|
42 | - $allowedMimeTypes = array_filter(array_map('trim', explode('|', strtolower($allowedMimeTypes)))); |
|
43 | - } |
|
44 | - } |
|
45 | - $_allowedMimeTypes = []; |
|
46 | - $extensionToMime = require_once $GLOBALS['xoops']->path('include/mimetypes.inc.php'); |
|
47 | - foreach ($allowedMimeTypes as $type) { |
|
48 | - if (isset($extensionToMime[$type])) { |
|
49 | - $_allowedMimeTypes[] = $extensionToMime[$type]; |
|
50 | - } else { |
|
51 | - $_allowedMimeTypes[] = $type; |
|
52 | - } |
|
53 | - } |
|
54 | - parent::__construct($uploadDir, $_allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
55 | - } |
|
38 | + if (!is_array($allowedMimeTypes)) { |
|
39 | + if (empty($allowedMimeTypes) || '*' === $allowedMimeTypes) { |
|
40 | + $allowedMimeTypes = []; |
|
41 | + } else { |
|
42 | + $allowedMimeTypes = array_filter(array_map('trim', explode('|', strtolower($allowedMimeTypes)))); |
|
43 | + } |
|
44 | + } |
|
45 | + $_allowedMimeTypes = []; |
|
46 | + $extensionToMime = require_once $GLOBALS['xoops']->path('include/mimetypes.inc.php'); |
|
47 | + foreach ($allowedMimeTypes as $type) { |
|
48 | + if (isset($extensionToMime[$type])) { |
|
49 | + $_allowedMimeTypes[] = $extensionToMime[$type]; |
|
50 | + } else { |
|
51 | + $_allowedMimeTypes[] = $type; |
|
52 | + } |
|
53 | + } |
|
54 | + parent::__construct($uploadDir, $_allowedMimeTypes, $maxFileSize, $maxWidth, $maxHeight); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Set the CheckMediaTypeByExt |
|
59 | - * Deprecated |
|
60 | - * |
|
61 | - * @param bool|string $value |
|
62 | - */ |
|
63 | - public function setCheckMediaTypeByExt($value = true) |
|
64 | - { |
|
65 | - } |
|
57 | + /** |
|
58 | + * Set the CheckMediaTypeByExt |
|
59 | + * Deprecated |
|
60 | + * |
|
61 | + * @param bool|string $value |
|
62 | + */ |
|
63 | + public function setCheckMediaTypeByExt($value = true) |
|
64 | + { |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Set the imageSizeCheck |
|
69 | - * Deprecated |
|
70 | - * |
|
71 | - * @param string $value |
|
72 | - */ |
|
73 | - public function setImageSizeCheck($value) |
|
74 | - { |
|
75 | - } |
|
67 | + /** |
|
68 | + * Set the imageSizeCheck |
|
69 | + * Deprecated |
|
70 | + * |
|
71 | + * @param string $value |
|
72 | + */ |
|
73 | + public function setImageSizeCheck($value) |
|
74 | + { |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Set the fileSizeCheck |
|
79 | - * Deprecated |
|
80 | - * |
|
81 | - * @param string $value |
|
82 | - */ |
|
83 | - public function setFileSizeCheck($value) |
|
84 | - { |
|
85 | - } |
|
77 | + /** |
|
78 | + * Set the fileSizeCheck |
|
79 | + * Deprecated |
|
80 | + * |
|
81 | + * @param string $value |
|
82 | + */ |
|
83 | + public function setFileSizeCheck($value) |
|
84 | + { |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Get the file extension |
|
89 | - * |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function getExt() |
|
93 | - { |
|
94 | - $this->ext = strtolower(ltrim(strrchr($this->getMediaName(), '.'), '.')); |
|
87 | + /** |
|
88 | + * Get the file extension |
|
89 | + * |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function getExt() |
|
93 | + { |
|
94 | + $this->ext = strtolower(ltrim(strrchr($this->getMediaName(), '.'), '.')); |
|
95 | 95 | |
96 | - return $this->ext; |
|
97 | - } |
|
96 | + return $this->ext; |
|
97 | + } |
|
98 | 98 | } |
@@ -24,18 +24,18 @@ |
||
24 | 24 | */ |
25 | 25 | class Moderate extends \XoopsObject |
26 | 26 | { |
27 | - /** |
|
28 | - * |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - parent::__construct(); |
|
33 | - $this->initVar('mod_id', XOBJ_DTYPE_INT); |
|
34 | - $this->initVar('mod_start', XOBJ_DTYPE_INT); |
|
35 | - $this->initVar('mod_end', XOBJ_DTYPE_INT); |
|
36 | - $this->initVar('mod_desc', XOBJ_DTYPE_TXTBOX); |
|
37 | - $this->initVar('uid', XOBJ_DTYPE_INT); |
|
38 | - $this->initVar('ip', XOBJ_DTYPE_TXTBOX); |
|
39 | - $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
40 | - } |
|
27 | + /** |
|
28 | + * |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + parent::__construct(); |
|
33 | + $this->initVar('mod_id', XOBJ_DTYPE_INT); |
|
34 | + $this->initVar('mod_start', XOBJ_DTYPE_INT); |
|
35 | + $this->initVar('mod_end', XOBJ_DTYPE_INT); |
|
36 | + $this->initVar('mod_desc', XOBJ_DTYPE_TXTBOX); |
|
37 | + $this->initVar('uid', XOBJ_DTYPE_INT); |
|
38 | + $this->initVar('ip', XOBJ_DTYPE_TXTBOX); |
|
39 | + $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
40 | + } |
|
41 | 41 | } |
@@ -39,17 +39,17 @@ |
||
39 | 39 | */ |
40 | 40 | class Rate extends \XoopsObject |
41 | 41 | { |
42 | - /** |
|
43 | - * |
|
44 | - */ |
|
45 | - public function __construct() |
|
46 | - { |
|
47 | - parent::__construct(); |
|
48 | - $this->initVar('ratingid', XOBJ_DTYPE_INT); |
|
49 | - $this->initVar('topic_id', XOBJ_DTYPE_INT); |
|
50 | - $this->initVar('ratinguser', XOBJ_DTYPE_INT); |
|
51 | - $this->initVar('rating', XOBJ_DTYPE_INT); |
|
52 | - $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT); |
|
53 | - $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX); |
|
54 | - } |
|
42 | + /** |
|
43 | + * |
|
44 | + */ |
|
45 | + public function __construct() |
|
46 | + { |
|
47 | + parent::__construct(); |
|
48 | + $this->initVar('ratingid', XOBJ_DTYPE_INT); |
|
49 | + $this->initVar('topic_id', XOBJ_DTYPE_INT); |
|
50 | + $this->initVar('ratinguser', XOBJ_DTYPE_INT); |
|
51 | + $this->initVar('rating', XOBJ_DTYPE_INT); |
|
52 | + $this->initVar('ratingtimestamp', XOBJ_DTYPE_INT); |
|
53 | + $this->initVar('ratinghostname', XOBJ_DTYPE_TXTBOX); |
|
54 | + } |
|
55 | 55 | } |
@@ -21,98 +21,98 @@ |
||
21 | 21 | */ |
22 | 22 | class UserHandler |
23 | 23 | { |
24 | - /** @var array */ |
|
25 | - public $users = []; |
|
26 | - |
|
27 | - /** @var bool */ |
|
28 | - private $enableGroup; |
|
29 | - |
|
30 | - /** @var bool */ |
|
31 | - private $enableOnline; |
|
32 | - |
|
33 | - /** @var array */ |
|
34 | - private $userlist = []; |
|
35 | - |
|
36 | - /** |
|
37 | - * @param bool $enableGroup |
|
38 | - * @param bool $enableOnline |
|
39 | - */ |
|
40 | - public function __construct($enableGroup = true, $enableOnline = true) |
|
41 | - { |
|
42 | - $this->enableGroup = $enableGroup; |
|
43 | - $this->enableOnline = $enableOnline; |
|
44 | - } |
|
45 | - |
|
46 | - public function loadUserInfo() |
|
47 | - { |
|
48 | - /** @var Newbb\Helper $helper */ |
|
49 | - $helper = Newbb\Helper::getInstance(); |
|
50 | - $helper->loadLanguage('user'); |
|
24 | + /** @var array */ |
|
25 | + public $users = []; |
|
26 | + |
|
27 | + /** @var bool */ |
|
28 | + private $enableGroup; |
|
29 | + |
|
30 | + /** @var bool */ |
|
31 | + private $enableOnline; |
|
32 | + |
|
33 | + /** @var array */ |
|
34 | + private $userlist = []; |
|
35 | + |
|
36 | + /** |
|
37 | + * @param bool $enableGroup |
|
38 | + * @param bool $enableOnline |
|
39 | + */ |
|
40 | + public function __construct($enableGroup = true, $enableOnline = true) |
|
41 | + { |
|
42 | + $this->enableGroup = $enableGroup; |
|
43 | + $this->enableOnline = $enableOnline; |
|
44 | + } |
|
45 | + |
|
46 | + public function loadUserInfo() |
|
47 | + { |
|
48 | + /** @var Newbb\Helper $helper */ |
|
49 | + $helper = Newbb\Helper::getInstance(); |
|
50 | + $helper->loadLanguage('user'); |
|
51 | 51 | // @require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/user.php'); |
52 | - if (class_exists('UserLanguage')) { |
|
53 | - $handler = new Newbb\UserLanguage(); |
|
54 | - } else { |
|
55 | - $handler = new User(); |
|
56 | - } |
|
57 | - foreach (array_keys($this->users) as $uid) { |
|
58 | - $this->userlist[$uid] = $handler->getInfo($this->users[$uid]); |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - public function loadUserOnline() |
|
63 | - { |
|
64 | - if (empty($this->users) || !$this->enableOnline) { |
|
65 | - return; |
|
66 | - } |
|
67 | - require_once dirname(__DIR__) . '/include/functions.render.php'; |
|
68 | - $image_online = newbbDisplayImage('online', _MD_NEWBB_ONLINE); |
|
69 | - $image_offline = newbbDisplayImage('offline', _MD_NEWBB_OFFLINE); |
|
70 | - |
|
71 | - /** @var Newbb\OnlineHandler $onlineHandler */ |
|
72 | - $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
73 | - $onlines = $onlineHandler->checkStatus(array_keys($this->users)); |
|
74 | - |
|
75 | - foreach (array_keys($this->users) as $uid) { |
|
76 | - $this->userlist[$uid]['status'] = empty($onlines[$uid]) ? $image_offline : $image_online; |
|
77 | - } |
|
78 | - } |
|
79 | - // START irmtfan remove function - no deprecated is needed because just use in this file |
|
80 | - // function loadUserGroups() |
|
81 | - // { |
|
82 | - // return true; |
|
83 | - // } |
|
84 | - // END irmtfan remove function - no deprecated is needed because just use in this file |
|
85 | - |
|
86 | - public function loadUserDigest() |
|
87 | - { |
|
88 | - if (empty($this->users)) { |
|
89 | - return; |
|
90 | - } |
|
91 | - |
|
92 | - $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . implode(', ', array_keys($this->users)) . ')'; |
|
93 | - $result = $GLOBALS['xoopsDB']->query($sql); |
|
94 | - while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
95 | - $this->userlist[$myrow['uid']]['digests'] = (int)$myrow['user_digests']; |
|
96 | - } |
|
97 | - } |
|
98 | - // START irmtfan remove function |
|
99 | - // function loadUserRank() |
|
100 | - // { |
|
101 | - // return true; |
|
102 | - // } |
|
103 | - // END irmtfan remove function |
|
104 | - |
|
105 | - /** |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - public function getUsers() |
|
109 | - { |
|
110 | - $this->loadUserInfo(); |
|
111 | - $this->loadUserOnline(); |
|
112 | - // irmtfan removed $this->loadUserGroups(); |
|
113 | - // irmtfan removed $this->loadUserRank(); |
|
114 | - $this->loadUserDigest(); |
|
115 | - |
|
116 | - return $this->userlist; |
|
117 | - } |
|
52 | + if (class_exists('UserLanguage')) { |
|
53 | + $handler = new Newbb\UserLanguage(); |
|
54 | + } else { |
|
55 | + $handler = new User(); |
|
56 | + } |
|
57 | + foreach (array_keys($this->users) as $uid) { |
|
58 | + $this->userlist[$uid] = $handler->getInfo($this->users[$uid]); |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + public function loadUserOnline() |
|
63 | + { |
|
64 | + if (empty($this->users) || !$this->enableOnline) { |
|
65 | + return; |
|
66 | + } |
|
67 | + require_once dirname(__DIR__) . '/include/functions.render.php'; |
|
68 | + $image_online = newbbDisplayImage('online', _MD_NEWBB_ONLINE); |
|
69 | + $image_offline = newbbDisplayImage('offline', _MD_NEWBB_OFFLINE); |
|
70 | + |
|
71 | + /** @var Newbb\OnlineHandler $onlineHandler */ |
|
72 | + $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
|
73 | + $onlines = $onlineHandler->checkStatus(array_keys($this->users)); |
|
74 | + |
|
75 | + foreach (array_keys($this->users) as $uid) { |
|
76 | + $this->userlist[$uid]['status'] = empty($onlines[$uid]) ? $image_offline : $image_online; |
|
77 | + } |
|
78 | + } |
|
79 | + // START irmtfan remove function - no deprecated is needed because just use in this file |
|
80 | + // function loadUserGroups() |
|
81 | + // { |
|
82 | + // return true; |
|
83 | + // } |
|
84 | + // END irmtfan remove function - no deprecated is needed because just use in this file |
|
85 | + |
|
86 | + public function loadUserDigest() |
|
87 | + { |
|
88 | + if (empty($this->users)) { |
|
89 | + return; |
|
90 | + } |
|
91 | + |
|
92 | + $sql = 'SELECT user_digests, uid FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . ' WHERE uid IN( ' . implode(', ', array_keys($this->users)) . ')'; |
|
93 | + $result = $GLOBALS['xoopsDB']->query($sql); |
|
94 | + while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
95 | + $this->userlist[$myrow['uid']]['digests'] = (int)$myrow['user_digests']; |
|
96 | + } |
|
97 | + } |
|
98 | + // START irmtfan remove function |
|
99 | + // function loadUserRank() |
|
100 | + // { |
|
101 | + // return true; |
|
102 | + // } |
|
103 | + // END irmtfan remove function |
|
104 | + |
|
105 | + /** |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + public function getUsers() |
|
109 | + { |
|
110 | + $this->loadUserInfo(); |
|
111 | + $this->loadUserOnline(); |
|
112 | + // irmtfan removed $this->loadUserGroups(); |
|
113 | + // irmtfan removed $this->loadUserRank(); |
|
114 | + $this->loadUserDigest(); |
|
115 | + |
|
116 | + return $this->userlist; |
|
117 | + } |
|
118 | 118 | } |
@@ -21,41 +21,41 @@ |
||
21 | 21 | |
22 | 22 | class Forum extends \XoopsObject |
23 | 23 | { |
24 | - /** |
|
25 | - * |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - parent::__construct(); |
|
30 | - $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
31 | - $this->initVar('forum_name', XOBJ_DTYPE_TXTBOX); |
|
32 | - $this->initVar('forum_desc', XOBJ_DTYPE_TXTAREA); |
|
33 | - $this->initVar('forum_moderator', XOBJ_DTYPE_ARRAY, serialize([])); |
|
34 | - $this->initVar('forum_topics', XOBJ_DTYPE_INT); |
|
35 | - $this->initVar('forum_posts', XOBJ_DTYPE_INT); |
|
36 | - $this->initVar('forum_last_post_id', XOBJ_DTYPE_INT); |
|
37 | - $this->initVar('cat_id', XOBJ_DTYPE_INT); |
|
38 | - $this->initVar('parent_forum', XOBJ_DTYPE_INT); |
|
39 | - $this->initVar('hot_threshold', XOBJ_DTYPE_INT, 20); |
|
40 | - $this->initVar('attach_maxkb', XOBJ_DTYPE_INT, 500); |
|
41 | - $this->initVar('attach_ext', XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png'); |
|
42 | - $this->initVar('forum_order', XOBJ_DTYPE_INT, 99); |
|
43 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1); |
|
44 | - } |
|
24 | + /** |
|
25 | + * |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + parent::__construct(); |
|
30 | + $this->initVar('forum_id', XOBJ_DTYPE_INT); |
|
31 | + $this->initVar('forum_name', XOBJ_DTYPE_TXTBOX); |
|
32 | + $this->initVar('forum_desc', XOBJ_DTYPE_TXTAREA); |
|
33 | + $this->initVar('forum_moderator', XOBJ_DTYPE_ARRAY, serialize([])); |
|
34 | + $this->initVar('forum_topics', XOBJ_DTYPE_INT); |
|
35 | + $this->initVar('forum_posts', XOBJ_DTYPE_INT); |
|
36 | + $this->initVar('forum_last_post_id', XOBJ_DTYPE_INT); |
|
37 | + $this->initVar('cat_id', XOBJ_DTYPE_INT); |
|
38 | + $this->initVar('parent_forum', XOBJ_DTYPE_INT); |
|
39 | + $this->initVar('hot_threshold', XOBJ_DTYPE_INT, 20); |
|
40 | + $this->initVar('attach_maxkb', XOBJ_DTYPE_INT, 500); |
|
41 | + $this->initVar('attach_ext', XOBJ_DTYPE_SOURCE, 'zip|jpg|gif|png'); |
|
42 | + $this->initVar('forum_order', XOBJ_DTYPE_INT, 99); |
|
43 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function dispForumModerators() |
|
50 | - { |
|
51 | - $ret = ''; |
|
52 | - if (!$valid_moderators = $this->getVar('forum_moderator')) { |
|
53 | - return $ret; |
|
54 | - } |
|
55 | - require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.user.php'); |
|
56 | - $moderators = newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); |
|
57 | - $ret = implode(', ', $moderators); |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function dispForumModerators() |
|
50 | + { |
|
51 | + $ret = ''; |
|
52 | + if (!$valid_moderators = $this->getVar('forum_moderator')) { |
|
53 | + return $ret; |
|
54 | + } |
|
55 | + require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.user.php'); |
|
56 | + $moderators = newbbGetUnameFromIds($valid_moderators, !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); |
|
57 | + $ret = implode(', ', $moderators); |
|
58 | 58 | |
59 | - return $ret; |
|
60 | - } |
|
59 | + return $ret; |
|
60 | + } |
|
61 | 61 | } |
@@ -32,43 +32,43 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function newbb_tag_iteminfo(&$items) |
34 | 34 | { |
35 | - if (0 === count($items) || !is_array($items)) { |
|
36 | - return false; |
|
37 | - } |
|
35 | + if (0 === count($items) || !is_array($items)) { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - $items_id = []; |
|
40 | - foreach (array_keys($items) as $cat_id) { |
|
41 | - // Some handling here to build the link upon catid |
|
42 | - // catid is not used in newbb, so just skip it |
|
43 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
44 | - // In newbb, the item_id is "topic_id" |
|
45 | - $items_id[] = (int)$item_id; |
|
46 | - } |
|
47 | - } |
|
48 | - /** @var TopicHandler $itemHandler */ |
|
49 | - $itemHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
50 | - /** @var \XoopsObject $itemsObject */ |
|
51 | - $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
39 | + $items_id = []; |
|
40 | + foreach (array_keys($items) as $cat_id) { |
|
41 | + // Some handling here to build the link upon catid |
|
42 | + // catid is not used in newbb, so just skip it |
|
43 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
44 | + // In newbb, the item_id is "topic_id" |
|
45 | + $items_id[] = (int)$item_id; |
|
46 | + } |
|
47 | + } |
|
48 | + /** @var TopicHandler $itemHandler */ |
|
49 | + $itemHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
50 | + /** @var \XoopsObject $itemsObject */ |
|
51 | + $itemsObject = $itemHandler->getObjects(new \Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
52 | 52 | |
53 | - foreach (array_keys($items) as $cat_id) { |
|
54 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
55 | - /** @var \XoopsObject $itemObject */ |
|
56 | - if (!$itemObject = $itemsObject[$item_id]) { |
|
57 | - continue; |
|
58 | - } |
|
59 | - $items[$cat_id][$item_id] = [ |
|
60 | - 'title' => $itemObject->getVar('topic_title'), |
|
61 | - 'uid' => $itemObject->getVar('topic_poster'), |
|
62 | - 'link' => "viewtopic.php?topic_id={$item_id}", |
|
63 | - 'time' => $itemObject->getVar('topic_time'), |
|
64 | - 'tags' => tag_parse_tag($itemObject->getVar('topic_tags', 'n')), |
|
65 | - 'content' => '' |
|
66 | - ]; |
|
67 | - } |
|
68 | - } |
|
69 | - unset($itemsObject); |
|
53 | + foreach (array_keys($items) as $cat_id) { |
|
54 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
55 | + /** @var \XoopsObject $itemObject */ |
|
56 | + if (!$itemObject = $itemsObject[$item_id]) { |
|
57 | + continue; |
|
58 | + } |
|
59 | + $items[$cat_id][$item_id] = [ |
|
60 | + 'title' => $itemObject->getVar('topic_title'), |
|
61 | + 'uid' => $itemObject->getVar('topic_poster'), |
|
62 | + 'link' => "viewtopic.php?topic_id={$item_id}", |
|
63 | + 'time' => $itemObject->getVar('topic_time'), |
|
64 | + 'tags' => tag_parse_tag($itemObject->getVar('topic_tags', 'n')), |
|
65 | + 'content' => '' |
|
66 | + ]; |
|
67 | + } |
|
68 | + } |
|
69 | + unset($itemsObject); |
|
70 | 70 | |
71 | - return true; |
|
71 | + return true; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | */ |
79 | 79 | function newbb_tag_synchronization($mid) |
80 | 80 | { |
81 | - /** @var TopicHandler $itemHandler */ |
|
82 | - $itemHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
83 | - /** @var \XoopsPersistableObjectHandler $linkHandler */ |
|
84 | - $linkHandler = Tag\Helper::getInstance()->getHandler('Link'); |
|
81 | + /** @var TopicHandler $itemHandler */ |
|
82 | + $itemHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
83 | + /** @var \XoopsPersistableObjectHandler $linkHandler */ |
|
84 | + $linkHandler = Tag\Helper::getInstance()->getHandler('Link'); |
|
85 | 85 | |
86 | - /* clear tag-item links */ |
|
87 | - $sql = " DELETE FROM {$linkHandler->table}" |
|
88 | - . ' WHERE ' |
|
89 | - . " tag_modid = {$mid}" |
|
90 | - . ' AND ' |
|
91 | - . ' ( tag_itemid NOT IN ' |
|
92 | - . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
93 | - . " FROM {$itemHandler->table} " |
|
94 | - . " WHERE {$itemHandler->table}.approved > 0" |
|
95 | - . ' ) ' |
|
96 | - . ' )'; |
|
97 | - $linkHandler->db->queryF($sql); |
|
86 | + /* clear tag-item links */ |
|
87 | + $sql = " DELETE FROM {$linkHandler->table}" |
|
88 | + . ' WHERE ' |
|
89 | + . " tag_modid = {$mid}" |
|
90 | + . ' AND ' |
|
91 | + . ' ( tag_itemid NOT IN ' |
|
92 | + . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
93 | + . " FROM {$itemHandler->table} " |
|
94 | + . " WHERE {$itemHandler->table}.approved > 0" |
|
95 | + . ' ) ' |
|
96 | + . ' )'; |
|
97 | + $linkHandler->db->queryF($sql); |
|
98 | 98 | } |
@@ -22,42 +22,42 @@ |
||
22 | 22 | */ |
23 | 23 | class XmlrssHandler |
24 | 24 | { |
25 | - /** |
|
26 | - * @return Xmlrss |
|
27 | - */ |
|
28 | - public function create() |
|
29 | - { |
|
30 | - $xmlrss = new Newbb\Xmlrss(); |
|
31 | - |
|
32 | - return $xmlrss; |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @param $rss |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function get(Xmlrss $rss) |
|
40 | - { |
|
41 | - $rss_array = []; |
|
42 | - $rss_array['xml_version'] = $rss->xml_version; |
|
43 | - $rss_array['xml_encoding'] = $rss->xml_encoding; |
|
44 | - $rss_array['rss_version'] = $rss->rss_version; |
|
45 | - $rss_array['channel_title'] = $rss->channel_title; |
|
46 | - $rss_array['channel_link'] = $rss->channel_link; |
|
47 | - $rss_array['channel_desc'] = $rss->channel_desc; |
|
48 | - $rss_array['channel_lastbuild'] = $rss->channel_lastbuild; |
|
49 | - $rss_array['channel_webmaster'] = $rss->channel_webmaster; |
|
50 | - $rss_array['channel_editor'] = $rss->channel_editor; |
|
51 | - $rss_array['channel_category'] = $rss->channel_category; |
|
52 | - $rss_array['channel_generator'] = $rss->channel_generator; |
|
53 | - $rss_array['channel_language'] = $rss->channel_language; |
|
54 | - $rss_array['image_title'] = $rss->channel_title; |
|
55 | - $rss_array['image_url'] = $rss->image_url; |
|
56 | - $rss_array['image_link'] = $rss->channel_link; |
|
57 | - $rss_array['image_width'] = $rss->image_width; |
|
58 | - $rss_array['image_height'] = $rss->image_height; |
|
59 | - $rss_array['items'] = $rss->items; |
|
60 | - |
|
61 | - return $rss_array; |
|
62 | - } |
|
25 | + /** |
|
26 | + * @return Xmlrss |
|
27 | + */ |
|
28 | + public function create() |
|
29 | + { |
|
30 | + $xmlrss = new Newbb\Xmlrss(); |
|
31 | + |
|
32 | + return $xmlrss; |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @param $rss |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function get(Xmlrss $rss) |
|
40 | + { |
|
41 | + $rss_array = []; |
|
42 | + $rss_array['xml_version'] = $rss->xml_version; |
|
43 | + $rss_array['xml_encoding'] = $rss->xml_encoding; |
|
44 | + $rss_array['rss_version'] = $rss->rss_version; |
|
45 | + $rss_array['channel_title'] = $rss->channel_title; |
|
46 | + $rss_array['channel_link'] = $rss->channel_link; |
|
47 | + $rss_array['channel_desc'] = $rss->channel_desc; |
|
48 | + $rss_array['channel_lastbuild'] = $rss->channel_lastbuild; |
|
49 | + $rss_array['channel_webmaster'] = $rss->channel_webmaster; |
|
50 | + $rss_array['channel_editor'] = $rss->channel_editor; |
|
51 | + $rss_array['channel_category'] = $rss->channel_category; |
|
52 | + $rss_array['channel_generator'] = $rss->channel_generator; |
|
53 | + $rss_array['channel_language'] = $rss->channel_language; |
|
54 | + $rss_array['image_title'] = $rss->channel_title; |
|
55 | + $rss_array['image_url'] = $rss->image_url; |
|
56 | + $rss_array['image_link'] = $rss->channel_link; |
|
57 | + $rss_array['image_width'] = $rss->image_width; |
|
58 | + $rss_array['image_height'] = $rss->image_height; |
|
59 | + $rss_array['items'] = $rss->items; |
|
60 | + |
|
61 | + return $rss_array; |
|
62 | + } |
|
63 | 63 | } |
@@ -19,14 +19,14 @@ |
||
19 | 19 | */ |
20 | 20 | class Text extends \XoopsObject |
21 | 21 | { |
22 | - /** |
|
23 | - * |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - parent::__construct(); |
|
28 | - $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
29 | - $this->initVar('post_text', XOBJ_DTYPE_TXTAREA); |
|
30 | - $this->initVar('post_edit', XOBJ_DTYPE_SOURCE); |
|
31 | - } |
|
22 | + /** |
|
23 | + * |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + parent::__construct(); |
|
28 | + $this->initVar('post_id', XOBJ_DTYPE_INT); |
|
29 | + $this->initVar('post_text', XOBJ_DTYPE_TXTAREA); |
|
30 | + $this->initVar('post_edit', XOBJ_DTYPE_SOURCE); |
|
31 | + } |
|
32 | 32 | } |
@@ -28,65 +28,65 @@ |
||
28 | 28 | |
29 | 29 | class Plugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface |
30 | 30 | { |
31 | - /** |
|
32 | - * @param string $subscribe_from Name of the script |
|
33 | - * |
|
34 | - * 'name' => 'thread'; |
|
35 | - * 'title' => _MI_NEWBB_THREAD_NOTIFY; |
|
36 | - * 'description' => _MI_NEWBB_THREAD_NOTIFYDSC; |
|
37 | - * 'subscribe_from' => 'viewtopic.php'; |
|
38 | - * 'item_name' => 'topic_id'; |
|
39 | - * 'allow_bookmark' => 1; |
|
40 | - * |
|
41 | - * publisher: |
|
42 | - * 'name' = 'category_item'; |
|
43 | - * 'title' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY; |
|
44 | - * 'description' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC; |
|
45 | - * 'subscribe_from' = array('index.php', 'category.php', 'item.php'); |
|
46 | - * 'item_name' = 'categoryid'; |
|
47 | - * 'allow_bookmark' = 1; |
|
48 | - * |
|
49 | - * empty($subscribe_from): |
|
50 | - * @return bool|array $script_arr["item_name"] name of the item = array("subscribe_from1", "subscribe_from2") Name of the script |
|
51 | - * |
|
52 | - * !empty($subscribe_from): |
|
53 | - * @return bool|array $item["item_name"] name of the item, $item["item_id"] id of the item |
|
54 | - */ |
|
55 | - public function item($subscribe_from) |
|
56 | - { |
|
57 | - if (empty($subscribe_from)) { |
|
58 | - $script_arr = []; |
|
59 | - $script_arr['topic_id'] = ['viewtopic.php']; |
|
60 | - $script_arr['forum'] = ['viewforum.php']; |
|
31 | + /** |
|
32 | + * @param string $subscribe_from Name of the script |
|
33 | + * |
|
34 | + * 'name' => 'thread'; |
|
35 | + * 'title' => _MI_NEWBB_THREAD_NOTIFY; |
|
36 | + * 'description' => _MI_NEWBB_THREAD_NOTIFYDSC; |
|
37 | + * 'subscribe_from' => 'viewtopic.php'; |
|
38 | + * 'item_name' => 'topic_id'; |
|
39 | + * 'allow_bookmark' => 1; |
|
40 | + * |
|
41 | + * publisher: |
|
42 | + * 'name' = 'category_item'; |
|
43 | + * 'title' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY; |
|
44 | + * 'description' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC; |
|
45 | + * 'subscribe_from' = array('index.php', 'category.php', 'item.php'); |
|
46 | + * 'item_name' = 'categoryid'; |
|
47 | + * 'allow_bookmark' = 1; |
|
48 | + * |
|
49 | + * empty($subscribe_from): |
|
50 | + * @return bool|array $script_arr["item_name"] name of the item = array("subscribe_from1", "subscribe_from2") Name of the script |
|
51 | + * |
|
52 | + * !empty($subscribe_from): |
|
53 | + * @return bool|array $item["item_name"] name of the item, $item["item_id"] id of the item |
|
54 | + */ |
|
55 | + public function item($subscribe_from) |
|
56 | + { |
|
57 | + if (empty($subscribe_from)) { |
|
58 | + $script_arr = []; |
|
59 | + $script_arr['topic_id'] = ['viewtopic.php']; |
|
60 | + $script_arr['forum'] = ['viewforum.php']; |
|
61 | 61 | |
62 | - return $script_arr; |
|
63 | - } |
|
62 | + return $script_arr; |
|
63 | + } |
|
64 | 64 | |
65 | - switch ($subscribe_from) { |
|
66 | - case 'viewtopic.php': |
|
67 | - /** @var Newbb\TopicHandler $topicHandler */ |
|
68 | - $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
69 | - $post_id = Request::getInt('post_id', 0);// !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0; |
|
70 | - $move = strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : ''; |
|
71 | - $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0; |
|
72 | - if (!empty($post_id)) { |
|
73 | - $topicObject = $topicHandler->getByPost($post_id); |
|
74 | - $topic_id = $topicObject->getVar('topic_id'); |
|
75 | - } elseif (!empty($move)) { |
|
76 | - $forum_id = Request::getInt('forum_id', 0); //!empty($_REQUEST["forum_id"]) ? (int)($_REQUEST["forum_id"]) : 0; |
|
77 | - $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); |
|
78 | - $topic_id = $topicObject->getVar('topic_id'); |
|
79 | - } |
|
65 | + switch ($subscribe_from) { |
|
66 | + case 'viewtopic.php': |
|
67 | + /** @var Newbb\TopicHandler $topicHandler */ |
|
68 | + $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
69 | + $post_id = Request::getInt('post_id', 0);// !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0; |
|
70 | + $move = strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : ''; |
|
71 | + $topic_id = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0; |
|
72 | + if (!empty($post_id)) { |
|
73 | + $topicObject = $topicHandler->getByPost($post_id); |
|
74 | + $topic_id = $topicObject->getVar('topic_id'); |
|
75 | + } elseif (!empty($move)) { |
|
76 | + $forum_id = Request::getInt('forum_id', 0); //!empty($_REQUEST["forum_id"]) ? (int)($_REQUEST["forum_id"]) : 0; |
|
77 | + $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); |
|
78 | + $topic_id = $topicObject->getVar('topic_id'); |
|
79 | + } |
|
80 | 80 | |
81 | - return ['item_name' => 'topic_id', 'item_id' => $topic_id]; |
|
82 | - break; |
|
83 | - case 'viewforum.php': |
|
84 | - $forum_id = Request::getInt('forum', 0); // !empty($_REQUEST["forum"]) ? (int)($_REQUEST["forum"]) : 0; |
|
81 | + return ['item_name' => 'topic_id', 'item_id' => $topic_id]; |
|
82 | + break; |
|
83 | + case 'viewforum.php': |
|
84 | + $forum_id = Request::getInt('forum', 0); // !empty($_REQUEST["forum"]) ? (int)($_REQUEST["forum"]) : 0; |
|
85 | 85 | |
86 | - return ['item_name' => 'forum', 'item_id' => $forum_id]; |
|
87 | - break; |
|
88 | - } |
|
86 | + return ['item_name' => 'forum', 'item_id' => $forum_id]; |
|
87 | + break; |
|
88 | + } |
|
89 | 89 | |
90 | - return false; |
|
91 | - } |
|
90 | + return false; |
|
91 | + } |
|
92 | 92 | } |