@@ -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 = null) |
|
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 = null) |
|
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 = null) |
|
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 = null) |
|
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 = null) |
|
26 | - { |
|
27 | - parent::__construct($db, 'newbb_report', Report::class, 'report_id', ''); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @param \XoopsDatabase $db |
|
24 | + */ |
|
25 | + public function __construct(\XoopsDatabase $db = null) |
|
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(dirname(__DIR__))); |
|
43 | - } |
|
40 | + public function __construct() |
|
41 | + { |
|
42 | + $this->dirname = basename(dirname(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 | } |
@@ -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 = null) |
|
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 = null) |
|
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 |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use XoopsModules\Newbb; |
5 | 5 | |
6 | -define('REAL_MODULE_NAME', 'modules/newbb'); //this is the Real Module directory |
|
7 | -define('SEO_MODULE_NAME', 'modules/newbb'); //this is SEO Name for rewrite Hack |
|
6 | +define('REAL_MODULE_NAME', 'modules/newbb'); //this is the Real Module directory |
|
7 | +define('SEO_MODULE_NAME', 'modules/newbb'); //this is SEO Name for rewrite Hack |
|
8 | 8 | |
9 | 9 | //ob_start('seo_urls'); |
10 | 10 | |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | $search = [ |
21 | 21 | |
22 | 22 | // Search URLs of modules' directry. |
23 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
24 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
25 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
26 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
27 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
28 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
29 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
23 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
24 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
25 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
26 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
27 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
28 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
29 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})'.$XPS_URL.'\/'.$module_name.'\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
30 | 30 | ]; |
31 | 31 | |
32 | 32 | $s = preg_replace_callback($search, 'replace_links', $s); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (!empty($matches[6])) { |
48 | 48 | // replacing cat=x |
49 | 49 | if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
50 | - $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
50 | + $add_to_url = 'c-'.$mvars[1].'/'.forum_seo_cat($mvars[1]).''; |
|
51 | 51 | $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
52 | 52 | } else { |
53 | 53 | return $matches['0']; |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | if (!empty($matches[6])) { |
61 | 61 | // replacing status=x |
62 | 62 | if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
63 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
63 | + $add_to_url = 'viewpost.php'.$matches[6]; |
|
64 | 64 | $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
65 | 65 | } else { |
66 | 66 | return $matches['0']; |
67 | 67 | } |
68 | 68 | } else { |
69 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
69 | + $add_to_url = 'viewpost.php'.$matches[6]; |
|
70 | 70 | } |
71 | 71 | break; |
72 | 72 | case 'rss.php': |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
78 | 78 | $add_to_url = 'rc-'; |
79 | 79 | if ($mvars[1] > 0) { |
80 | - $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
80 | + $add_to_url .= $mvars[1].'/'.forum_seo_cat($mvars[1]).''; |
|
81 | 81 | } else { |
82 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
82 | + $add_to_url .= $mvars[1].'/rss.html'; |
|
83 | 83 | } |
84 | 84 | $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
85 | 85 | } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
86 | 86 | $add_to_url = 'rf-'; |
87 | 87 | if ($mvars[1] > 0) { |
88 | - $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
88 | + $add_to_url .= $mvars[1].'/'.forum_seo_forum($mvars[1]).''; |
|
89 | 89 | } else { |
90 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
90 | + $add_to_url .= $mvars[1].'/rss.html'; |
|
91 | 91 | } |
92 | 92 | $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
93 | 93 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (!empty($matches[6])) { |
103 | 103 | // replacing forum=x |
104 | 104 | if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
105 | - $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
105 | + $add_to_url = 'f-'.$mvars[1].'/'.forum_seo_forum($mvars[1]).''; |
|
106 | 106 | $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
107 | 107 | } else { |
108 | 108 | return $matches['0']; |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | if (!empty($matches[6])) { |
116 | 116 | // replacing topic_id=x |
117 | 117 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
118 | - $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
118 | + $add_to_url = 't-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
119 | 119 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
120 | 120 | } //replacing post_id=x |
121 | 121 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
122 | - $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
122 | + $add_to_url = 'p-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
123 | 123 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
124 | 124 | } else { |
125 | 125 | return $matches['0']; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | if (!empty($matches[6])) { |
133 | 133 | // replacing topic_id=x |
134 | 134 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
135 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
135 | + $add_to_url = 'pr-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
136 | 136 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
137 | 137 | } //replacing post_id=x |
138 | 138 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
139 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
139 | + $add_to_url = 'pr-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
140 | 140 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
141 | 141 | } else { |
142 | 142 | return $matches['0']; |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | if (!empty($matches[6])) { |
150 | 150 | // replacing topic_id=x |
151 | 151 | if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
152 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
152 | + $add_to_url = 'pdf-'.$mvars[1].'/'.forum_seo_topic($mvars[1]).''; |
|
153 | 153 | $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
154 | 154 | } //replacing post_id=x |
155 | 155 | elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
156 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
156 | + $add_to_url = 'pdf-'.$mvars[1].'/'.forum_seo_post($mvars[1]).''; |
|
157 | 157 | $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
158 | 158 | } else { |
159 | 159 | return $matches['0']; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | if ('?' === $req_string) { |
170 | 170 | $req_string = ''; |
171 | 171 | } |
172 | - $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
172 | + $ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.SEO_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
173 | 173 | |
174 | 174 | //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
175 | 175 | return $ret; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return $ret; |
191 | 191 | } |
192 | 192 | } |
193 | - $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
193 | + $query = 'SELECT cat_id, cat_title FROM '.$GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
194 | 194 | $result = $GLOBALS['xoopsDB']->query($query); |
195 | 195 | $_ret = []; |
196 | 196 | while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | return $ret; |
219 | 219 | } |
220 | 220 | } |
221 | - $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
221 | + $query = 'SELECT forum_id, forum_name FROM '.$GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
222 | 222 | $result = $GLOBALS['xoopsDB']->query($query); |
223 | 223 | $_ret = []; |
224 | 224 | while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function forum_seo_topic($_cat_id) |
239 | 239 | { |
240 | - $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
240 | + $query = 'SELECT topic_title FROM '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' WHERE topic_id = '.$_cat_id; |
|
241 | 241 | $result = $GLOBALS['xoopsDB']->query($query); |
242 | 242 | $res = $GLOBALS['xoopsDB']->fetchArray($result); |
243 | 243 | $ret = forum_seo_title($res['topic_title']); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | function forum_seo_post($_cat_id) |
260 | 260 | { |
261 | - $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
261 | + $query = 'SELECT subject FROM '.$GLOBALS['xoopsDB']->prefix('newbb_posts').' WHERE post_id = '.$_cat_id; |
|
262 | 262 | $result = $GLOBALS['xoopsDB']->query($query); |
263 | 263 | $res = $GLOBALS['xoopsDB']->fetchArray($result); |
264 | 264 | $ret = forum_seo_title($res['subject']); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | '', |
350 | 350 | '' |
351 | 351 | ]; |
352 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
352 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
353 | 353 | |
354 | 354 | // Transformation des caractères accentués |
355 | 355 | // è é ê ë ç à â ä î ï ù ü û ô ö |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'ae', |
406 | 406 | 'ss' |
407 | 407 | ]; |
408 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
408 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
409 | 409 | |
410 | 410 | /*$string = str_replace(' ', '-', $title); |
411 | 411 | $string = iconv('utf-8', 'ascii//translit', $string); |
@@ -14,24 +14,24 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function seo_urls($s) |
16 | 16 | { |
17 | - $XPS_URL = str_replace('/', '\/', quotemeta(XOOPS_URL)); |
|
18 | - $module_name = str_replace('/', '\/', quotemeta(SEO_MODULE_NAME)); |
|
17 | + $XPS_URL = str_replace('/', '\/', quotemeta(XOOPS_URL)); |
|
18 | + $module_name = str_replace('/', '\/', quotemeta(SEO_MODULE_NAME)); |
|
19 | 19 | |
20 | - $search = [ |
|
20 | + $search = [ |
|
21 | 21 | |
22 | - // Search URLs of modules' directry. |
|
23 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
24 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
25 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
26 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
27 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
28 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
29 | - '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
30 | - ]; |
|
22 | + // Search URLs of modules' directry. |
|
23 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(index.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
24 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewpost.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
25 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(rss.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
26 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewforum.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
27 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(viewtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
28 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(newtopic.php)([^>\'\"]*)([\'\"]{1})([^>]*)>/i', |
|
29 | + '/<(a|meta)([^>]*)(href|url)=([\'\"]{0,1})' . $XPS_URL . '\/' . $module_name . '\/(.*)([^>\'\"]*)([\'\"]{1})([^>]*)>/i' |
|
30 | + ]; |
|
31 | 31 | |
32 | - $s = preg_replace_callback($search, 'replace_links', $s); |
|
32 | + $s = preg_replace_callback($search, 'replace_links', $s); |
|
33 | 33 | |
34 | - return $s; |
|
34 | + return $s; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,139 +40,139 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function replace_links($matches) |
42 | 42 | { |
43 | - switch ($matches[5]) { |
|
44 | - case 'index.php': |
|
45 | - $add_to_url = ''; |
|
46 | - $req_string = $matches[6]; |
|
47 | - if (!empty($matches[6])) { |
|
48 | - // replacing cat=x |
|
49 | - if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
|
50 | - $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
51 | - $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
|
52 | - } else { |
|
53 | - return $matches['0']; |
|
54 | - } |
|
55 | - } |
|
56 | - break; |
|
57 | - case 'viewpost.php': |
|
58 | - $add_to_url = ''; |
|
59 | - $req_string = $matches[6]; |
|
60 | - if (!empty($matches[6])) { |
|
61 | - // replacing status=x |
|
62 | - if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
|
63 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
64 | - $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
|
65 | - } else { |
|
66 | - return $matches['0']; |
|
67 | - } |
|
68 | - } else { |
|
69 | - $add_to_url = 'viewpost.php' . $matches[6]; |
|
70 | - } |
|
71 | - break; |
|
72 | - case 'rss.php': |
|
73 | - $add_to_url = ''; |
|
74 | - $req_string = $matches[6]; |
|
75 | - if (!empty($matches[6])) { |
|
76 | - // replacing c=x |
|
77 | - if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
|
78 | - $add_to_url = 'rc-'; |
|
79 | - if ($mvars[1] > 0) { |
|
80 | - $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
81 | - } else { |
|
82 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
83 | - } |
|
84 | - $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
|
85 | - } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
|
86 | - $add_to_url = 'rf-'; |
|
87 | - if ($mvars[1] > 0) { |
|
88 | - $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
89 | - } else { |
|
90 | - $add_to_url .= $mvars[1] . '/rss.html'; |
|
91 | - } |
|
92 | - $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
|
93 | - } else { |
|
94 | - return $matches['0']; |
|
95 | - } |
|
96 | - //$add_to_url .= 'rss-feed.html'; |
|
97 | - } |
|
98 | - break; |
|
99 | - case 'viewforum.php': |
|
100 | - $add_to_url = ''; |
|
101 | - $req_string = $matches[6]; |
|
102 | - if (!empty($matches[6])) { |
|
103 | - // replacing forum=x |
|
104 | - if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
|
105 | - $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
106 | - $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
|
107 | - } else { |
|
108 | - return $matches['0']; |
|
109 | - } |
|
110 | - } |
|
111 | - break; |
|
112 | - case 'viewtopic.php': |
|
113 | - $add_to_url = ''; |
|
114 | - $req_string = $matches[6]; |
|
115 | - if (!empty($matches[6])) { |
|
116 | - // replacing topic_id=x |
|
117 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
118 | - $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
119 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
120 | - } //replacing post_id=x |
|
121 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
122 | - $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
123 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
124 | - } else { |
|
125 | - return $matches['0']; |
|
126 | - } |
|
127 | - } |
|
128 | - break; |
|
129 | - case 'print.php': |
|
130 | - $add_to_url = ''; |
|
131 | - $req_string = $matches[6]; |
|
132 | - if (!empty($matches[6])) { |
|
133 | - // replacing topic_id=x |
|
134 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
135 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
136 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
137 | - } //replacing post_id=x |
|
138 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
139 | - $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
140 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
141 | - } else { |
|
142 | - return $matches['0']; |
|
143 | - } |
|
144 | - } |
|
145 | - break; |
|
146 | - case 'makepdf.php': |
|
147 | - $add_to_url = ''; |
|
148 | - $req_string = $matches[6]; |
|
149 | - if (!empty($matches[6])) { |
|
150 | - // replacing topic_id=x |
|
151 | - if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
152 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
153 | - $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
154 | - } //replacing post_id=x |
|
155 | - elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
156 | - $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
157 | - $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
158 | - } else { |
|
159 | - return $matches['0']; |
|
160 | - } |
|
161 | - } |
|
162 | - break; |
|
163 | - default: |
|
164 | - $req_string = $matches[6]; |
|
165 | - $add_to_url = $matches[5]; |
|
166 | - //if ($add_to_url === '') $add_to_url ='index.php'; |
|
167 | - break; |
|
168 | - } |
|
169 | - if ('?' === $req_string) { |
|
170 | - $req_string = ''; |
|
171 | - } |
|
172 | - $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
43 | + switch ($matches[5]) { |
|
44 | + case 'index.php': |
|
45 | + $add_to_url = ''; |
|
46 | + $req_string = $matches[6]; |
|
47 | + if (!empty($matches[6])) { |
|
48 | + // replacing cat=x |
|
49 | + if (preg_match('/cat=(\d+)/', $matches[6], $mvars)) { |
|
50 | + $add_to_url = 'c-' . $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
51 | + $req_string = preg_replace('/cat=\d+/', '', $matches[6]); |
|
52 | + } else { |
|
53 | + return $matches['0']; |
|
54 | + } |
|
55 | + } |
|
56 | + break; |
|
57 | + case 'viewpost.php': |
|
58 | + $add_to_url = ''; |
|
59 | + $req_string = $matches[6]; |
|
60 | + if (!empty($matches[6])) { |
|
61 | + // replacing status=x |
|
62 | + if (preg_match('/status=([a-z]+)/', $matches[6], $mvars)) { |
|
63 | + $add_to_url = 'viewpost.php' . $matches[6]; |
|
64 | + $req_string = preg_replace('/status=([a-z])+/', '', $matches[6]); |
|
65 | + } else { |
|
66 | + return $matches['0']; |
|
67 | + } |
|
68 | + } else { |
|
69 | + $add_to_url = 'viewpost.php' . $matches[6]; |
|
70 | + } |
|
71 | + break; |
|
72 | + case 'rss.php': |
|
73 | + $add_to_url = ''; |
|
74 | + $req_string = $matches[6]; |
|
75 | + if (!empty($matches[6])) { |
|
76 | + // replacing c=x |
|
77 | + if (preg_match('/c=(\d+)/', $matches[6], $mvars)) { |
|
78 | + $add_to_url = 'rc-'; |
|
79 | + if ($mvars[1] > 0) { |
|
80 | + $add_to_url .= $mvars[1] . '/' . forum_seo_cat($mvars[1]) . ''; |
|
81 | + } else { |
|
82 | + $add_to_url .= $mvars[1] . '/rss.html'; |
|
83 | + } |
|
84 | + $req_string = preg_replace('/c=\d+/', '', $matches[6]); |
|
85 | + } elseif (preg_match('/f=(\d+)/', $matches[6], $mvars)) { |
|
86 | + $add_to_url = 'rf-'; |
|
87 | + if ($mvars[1] > 0) { |
|
88 | + $add_to_url .= $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
89 | + } else { |
|
90 | + $add_to_url .= $mvars[1] . '/rss.html'; |
|
91 | + } |
|
92 | + $req_string = preg_replace('/f=\d+/', '', $matches[6]); |
|
93 | + } else { |
|
94 | + return $matches['0']; |
|
95 | + } |
|
96 | + //$add_to_url .= 'rss-feed.html'; |
|
97 | + } |
|
98 | + break; |
|
99 | + case 'viewforum.php': |
|
100 | + $add_to_url = ''; |
|
101 | + $req_string = $matches[6]; |
|
102 | + if (!empty($matches[6])) { |
|
103 | + // replacing forum=x |
|
104 | + if (preg_match('/forum=(\d+)/', $matches[6], $mvars)) { |
|
105 | + $add_to_url = 'f-' . $mvars[1] . '/' . forum_seo_forum($mvars[1]) . ''; |
|
106 | + $req_string = preg_replace('/forum=\d+/', '', $matches[6]); |
|
107 | + } else { |
|
108 | + return $matches['0']; |
|
109 | + } |
|
110 | + } |
|
111 | + break; |
|
112 | + case 'viewtopic.php': |
|
113 | + $add_to_url = ''; |
|
114 | + $req_string = $matches[6]; |
|
115 | + if (!empty($matches[6])) { |
|
116 | + // replacing topic_id=x |
|
117 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
118 | + $add_to_url = 't-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
119 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
120 | + } //replacing post_id=x |
|
121 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
122 | + $add_to_url = 'p-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
123 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
124 | + } else { |
|
125 | + return $matches['0']; |
|
126 | + } |
|
127 | + } |
|
128 | + break; |
|
129 | + case 'print.php': |
|
130 | + $add_to_url = ''; |
|
131 | + $req_string = $matches[6]; |
|
132 | + if (!empty($matches[6])) { |
|
133 | + // replacing topic_id=x |
|
134 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
135 | + $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
136 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
137 | + } //replacing post_id=x |
|
138 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
139 | + $add_to_url = 'pr-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
140 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
141 | + } else { |
|
142 | + return $matches['0']; |
|
143 | + } |
|
144 | + } |
|
145 | + break; |
|
146 | + case 'makepdf.php': |
|
147 | + $add_to_url = ''; |
|
148 | + $req_string = $matches[6]; |
|
149 | + if (!empty($matches[6])) { |
|
150 | + // replacing topic_id=x |
|
151 | + if (preg_match('/topic_id=(\d+)/', $matches[6], $mvars)) { |
|
152 | + $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_topic($mvars[1]) . ''; |
|
153 | + $req_string = preg_replace('/topic_id=\d+/', '', $matches[6]); |
|
154 | + } //replacing post_id=x |
|
155 | + elseif (preg_match('/post_id=(\d+)/', $matches[6], $mvars)) { |
|
156 | + $add_to_url = 'pdf-' . $mvars[1] . '/' . forum_seo_post($mvars[1]) . ''; |
|
157 | + $req_string = preg_replace('/post_id=\d+/', '', $matches[6]); |
|
158 | + } else { |
|
159 | + return $matches['0']; |
|
160 | + } |
|
161 | + } |
|
162 | + break; |
|
163 | + default: |
|
164 | + $req_string = $matches[6]; |
|
165 | + $add_to_url = $matches[5]; |
|
166 | + //if ($add_to_url === '') $add_to_url ='index.php'; |
|
167 | + break; |
|
168 | + } |
|
169 | + if ('?' === $req_string) { |
|
170 | + $req_string = ''; |
|
171 | + } |
|
172 | + $ret = '<' . $matches[1] . $matches[2] . $matches[3] . '=' . $matches[4] . XOOPS_URL . '/' . SEO_MODULE_NAME . '/' . $add_to_url . $req_string . $matches[7] . $matches[8] . '>'; |
|
173 | 173 | |
174 | - //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
175 | - return $ret; |
|
174 | + //$ret = '<'.$matches[1].$matches[2].$matches[3].'='.$matches[4].XOOPS_URL.'/'.REAL_MODULE_NAME.'/'.$add_to_url.$req_string.$matches[7].$matches[8].'>'; |
|
175 | + return $ret; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function forum_seo_cat($_cat_id) |
183 | 183 | { |
184 | - xoops_load('XoopsCache'); |
|
185 | - $key = 'newbb_seo_cat'; |
|
186 | - $ret = false; |
|
187 | - if ($ret = \XoopsCache::read($key)) { |
|
188 | - $ret = @$ret[$_cat_id]; |
|
189 | - if ($ret) { |
|
190 | - return $ret; |
|
191 | - } |
|
192 | - } |
|
193 | - $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
194 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
195 | - $_ret = []; |
|
196 | - while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
197 | - $_ret[$res['cat_id']] = forum_seo_title($res['cat_title']); |
|
198 | - } |
|
199 | - XoopsCache::write($key, $_ret); |
|
200 | - $ret = \XoopsCache::read($key); |
|
201 | - $ret = $ret[$_cat_id]; |
|
184 | + xoops_load('XoopsCache'); |
|
185 | + $key = 'newbb_seo_cat'; |
|
186 | + $ret = false; |
|
187 | + if ($ret = \XoopsCache::read($key)) { |
|
188 | + $ret = @$ret[$_cat_id]; |
|
189 | + if ($ret) { |
|
190 | + return $ret; |
|
191 | + } |
|
192 | + } |
|
193 | + $query = 'SELECT cat_id, cat_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_categories'); |
|
194 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
195 | + $_ret = []; |
|
196 | + while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
197 | + $_ret[$res['cat_id']] = forum_seo_title($res['cat_title']); |
|
198 | + } |
|
199 | + XoopsCache::write($key, $_ret); |
|
200 | + $ret = \XoopsCache::read($key); |
|
201 | + $ret = $ret[$_cat_id]; |
|
202 | 202 | |
203 | - return $ret; |
|
203 | + return $ret; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,26 +209,26 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function forum_seo_forum($_cat_id) |
211 | 211 | { |
212 | - xoops_load('XoopsCache'); |
|
213 | - $key = 'newbb_seo_forum'; |
|
214 | - $ret = false; |
|
215 | - if ($ret = \XoopsCache::read($key)) { |
|
216 | - $ret = @$ret[$_cat_id]; |
|
217 | - if ($ret) { |
|
218 | - return $ret; |
|
219 | - } |
|
220 | - } |
|
221 | - $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
222 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
223 | - $_ret = []; |
|
224 | - while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
225 | - $_ret[$res['forum_id']] = forum_seo_title($res['forum_name']); |
|
226 | - } |
|
227 | - XoopsCache::write($key, $_ret); |
|
228 | - $ret = \XoopsCache::read($key); |
|
229 | - $ret = $ret[$_cat_id]; |
|
212 | + xoops_load('XoopsCache'); |
|
213 | + $key = 'newbb_seo_forum'; |
|
214 | + $ret = false; |
|
215 | + if ($ret = \XoopsCache::read($key)) { |
|
216 | + $ret = @$ret[$_cat_id]; |
|
217 | + if ($ret) { |
|
218 | + return $ret; |
|
219 | + } |
|
220 | + } |
|
221 | + $query = 'SELECT forum_id, forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_forums'); |
|
222 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
223 | + $_ret = []; |
|
224 | + while (false !== ($res = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
225 | + $_ret[$res['forum_id']] = forum_seo_title($res['forum_name']); |
|
226 | + } |
|
227 | + XoopsCache::write($key, $_ret); |
|
228 | + $ret = \XoopsCache::read($key); |
|
229 | + $ret = $ret[$_cat_id]; |
|
230 | 230 | |
231 | - return $ret; |
|
231 | + return $ret; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -237,19 +237,19 @@ discard block |
||
237 | 237 | */ |
238 | 238 | function forum_seo_topic($_cat_id) |
239 | 239 | { |
240 | - $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
241 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
242 | - $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
243 | - $ret = forum_seo_title($res['topic_title']); |
|
240 | + $query = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id = ' . $_cat_id; |
|
241 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
242 | + $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
243 | + $ret = forum_seo_title($res['topic_title']); |
|
244 | 244 | |
245 | - $moduleDirName = basename(__DIR__); |
|
246 | - /** @var Newbb\TopicHandler $topicsHandler */ |
|
247 | - $topicsHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
248 | - $criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '=')); |
|
249 | - $fields = ['topic_title']; |
|
250 | - $ret0 = $topicsHandler->getAll($criteria, $fields, false); |
|
245 | + $moduleDirName = basename(__DIR__); |
|
246 | + /** @var Newbb\TopicHandler $topicsHandler */ |
|
247 | + $topicsHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
|
248 | + $criteria = new \CriteriaCompo(new \Criteria('topic_id', $_cat_id, '=')); |
|
249 | + $fields = ['topic_title']; |
|
250 | + $ret0 = $topicsHandler->getAll($criteria, $fields, false); |
|
251 | 251 | |
252 | - return $ret; |
|
252 | + return $ret; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | */ |
259 | 259 | function forum_seo_post($_cat_id) |
260 | 260 | { |
261 | - $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
262 | - $result = $GLOBALS['xoopsDB']->query($query); |
|
263 | - $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
264 | - $ret = forum_seo_title($res['subject']); |
|
261 | + $query = 'SELECT subject FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' WHERE post_id = ' . $_cat_id; |
|
262 | + $result = $GLOBALS['xoopsDB']->query($query); |
|
263 | + $res = $GLOBALS['xoopsDB']->fetchArray($result); |
|
264 | + $ret = forum_seo_title($res['subject']); |
|
265 | 265 | |
266 | - return $ret; |
|
266 | + return $ret; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,152 +273,152 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function forum_seo_title($title = '', $withExt = true) |
275 | 275 | { |
276 | - /** |
|
277 | - * if XOOPS ML is present, let's sanitize the title with the current language |
|
278 | - */ |
|
279 | - $myts = \MyTextSanitizer::getInstance(); |
|
280 | - if (method_exists($myts, 'formatForML')) { |
|
281 | - $title = $myts->formatForML($title); |
|
282 | - } |
|
276 | + /** |
|
277 | + * if XOOPS ML is present, let's sanitize the title with the current language |
|
278 | + */ |
|
279 | + $myts = \MyTextSanitizer::getInstance(); |
|
280 | + if (method_exists($myts, 'formatForML')) { |
|
281 | + $title = $myts->formatForML($title); |
|
282 | + } |
|
283 | 283 | |
284 | - // Transformation de la chaine en minuscule |
|
285 | - // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus |
|
286 | - $title = rawurlencode(strtolower($title)); |
|
284 | + // Transformation de la chaine en minuscule |
|
285 | + // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus |
|
286 | + $title = rawurlencode(strtolower($title)); |
|
287 | 287 | |
288 | - // Transformation des ponctuations |
|
289 | - // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . |
|
290 | - $pattern = [ |
|
291 | - '/%09/', |
|
292 | - '/%20/', |
|
293 | - '/%21/', |
|
294 | - '/%22/', |
|
295 | - '/%23/', |
|
296 | - '/%25/', |
|
297 | - '/%26/', |
|
298 | - '/%27/', |
|
299 | - '/%28/', |
|
300 | - '/%29/', |
|
301 | - '/%2C/', |
|
302 | - '/%2F/', |
|
303 | - '/%3A/', |
|
304 | - '/%3B/', |
|
305 | - '/%3C/', |
|
306 | - '/%3D/', |
|
307 | - '/%3E/', |
|
308 | - '/%3F/', |
|
309 | - '/%40/', |
|
310 | - '/%5B/', |
|
311 | - '/%5C/', |
|
312 | - '/%5D/', |
|
313 | - '/%5E/', |
|
314 | - '/%7B/', |
|
315 | - '/%7C/', |
|
316 | - '/%7D/', |
|
317 | - '/%7E/', |
|
318 | - '/\./', |
|
319 | - '/%2A/' |
|
320 | - ]; |
|
321 | - $rep_pat = [ |
|
322 | - '-', |
|
323 | - '-', |
|
324 | - '', |
|
325 | - '', |
|
326 | - '', |
|
327 | - '-100', |
|
328 | - '', |
|
329 | - '-', |
|
330 | - '', |
|
331 | - '', |
|
332 | - '', |
|
333 | - '-', |
|
334 | - '', |
|
335 | - '', |
|
336 | - '', |
|
337 | - '-', |
|
338 | - '', |
|
339 | - '', |
|
340 | - '-at-', |
|
341 | - '', |
|
342 | - '-', |
|
343 | - '', |
|
344 | - '-', |
|
345 | - '', |
|
346 | - '-', |
|
347 | - '', |
|
348 | - '-', |
|
349 | - '', |
|
350 | - '' |
|
351 | - ]; |
|
352 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
288 | + // Transformation des ponctuations |
|
289 | + // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . |
|
290 | + $pattern = [ |
|
291 | + '/%09/', |
|
292 | + '/%20/', |
|
293 | + '/%21/', |
|
294 | + '/%22/', |
|
295 | + '/%23/', |
|
296 | + '/%25/', |
|
297 | + '/%26/', |
|
298 | + '/%27/', |
|
299 | + '/%28/', |
|
300 | + '/%29/', |
|
301 | + '/%2C/', |
|
302 | + '/%2F/', |
|
303 | + '/%3A/', |
|
304 | + '/%3B/', |
|
305 | + '/%3C/', |
|
306 | + '/%3D/', |
|
307 | + '/%3E/', |
|
308 | + '/%3F/', |
|
309 | + '/%40/', |
|
310 | + '/%5B/', |
|
311 | + '/%5C/', |
|
312 | + '/%5D/', |
|
313 | + '/%5E/', |
|
314 | + '/%7B/', |
|
315 | + '/%7C/', |
|
316 | + '/%7D/', |
|
317 | + '/%7E/', |
|
318 | + '/\./', |
|
319 | + '/%2A/' |
|
320 | + ]; |
|
321 | + $rep_pat = [ |
|
322 | + '-', |
|
323 | + '-', |
|
324 | + '', |
|
325 | + '', |
|
326 | + '', |
|
327 | + '-100', |
|
328 | + '', |
|
329 | + '-', |
|
330 | + '', |
|
331 | + '', |
|
332 | + '', |
|
333 | + '-', |
|
334 | + '', |
|
335 | + '', |
|
336 | + '', |
|
337 | + '-', |
|
338 | + '', |
|
339 | + '', |
|
340 | + '-at-', |
|
341 | + '', |
|
342 | + '-', |
|
343 | + '', |
|
344 | + '-', |
|
345 | + '', |
|
346 | + '-', |
|
347 | + '', |
|
348 | + '-', |
|
349 | + '', |
|
350 | + '' |
|
351 | + ]; |
|
352 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
353 | 353 | |
354 | - // Transformation des caractères accentués |
|
355 | - // è é ê ë ç à â ä î ï ù ü û ô ö |
|
356 | - $pattern = [ |
|
357 | - '/%B0/', |
|
358 | - '/%E8/', |
|
359 | - '/%E9/', |
|
360 | - '/%EA/', |
|
361 | - '/%EB/', |
|
362 | - '/%E7/', |
|
363 | - '/%E0/', |
|
364 | - '/%E2/', |
|
365 | - '/%E4/', |
|
366 | - '/%EE/', |
|
367 | - '/%EF/', |
|
368 | - '/%F9/', |
|
369 | - '/%FC/', |
|
370 | - '/%FB/', |
|
371 | - '/%F4/', |
|
372 | - '/%F6/', |
|
373 | - '/%E3%BC/', |
|
374 | - '/%E3%96/', |
|
375 | - '/%E3%84/', |
|
376 | - '/%E3%9C/', |
|
377 | - '/%E3%FF/', |
|
378 | - '/%E3%B6/', |
|
379 | - '/%E3%A4/', |
|
380 | - '/%E3%9F/' |
|
381 | - ]; |
|
382 | - $rep_pat = [ |
|
383 | - '-', |
|
384 | - 'e', |
|
385 | - 'e', |
|
386 | - 'e', |
|
387 | - 'e', |
|
388 | - 'c', |
|
389 | - 'a', |
|
390 | - 'a', |
|
391 | - 'a', |
|
392 | - 'i', |
|
393 | - 'i', |
|
394 | - 'u', |
|
395 | - 'u', |
|
396 | - 'u', |
|
397 | - 'o', |
|
398 | - 'o', |
|
399 | - 'ue', |
|
400 | - 'oe', |
|
401 | - 'ae', |
|
402 | - 'ue', |
|
403 | - 'ss', |
|
404 | - 'oe', |
|
405 | - 'ae', |
|
406 | - 'ss' |
|
407 | - ]; |
|
408 | - $title = preg_replace($pattern, $rep_pat, $title); |
|
354 | + // Transformation des caractères accentués |
|
355 | + // è é ê ë ç à â ä î ï ù ü û ô ö |
|
356 | + $pattern = [ |
|
357 | + '/%B0/', |
|
358 | + '/%E8/', |
|
359 | + '/%E9/', |
|
360 | + '/%EA/', |
|
361 | + '/%EB/', |
|
362 | + '/%E7/', |
|
363 | + '/%E0/', |
|
364 | + '/%E2/', |
|
365 | + '/%E4/', |
|
366 | + '/%EE/', |
|
367 | + '/%EF/', |
|
368 | + '/%F9/', |
|
369 | + '/%FC/', |
|
370 | + '/%FB/', |
|
371 | + '/%F4/', |
|
372 | + '/%F6/', |
|
373 | + '/%E3%BC/', |
|
374 | + '/%E3%96/', |
|
375 | + '/%E3%84/', |
|
376 | + '/%E3%9C/', |
|
377 | + '/%E3%FF/', |
|
378 | + '/%E3%B6/', |
|
379 | + '/%E3%A4/', |
|
380 | + '/%E3%9F/' |
|
381 | + ]; |
|
382 | + $rep_pat = [ |
|
383 | + '-', |
|
384 | + 'e', |
|
385 | + 'e', |
|
386 | + 'e', |
|
387 | + 'e', |
|
388 | + 'c', |
|
389 | + 'a', |
|
390 | + 'a', |
|
391 | + 'a', |
|
392 | + 'i', |
|
393 | + 'i', |
|
394 | + 'u', |
|
395 | + 'u', |
|
396 | + 'u', |
|
397 | + 'o', |
|
398 | + 'o', |
|
399 | + 'ue', |
|
400 | + 'oe', |
|
401 | + 'ae', |
|
402 | + 'ue', |
|
403 | + 'ss', |
|
404 | + 'oe', |
|
405 | + 'ae', |
|
406 | + 'ss' |
|
407 | + ]; |
|
408 | + $title = preg_replace($pattern, $rep_pat, $title); |
|
409 | 409 | |
410 | - /*$string = str_replace(' ', '-', $title); |
|
410 | + /*$string = str_replace(' ', '-', $title); |
|
411 | 411 | $string = iconv('utf-8', 'ascii//translit', $string); |
412 | 412 | $string = preg_replace('#[^a-z0-9\-\.]#si', '', $string); |
413 | 413 | $title = str_replace('\/','', $string); */ |
414 | 414 | |
415 | - if (count($title) > 0) { |
|
416 | - if ($withExt) { |
|
417 | - $title .= '.html'; |
|
418 | - } |
|
415 | + if (count($title) > 0) { |
|
416 | + if ($withExt) { |
|
417 | + $title .= '.html'; |
|
418 | + } |
|
419 | 419 | |
420 | - return $title; |
|
421 | - } |
|
420 | + return $title; |
|
421 | + } |
|
422 | 422 | |
423 | - return ''; |
|
423 | + return ''; |
|
424 | 424 | } |