@@ -50,7 +50,7 @@ |
||
50 | 50 | if (!$valid_ids = $this->getIdsByPermission($permission)) { |
51 | 51 | return $categories; |
52 | 52 | } |
53 | - $criteria = new \Criteria('cat_id', '(' . implode(', ', $valid_ids) . ')', 'IN'); |
|
53 | + $criteria = new \Criteria('cat_id', '('.implode(', ', $valid_ids).')', 'IN'); |
|
54 | 54 | $criteria->setSort('cat_order'); |
55 | 55 | $categories = $this->getAll($criteria, $tags, $asObject); |
56 | 56 |
@@ -19,136 +19,136 @@ |
||
19 | 19 | */ |
20 | 20 | class CategoryHandler extends \XoopsPersistableObjectHandler |
21 | 21 | { |
22 | - /** |
|
23 | - * @param null|\XoopsDatabase $db |
|
24 | - */ |
|
25 | - public function __construct(\XoopsDatabase $db) |
|
26 | - { |
|
27 | - parent::__construct($db, 'newbb_categories', Category::class, 'cat_id', 'cat_title'); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * @param string $perm |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function getIdsByPermission($perm = 'access') |
|
35 | - { |
|
36 | - /** var Newbb\PermissionHandler $permHandler */ |
|
37 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
38 | - return $permHandler->getCategories($perm); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $permission |
|
43 | - * @param null $tags |
|
44 | - * @param bool $asObject |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function &getByPermission($permission = 'access', $tags = null, $asObject = true) |
|
48 | - { |
|
49 | - $categories = []; |
|
50 | - if (!$valid_ids = $this->getIdsByPermission($permission)) { |
|
51 | - return $categories; |
|
52 | - } |
|
53 | - $criteria = new \Criteria('cat_id', '(' . implode(', ', $valid_ids) . ')', 'IN'); |
|
54 | - $criteria->setSort('cat_order'); |
|
55 | - $categories = $this->getAll($criteria, $tags, $asObject); |
|
56 | - |
|
57 | - return $categories; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @param \XoopsObject $category |
|
62 | - * @param bool $force |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - public function insert(\XoopsObject $category, $force = true) |
|
66 | - { |
|
67 | - $className = Category::class; |
|
68 | - if (!($category instanceof $className)) { |
|
69 | - return false; |
|
70 | - } |
|
71 | - parent::insert($category, $force); |
|
72 | - if ($category->isNew()) { |
|
73 | - $this->applyPermissionTemplate($category); |
|
74 | - } |
|
75 | - |
|
76 | - return $category->getVar('cat_id'); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @param \XoopsObject $category |
|
81 | - * @param bool $force |
|
82 | - * @return bool|mixed |
|
83 | - * @internal param Category $category |
|
84 | - */ |
|
85 | - public function delete(\XoopsObject $category, $force = false)//delete(Category $category) |
|
86 | - { |
|
87 | - $className = Category::class; |
|
88 | - if (!($category instanceof $className)) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
92 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
93 | - $forumHandler->deleteAll(new \Criteria('cat_id', $category->getVar('cat_id')), true, true); |
|
94 | - if ($result = parent::delete($category)) { |
|
95 | - // Delete group permissions |
|
96 | - return $this->deletePermission($category); |
|
97 | - } else { |
|
98 | - $category->setErrors('delete category error'); |
|
99 | - |
|
100 | - return false; |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Check permission for a category |
|
106 | - * |
|
107 | - * @param Category|int $category object or id |
|
108 | - * @param string $perm permission name |
|
109 | - * |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function getPermission($category, $perm = 'access') |
|
113 | - { |
|
114 | - if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { |
|
115 | - return true; |
|
116 | - } |
|
117 | - |
|
118 | - $cat_id = is_object($category) ? $category->getVar('cat_id') : (int)$category; |
|
119 | - /** @var PermissionHandler $permHandler */ |
|
120 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
121 | - return $permHandler->getPermission('category', $perm, $cat_id); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @param Category $category |
|
126 | - * @return mixed |
|
127 | - */ |
|
128 | - public function deletePermission(Category $category) |
|
129 | - { |
|
130 | - /** @var PermissionHandler $permHandler */ |
|
131 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
132 | - return $permHandler->deleteByCategory($category->getVar('cat_id')); |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @param Category $category |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - public function applyPermissionTemplate(Category $category) |
|
140 | - { |
|
141 | - /** @var PermissionHandler $permHandler */ |
|
142 | - $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
143 | - return $permHandler->setCategoryPermission($category->getVar('cat_id')); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @param mixed $object |
|
148 | - * @return bool |
|
149 | - */ |
|
150 | - public function synchronization($object = null) |
|
151 | - { |
|
152 | - return true; |
|
153 | - } |
|
22 | + /** |
|
23 | + * @param null|\XoopsDatabase $db |
|
24 | + */ |
|
25 | + public function __construct(\XoopsDatabase $db) |
|
26 | + { |
|
27 | + parent::__construct($db, 'newbb_categories', Category::class, 'cat_id', 'cat_title'); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * @param string $perm |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function getIdsByPermission($perm = 'access') |
|
35 | + { |
|
36 | + /** var Newbb\PermissionHandler $permHandler */ |
|
37 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
38 | + return $permHandler->getCategories($perm); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $permission |
|
43 | + * @param null $tags |
|
44 | + * @param bool $asObject |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function &getByPermission($permission = 'access', $tags = null, $asObject = true) |
|
48 | + { |
|
49 | + $categories = []; |
|
50 | + if (!$valid_ids = $this->getIdsByPermission($permission)) { |
|
51 | + return $categories; |
|
52 | + } |
|
53 | + $criteria = new \Criteria('cat_id', '(' . implode(', ', $valid_ids) . ')', 'IN'); |
|
54 | + $criteria->setSort('cat_order'); |
|
55 | + $categories = $this->getAll($criteria, $tags, $asObject); |
|
56 | + |
|
57 | + return $categories; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @param \XoopsObject $category |
|
62 | + * @param bool $force |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + public function insert(\XoopsObject $category, $force = true) |
|
66 | + { |
|
67 | + $className = Category::class; |
|
68 | + if (!($category instanceof $className)) { |
|
69 | + return false; |
|
70 | + } |
|
71 | + parent::insert($category, $force); |
|
72 | + if ($category->isNew()) { |
|
73 | + $this->applyPermissionTemplate($category); |
|
74 | + } |
|
75 | + |
|
76 | + return $category->getVar('cat_id'); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @param \XoopsObject $category |
|
81 | + * @param bool $force |
|
82 | + * @return bool|mixed |
|
83 | + * @internal param Category $category |
|
84 | + */ |
|
85 | + public function delete(\XoopsObject $category, $force = false)//delete(Category $category) |
|
86 | + { |
|
87 | + $className = Category::class; |
|
88 | + if (!($category instanceof $className)) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
92 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
93 | + $forumHandler->deleteAll(new \Criteria('cat_id', $category->getVar('cat_id')), true, true); |
|
94 | + if ($result = parent::delete($category)) { |
|
95 | + // Delete group permissions |
|
96 | + return $this->deletePermission($category); |
|
97 | + } else { |
|
98 | + $category->setErrors('delete category error'); |
|
99 | + |
|
100 | + return false; |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Check permission for a category |
|
106 | + * |
|
107 | + * @param Category|int $category object or id |
|
108 | + * @param string $perm permission name |
|
109 | + * |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function getPermission($category, $perm = 'access') |
|
113 | + { |
|
114 | + if ($GLOBALS['xoopsUserIsAdmin'] && 'newbb' === $GLOBALS['xoopsModule']->getVar('dirname')) { |
|
115 | + return true; |
|
116 | + } |
|
117 | + |
|
118 | + $cat_id = is_object($category) ? $category->getVar('cat_id') : (int)$category; |
|
119 | + /** @var PermissionHandler $permHandler */ |
|
120 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
121 | + return $permHandler->getPermission('category', $perm, $cat_id); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @param Category $category |
|
126 | + * @return mixed |
|
127 | + */ |
|
128 | + public function deletePermission(Category $category) |
|
129 | + { |
|
130 | + /** @var PermissionHandler $permHandler */ |
|
131 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
132 | + return $permHandler->deleteByCategory($category->getVar('cat_id')); |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @param Category $category |
|
137 | + * @return mixed |
|
138 | + */ |
|
139 | + public function applyPermissionTemplate(Category $category) |
|
140 | + { |
|
141 | + /** @var PermissionHandler $permHandler */ |
|
142 | + $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
|
143 | + return $permHandler->setCategoryPermission($category->getVar('cat_id')); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @param mixed $object |
|
148 | + * @return bool |
|
149 | + */ |
|
150 | + public function synchronization($object = null) |
|
151 | + { |
|
152 | + return true; |
|
153 | + } |
|
154 | 154 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | if (empty($id)) { |
83 | 83 | return null; |
84 | 84 | } |
85 | - $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->keyName . ' = ' . (int)$id; |
|
85 | + $sql = 'SELECT * FROM '.$this->table.' WHERE '.$this->keyName.' = '.(int)$id; |
|
86 | 86 | if (!$result = $this->db->query($sql)) { |
87 | 87 | return null; |
88 | 88 | } |
@@ -20,47 +20,47 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class UserstatsHandler extends \XoopsPersistableObjectHandler |
22 | 22 | { |
23 | - /** |
|
24 | - * @param \XoopsDatabase $db |
|
25 | - */ |
|
26 | - public function __construct(\XoopsDatabase $db) |
|
27 | - { |
|
28 | - parent::__construct($db, 'newbb_user_stats', Userstats::class, 'uid', ''); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @param null $db |
|
33 | - * @return UserstatsHandler |
|
34 | - */ |
|
35 | - public static function getInstance($db = null) |
|
36 | - { |
|
37 | - static $instance; |
|
38 | - if (null === $instance) { |
|
39 | - $instance = new static($db); |
|
40 | - } |
|
41 | - |
|
42 | - return $instance; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @param mixed $id |
|
47 | - * @param null $fields |
|
48 | - * @return null|\XoopsObject |
|
49 | - */ |
|
50 | - public function get($id = null, $fields = null) //get($id) |
|
51 | - { |
|
52 | - $object = null; |
|
53 | - if (!$id = (int)$id) { |
|
54 | - return $object; |
|
55 | - } |
|
56 | - $object = $this->create(false); |
|
57 | - $object->setVar($this->keyName, $id); |
|
58 | - if (!$row = $this->getStats($id)) { |
|
59 | - return $object; |
|
60 | - } |
|
61 | - $object->assignVars($row); |
|
62 | - |
|
63 | - /* |
|
23 | + /** |
|
24 | + * @param \XoopsDatabase $db |
|
25 | + */ |
|
26 | + public function __construct(\XoopsDatabase $db) |
|
27 | + { |
|
28 | + parent::__construct($db, 'newbb_user_stats', Userstats::class, 'uid', ''); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @param null $db |
|
33 | + * @return UserstatsHandler |
|
34 | + */ |
|
35 | + public static function getInstance($db = null) |
|
36 | + { |
|
37 | + static $instance; |
|
38 | + if (null === $instance) { |
|
39 | + $instance = new static($db); |
|
40 | + } |
|
41 | + |
|
42 | + return $instance; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @param mixed $id |
|
47 | + * @param null $fields |
|
48 | + * @return null|\XoopsObject |
|
49 | + */ |
|
50 | + public function get($id = null, $fields = null) //get($id) |
|
51 | + { |
|
52 | + $object = null; |
|
53 | + if (!$id = (int)$id) { |
|
54 | + return $object; |
|
55 | + } |
|
56 | + $object = $this->create(false); |
|
57 | + $object->setVar($this->keyName, $id); |
|
58 | + if (!$row = $this->getStats($id)) { |
|
59 | + return $object; |
|
60 | + } |
|
61 | + $object->assignVars($row); |
|
62 | + |
|
63 | + /* |
|
64 | 64 | $sql = "SELECT * FROM " . $this->table . " WHERE ".$this->keyName." = " . $id; |
65 | 65 | if (!$result = $this->db->query($sql)) { |
66 | 66 | return $object; |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | } |
71 | 71 | */ |
72 | 72 | |
73 | - return $object; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @param $id |
|
78 | - * @return null|array |
|
79 | - */ |
|
80 | - public function getStats($id) |
|
81 | - { |
|
82 | - if (empty($id)) { |
|
83 | - return null; |
|
84 | - } |
|
85 | - $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->keyName . ' = ' . (int)$id; |
|
86 | - if (!$result = $this->db->query($sql)) { |
|
87 | - return null; |
|
88 | - } |
|
89 | - $row = $this->db->fetchArray($result); |
|
90 | - |
|
91 | - return $row; |
|
92 | - } |
|
93 | - /* |
|
73 | + return $object; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @param $id |
|
78 | + * @return null|array |
|
79 | + */ |
|
80 | + public function getStats($id) |
|
81 | + { |
|
82 | + if (empty($id)) { |
|
83 | + return null; |
|
84 | + } |
|
85 | + $sql = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->keyName . ' = ' . (int)$id; |
|
86 | + if (!$result = $this->db->query($sql)) { |
|
87 | + return null; |
|
88 | + } |
|
89 | + $row = $this->db->fetchArray($result); |
|
90 | + |
|
91 | + return $row; |
|
92 | + } |
|
93 | + /* |
|
94 | 94 | function insert(\XoopsObject $object, $force = true) |
95 | 95 | { |
96 | 96 | if (!$object->isDirty()) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if (!is_array($posts)) { |
41 | 41 | $posts = [$posts]; |
42 | 42 | } |
43 | - $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'); |
|
43 | + $post_criteria = new \Criteria('post_id', '('.implode(', ', $posts).')', 'IN'); |
|
44 | 44 | $ret = $this->getAll($post_criteria); |
45 | 45 | |
46 | 46 | return $ret; |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | if (empty($start)) { |
80 | 80 | $start = 0; |
81 | 81 | } |
82 | - $result_criteria = ' AND r.report_result = ' . $report_result; |
|
82 | + $result_criteria = ' AND r.report_result = '.$report_result; |
|
83 | 83 | |
84 | 84 | if ($forums) { |
85 | 85 | $forumCriteria = ''; |
86 | 86 | } elseif (!is_array($forums)) { |
87 | 87 | $forums = [$forums]; |
88 | - $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')'; |
|
88 | + $forumCriteria = ' AND p.forum_id IN ('.implode(',', $forums).')'; |
|
89 | 89 | } |
90 | - $tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id'; |
|
90 | + $tables_criteria = ' FROM '.$this->db->prefix('newbb_report').' r, '.$this->db->prefix('newbb_posts').' p WHERE r.post_id= p.post_id'; |
|
91 | 91 | |
92 | 92 | if ($report_id) { |
93 | - $result = $this->db->query('SELECT COUNT(*) as report_count' . $tables_criteria . $forumCriteria . $result_criteria . " AND report_id $operator_for_position $report_id" . $order_criteria); |
|
93 | + $result = $this->db->query('SELECT COUNT(*) as report_count'.$tables_criteria.$forumCriteria.$result_criteria." AND report_id $operator_for_position $report_id".$order_criteria); |
|
94 | 94 | if ($result) { |
95 | 95 | $row = $this->db->fetchArray($result); |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $start = (int)($position / $perpage) * $perpage; |
99 | 99 | } |
100 | 100 | |
101 | - $sql = 'SELECT r.*, p.subject, p.topic_id, p.forum_id' . $tables_criteria . $forumCriteria . $result_criteria . $order_criteria; |
|
101 | + $sql = 'SELECT r.*, p.subject, p.topic_id, p.forum_id'.$tables_criteria.$forumCriteria.$result_criteria.$order_criteria; |
|
102 | 102 | $result = $this->db->query($sql, $perpage, $start); |
103 | 103 | $ret = []; |
104 | 104 | //$reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
@@ -19,114 +19,114 @@ |
||
19 | 19 | */ |
20 | 20 | class ReportHandler extends \XoopsPersistableObjectHandler |
21 | 21 | { |
22 | - /** |
|
23 | - * @param \XoopsDatabase $db |
|
24 | - */ |
|
25 | - public function __construct(\XoopsDatabase $db) |
|
26 | - { |
|
27 | - parent::__construct($db, 'newbb_report', Report::class, 'report_id', ''); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @param \XoopsDatabase $db |
|
24 | + */ |
|
25 | + public function __construct(\XoopsDatabase $db) |
|
26 | + { |
|
27 | + parent::__construct($db, 'newbb_report', Report::class, 'report_id', ''); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param $posts |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - public function getByPost($posts) |
|
35 | - { |
|
36 | - $ret = []; |
|
37 | - if (!$posts) { |
|
38 | - return $ret; |
|
39 | - } |
|
40 | - if (!is_array($posts)) { |
|
41 | - $posts = [$posts]; |
|
42 | - } |
|
43 | - $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'); |
|
44 | - $ret = $this->getAll($post_criteria); |
|
30 | + /** |
|
31 | + * @param $posts |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + public function getByPost($posts) |
|
35 | + { |
|
36 | + $ret = []; |
|
37 | + if (!$posts) { |
|
38 | + return $ret; |
|
39 | + } |
|
40 | + if (!is_array($posts)) { |
|
41 | + $posts = [$posts]; |
|
42 | + } |
|
43 | + $post_criteria = new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'); |
|
44 | + $ret = $this->getAll($post_criteria); |
|
45 | 45 | |
46 | - return $ret; |
|
47 | - } |
|
46 | + return $ret; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param int|array $forums |
|
51 | - * @param string $order |
|
52 | - * @param int $perpage |
|
53 | - * @param $start |
|
54 | - * @param int $report_result |
|
55 | - * @param int $report_id |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function getAllReports( |
|
59 | - $forums = 0, |
|
60 | - $order = 'ASC', |
|
61 | - $perpage = 0, |
|
62 | - &$start, |
|
63 | - $report_result = 0, |
|
64 | - $report_id = 0 |
|
65 | - ) { |
|
66 | - $forumCriteria = ''; |
|
67 | - $row = []; |
|
68 | - if ('DESC' === $order) { |
|
69 | - $operator_for_position = '>'; |
|
70 | - } else { |
|
71 | - $order = 'ASC'; |
|
72 | - $operator_for_position = '<'; |
|
73 | - } |
|
74 | - $order_criteria = " ORDER BY r.report_id $order"; |
|
49 | + /** |
|
50 | + * @param int|array $forums |
|
51 | + * @param string $order |
|
52 | + * @param int $perpage |
|
53 | + * @param $start |
|
54 | + * @param int $report_result |
|
55 | + * @param int $report_id |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function getAllReports( |
|
59 | + $forums = 0, |
|
60 | + $order = 'ASC', |
|
61 | + $perpage = 0, |
|
62 | + &$start, |
|
63 | + $report_result = 0, |
|
64 | + $report_id = 0 |
|
65 | + ) { |
|
66 | + $forumCriteria = ''; |
|
67 | + $row = []; |
|
68 | + if ('DESC' === $order) { |
|
69 | + $operator_for_position = '>'; |
|
70 | + } else { |
|
71 | + $order = 'ASC'; |
|
72 | + $operator_for_position = '<'; |
|
73 | + } |
|
74 | + $order_criteria = " ORDER BY r.report_id $order"; |
|
75 | 75 | |
76 | - if ($perpage <= 0) { |
|
77 | - $perpage = 10; |
|
78 | - } |
|
79 | - if (empty($start)) { |
|
80 | - $start = 0; |
|
81 | - } |
|
82 | - $result_criteria = ' AND r.report_result = ' . $report_result; |
|
76 | + if ($perpage <= 0) { |
|
77 | + $perpage = 10; |
|
78 | + } |
|
79 | + if (empty($start)) { |
|
80 | + $start = 0; |
|
81 | + } |
|
82 | + $result_criteria = ' AND r.report_result = ' . $report_result; |
|
83 | 83 | |
84 | - if ($forums) { |
|
85 | - $forumCriteria = ''; |
|
86 | - } elseif (!is_array($forums)) { |
|
87 | - $forums = [$forums]; |
|
88 | - $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')'; |
|
89 | - } |
|
90 | - $tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id'; |
|
84 | + if ($forums) { |
|
85 | + $forumCriteria = ''; |
|
86 | + } elseif (!is_array($forums)) { |
|
87 | + $forums = [$forums]; |
|
88 | + $forumCriteria = ' AND p.forum_id IN (' . implode(',', $forums) . ')'; |
|
89 | + } |
|
90 | + $tables_criteria = ' FROM ' . $this->db->prefix('newbb_report') . ' r, ' . $this->db->prefix('newbb_posts') . ' p WHERE r.post_id= p.post_id'; |
|
91 | 91 | |
92 | - if ($report_id) { |
|
93 | - $result = $this->db->query('SELECT COUNT(*) as report_count' . $tables_criteria . $forumCriteria . $result_criteria . " AND report_id $operator_for_position $report_id" . $order_criteria); |
|
94 | - if ($result) { |
|
95 | - $row = $this->db->fetchArray($result); |
|
96 | - } |
|
97 | - $position = $row['report_count']; |
|
98 | - $start = (int)($position / $perpage) * $perpage; |
|
99 | - } |
|
92 | + if ($report_id) { |
|
93 | + $result = $this->db->query('SELECT COUNT(*) as report_count' . $tables_criteria . $forumCriteria . $result_criteria . " AND report_id $operator_for_position $report_id" . $order_criteria); |
|
94 | + if ($result) { |
|
95 | + $row = $this->db->fetchArray($result); |
|
96 | + } |
|
97 | + $position = $row['report_count']; |
|
98 | + $start = (int)($position / $perpage) * $perpage; |
|
99 | + } |
|
100 | 100 | |
101 | - $sql = 'SELECT r.*, p.subject, p.topic_id, p.forum_id' . $tables_criteria . $forumCriteria . $result_criteria . $order_criteria; |
|
102 | - $result = $this->db->query($sql, $perpage, $start); |
|
103 | - $ret = []; |
|
104 | - //$reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
105 | - while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
106 | - $ret[] = $myrow; // return as array |
|
107 | - } |
|
101 | + $sql = 'SELECT r.*, p.subject, p.topic_id, p.forum_id' . $tables_criteria . $forumCriteria . $result_criteria . $order_criteria; |
|
102 | + $result = $this->db->query($sql, $perpage, $start); |
|
103 | + $ret = []; |
|
104 | + //$reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
105 | + while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
106 | + $ret[] = $myrow; // return as array |
|
107 | + } |
|
108 | 108 | |
109 | - return $ret; |
|
110 | - } |
|
109 | + return $ret; |
|
110 | + } |
|
111 | 111 | |
112 | - /** |
|
113 | - * |
|
114 | - */ |
|
115 | - public function synchronization() |
|
116 | - { |
|
117 | - // return; |
|
118 | - } |
|
112 | + /** |
|
113 | + * |
|
114 | + */ |
|
115 | + public function synchronization() |
|
116 | + { |
|
117 | + // return; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * clean orphan items from database |
|
122 | - * |
|
123 | - * @param string $table_link |
|
124 | - * @param string $field_link |
|
125 | - * @param string $field_object |
|
126 | - * @return bool true on success |
|
127 | - */ |
|
128 | - public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() |
|
129 | - { |
|
130 | - return parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id'); |
|
131 | - } |
|
120 | + /** |
|
121 | + * clean orphan items from database |
|
122 | + * |
|
123 | + * @param string $table_link |
|
124 | + * @param string $field_link |
|
125 | + * @param string $field_object |
|
126 | + * @return bool true on success |
|
127 | + */ |
|
128 | + public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan() |
|
129 | + { |
|
130 | + return parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id'); |
|
131 | + } |
|
132 | 132 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | require_once $GLOBALS['xoops']->path('class/template.php'); |
71 | 71 | $breadcrumbTpl = new \XoopsTpl(); |
72 | 72 | $breadcrumbTpl->assign('breadcrumb', $this->bread); |
73 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
73 | + $html = $breadcrumbTpl->fetch('db:'.$this->dirname.'_common_breadcrumb.tpl'); |
|
74 | 74 | unset($breadcrumbTpl); |
75 | 75 | |
76 | 76 | return $html; |
@@ -31,49 +31,49 @@ |
||
31 | 31 | */ |
32 | 32 | class Breadcrumb |
33 | 33 | { |
34 | - /** @var string */ |
|
35 | - private $dirname; |
|
34 | + /** @var string */ |
|
35 | + private $dirname; |
|
36 | 36 | |
37 | - /** @var array */ |
|
38 | - private $bread = []; |
|
37 | + /** @var array */ |
|
38 | + private $bread = []; |
|
39 | 39 | |
40 | - public function __construct() |
|
41 | - { |
|
42 | - $this->dirname = basename(dirname(__DIR__)); |
|
43 | - } |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + $this->dirname = basename(dirname(__DIR__)); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Add link to breadcrumb |
|
47 | - * |
|
48 | - * @param string $title |
|
49 | - * @param string $link |
|
50 | - */ |
|
51 | - public function addLink($title = '', $link = '') |
|
52 | - { |
|
53 | - $this->bread[] = [ |
|
54 | - 'link' => $link, |
|
55 | - 'title' => $title |
|
56 | - ]; |
|
57 | - } |
|
45 | + /** |
|
46 | + * Add link to breadcrumb |
|
47 | + * |
|
48 | + * @param string $title |
|
49 | + * @param string $link |
|
50 | + */ |
|
51 | + public function addLink($title = '', $link = '') |
|
52 | + { |
|
53 | + $this->bread[] = [ |
|
54 | + 'link' => $link, |
|
55 | + 'title' => $title |
|
56 | + ]; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Render Pedigree BreadCrumb |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function render() |
|
65 | - { |
|
66 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
67 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
68 | - $GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
|
69 | - } |
|
59 | + /** |
|
60 | + * Render Pedigree BreadCrumb |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function render() |
|
65 | + { |
|
66 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
67 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
68 | + $GLOBALS['xoTheme'] = new \xos_opal_Theme(); |
|
69 | + } |
|
70 | 70 | |
71 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
72 | - $breadcrumbTpl = new \XoopsTpl(); |
|
73 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
74 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
75 | - unset($breadcrumbTpl); |
|
71 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
72 | + $breadcrumbTpl = new \XoopsTpl(); |
|
73 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
74 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
75 | + unset($breadcrumbTpl); |
|
76 | 76 | |
77 | - return $html; |
|
78 | - } |
|
77 | + return $html; |
|
78 | + } |
|
79 | 79 | } |
@@ -102,7 +102,7 @@ |
||
102 | 102 | $this->synchronizeTable($tableName); |
103 | 103 | $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); |
104 | 104 | $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); |
105 | - $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; |
|
105 | + $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n"."SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n".' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; |
|
106 | 106 | $this->tableHandler->addToQueue($sql); |
107 | 107 | } |
108 | 108 | } |
@@ -22,111 +22,111 @@ |
||
22 | 22 | */ |
23 | 23 | class Migrate extends \Xmf\Database\Migrate |
24 | 24 | { |
25 | - private $renameTables = [ |
|
26 | - 'bb_archive' => 'newbb_archive', |
|
27 | - 'bb_categories' => 'newbb_categories', |
|
28 | - 'bb_votedata' => 'newbb_votedata', |
|
29 | - 'bb_forums' => 'newbb_forums', |
|
30 | - 'bb_posts' => 'newbb_posts', |
|
31 | - 'bb_posts_text' => 'newbb_posts_text', |
|
32 | - 'bb_topics' => 'newbb_topics', |
|
33 | - 'bb_online' => 'newbb_online', |
|
34 | - 'bb_digest' => 'newbb_digest', |
|
35 | - 'bb_report' => 'newbb_report', |
|
36 | - 'bb_attachments' => 'newbb_attachments', |
|
37 | - 'bb_moderates' => 'newbb_moderates', |
|
38 | - 'bb_reads_forum' => 'newbb_reads_forum', |
|
39 | - 'bb_reads_topic' => 'newbb_reads_topic', |
|
40 | - 'bb_type' => 'newbb_type', |
|
41 | - 'bb_type_forum' => 'newbb_type_forum', |
|
42 | - 'bb_stats' => 'newbb_stats', |
|
43 | - 'bb_user_stats' => 'newbb_user_stats', |
|
44 | - ]; |
|
25 | + private $renameTables = [ |
|
26 | + 'bb_archive' => 'newbb_archive', |
|
27 | + 'bb_categories' => 'newbb_categories', |
|
28 | + 'bb_votedata' => 'newbb_votedata', |
|
29 | + 'bb_forums' => 'newbb_forums', |
|
30 | + 'bb_posts' => 'newbb_posts', |
|
31 | + 'bb_posts_text' => 'newbb_posts_text', |
|
32 | + 'bb_topics' => 'newbb_topics', |
|
33 | + 'bb_online' => 'newbb_online', |
|
34 | + 'bb_digest' => 'newbb_digest', |
|
35 | + 'bb_report' => 'newbb_report', |
|
36 | + 'bb_attachments' => 'newbb_attachments', |
|
37 | + 'bb_moderates' => 'newbb_moderates', |
|
38 | + 'bb_reads_forum' => 'newbb_reads_forum', |
|
39 | + 'bb_reads_topic' => 'newbb_reads_topic', |
|
40 | + 'bb_type' => 'newbb_type', |
|
41 | + 'bb_type_forum' => 'newbb_type_forum', |
|
42 | + 'bb_stats' => 'newbb_stats', |
|
43 | + 'bb_user_stats' => 'newbb_user_stats', |
|
44 | + ]; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Migrate constructor. |
|
48 | - * @throws \RuntimeException |
|
49 | - * @throws \InvalidArgumentException |
|
50 | - */ |
|
51 | - public function __construct() |
|
52 | - { |
|
53 | - parent::__construct('newbb'); |
|
54 | - } |
|
46 | + /** |
|
47 | + * Migrate constructor. |
|
48 | + * @throws \RuntimeException |
|
49 | + * @throws \InvalidArgumentException |
|
50 | + */ |
|
51 | + public function __construct() |
|
52 | + { |
|
53 | + parent::__construct('newbb'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * change table prefix if needed |
|
58 | - */ |
|
59 | - private function changePrefix() |
|
60 | - { |
|
61 | - foreach ($this->renameTables as $oldName => $newName) { |
|
62 | - if ($this->tableHandler->useTable($oldName)) { |
|
63 | - $this->tableHandler->renameTable($oldName, $newName); |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
56 | + /** |
|
57 | + * change table prefix if needed |
|
58 | + */ |
|
59 | + private function changePrefix() |
|
60 | + { |
|
61 | + foreach ($this->renameTables as $oldName => $newName) { |
|
62 | + if ($this->tableHandler->useTable($oldName)) { |
|
63 | + $this->tableHandler->renameTable($oldName, $newName); |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Change integer IPv4 column to varchar IPv6 capable |
|
70 | - * |
|
71 | - * @param string $tableName table to convert |
|
72 | - * @param string $columnName column with IP address |
|
73 | - * |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - private function convertIPAddresses($tableName, $columnName) |
|
77 | - { |
|
78 | - if ($this->tableHandler->useTable($tableName)) { |
|
79 | - $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); |
|
80 | - if (false !== strpos($attributes, ' int(')) { |
|
81 | - if (false === strpos($attributes, 'unsigned')) { |
|
82 | - $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL DEFAULT '0' "); |
|
83 | - $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false); |
|
84 | - } |
|
85 | - $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45) NOT NULL DEFAULT '' "); |
|
86 | - $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false); |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
68 | + /** |
|
69 | + * Change integer IPv4 column to varchar IPv6 capable |
|
70 | + * |
|
71 | + * @param string $tableName table to convert |
|
72 | + * @param string $columnName column with IP address |
|
73 | + * |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + private function convertIPAddresses($tableName, $columnName) |
|
77 | + { |
|
78 | + if ($this->tableHandler->useTable($tableName)) { |
|
79 | + $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName); |
|
80 | + if (false !== strpos($attributes, ' int(')) { |
|
81 | + if (false === strpos($attributes, 'unsigned')) { |
|
82 | + $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL DEFAULT '0' "); |
|
83 | + $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false); |
|
84 | + } |
|
85 | + $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45) NOT NULL DEFAULT '' "); |
|
86 | + $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false); |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Move do* columns from newbb_posts to newbb_posts_text table |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - private function moveDoColumns() |
|
97 | - { |
|
98 | - $tableName = 'newbb_posts_text'; |
|
99 | - $srcTableName = 'newbb_posts'; |
|
100 | - if (false !== $this->tableHandler->useTable($tableName) |
|
101 | - && false !== $this->tableHandler->useTable($srcTableName)) { |
|
102 | - $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); |
|
103 | - if (false === $attributes) { |
|
104 | - $this->synchronizeTable($tableName); |
|
105 | - $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); |
|
106 | - $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); |
|
107 | - $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; |
|
108 | - $this->tableHandler->addToQueue($sql); |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
91 | + /** |
|
92 | + * Move do* columns from newbb_posts to newbb_posts_text table |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + private function moveDoColumns() |
|
97 | + { |
|
98 | + $tableName = 'newbb_posts_text'; |
|
99 | + $srcTableName = 'newbb_posts'; |
|
100 | + if (false !== $this->tableHandler->useTable($tableName) |
|
101 | + && false !== $this->tableHandler->useTable($srcTableName)) { |
|
102 | + $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml'); |
|
103 | + if (false === $attributes) { |
|
104 | + $this->synchronizeTable($tableName); |
|
105 | + $updateTable = $GLOBALS['xoopsDB']->prefix($tableName); |
|
106 | + $joinTable = $GLOBALS['xoopsDB']->prefix($srcTableName); |
|
107 | + $sql = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml, t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . ' , t1.doimage = t2.doimage, t1.dobr = t2.dobr'; |
|
108 | + $this->tableHandler->addToQueue($sql); |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Perform any upfront actions before synchronizing the schema |
|
115 | - * |
|
116 | - * Some typical uses include |
|
117 | - * table and column renames |
|
118 | - * data conversions |
|
119 | - * |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - protected function preSyncActions() |
|
123 | - { |
|
124 | - // change 'bb' table prefix to 'newbb' |
|
125 | - $this->changePrefix(); |
|
126 | - // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point |
|
127 | - $this->moveDoColumns(); |
|
128 | - // Convert IP address columns from int to readable varchar(45) for IPv6 |
|
129 | - $this->convertIPAddresses('newbb_posts', 'poster_ip'); |
|
130 | - $this->convertIPAddresses('newbb_report', 'reporter_ip'); |
|
131 | - } |
|
113 | + /** |
|
114 | + * Perform any upfront actions before synchronizing the schema |
|
115 | + * |
|
116 | + * Some typical uses include |
|
117 | + * table and column renames |
|
118 | + * data conversions |
|
119 | + * |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + protected function preSyncActions() |
|
123 | + { |
|
124 | + // change 'bb' table prefix to 'newbb' |
|
125 | + $this->changePrefix(); |
|
126 | + // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point |
|
127 | + $this->moveDoColumns(); |
|
128 | + // Convert IP address columns from int to readable varchar(45) for IPv6 |
|
129 | + $this->convertIPAddresses('newbb_posts', 'poster_ip'); |
|
130 | + $this->convertIPAddresses('newbb_report', 'reporter_ip'); |
|
131 | + } |
|
132 | 132 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // $start = 0; |
87 | 87 | // } |
88 | 88 | |
89 | - $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_digest') . ' ORDER BY digest_id DESC'; |
|
89 | + $sql = 'SELECT * FROM '.$this->db->prefix('newbb_digest').' ORDER BY digest_id DESC'; |
|
90 | 90 | $result = $this->db->query($sql, $perpage, $start); |
91 | 91 | $ret = []; |
92 | 92 | // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function getDigestCount() |
104 | 104 | { |
105 | - $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_digest'); |
|
105 | + $sql = 'SELECT COUNT(*) AS count FROM '.$this->db->prefix('newbb_digest'); |
|
106 | 106 | $result = $this->db->query($sql); |
107 | 107 | if (!$result) { |
108 | 108 | return 0; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | public function getLastDigest() |
117 | 117 | { |
118 | - $sql = 'SELECT MAX(digest_time) AS last_digest FROM ' . $this->db->prefix('newbb_digest'); |
|
118 | + $sql = 'SELECT MAX(digest_time) AS last_digest FROM '.$this->db->prefix('newbb_digest'); |
|
119 | 119 | $result = $this->db->query($sql); |
120 | 120 | if (!$result) { |
121 | 121 | $this->last_digest = 0; |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $GLOBALS['xoopsUser'] = $thisUser; |
207 | 207 | |
208 | 208 | $accessForums = $forumHandler->getIdsByPermission(); // get all accessible forums |
209 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $accessForums) . ')'; |
|
209 | + $forumCriteria = ' AND t.forum_id IN ('.implode(',', $accessForums).')'; |
|
210 | 210 | $approveCriteria = ' AND t.approved = 1 AND p.approved = 1'; |
211 | - $time_criteria = ' AND t.digest_time > ' . $this->last_digest; |
|
211 | + $time_criteria = ' AND t.digest_time > '.$this->last_digest; |
|
212 | 212 | |
213 | 213 | $karma_criteria = $GLOBALS['xoopsModuleConfig']['enable_karma'] ? ' AND p.post_karma=0' : ''; |
214 | 214 | $reply_criteria = $GLOBALS['xoopsModuleConfig']['allow_require_reply'] ? ' AND p.require_reply=0' : ''; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if (count($uids) > 0) { |
244 | 244 | /** @var \XoopsMemberHandler $memberHandler */ |
245 | 245 | $memberHandler = xoops_getHandler('member'); |
246 | - $user_criteria = new \Criteria('uid', '(' . implode(',', $uids) . ')', 'IN'); |
|
246 | + $user_criteria = new \Criteria('uid', '('.implode(',', $uids).')', 'IN'); |
|
247 | 247 | $users = $memberHandler->getUsers($user_criteria, true); |
248 | 248 | } else { |
249 | 249 | $users = []; |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | $topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']; |
262 | 262 | } |
263 | 263 | $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); |
264 | - $author = $topic['uname'] . ' (' . formatTimestamp($topic['topic_time']) . ')'; |
|
265 | - $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; |
|
264 | + $author = $topic['uname'].' ('.formatTimestamp($topic['topic_time']).')'; |
|
265 | + $link = XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/viewtopic.php?topic_id='.$topic['topic_id'].'&forum='.$topic['forum_id']; |
|
266 | 266 | $title = $topic['topic_title']; |
267 | 267 | $digest->addItem($title, $link, $author, $summary); |
268 | 268 | } |
@@ -17,139 +17,139 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class DigestHandler extends \XoopsPersistableObjectHandler |
19 | 19 | { |
20 | - public $last_digest; |
|
20 | + public $last_digest; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Constructor |
|
24 | - * |
|
25 | - * @param null|\XoopsDatabase $db database connection |
|
26 | - */ |
|
27 | - public function __construct(\XoopsDatabase $db) |
|
28 | - { |
|
29 | - parent::__construct($db, 'newbb_digest', Digest::class, 'digest_id'); |
|
30 | - } |
|
22 | + /** |
|
23 | + * Constructor |
|
24 | + * |
|
25 | + * @param null|\XoopsDatabase $db database connection |
|
26 | + */ |
|
27 | + public function __construct(\XoopsDatabase $db) |
|
28 | + { |
|
29 | + parent::__construct($db, 'newbb_digest', Digest::class, 'digest_id'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param bool $isForced |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function process($isForced = false) |
|
37 | - { |
|
38 | - $this->getLastDigest(); |
|
39 | - if (!$isForced) { |
|
40 | - $status = $this->checkStatus(); |
|
41 | - if ($status < 1) { |
|
42 | - return 1; |
|
43 | - } |
|
44 | - } |
|
45 | - $digest = $this->create(); |
|
46 | - $status = $this->buildDigest($digest); |
|
47 | - if (!$status) { |
|
48 | - return 2; |
|
49 | - } |
|
50 | - $status = $this->insert($digest); |
|
51 | - if (!$status) { |
|
52 | - return 3; |
|
53 | - } |
|
54 | - $status = $this->notify($digest); |
|
55 | - if (!$status) { |
|
56 | - return 4; |
|
57 | - } |
|
32 | + /** |
|
33 | + * @param bool $isForced |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function process($isForced = false) |
|
37 | + { |
|
38 | + $this->getLastDigest(); |
|
39 | + if (!$isForced) { |
|
40 | + $status = $this->checkStatus(); |
|
41 | + if ($status < 1) { |
|
42 | + return 1; |
|
43 | + } |
|
44 | + } |
|
45 | + $digest = $this->create(); |
|
46 | + $status = $this->buildDigest($digest); |
|
47 | + if (!$status) { |
|
48 | + return 2; |
|
49 | + } |
|
50 | + $status = $this->insert($digest); |
|
51 | + if (!$status) { |
|
52 | + return 3; |
|
53 | + } |
|
54 | + $status = $this->notify($digest); |
|
55 | + if (!$status) { |
|
56 | + return 4; |
|
57 | + } |
|
58 | 58 | |
59 | - return 0; |
|
60 | - } |
|
59 | + return 0; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param \XoopsObject $digest |
|
64 | - * @return bool |
|
65 | - */ |
|
66 | - public function notify(\XoopsObject $digest) |
|
67 | - { |
|
68 | - //$content = $digest->getVar('digest_content'); |
|
69 | - /** @var \XoopsNotificationHandler $notificationHandler */ |
|
70 | - $notificationHandler = xoops_getHandler('notification'); |
|
71 | - $tags['DIGEST_ID'] = $digest->getVar('digest_id'); |
|
72 | - $tags['DIGEST_CONTENT'] = $digest->getVar('digest_content', 'E'); |
|
73 | - $notificationHandler->triggerEvent('global', 0, 'digest', $tags); |
|
62 | + /** |
|
63 | + * @param \XoopsObject $digest |
|
64 | + * @return bool |
|
65 | + */ |
|
66 | + public function notify(\XoopsObject $digest) |
|
67 | + { |
|
68 | + //$content = $digest->getVar('digest_content'); |
|
69 | + /** @var \XoopsNotificationHandler $notificationHandler */ |
|
70 | + $notificationHandler = xoops_getHandler('notification'); |
|
71 | + $tags['DIGEST_ID'] = $digest->getVar('digest_id'); |
|
72 | + $tags['DIGEST_CONTENT'] = $digest->getVar('digest_content', 'E'); |
|
73 | + $notificationHandler->triggerEvent('global', 0, 'digest', $tags); |
|
74 | 74 | |
75 | - return true; |
|
76 | - } |
|
75 | + return true; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param $start |
|
80 | - * @param int $perpage |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function getAllDigests($start = 0, $perpage = 5) |
|
84 | - { |
|
85 | - // if (empty($start)) { |
|
86 | - // $start = 0; |
|
87 | - // } |
|
78 | + /** |
|
79 | + * @param $start |
|
80 | + * @param int $perpage |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function getAllDigests($start = 0, $perpage = 5) |
|
84 | + { |
|
85 | + // if (empty($start)) { |
|
86 | + // $start = 0; |
|
87 | + // } |
|
88 | 88 | |
89 | - $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_digest') . ' ORDER BY digest_id DESC'; |
|
90 | - $result = $this->db->query($sql, $perpage, $start); |
|
91 | - $ret = []; |
|
92 | - // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
93 | - while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
94 | - $ret[] = $myrow; // return as array |
|
95 | - } |
|
89 | + $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_digest') . ' ORDER BY digest_id DESC'; |
|
90 | + $result = $this->db->query($sql, $perpage, $start); |
|
91 | + $ret = []; |
|
92 | + // $reportHandler = Newbb\Helper::getInstance()->getHandler('Report'); |
|
93 | + while (false !== ($myrow = $this->db->fetchArray($result))) { |
|
94 | + $ret[] = $myrow; // return as array |
|
95 | + } |
|
96 | 96 | |
97 | - return $ret; |
|
98 | - } |
|
97 | + return $ret; |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return int |
|
102 | - */ |
|
103 | - public function getDigestCount() |
|
104 | - { |
|
105 | - $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_digest'); |
|
106 | - $result = $this->db->query($sql); |
|
107 | - if (!$result) { |
|
108 | - return 0; |
|
109 | - } else { |
|
110 | - $array = $this->db->fetchArray($result); |
|
100 | + /** |
|
101 | + * @return int |
|
102 | + */ |
|
103 | + public function getDigestCount() |
|
104 | + { |
|
105 | + $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_digest'); |
|
106 | + $result = $this->db->query($sql); |
|
107 | + if (!$result) { |
|
108 | + return 0; |
|
109 | + } else { |
|
110 | + $array = $this->db->fetchArray($result); |
|
111 | 111 | |
112 | - return $array['count']; |
|
113 | - } |
|
114 | - } |
|
112 | + return $array['count']; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - public function getLastDigest() |
|
117 | - { |
|
118 | - $sql = 'SELECT MAX(digest_time) AS last_digest FROM ' . $this->db->prefix('newbb_digest'); |
|
119 | - $result = $this->db->query($sql); |
|
120 | - if (!$result) { |
|
121 | - $this->last_digest = 0; |
|
122 | - // echo "<br>no data:".$query; |
|
123 | - } else { |
|
124 | - $array = $this->db->fetchArray($result); |
|
125 | - $this->last_digest = isset($array['last_digest']) ? $array['last_digest'] : 0; |
|
126 | - } |
|
127 | - } |
|
116 | + public function getLastDigest() |
|
117 | + { |
|
118 | + $sql = 'SELECT MAX(digest_time) AS last_digest FROM ' . $this->db->prefix('newbb_digest'); |
|
119 | + $result = $this->db->query($sql); |
|
120 | + if (!$result) { |
|
121 | + $this->last_digest = 0; |
|
122 | + // echo "<br>no data:".$query; |
|
123 | + } else { |
|
124 | + $array = $this->db->fetchArray($result); |
|
125 | + $this->last_digest = isset($array['last_digest']) ? $array['last_digest'] : 0; |
|
126 | + } |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function checkStatus() |
|
133 | - { |
|
134 | - if (!isset($this->last_digest)) { |
|
135 | - $this->getLastDigest(); |
|
136 | - } |
|
137 | - $deadline = (1 == $GLOBALS['xoopsModuleConfig']['email_digest']) ? 60 * 60 * 24 : 60 * 60 * 24 * 7; |
|
138 | - $time_diff = time() - $this->last_digest; |
|
129 | + /** |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function checkStatus() |
|
133 | + { |
|
134 | + if (!isset($this->last_digest)) { |
|
135 | + $this->getLastDigest(); |
|
136 | + } |
|
137 | + $deadline = (1 == $GLOBALS['xoopsModuleConfig']['email_digest']) ? 60 * 60 * 24 : 60 * 60 * 24 * 7; |
|
138 | + $time_diff = time() - $this->last_digest; |
|
139 | 139 | |
140 | - return $time_diff - $deadline; |
|
141 | - } |
|
140 | + return $time_diff - $deadline; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * @param \XoopsObject $digest |
|
145 | - * @param bool $force flag to force the query execution despite security settings |
|
146 | - * @return mixed object ID or false |
|
147 | - */ |
|
148 | - public function insert(\XoopsObject $digest, $force = true) |
|
149 | - { |
|
150 | - $digest->setVar('digest_time', time()); |
|
151 | - return parent::insert($digest, $force); |
|
152 | - /* |
|
143 | + /** |
|
144 | + * @param \XoopsObject $digest |
|
145 | + * @param bool $force flag to force the query execution despite security settings |
|
146 | + * @return mixed object ID or false |
|
147 | + */ |
|
148 | + public function insert(\XoopsObject $digest, $force = true) |
|
149 | + { |
|
150 | + $digest->setVar('digest_time', time()); |
|
151 | + return parent::insert($digest, $force); |
|
152 | + /* |
|
153 | 153 | $content = $digest->getVar('digest_content', 'E'); |
154 | 154 | |
155 | 155 | $id = $this->db->genId($digest->table . '_digest_id_seq'); |
@@ -166,108 +166,108 @@ discard block |
||
166 | 166 | |
167 | 167 | return true; |
168 | 168 | */ |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * @param \XoopsObject $digest |
|
173 | - * @param bool $force (ignored) |
|
174 | - * @return bool FALSE if failed. |
|
175 | - */ |
|
176 | - public function delete(\XoopsObject $digest, $force = false) |
|
177 | - { |
|
178 | - $digest_id = $digest->getVar('digest_id'); |
|
171 | + /** |
|
172 | + * @param \XoopsObject $digest |
|
173 | + * @param bool $force (ignored) |
|
174 | + * @return bool FALSE if failed. |
|
175 | + */ |
|
176 | + public function delete(\XoopsObject $digest, $force = false) |
|
177 | + { |
|
178 | + $digest_id = $digest->getVar('digest_id'); |
|
179 | 179 | |
180 | - if (!isset($this->last_digest)) { |
|
181 | - $this->getLastDigest(); |
|
182 | - } |
|
183 | - if ($this->last_digest == $digest_id) { |
|
184 | - return false; |
|
185 | - } // It is not allowed to delete the last digest |
|
180 | + if (!isset($this->last_digest)) { |
|
181 | + $this->getLastDigest(); |
|
182 | + } |
|
183 | + if ($this->last_digest == $digest_id) { |
|
184 | + return false; |
|
185 | + } // It is not allowed to delete the last digest |
|
186 | 186 | |
187 | - return parent::delete($digest, true); |
|
188 | - } |
|
187 | + return parent::delete($digest, true); |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * @param \XoopsObject $digest |
|
192 | - * @return bool |
|
193 | - */ |
|
194 | - public function buildDigest(\XoopsObject $digest) |
|
195 | - { |
|
196 | - global $xoopsModule; |
|
190 | + /** |
|
191 | + * @param \XoopsObject $digest |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | + public function buildDigest(\XoopsObject $digest) |
|
195 | + { |
|
196 | + global $xoopsModule; |
|
197 | 197 | |
198 | - if (!defined('SUMMARY_LENGTH')) { |
|
199 | - define('SUMMARY_LENGTH', 100); |
|
200 | - } |
|
198 | + if (!defined('SUMMARY_LENGTH')) { |
|
199 | + define('SUMMARY_LENGTH', 100); |
|
200 | + } |
|
201 | 201 | |
202 | - /** @var Newbb\ForumHandler $forumHandler */ |
|
203 | - $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
204 | - $thisUser = $GLOBALS['xoopsUser']; |
|
205 | - $GLOBALS['xoopsUser'] = null; // To get posts accessible by anonymous |
|
206 | - $GLOBALS['xoopsUser'] = $thisUser; |
|
202 | + /** @var Newbb\ForumHandler $forumHandler */ |
|
203 | + $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
|
204 | + $thisUser = $GLOBALS['xoopsUser']; |
|
205 | + $GLOBALS['xoopsUser'] = null; // To get posts accessible by anonymous |
|
206 | + $GLOBALS['xoopsUser'] = $thisUser; |
|
207 | 207 | |
208 | - $accessForums = $forumHandler->getIdsByPermission(); // get all accessible forums |
|
209 | - $forumCriteria = ' AND t.forum_id IN (' . implode(',', $accessForums) . ')'; |
|
210 | - $approveCriteria = ' AND t.approved = 1 AND p.approved = 1'; |
|
211 | - $time_criteria = ' AND t.digest_time > ' . $this->last_digest; |
|
208 | + $accessForums = $forumHandler->getIdsByPermission(); // get all accessible forums |
|
209 | + $forumCriteria = ' AND t.forum_id IN (' . implode(',', $accessForums) . ')'; |
|
210 | + $approveCriteria = ' AND t.approved = 1 AND p.approved = 1'; |
|
211 | + $time_criteria = ' AND t.digest_time > ' . $this->last_digest; |
|
212 | 212 | |
213 | - $karma_criteria = $GLOBALS['xoopsModuleConfig']['enable_karma'] ? ' AND p.post_karma=0' : ''; |
|
214 | - $reply_criteria = $GLOBALS['xoopsModuleConfig']['allow_require_reply'] ? ' AND p.require_reply=0' : ''; |
|
213 | + $karma_criteria = $GLOBALS['xoopsModuleConfig']['enable_karma'] ? ' AND p.post_karma=0' : ''; |
|
214 | + $reply_criteria = $GLOBALS['xoopsModuleConfig']['allow_require_reply'] ? ' AND p.require_reply=0' : ''; |
|
215 | 215 | |
216 | - $query = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.digest_time, p.uid, p.poster_name, pt.post_text FROM ' |
|
217 | - . $this->db->prefix('newbb_topics') |
|
218 | - . ' t, ' |
|
219 | - . $this->db->prefix('newbb_posts_text') |
|
220 | - . ' pt, ' |
|
221 | - . $this->db->prefix('newbb_posts') |
|
222 | - . ' p WHERE t.topic_digest = 1 AND p.topic_id=t.topic_id AND p.pid=0 ' |
|
223 | - . $forumCriteria |
|
224 | - . $approveCriteria |
|
225 | - . $time_criteria |
|
226 | - . $karma_criteria |
|
227 | - . $reply_criteria |
|
228 | - . ' AND pt.post_id=p.post_id ORDER BY t.digest_time DESC'; |
|
229 | - if (!$result = $this->db->query($query)) { |
|
230 | - //echo "<br>No result:<br>$query"; |
|
231 | - return false; |
|
232 | - } |
|
233 | - $rows = []; |
|
234 | - $users = []; |
|
235 | - while (false !== ($row = $this->db->fetchArray($result))) { |
|
236 | - $users[$row['uid']] = 1; |
|
237 | - $rows[] = $row; |
|
238 | - } |
|
239 | - if (count($rows) < 1) { |
|
240 | - return false; |
|
241 | - } |
|
242 | - $uids = array_keys($users); |
|
243 | - if (count($uids) > 0) { |
|
244 | - /** @var \XoopsMemberHandler $memberHandler */ |
|
245 | - $memberHandler = xoops_getHandler('member'); |
|
246 | - $user_criteria = new \Criteria('uid', '(' . implode(',', $uids) . ')', 'IN'); |
|
247 | - $users = $memberHandler->getUsers($user_criteria, true); |
|
248 | - } else { |
|
249 | - $users = []; |
|
250 | - } |
|
216 | + $query = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.digest_time, p.uid, p.poster_name, pt.post_text FROM ' |
|
217 | + . $this->db->prefix('newbb_topics') |
|
218 | + . ' t, ' |
|
219 | + . $this->db->prefix('newbb_posts_text') |
|
220 | + . ' pt, ' |
|
221 | + . $this->db->prefix('newbb_posts') |
|
222 | + . ' p WHERE t.topic_digest = 1 AND p.topic_id=t.topic_id AND p.pid=0 ' |
|
223 | + . $forumCriteria |
|
224 | + . $approveCriteria |
|
225 | + . $time_criteria |
|
226 | + . $karma_criteria |
|
227 | + . $reply_criteria |
|
228 | + . ' AND pt.post_id=p.post_id ORDER BY t.digest_time DESC'; |
|
229 | + if (!$result = $this->db->query($query)) { |
|
230 | + //echo "<br>No result:<br>$query"; |
|
231 | + return false; |
|
232 | + } |
|
233 | + $rows = []; |
|
234 | + $users = []; |
|
235 | + while (false !== ($row = $this->db->fetchArray($result))) { |
|
236 | + $users[$row['uid']] = 1; |
|
237 | + $rows[] = $row; |
|
238 | + } |
|
239 | + if (count($rows) < 1) { |
|
240 | + return false; |
|
241 | + } |
|
242 | + $uids = array_keys($users); |
|
243 | + if (count($uids) > 0) { |
|
244 | + /** @var \XoopsMemberHandler $memberHandler */ |
|
245 | + $memberHandler = xoops_getHandler('member'); |
|
246 | + $user_criteria = new \Criteria('uid', '(' . implode(',', $uids) . ')', 'IN'); |
|
247 | + $users = $memberHandler->getUsers($user_criteria, true); |
|
248 | + } else { |
|
249 | + $users = []; |
|
250 | + } |
|
251 | 251 | |
252 | - foreach ($rows as $topic) { |
|
253 | - if ($topic['uid'] > 0) { |
|
254 | - if (isset($users[$topic['uid']]) && is_object($users[$topic['uid']]) |
|
255 | - && $users[$topic['uid']]->isActive()) { |
|
256 | - $topic['uname'] = $users[$topic['uid']]->getVar('uname'); |
|
257 | - } else { |
|
258 | - $topic['uname'] = $GLOBALS['xoopsConfig']['anonymous']; |
|
259 | - } |
|
260 | - } else { |
|
261 | - $topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']; |
|
262 | - } |
|
263 | - $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); |
|
264 | - $author = $topic['uname'] . ' (' . formatTimestamp($topic['topic_time']) . ')'; |
|
265 | - $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; |
|
266 | - $title = $topic['topic_title']; |
|
267 | - $digest->addItem($title, $link, $author, $summary); |
|
268 | - } |
|
269 | - $digest->buildContent(); |
|
252 | + foreach ($rows as $topic) { |
|
253 | + if ($topic['uid'] > 0) { |
|
254 | + if (isset($users[$topic['uid']]) && is_object($users[$topic['uid']]) |
|
255 | + && $users[$topic['uid']]->isActive()) { |
|
256 | + $topic['uname'] = $users[$topic['uid']]->getVar('uname'); |
|
257 | + } else { |
|
258 | + $topic['uname'] = $GLOBALS['xoopsConfig']['anonymous']; |
|
259 | + } |
|
260 | + } else { |
|
261 | + $topic['uname'] = $topic['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']; |
|
262 | + } |
|
263 | + $summary = \Xmf\Metagen::generateDescription($topic['post_text'], SUMMARY_LENGTH); |
|
264 | + $author = $topic['uname'] . ' (' . formatTimestamp($topic['topic_time']) . ')'; |
|
265 | + $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?topic_id=' . $topic['topic_id'] . '&forum=' . $topic['forum_id']; |
|
266 | + $title = $topic['topic_title']; |
|
267 | + $digest->addItem($title, $link, $author, $summary); |
|
268 | + } |
|
269 | + $digest->buildContent(); |
|
270 | 270 | |
271 | - return true; |
|
272 | - } |
|
271 | + return true; |
|
272 | + } |
|
273 | 273 | } |
@@ -21,49 +21,49 @@ |
||
21 | 21 | $moduleDirName = basename(dirname(dirname(__DIR__))); |
22 | 22 | $moduleDirNameUpper = strtoupper($moduleDirName); |
23 | 23 | |
24 | -define('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS', 'GD library support: '); |
|
25 | -define('CO_' . $moduleDirNameUpper . '_GDLIBVERSION', 'GD Library version: '); |
|
26 | -define('CO_' . $moduleDirNameUpper . '_GDOFF', "<span style='font-weight: bold;'>Disabled</span> (No thumbnails available)"); |
|
27 | -define('CO_' . $moduleDirNameUpper . '_GDON', "<span style='font-weight: bold;'>Enabled</span> (Thumbsnails available)"); |
|
28 | -define('CO_' . $moduleDirNameUpper . '_IMAGEINFO', 'Server status'); |
|
29 | -define('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); |
|
30 | -define('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); |
|
31 | -define('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); |
|
32 | -define('CO_' . $moduleDirNameUpper . '_METAVERSION', "<span style='font-weight: bold;'>Downloads meta version:</span> "); |
|
33 | -define('CO_' . $moduleDirNameUpper . '_OFF', "<span style='font-weight: bold;'>OFF</span>"); |
|
34 | -define('CO_' . $moduleDirNameUpper . '_ON', "<span style='font-weight: bold;'>ON</span>"); |
|
35 | -define('CO_' . $moduleDirNameUpper . '_SERVERPATH', 'Server path to XOOPS root: '); |
|
36 | -define('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS', 'Server uploads status: '); |
|
37 | -define('CO_' . $moduleDirNameUpper . '_SPHPINI', "<span style='font-weight: bold;'>Information taken from PHP ini file:</span>"); |
|
38 | -define('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); |
|
24 | +define('CO_'.$moduleDirNameUpper.'_GDLIBSTATUS', 'GD library support: '); |
|
25 | +define('CO_'.$moduleDirNameUpper.'_GDLIBVERSION', 'GD Library version: '); |
|
26 | +define('CO_'.$moduleDirNameUpper.'_GDOFF', "<span style='font-weight: bold;'>Disabled</span> (No thumbnails available)"); |
|
27 | +define('CO_'.$moduleDirNameUpper.'_GDON', "<span style='font-weight: bold;'>Enabled</span> (Thumbsnails available)"); |
|
28 | +define('CO_'.$moduleDirNameUpper.'_IMAGEINFO', 'Server status'); |
|
29 | +define('CO_'.$moduleDirNameUpper.'_MAXPOSTSIZE', 'Max post size permitted (post_max_size directive in php.ini): '); |
|
30 | +define('CO_'.$moduleDirNameUpper.'_MAXUPLOADSIZE', 'Max upload size permitted (upload_max_filesize directive in php.ini): '); |
|
31 | +define('CO_'.$moduleDirNameUpper.'_MEMORYLIMIT', 'Memory limit (memory_limit directive in php.ini): '); |
|
32 | +define('CO_'.$moduleDirNameUpper.'_METAVERSION', "<span style='font-weight: bold;'>Downloads meta version:</span> "); |
|
33 | +define('CO_'.$moduleDirNameUpper.'_OFF', "<span style='font-weight: bold;'>OFF</span>"); |
|
34 | +define('CO_'.$moduleDirNameUpper.'_ON', "<span style='font-weight: bold;'>ON</span>"); |
|
35 | +define('CO_'.$moduleDirNameUpper.'_SERVERPATH', 'Server path to XOOPS root: '); |
|
36 | +define('CO_'.$moduleDirNameUpper.'_SERVERUPLOADSTATUS', 'Server uploads status: '); |
|
37 | +define('CO_'.$moduleDirNameUpper.'_SPHPINI', "<span style='font-weight: bold;'>Information taken from PHP ini file:</span>"); |
|
38 | +define('CO_'.$moduleDirNameUpper.'_UPLOADPATHDSC', 'Note. Upload path *MUST* contain the full server path of your upload folder.'); |
|
39 | 39 | |
40 | -define('CO_' . $moduleDirNameUpper . '_PRINT', "<span style='font-weight: bold;'>Print</span>"); |
|
41 | -define('CO_' . $moduleDirNameUpper . '_PDF', "<span style='font-weight: bold;'>Create PDF</span>"); |
|
40 | +define('CO_'.$moduleDirNameUpper.'_PRINT', "<span style='font-weight: bold;'>Print</span>"); |
|
41 | +define('CO_'.$moduleDirNameUpper.'_PDF', "<span style='font-weight: bold;'>Create PDF</span>"); |
|
42 | 42 | |
43 | -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); |
|
44 | -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED1', "Update failed - couldn't add new fields"); |
|
45 | -define('CO_' . $moduleDirNameUpper . '_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); |
|
46 | -define('CO_' . $moduleDirNameUpper . '_ERROR_COLUMN', 'Could not create column in database : %s'); |
|
47 | -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); |
|
48 | -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); |
|
49 | -define('CO_' . $moduleDirNameUpper . '_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); |
|
43 | +define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED0', "Update failed - couldn't rename field '%s'"); |
|
44 | +define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED1', "Update failed - couldn't add new fields"); |
|
45 | +define('CO_'.$moduleDirNameUpper.'_UPGRADEFAILED2', "Update failed - couldn't rename table '%s'"); |
|
46 | +define('CO_'.$moduleDirNameUpper.'_ERROR_COLUMN', 'Could not create column in database : %s'); |
|
47 | +define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS', 'This module requires XOOPS %s+ (%s installed)'); |
|
48 | +define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP', 'This module requires PHP version %s+ (%s installed)'); |
|
49 | +define('CO_'.$moduleDirNameUpper.'_ERROR_TAG_REMOVAL', 'Could not remove tags from Tag Module'); |
|
50 | 50 | |
51 | -define('CO_' . $moduleDirNameUpper . '_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); |
|
51 | +define('CO_'.$moduleDirNameUpper.'_FOLDERS_DELETED_OK', 'Upload Folders have been deleted'); |
|
52 | 52 | |
53 | 53 | // Error Msgs |
54 | -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); |
|
55 | -define('CO_' . $moduleDirNameUpper . '_ERROR_BAD_REMOVE', 'Could not delete %s'); |
|
56 | -define('CO_' . $moduleDirNameUpper . '_ERROR_NO_PLUGIN', 'Could not load plugin'); |
|
54 | +define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_DEL_PATH', 'Could not delete %s directory'); |
|
55 | +define('CO_'.$moduleDirNameUpper.'_ERROR_BAD_REMOVE', 'Could not delete %s'); |
|
56 | +define('CO_'.$moduleDirNameUpper.'_ERROR_NO_PLUGIN', 'Could not load plugin'); |
|
57 | 57 | |
58 | 58 | //Help |
59 | -define('CO_' . $moduleDirNameUpper . '_DIRNAME', basename(dirname(dirname(__DIR__)))); |
|
60 | -define('CO_' . $moduleDirNameUpper . '_HELP_HEADER', __DIR__ . '/help/helpheader.tpl'); |
|
61 | -define('CO_' . $moduleDirNameUpper . '_BACK_2_ADMIN', 'Back to Administration of '); |
|
62 | -define('CO_' . $moduleDirNameUpper . '_OVERVIEW', 'Overview'); |
|
59 | +define('CO_'.$moduleDirNameUpper.'_DIRNAME', basename(dirname(dirname(__DIR__)))); |
|
60 | +define('CO_'.$moduleDirNameUpper.'_HELP_HEADER', __DIR__.'/help/helpheader.tpl'); |
|
61 | +define('CO_'.$moduleDirNameUpper.'_BACK_2_ADMIN', 'Back to Administration of '); |
|
62 | +define('CO_'.$moduleDirNameUpper.'_OVERVIEW', 'Overview'); |
|
63 | 63 | |
64 | 64 | //define('CO_' . $moduleDirNameUpper . '_HELP_DIR', __DIR__); |
65 | 65 | |
66 | 66 | //help multi-page |
67 | -define('CO_' . $moduleDirNameUpper . '_DISCLAIMER', 'Disclaimer'); |
|
68 | -define('CO_' . $moduleDirNameUpper . '_LICENSE', 'License'); |
|
69 | -define('CO_' . $moduleDirNameUpper . '_SUPPORT', 'Support'); |
|
67 | +define('CO_'.$moduleDirNameUpper.'_DISCLAIMER', 'Disclaimer'); |
|
68 | +define('CO_'.$moduleDirNameUpper.'_LICENSE', 'License'); |
|
69 | +define('CO_'.$moduleDirNameUpper.'_SUPPORT', 'Support'); |
@@ -178,8 +178,8 @@ |
||
178 | 178 | define('_AM_NEWBB_CAN_ATTACH', 'Can use attachment'); |
179 | 179 | define('_AM_NEWBB_CAN_NOAPPROVE', 'Can post directly'); |
180 | 180 | define('_AM_NEWBB_CAN_TYPE', 'Can use topic type'); |
181 | -define('_AM_NEWBB_CAN_HTML', 'Can use and disable/enable HTML in posts');//irmtfan revised |
|
182 | -define('_AM_NEWBB_CAN_SIGNATURE', 'Can use and disable/enable signature. Default is set in profile module.');//irmtfan revised |
|
181 | +define('_AM_NEWBB_CAN_HTML', 'Can use and disable/enable HTML in posts'); //irmtfan revised |
|
182 | +define('_AM_NEWBB_CAN_SIGNATURE', 'Can use and disable/enable signature. Default is set in profile module.'); //irmtfan revised |
|
183 | 183 | define('_AM_NEWBB_ACTION', 'Action'); |
184 | 184 | define('_AM_NEWBB_PERM_TEMPLATE', 'Set default permission template'); |
185 | 185 | define('_AM_NEWBB_PERM_TEMPLATE_DESC', 'Edit the following permission template so that it can be applied to a forum or a couple of forums'); |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // |
3 | 3 | if (defined('NEWBB_ADMIN_DEFINED')) { |
4 | - return; |
|
4 | + return; |
|
5 | 5 | } else { |
6 | - define('NEWBB_ADMIN_DEFINED', true); |
|
6 | + define('NEWBB_ADMIN_DEFINED', true); |
|
7 | 7 | } |
8 | 8 | //%%%%%% File Name index.php %%%%% |
9 | 9 | define('_AM_NEWBB_FORUMCONF', 'Forum Configuration'); |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | define('_AM_NEWBB_DIGEST_HELP_3', 'The dispatch is made only to users signed up for notification of digest topics.'); |
76 | 76 | define('_AM_NEWBB_DIGEST_HELP_4', 'After creating and sending, do not delete the created messages. Otherwise they will be generated again.'); |
77 | 77 | define( |
78 | - '_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST', |
|
79 | - 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server.<br>For example: * NIX systems: <strong>0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php</strong><br>In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done.<br>If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above.<br>Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.' |
|
78 | + '_AM_NEWBB_DIGEST_HELP_AUTO_DIGEST', |
|
79 | + 'To configure the automatic creation and distribution of Digest topics, you need to create a cron task on your server.<br>For example: * NIX systems: <strong>0 6 * * * wget --post-data \'foo=bar\' https://example.com/modules/newbb/digest.php</strong><br>In this example, the script will run every day at 6.00 and check if there are any new Digest topics. If they are not found, mailing will not be done.<br>If for any reason you do not have the opportunity to create a task, then it is possible to create and make the dispatch on this page manually by clicking on the button above.<br>Please note that it is not recommended to delete created mailings, otherwise they will be created and sent again.' |
|
80 | 80 | ); |
81 | 81 | //define('_AM_NEWBB_DIGEST_PAST', '<span style="color:red;">Should be sent out %d minutes ago</span>'); |
82 | 82 | //define('_AM_NEWBB_DIGEST_NEXT', 'Need to send out in %d minutes'); |
@@ -324,31 +324,31 @@ discard block |
||
324 | 324 | |
325 | 325 | // Help tab |
326 | 326 | define( |
327 | - '_AM_NEWBB_HELP_CATEGORY_TAB', |
|
328 | - 'To create a category, use the button above and fill in all the fields on the form.<br>By default, category images are located: /modules/newbb/assets/images/category/<br>Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.' |
|
327 | + '_AM_NEWBB_HELP_CATEGORY_TAB', |
|
328 | + 'To create a category, use the button above and fill in all the fields on the form.<br>By default, category images are located: /modules/newbb/assets/images/category/<br>Sponsor link should be written in the following format: https://xoops.org/modules/newbb/ newBB Support. First the link, then the sponsor\'s name or other text.' |
|
329 | 329 | ); |
330 | 330 | define( |
331 | - '_AM_NEWBB_HELP_FORUM_TAB', |
|
332 | - 'To create and manage the forums use the buttons with the right<br>To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum.<br>To move the forum between categories, use the \'Move\' button. Follow the further instructions.<br>To merge forums, use the \'Merge\' button. Follow the further instructions.<br>If you have an access rights template, then you can apply it to the forum you are creating.' |
|
331 | + '_AM_NEWBB_HELP_FORUM_TAB', |
|
332 | + 'To create and manage the forums use the buttons with the right<br>To create the forum, use the \'Create forum\' button. Then fill in all the fields of the form. You can also create a subforum.<br>To move the forum between categories, use the \'Move\' button. Follow the further instructions.<br>To merge forums, use the \'Merge\' button. Follow the further instructions.<br>If you have an access rights template, then you can apply it to the forum you are creating.' |
|
333 | 333 | ); |
334 | 334 | define( |
335 | - '_AM_NEWBB_HELP_PERMISSION_TAB', |
|
336 | - '<strong>When setting permissions, be careful.</strong><br>After you install and apply the settings, you will automatically go to the next permissions tab.<br>Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.' |
|
335 | + '_AM_NEWBB_HELP_PERMISSION_TAB', |
|
336 | + '<strong>When setting permissions, be careful.</strong><br>After you install and apply the settings, you will automatically go to the next permissions tab.<br>Also here it is possible to create a default access rights template and apply it either to one forum or to all forums.' |
|
337 | 337 | ); |
338 | 338 | define('_AM_NEWBB_HELP_ORDER_TAB', 'Allows you to set the order of categories and forums relative to each other.<br>The order (Weight) is set to 0 - top, 99 (and further) - bottom.'); |
339 | 339 | define('_AM_NEWBB_HELP_PRUNE_TAB', 'Allows you to clear forums from empty themes, obsolete themes, etc.<br>Also you can not delete topics that you want to clear, but transfer them to a specially created category \'Archive\' or any other.'); |
340 | 340 | define( |
341 | - '_AM_NEWBB_HELP_REPORT_TAB', |
|
342 | - 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules.<br>You can review the report and take action in relation to the message, the author, etc.<br>When a user sends a message, moderators and administrators are notified by e-mail.' |
|
341 | + '_AM_NEWBB_HELP_REPORT_TAB', |
|
342 | + 'Allows you to process reports that users send to you if they believe that the message on the forum does not comply with forum rules or ethical rules.<br>You can review the report and take action in relation to the message, the author, etc.<br>When a user sends a message, moderators and administrators are notified by e-mail.' |
|
343 | 343 | ); |
344 | 344 | define('_AM_NEWBB_HELP_VOTE_TAB', 'If you have the voting function enabled, here you can see the results of the voting.<br>This vote is not associated with other XOOPS modules.'); |
345 | 345 | define( |
346 | - '_AM_NEWBB_HELP_TYPE_TAB', |
|
347 | - 'Allows you to create tags for highlighting themes. For example:<br><strong style="color:blue;">[Important]</strong> <strong>Topic Title</strong><br><strong style="color:red;">[ATTENTION]</strong> <strong>Topic Title</strong><br>You can set theme types when creating a theme on the user side.' |
|
346 | + '_AM_NEWBB_HELP_TYPE_TAB', |
|
347 | + 'Allows you to create tags for highlighting themes. For example:<br><strong style="color:blue;">[Important]</strong> <strong>Topic Title</strong><br><strong style="color:red;">[ATTENTION]</strong> <strong>Topic Title</strong><br>You can set theme types when creating a theme on the user side.' |
|
348 | 348 | ); |
349 | 349 | define( |
350 | - '_AM_NEWBB_HELP_GROUPMOD_TAB', |
|
351 | - 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums.<br>It is recommended to create separate groups of moderators, for more convenient management of moderators.<br>You can also assign specific users to moderators when creating a forum.' |
|
350 | + '_AM_NEWBB_HELP_GROUPMOD_TAB', |
|
351 | + 'Allows you to install users of certain groups as moderators for the entire module, and for individual categories and forums.<br>It is recommended to create separate groups of moderators, for more convenient management of moderators.<br>You can also assign specific users to moderators when creating a forum.' |
|
352 | 352 | ); |
353 | 353 | define('_AM_NEWBB_HELP_SYNC_TAB', 'If you notice a problem with the message dates, the appearance of blank messages, etc. Here you can synchronize and correct forum data and topics'); |
354 | 354 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | define('_MD_NEWBB_NEWPOSTS', 'New posts'); |
36 | 36 | define('_MD_NEWBB_NONEWPOSTS', 'No new posts'); |
37 | 37 | define('_MD_NEWBB_PRIVATEFORUM', 'Inactive Forum'); |
38 | -define('_MD_NEWBB_BY', 'by');// Posted by |
|
38 | +define('_MD_NEWBB_BY', 'by'); // Posted by |
|
39 | 39 | define('_MD_NEWBB_TOSTART', 'To start viewing messages, select the forum that you want to visit from the list below.'); |
40 | 40 | define('_MD_NEWBB_TOTALTOPICSC', 'Total Topics: '); |
41 | 41 | define('_MD_NEWBB_TOTALPOSTSC', 'Total Posts: '); |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | define('_MD_NEWBB_TIMEISUP', 'You\'ve reached the time limit for editing your post.'); |
275 | 275 | define('_MD_NEWBB_TIMEISUPDEL', 'You\'ve reached the time limit for deleting your post.'); |
276 | 276 | //reply.php |
277 | -define('_MD_NEWBB_ON', 'on');//Posted on |
|
278 | -define('_MD_NEWBB_USERWROTE', '%s wrote:');// %s is username |
|
277 | +define('_MD_NEWBB_ON', 'on'); //Posted on |
|
278 | +define('_MD_NEWBB_USERWROTE', '%s wrote:'); // %s is username |
|
279 | 279 | define('_MD_NEWBB_RE', 'Re'); |
280 | 280 | //post.php |
281 | 281 | define('_MD_NEWBB_EDITNOTALLOWED', 'You\'re not allowed to edit this post!'); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | define('_MD_NEWBB_THANKSSUBMIT', 'Thanks for your submission!'); |
285 | 285 | define('_MD_NEWBB_REPLYPOSTED', 'A reply to your topic has been posted.'); |
286 | 286 | define('_MD_NEWBB_HELLO', 'Hello %s,'); |
287 | -define('_MD_NEWBB_URRECEIVING', 'You are receiving this email because a message you posted on %s forums has been replied to.');// %s is your site name |
|
287 | +define('_MD_NEWBB_URRECEIVING', 'You are receiving this email because a message you posted on %s forums has been replied to.'); // %s is your site name |
|
288 | 288 | define('_MD_NEWBB_CLICKBELOW', 'Click on the link below to view the thread:'); |
289 | 289 | define('_MD_NEWBB_WAITFORAPPROVAL', 'Thank you. Your post will be approved before publication.'); |
290 | 290 | define('_MD_NEWBB_POSTING_LIMITED', 'Why not take a break and come back in %d sec'); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | define('_MD_NEWBB_CANTVOTEOWN', 'You cannot vote on the topic you submitted.<br>All votes are logged and reviewed.'); |
379 | 379 | define('_MD_NEWBB_VOTEONCE', 'Please do not vote for the same topic more than once.'); |
380 | 380 | define('_MD_NEWBB_VOTEAPPRE', 'Your vote is appreciated.'); |
381 | -define('_MD_NEWBB_THANKYOU', 'Thank you for taking the time to vote here at %s');// %s is your site name |
|
381 | +define('_MD_NEWBB_THANKYOU', 'Thank you for taking the time to vote here at %s'); // %s is your site name |
|
382 | 382 | define('_MD_NEWBB_VOTES', 'Votes'); |
383 | 383 | define('_MD_NEWBB_NOVOTERATE', 'You did not rate this Topic'); |
384 | 384 | // polls.php |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | // |
3 | 3 | if (defined('NEWBB_MAIN_DEFINED')) { |
4 | - return; |
|
4 | + return; |
|
5 | 5 | } |
6 | 6 | define('NEWBB_MAIN_DEFINED', true); |
7 | 7 |