@@ -9,354 +9,354 @@ |
||
| 9 | 9 | |
| 10 | 10 | class categories |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | - protected $db; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\config\config */ |
|
| 16 | - protected $config; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\template\template */ |
|
| 19 | - protected $template; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\user */ |
|
| 22 | - protected $user; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\controller\helper */ |
|
| 25 | - protected $helper; |
|
| 26 | - |
|
| 27 | - /** @var \phpbb\request\request */ |
|
| 28 | - protected $request; |
|
| 29 | - |
|
| 30 | - /** @var \phpbb\auth\auth */ |
|
| 31 | - protected $auth; |
|
| 32 | - |
|
| 33 | - /** @var \phpbb\pagination */ |
|
| 34 | - protected $pagination; |
|
| 35 | - |
|
| 36 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 37 | - protected $categorie; |
|
| 38 | - |
|
| 39 | - /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 40 | - protected $link; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Constructor. |
|
| 44 | - * |
|
| 45 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 46 | - * @param \phpbb\config\config $config Config object |
|
| 47 | - * @param \phpbb\template\template $template Template object |
|
| 48 | - * @param \phpbb\user $user User object |
|
| 49 | - * @param \phpbb\controller\helper $helper Controller helper object |
|
| 50 | - * @param \phpbb\request\request $request Request object |
|
| 51 | - * @param \phpbb\auth\auth $auth Auth object |
|
| 52 | - * @param \phpbb\pagination $pagination Pagination object |
|
| 53 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 54 | - * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 55 | - */ |
|
| 56 | - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link) |
|
| 57 | - { |
|
| 58 | - $this->db = $db; |
|
| 59 | - $this->config = $config; |
|
| 60 | - $this->template = $template; |
|
| 61 | - $this->user = $user; |
|
| 62 | - $this->helper = $helper; |
|
| 63 | - $this->request = $request; |
|
| 64 | - $this->auth = $auth; |
|
| 65 | - $this->pagination = $pagination; |
|
| 66 | - $this->categorie = $categorie; |
|
| 67 | - $this->link = $link; |
|
| 68 | - |
|
| 69 | - $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 70 | - |
|
| 71 | - $this->template->assign_vars([ |
|
| 72 | - 'S_PHPBB_DIRECTORY' => true, |
|
| 73 | - 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 74 | - ]); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Base controller to be accessed with the URL /directory. |
|
| 79 | - * |
|
| 80 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 81 | - */ |
|
| 82 | - public function base() |
|
| 83 | - { |
|
| 84 | - $this->categorie->display(); |
|
| 85 | - $this->link->recents(); |
|
| 86 | - |
|
| 87 | - return $this->helper->render('body.html', $this->user->lang['DIRECTORY']); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * View controller for display a category. |
|
| 92 | - * |
|
| 93 | - * @param int $cat_id The category ID |
|
| 94 | - * @param int $page Page number taken from the URL |
|
| 95 | - * @param int $sort_days Specifies the maximum amount of days a link may be old |
|
| 96 | - * @param string $sort_key is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p |
|
| 97 | - * @param string $sort_dir is either a or d representing ASC and DESC (ascending|descending) |
|
| 98 | - * @param string $mode watch|unwatch |
|
| 99 | - * |
|
| 100 | - * @throws \phpbb\exception\http_exception |
|
| 101 | - * |
|
| 102 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 103 | - */ |
|
| 104 | - public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '') |
|
| 105 | - { |
|
| 106 | - if (false === $this->categorie->get($cat_id)) { |
|
| 107 | - throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $start = ($page - 1) * $this->config['dir_show']; |
|
| 111 | - |
|
| 112 | - $default_sort_days = 0; |
|
| 113 | - $default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1); |
|
| 114 | - $default_sort_dir = (string) substr($this->config['dir_default_order'], 2); |
|
| 115 | - |
|
| 116 | - $sort_days = (!$sort_days) ? $this->request->variable('st', $default_sort_days) : $sort_days; |
|
| 117 | - $sort_key = (!$sort_key) ? $this->request->variable('sk', $default_sort_key) : $sort_key; |
|
| 118 | - $sort_dir = (!$sort_dir) ? $this->request->variable('sd', $default_sort_dir) : $sort_dir; |
|
| 119 | - $link_list = $rowset = []; |
|
| 120 | - |
|
| 121 | - // Categorie ordering options |
|
| 122 | - $limit_days = [0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 123 | - $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']]; |
|
| 124 | - $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view']; |
|
| 125 | - |
|
| 126 | - if ($this->config['dir_activ_pagerank']) { |
|
| 127 | - $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER']; |
|
| 128 | - $sort_by_sql['p'] = 'l.link_pagerank'; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 132 | - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); |
|
| 133 | - |
|
| 134 | - $u_sort_param = ($sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir) ? [] : ['sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir]; |
|
| 135 | - |
|
| 136 | - // Are we watching this categorie? |
|
| 137 | - $s_watching_categorie = [ |
|
| 138 | - 'link' => '', |
|
| 139 | - 'link_toggle' => '', |
|
| 140 | - 'title' => '', |
|
| 141 | - 'title_toggle' => '', |
|
| 142 | - 'is_watching' => false, |
|
| 143 | - ]; |
|
| 144 | - |
|
| 145 | - if ($this->config['email_enable'] && $this->user->data['is_registered']) { |
|
| 146 | - $notify_status = (isset($this->categorie->data['notify_status'])) ? $this->categorie->data['notify_status'] : null; |
|
| 147 | - |
|
| 148 | - if (($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status))) { |
|
| 149 | - return $this->helper->message($message); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // A deadline has been selected |
|
| 154 | - if ($sort_days) { |
|
| 155 | - $min_post_time = time() - ($sort_days * 86400); |
|
| 156 | - |
|
| 157 | - $sql = 'SELECT COUNT(link_id) AS nb_links |
|
| 12 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | + protected $db; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\config\config */ |
|
| 16 | + protected $config; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\template\template */ |
|
| 19 | + protected $template; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\user */ |
|
| 22 | + protected $user; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\controller\helper */ |
|
| 25 | + protected $helper; |
|
| 26 | + |
|
| 27 | + /** @var \phpbb\request\request */ |
|
| 28 | + protected $request; |
|
| 29 | + |
|
| 30 | + /** @var \phpbb\auth\auth */ |
|
| 31 | + protected $auth; |
|
| 32 | + |
|
| 33 | + /** @var \phpbb\pagination */ |
|
| 34 | + protected $pagination; |
|
| 35 | + |
|
| 36 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 37 | + protected $categorie; |
|
| 38 | + |
|
| 39 | + /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 40 | + protected $link; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Constructor. |
|
| 44 | + * |
|
| 45 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 46 | + * @param \phpbb\config\config $config Config object |
|
| 47 | + * @param \phpbb\template\template $template Template object |
|
| 48 | + * @param \phpbb\user $user User object |
|
| 49 | + * @param \phpbb\controller\helper $helper Controller helper object |
|
| 50 | + * @param \phpbb\request\request $request Request object |
|
| 51 | + * @param \phpbb\auth\auth $auth Auth object |
|
| 52 | + * @param \phpbb\pagination $pagination Pagination object |
|
| 53 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 54 | + * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 55 | + */ |
|
| 56 | + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link) |
|
| 57 | + { |
|
| 58 | + $this->db = $db; |
|
| 59 | + $this->config = $config; |
|
| 60 | + $this->template = $template; |
|
| 61 | + $this->user = $user; |
|
| 62 | + $this->helper = $helper; |
|
| 63 | + $this->request = $request; |
|
| 64 | + $this->auth = $auth; |
|
| 65 | + $this->pagination = $pagination; |
|
| 66 | + $this->categorie = $categorie; |
|
| 67 | + $this->link = $link; |
|
| 68 | + |
|
| 69 | + $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 70 | + |
|
| 71 | + $this->template->assign_vars([ |
|
| 72 | + 'S_PHPBB_DIRECTORY' => true, |
|
| 73 | + 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 74 | + ]); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Base controller to be accessed with the URL /directory. |
|
| 79 | + * |
|
| 80 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 81 | + */ |
|
| 82 | + public function base() |
|
| 83 | + { |
|
| 84 | + $this->categorie->display(); |
|
| 85 | + $this->link->recents(); |
|
| 86 | + |
|
| 87 | + return $this->helper->render('body.html', $this->user->lang['DIRECTORY']); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * View controller for display a category. |
|
| 92 | + * |
|
| 93 | + * @param int $cat_id The category ID |
|
| 94 | + * @param int $page Page number taken from the URL |
|
| 95 | + * @param int $sort_days Specifies the maximum amount of days a link may be old |
|
| 96 | + * @param string $sort_key is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p |
|
| 97 | + * @param string $sort_dir is either a or d representing ASC and DESC (ascending|descending) |
|
| 98 | + * @param string $mode watch|unwatch |
|
| 99 | + * |
|
| 100 | + * @throws \phpbb\exception\http_exception |
|
| 101 | + * |
|
| 102 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 103 | + */ |
|
| 104 | + public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '') |
|
| 105 | + { |
|
| 106 | + if (false === $this->categorie->get($cat_id)) { |
|
| 107 | + throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $start = ($page - 1) * $this->config['dir_show']; |
|
| 111 | + |
|
| 112 | + $default_sort_days = 0; |
|
| 113 | + $default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1); |
|
| 114 | + $default_sort_dir = (string) substr($this->config['dir_default_order'], 2); |
|
| 115 | + |
|
| 116 | + $sort_days = (!$sort_days) ? $this->request->variable('st', $default_sort_days) : $sort_days; |
|
| 117 | + $sort_key = (!$sort_key) ? $this->request->variable('sk', $default_sort_key) : $sort_key; |
|
| 118 | + $sort_dir = (!$sort_dir) ? $this->request->variable('sd', $default_sort_dir) : $sort_dir; |
|
| 119 | + $link_list = $rowset = []; |
|
| 120 | + |
|
| 121 | + // Categorie ordering options |
|
| 122 | + $limit_days = [0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 123 | + $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']]; |
|
| 124 | + $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view']; |
|
| 125 | + |
|
| 126 | + if ($this->config['dir_activ_pagerank']) { |
|
| 127 | + $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER']; |
|
| 128 | + $sort_by_sql['p'] = 'l.link_pagerank'; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 132 | + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); |
|
| 133 | + |
|
| 134 | + $u_sort_param = ($sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir) ? [] : ['sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir]; |
|
| 135 | + |
|
| 136 | + // Are we watching this categorie? |
|
| 137 | + $s_watching_categorie = [ |
|
| 138 | + 'link' => '', |
|
| 139 | + 'link_toggle' => '', |
|
| 140 | + 'title' => '', |
|
| 141 | + 'title_toggle' => '', |
|
| 142 | + 'is_watching' => false, |
|
| 143 | + ]; |
|
| 144 | + |
|
| 145 | + if ($this->config['email_enable'] && $this->user->data['is_registered']) { |
|
| 146 | + $notify_status = (isset($this->categorie->data['notify_status'])) ? $this->categorie->data['notify_status'] : null; |
|
| 147 | + |
|
| 148 | + if (($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status))) { |
|
| 149 | + return $this->helper->message($message); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // A deadline has been selected |
|
| 154 | + if ($sort_days) { |
|
| 155 | + $min_post_time = time() - ($sort_days * 86400); |
|
| 156 | + |
|
| 157 | + $sql = 'SELECT COUNT(link_id) AS nb_links |
|
| 158 | 158 | FROM '.DIR_LINK_TABLE.' |
| 159 | 159 | WHERE link_cat = '.(int) $cat_id.' |
| 160 | 160 | AND link_time >= '.$min_post_time; |
| 161 | - $result = $this->db->sql_query($sql); |
|
| 162 | - $nb_links = (int) $this->db->sql_fetchfield('nb_links'); |
|
| 163 | - $this->db->sql_freeresult($result); |
|
| 164 | - |
|
| 165 | - if ($this->request->is_set_post('sort')) { |
|
| 166 | - $start = 0; |
|
| 167 | - } |
|
| 168 | - $sql_limit_time = " AND l.link_time >= $min_post_time"; |
|
| 169 | - } else { |
|
| 170 | - $sql_limit_time = ''; |
|
| 171 | - $nb_links = (int) $this->categorie->data['cat_links']; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Make sure $start is set to the last page if it exceeds the amount |
|
| 175 | - $start = $this->pagination->validate_start($start, $this->config['dir_show'], $nb_links); |
|
| 176 | - |
|
| 177 | - // Build navigation links |
|
| 178 | - $this->categorie->generate_dir_nav($this->categorie->data); |
|
| 179 | - |
|
| 180 | - // Jumpbox |
|
| 181 | - $this->categorie->make_cat_jumpbox(); |
|
| 182 | - |
|
| 183 | - $base_url = [ |
|
| 184 | - 'routes' => 'ernadoo_phpbbdirectory_page_controller', |
|
| 185 | - 'params' => array_merge(['cat_id' => $cat_id], $u_sort_param), |
|
| 186 | - ]; |
|
| 187 | - |
|
| 188 | - $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_links, $this->config['dir_show'], $start); |
|
| 189 | - |
|
| 190 | - $this->template->assign_vars([ |
|
| 191 | - 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 192 | - 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 193 | - 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 194 | - 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), |
|
| 195 | - 'S_PAGE_ACTION' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => $cat_id, 'page' => $page]), |
|
| 196 | - 'S_CAT_ID' => $cat_id, |
|
| 197 | - |
|
| 198 | - 'TOTAL_LINKS' => $this->user->lang('DIR_NB_LINKS', (int) $nb_links), |
|
| 199 | - |
|
| 200 | - 'U_NEW_SITE' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', ['cat_id' => $cat_id]), |
|
| 201 | - |
|
| 202 | - 'U_WATCH_CAT' => $s_watching_categorie['link'], |
|
| 203 | - 'U_WATCH_CAT_TOGGLE' => $s_watching_categorie['link_toggle'], |
|
| 204 | - 'S_WATCH_CAT_TITLE' => $s_watching_categorie['title'], |
|
| 205 | - 'S_WATCH_CAT_TOGGLE' => $s_watching_categorie['title_toggle'], |
|
| 206 | - 'S_WATCHING_CAT' => $s_watching_categorie['is_watching'], |
|
| 207 | - ]); |
|
| 208 | - |
|
| 209 | - // If the user is trying to reach late pages, start searching from the end |
|
| 210 | - $store_reverse = false; |
|
| 211 | - $sql_limit = $this->config['dir_show']; |
|
| 212 | - if ($start > $nb_links / 2) { |
|
| 213 | - $store_reverse = true; |
|
| 214 | - |
|
| 215 | - // Select the sort order |
|
| 216 | - $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
|
| 217 | - |
|
| 218 | - $sql_limit = $this->pagination->reverse_limit($start, $sql_limit, $nb_links); |
|
| 219 | - $sql_start = $this->pagination->reverse_start($start, $sql_limit, $nb_links); |
|
| 220 | - } else { |
|
| 221 | - // Select the sort order |
|
| 222 | - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
| 223 | - $sql_start = $start; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if (is_array($sort_by_sql[$sort_key])) { |
|
| 227 | - $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction; |
|
| 228 | - } else { |
|
| 229 | - $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - // Grab just the sorted link ids |
|
| 233 | - $sql_array = [ |
|
| 234 | - 'SELECT' => 'l.link_id', |
|
| 235 | - 'FROM' => [ |
|
| 236 | - DIR_LINK_TABLE => 'l', ], |
|
| 237 | - 'LEFT_JOIN' => [ |
|
| 238 | - [ |
|
| 239 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 240 | - 'ON' => 'l.link_user_id = u.user_id', |
|
| 241 | - ], |
|
| 242 | - ], |
|
| 243 | - 'WHERE' => "l.link_cat = $cat_id |
|
| 161 | + $result = $this->db->sql_query($sql); |
|
| 162 | + $nb_links = (int) $this->db->sql_fetchfield('nb_links'); |
|
| 163 | + $this->db->sql_freeresult($result); |
|
| 164 | + |
|
| 165 | + if ($this->request->is_set_post('sort')) { |
|
| 166 | + $start = 0; |
|
| 167 | + } |
|
| 168 | + $sql_limit_time = " AND l.link_time >= $min_post_time"; |
|
| 169 | + } else { |
|
| 170 | + $sql_limit_time = ''; |
|
| 171 | + $nb_links = (int) $this->categorie->data['cat_links']; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Make sure $start is set to the last page if it exceeds the amount |
|
| 175 | + $start = $this->pagination->validate_start($start, $this->config['dir_show'], $nb_links); |
|
| 176 | + |
|
| 177 | + // Build navigation links |
|
| 178 | + $this->categorie->generate_dir_nav($this->categorie->data); |
|
| 179 | + |
|
| 180 | + // Jumpbox |
|
| 181 | + $this->categorie->make_cat_jumpbox(); |
|
| 182 | + |
|
| 183 | + $base_url = [ |
|
| 184 | + 'routes' => 'ernadoo_phpbbdirectory_page_controller', |
|
| 185 | + 'params' => array_merge(['cat_id' => $cat_id], $u_sort_param), |
|
| 186 | + ]; |
|
| 187 | + |
|
| 188 | + $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_links, $this->config['dir_show'], $start); |
|
| 189 | + |
|
| 190 | + $this->template->assign_vars([ |
|
| 191 | + 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 192 | + 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 193 | + 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 194 | + 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), |
|
| 195 | + 'S_PAGE_ACTION' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => $cat_id, 'page' => $page]), |
|
| 196 | + 'S_CAT_ID' => $cat_id, |
|
| 197 | + |
|
| 198 | + 'TOTAL_LINKS' => $this->user->lang('DIR_NB_LINKS', (int) $nb_links), |
|
| 199 | + |
|
| 200 | + 'U_NEW_SITE' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', ['cat_id' => $cat_id]), |
|
| 201 | + |
|
| 202 | + 'U_WATCH_CAT' => $s_watching_categorie['link'], |
|
| 203 | + 'U_WATCH_CAT_TOGGLE' => $s_watching_categorie['link_toggle'], |
|
| 204 | + 'S_WATCH_CAT_TITLE' => $s_watching_categorie['title'], |
|
| 205 | + 'S_WATCH_CAT_TOGGLE' => $s_watching_categorie['title_toggle'], |
|
| 206 | + 'S_WATCHING_CAT' => $s_watching_categorie['is_watching'], |
|
| 207 | + ]); |
|
| 208 | + |
|
| 209 | + // If the user is trying to reach late pages, start searching from the end |
|
| 210 | + $store_reverse = false; |
|
| 211 | + $sql_limit = $this->config['dir_show']; |
|
| 212 | + if ($start > $nb_links / 2) { |
|
| 213 | + $store_reverse = true; |
|
| 214 | + |
|
| 215 | + // Select the sort order |
|
| 216 | + $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
|
| 217 | + |
|
| 218 | + $sql_limit = $this->pagination->reverse_limit($start, $sql_limit, $nb_links); |
|
| 219 | + $sql_start = $this->pagination->reverse_start($start, $sql_limit, $nb_links); |
|
| 220 | + } else { |
|
| 221 | + // Select the sort order |
|
| 222 | + $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
| 223 | + $sql_start = $start; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if (is_array($sort_by_sql[$sort_key])) { |
|
| 227 | + $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction; |
|
| 228 | + } else { |
|
| 229 | + $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + // Grab just the sorted link ids |
|
| 233 | + $sql_array = [ |
|
| 234 | + 'SELECT' => 'l.link_id', |
|
| 235 | + 'FROM' => [ |
|
| 236 | + DIR_LINK_TABLE => 'l', ], |
|
| 237 | + 'LEFT_JOIN' => [ |
|
| 238 | + [ |
|
| 239 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 240 | + 'ON' => 'l.link_user_id = u.user_id', |
|
| 241 | + ], |
|
| 242 | + ], |
|
| 243 | + 'WHERE' => "l.link_cat = $cat_id |
|
| 244 | 244 | AND l.link_active = 1 |
| 245 | 245 | $sql_limit_time", |
| 246 | - 'ORDER_BY' => $sql_sort_order, |
|
| 247 | - ]; |
|
| 248 | - |
|
| 249 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 250 | - $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start); |
|
| 251 | - |
|
| 252 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 253 | - $link_list[] = (int) $row['link_id']; |
|
| 254 | - } |
|
| 255 | - $this->db->sql_freeresult($result); |
|
| 256 | - |
|
| 257 | - if (count($link_list)) { |
|
| 258 | - // We get links, informations about poster, votes and number of comments |
|
| 259 | - $sql_array = [ |
|
| 260 | - 'SELECT' => 'l.link_id, l.link_cat, l.link_url, l.link_user_id, l.link_comment, l. link_description, l.link_banner, l.link_rss, l. link_uid, l.link_bitfield, l.link_flags, l.link_vote, l.link_note, l.link_view, l.link_time, l.link_name, l.link_flag, l.link_pagerank, l.link_thumb, u.user_id, u.username, u.user_colour, v.vote_user_id', |
|
| 261 | - 'FROM' => [ |
|
| 262 | - DIR_LINK_TABLE => 'l', ], |
|
| 263 | - 'LEFT_JOIN' => [ |
|
| 264 | - [ |
|
| 265 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 266 | - 'ON' => 'l.link_user_id = u.user_id', |
|
| 267 | - ], |
|
| 268 | - [ |
|
| 269 | - 'FROM' => [DIR_VOTE_TABLE => 'v'], |
|
| 270 | - 'ON' => 'l.link_id = v.vote_link_id AND v.vote_user_id = '.$this->user->data['user_id'], |
|
| 271 | - ], |
|
| 272 | - ], |
|
| 273 | - 'WHERE' => $this->db->sql_in_set('l.link_id', $link_list), |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 277 | - $result = $this->db->sql_query($sql); |
|
| 278 | - |
|
| 279 | - while ($site = $this->db->sql_fetchrow($result)) { |
|
| 280 | - $rowset[$site['link_id']] = $site; |
|
| 281 | - } |
|
| 282 | - $this->db->sql_freeresult($result); |
|
| 283 | - |
|
| 284 | - $link_list = ($store_reverse) ? array_reverse($link_list) : $link_list; |
|
| 285 | - |
|
| 286 | - $votes_status = ($this->categorie->data['cat_allow_votes']) ? true : false; |
|
| 287 | - $comments_status = ($this->categorie->data['cat_allow_comments']) ? true : false; |
|
| 288 | - |
|
| 289 | - foreach ($link_list as $link_id) { |
|
| 290 | - $site = &$rowset[$link_id]; |
|
| 291 | - |
|
| 292 | - $s_flag = $this->link->display_flag($site); |
|
| 293 | - $s_note = $this->link->display_note($site['link_note'], $site['link_vote'], $votes_status); |
|
| 294 | - $s_thumb = $this->link->display_thumb($site); |
|
| 295 | - $s_vote = $this->link->display_vote($site); |
|
| 296 | - $s_banner = $this->link->display_bann($site); |
|
| 297 | - $s_pr = $this->link->display_pagerank($site); |
|
| 298 | - $s_rss = $this->link->display_rss($site); |
|
| 299 | - |
|
| 300 | - $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_edit_dir')))); |
|
| 301 | - $delete_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_delete_dir')))); |
|
| 302 | - |
|
| 303 | - $this->template->assign_block_vars('site', [ |
|
| 304 | - 'BANNER' => $s_banner, |
|
| 305 | - 'COUNT' => $this->user->lang('DIR_NB_CLICKS', (int) $site['link_view']), |
|
| 306 | - 'DESCRIPTION' => generate_text_for_display($site['link_description'], $site['link_uid'], $site['link_bitfield'], $site['link_flags']), |
|
| 307 | - 'LINK_ID' => $site['link_id'], |
|
| 308 | - 'NAME' => $site['link_name'], |
|
| 309 | - 'NB_COMMENT' => ($comments_status) ? $this->user->lang('DIR_NB_COMMS', (int) $site['link_comment']) : '', |
|
| 310 | - 'NB_VOTE' => $this->user->lang('DIR_NB_VOTES', (int) $site['link_vote']), |
|
| 311 | - 'NOTE' => $s_note, |
|
| 312 | - 'PAGERANK' => $s_pr, |
|
| 313 | - 'RSS' => $s_rss, |
|
| 314 | - 'TIME' => ($site['link_time']) ? $this->user->format_date($site['link_time']) : '', |
|
| 315 | - 'USER' => get_username_string('full', $site['link_user_id'], $site['username'], $site['user_colour']), |
|
| 316 | - 'VOTE_LIST' => ($votes_status) ? $s_vote : '', |
|
| 317 | - |
|
| 318 | - 'IMG_FLAG' => $s_flag, |
|
| 319 | - 'ON_CLICK' => "onclick=\"window.open('".$this->helper->route('ernadoo_phpbbdirectory_view_controller', ['link_id' => (int) $site['link_id']])."'); return false;\"", |
|
| 320 | - |
|
| 321 | - 'S_NEW_LINK' => (((time() - $site['link_time']) / 86400) <= $this->config['dir_new_time']) ? true : false, |
|
| 322 | - |
|
| 323 | - 'U_COMMENT' => ($comments_status) ? $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $site['link_id']]) : '', |
|
| 324 | - 'U_DELETE' => $delete_allowed ? $this->helper->route('ernadoo_phpbbdirectory_delete_controller', ['cat_id' => (int) $cat_id, 'link_id' => (int) $site['link_id'], '_referer' => $this->helper->get_current_url()]) : '', |
|
| 325 | - 'U_EDIT' => $edit_allowed ? $this->helper->route('ernadoo_phpbbdirectory_edit_controller', ['cat_id' => (int) $cat_id, 'link_id' => (int) $site['link_id']]) : '', |
|
| 326 | - 'U_FORM_VOTE' => ($votes_status) ? $this->helper->route('ernadoo_phpbbdirectory_vote_controller', ['cat_id' => (int) $site['link_cat'], 'link_id' => (int) $site['link_id']]) : '', |
|
| 327 | - 'U_LINK' => $site['link_url'], |
|
| 328 | - 'U_THUMB' => $s_thumb, |
|
| 329 | - ]); |
|
| 330 | - } |
|
| 331 | - } else { |
|
| 332 | - $this->template->assign_block_vars('no_draw_link', []); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - $page_title = $this->user->lang['DIRECTORY'].' - '.$this->categorie->data['cat_name']; |
|
| 336 | - |
|
| 337 | - $this->categorie->display(); |
|
| 338 | - |
|
| 339 | - return $this->helper->render('view_cat.html', $page_title); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * date controller for return a date. |
|
| 344 | - * |
|
| 345 | - * @throws \phpbb\exception\http_exception |
|
| 346 | - * |
|
| 347 | - * @return \phpbb\json_response A Json Response |
|
| 348 | - */ |
|
| 349 | - public function return_date() |
|
| 350 | - { |
|
| 351 | - if (!$this->request->is_ajax()) { |
|
| 352 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - $timestamp = $this->request->variable('timestamp', 0); |
|
| 356 | - $json_response = new \phpbb\json_response(); |
|
| 357 | - $json_response->send([ |
|
| 358 | - 'success' => true, |
|
| 359 | - 'DATE' => $this->user->format_date((int) $timestamp), |
|
| 360 | - ]); |
|
| 361 | - } |
|
| 246 | + 'ORDER_BY' => $sql_sort_order, |
|
| 247 | + ]; |
|
| 248 | + |
|
| 249 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 250 | + $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start); |
|
| 251 | + |
|
| 252 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 253 | + $link_list[] = (int) $row['link_id']; |
|
| 254 | + } |
|
| 255 | + $this->db->sql_freeresult($result); |
|
| 256 | + |
|
| 257 | + if (count($link_list)) { |
|
| 258 | + // We get links, informations about poster, votes and number of comments |
|
| 259 | + $sql_array = [ |
|
| 260 | + 'SELECT' => 'l.link_id, l.link_cat, l.link_url, l.link_user_id, l.link_comment, l. link_description, l.link_banner, l.link_rss, l. link_uid, l.link_bitfield, l.link_flags, l.link_vote, l.link_note, l.link_view, l.link_time, l.link_name, l.link_flag, l.link_pagerank, l.link_thumb, u.user_id, u.username, u.user_colour, v.vote_user_id', |
|
| 261 | + 'FROM' => [ |
|
| 262 | + DIR_LINK_TABLE => 'l', ], |
|
| 263 | + 'LEFT_JOIN' => [ |
|
| 264 | + [ |
|
| 265 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 266 | + 'ON' => 'l.link_user_id = u.user_id', |
|
| 267 | + ], |
|
| 268 | + [ |
|
| 269 | + 'FROM' => [DIR_VOTE_TABLE => 'v'], |
|
| 270 | + 'ON' => 'l.link_id = v.vote_link_id AND v.vote_user_id = '.$this->user->data['user_id'], |
|
| 271 | + ], |
|
| 272 | + ], |
|
| 273 | + 'WHERE' => $this->db->sql_in_set('l.link_id', $link_list), |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 277 | + $result = $this->db->sql_query($sql); |
|
| 278 | + |
|
| 279 | + while ($site = $this->db->sql_fetchrow($result)) { |
|
| 280 | + $rowset[$site['link_id']] = $site; |
|
| 281 | + } |
|
| 282 | + $this->db->sql_freeresult($result); |
|
| 283 | + |
|
| 284 | + $link_list = ($store_reverse) ? array_reverse($link_list) : $link_list; |
|
| 285 | + |
|
| 286 | + $votes_status = ($this->categorie->data['cat_allow_votes']) ? true : false; |
|
| 287 | + $comments_status = ($this->categorie->data['cat_allow_comments']) ? true : false; |
|
| 288 | + |
|
| 289 | + foreach ($link_list as $link_id) { |
|
| 290 | + $site = &$rowset[$link_id]; |
|
| 291 | + |
|
| 292 | + $s_flag = $this->link->display_flag($site); |
|
| 293 | + $s_note = $this->link->display_note($site['link_note'], $site['link_vote'], $votes_status); |
|
| 294 | + $s_thumb = $this->link->display_thumb($site); |
|
| 295 | + $s_vote = $this->link->display_vote($site); |
|
| 296 | + $s_banner = $this->link->display_bann($site); |
|
| 297 | + $s_pr = $this->link->display_pagerank($site); |
|
| 298 | + $s_rss = $this->link->display_rss($site); |
|
| 299 | + |
|
| 300 | + $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_edit_dir')))); |
|
| 301 | + $delete_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_delete_dir')))); |
|
| 302 | + |
|
| 303 | + $this->template->assign_block_vars('site', [ |
|
| 304 | + 'BANNER' => $s_banner, |
|
| 305 | + 'COUNT' => $this->user->lang('DIR_NB_CLICKS', (int) $site['link_view']), |
|
| 306 | + 'DESCRIPTION' => generate_text_for_display($site['link_description'], $site['link_uid'], $site['link_bitfield'], $site['link_flags']), |
|
| 307 | + 'LINK_ID' => $site['link_id'], |
|
| 308 | + 'NAME' => $site['link_name'], |
|
| 309 | + 'NB_COMMENT' => ($comments_status) ? $this->user->lang('DIR_NB_COMMS', (int) $site['link_comment']) : '', |
|
| 310 | + 'NB_VOTE' => $this->user->lang('DIR_NB_VOTES', (int) $site['link_vote']), |
|
| 311 | + 'NOTE' => $s_note, |
|
| 312 | + 'PAGERANK' => $s_pr, |
|
| 313 | + 'RSS' => $s_rss, |
|
| 314 | + 'TIME' => ($site['link_time']) ? $this->user->format_date($site['link_time']) : '', |
|
| 315 | + 'USER' => get_username_string('full', $site['link_user_id'], $site['username'], $site['user_colour']), |
|
| 316 | + 'VOTE_LIST' => ($votes_status) ? $s_vote : '', |
|
| 317 | + |
|
| 318 | + 'IMG_FLAG' => $s_flag, |
|
| 319 | + 'ON_CLICK' => "onclick=\"window.open('".$this->helper->route('ernadoo_phpbbdirectory_view_controller', ['link_id' => (int) $site['link_id']])."'); return false;\"", |
|
| 320 | + |
|
| 321 | + 'S_NEW_LINK' => (((time() - $site['link_time']) / 86400) <= $this->config['dir_new_time']) ? true : false, |
|
| 322 | + |
|
| 323 | + 'U_COMMENT' => ($comments_status) ? $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $site['link_id']]) : '', |
|
| 324 | + 'U_DELETE' => $delete_allowed ? $this->helper->route('ernadoo_phpbbdirectory_delete_controller', ['cat_id' => (int) $cat_id, 'link_id' => (int) $site['link_id'], '_referer' => $this->helper->get_current_url()]) : '', |
|
| 325 | + 'U_EDIT' => $edit_allowed ? $this->helper->route('ernadoo_phpbbdirectory_edit_controller', ['cat_id' => (int) $cat_id, 'link_id' => (int) $site['link_id']]) : '', |
|
| 326 | + 'U_FORM_VOTE' => ($votes_status) ? $this->helper->route('ernadoo_phpbbdirectory_vote_controller', ['cat_id' => (int) $site['link_cat'], 'link_id' => (int) $site['link_id']]) : '', |
|
| 327 | + 'U_LINK' => $site['link_url'], |
|
| 328 | + 'U_THUMB' => $s_thumb, |
|
| 329 | + ]); |
|
| 330 | + } |
|
| 331 | + } else { |
|
| 332 | + $this->template->assign_block_vars('no_draw_link', []); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + $page_title = $this->user->lang['DIRECTORY'].' - '.$this->categorie->data['cat_name']; |
|
| 336 | + |
|
| 337 | + $this->categorie->display(); |
|
| 338 | + |
|
| 339 | + return $this->helper->render('view_cat.html', $page_title); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * date controller for return a date. |
|
| 344 | + * |
|
| 345 | + * @throws \phpbb\exception\http_exception |
|
| 346 | + * |
|
| 347 | + * @return \phpbb\json_response A Json Response |
|
| 348 | + */ |
|
| 349 | + public function return_date() |
|
| 350 | + { |
|
| 351 | + if (!$this->request->is_ajax()) { |
|
| 352 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + $timestamp = $this->request->variable('timestamp', 0); |
|
| 356 | + $json_response = new \phpbb\json_response(); |
|
| 357 | + $json_response->send([ |
|
| 358 | + 'success' => true, |
|
| 359 | + 'DATE' => $this->user->format_date((int) $timestamp), |
|
| 360 | + ]); |
|
| 361 | + } |
|
| 362 | 362 | } |
@@ -9,475 +9,475 @@ |
||
| 9 | 9 | |
| 10 | 10 | class comments |
| 11 | 11 | { |
| 12 | - private $captcha; |
|
| 13 | - private $s_comment; |
|
| 14 | - private $s_hidden_fields = []; |
|
| 15 | - |
|
| 16 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 17 | - protected $db; |
|
| 18 | - |
|
| 19 | - /** @var \phpbb\config\config */ |
|
| 20 | - protected $config; |
|
| 21 | - |
|
| 22 | - /** @var \phpbb\template\template */ |
|
| 23 | - protected $template; |
|
| 24 | - |
|
| 25 | - /** @var \phpbb\user */ |
|
| 26 | - protected $user; |
|
| 27 | - |
|
| 28 | - /** @var \phpbb\controller\helper */ |
|
| 29 | - protected $helper; |
|
| 30 | - |
|
| 31 | - /** @var \phpbb\request\request */ |
|
| 32 | - protected $request; |
|
| 33 | - |
|
| 34 | - /** @var \phpbb\auth\auth */ |
|
| 35 | - protected $auth; |
|
| 36 | - |
|
| 37 | - /** @var \phpbb\pagination */ |
|
| 38 | - protected $pagination; |
|
| 39 | - |
|
| 40 | - /** @var \phpbb\captcha\factory */ |
|
| 41 | - protected $captcha_factory; |
|
| 42 | - |
|
| 43 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 44 | - protected $categorie; |
|
| 45 | - |
|
| 46 | - /** @var \ernadoo\phpbbdirectory\core\comment */ |
|
| 47 | - protected $comment; |
|
| 48 | - |
|
| 49 | - /** @var string phpBB root path */ |
|
| 50 | - protected $root_path; |
|
| 51 | - |
|
| 52 | - /** @var string phpEx */ |
|
| 53 | - protected $php_ext; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Constructor. |
|
| 57 | - * |
|
| 58 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 59 | - * @param \phpbb\config\config $config Config object |
|
| 60 | - * @param \phpbb\template\template $template Template object |
|
| 61 | - * @param \phpbb\user $user User object |
|
| 62 | - * @param \phpbb\controller\helper $helper Controller helper object |
|
| 63 | - * @param \phpbb\request\request $request Request object |
|
| 64 | - * @param \phpbb\auth\auth $auth Auth object |
|
| 65 | - * @param \phpbb\pagination $pagination Pagination object |
|
| 66 | - * @param \phpbb\captcha\factory $captcha_factory Captcha object |
|
| 67 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 68 | - * @param \ernadoo\phpbbdirectory\core\comment $comment PhpBB Directory extension comment object |
|
| 69 | - * @param string $root_path phpBB root path |
|
| 70 | - * @param string $php_ext phpEx |
|
| 71 | - */ |
|
| 72 | - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \phpbb\captcha\factory $captcha_factory, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\comment $comment, $root_path, $php_ext) |
|
| 73 | - { |
|
| 74 | - $this->db = $db; |
|
| 75 | - $this->config = $config; |
|
| 76 | - $this->template = $template; |
|
| 77 | - $this->user = $user; |
|
| 78 | - $this->helper = $helper; |
|
| 79 | - $this->request = $request; |
|
| 80 | - $this->auth = $auth; |
|
| 81 | - $this->pagination = $pagination; |
|
| 82 | - $this->captcha_factory = $captcha_factory; |
|
| 83 | - $this->categorie = $categorie; |
|
| 84 | - $this->comment = $comment; |
|
| 85 | - $this->root_path = $root_path; |
|
| 86 | - $this->php_ext = $php_ext; |
|
| 87 | - |
|
| 88 | - $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 89 | - $user->add_lang(['ucp', 'posting']); |
|
| 90 | - |
|
| 91 | - $this->template->assign_vars([ |
|
| 92 | - 'S_PHPBB_DIRECTORY' => true, |
|
| 93 | - 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 94 | - 'S_SIMPLE_MESSAGE' => true, |
|
| 95 | - ]); |
|
| 96 | - |
|
| 97 | - // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. |
|
| 98 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 99 | - $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); |
|
| 100 | - $this->captcha->init(CONFIRM_POST); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Populate form when an error occurred. |
|
| 106 | - * |
|
| 107 | - * @param int $link_id The link ID |
|
| 108 | - * @param int $comment_id The comment ID |
|
| 109 | - * |
|
| 110 | - * @throws \phpbb\exception\http_exception |
|
| 111 | - * |
|
| 112 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 113 | - */ |
|
| 114 | - public function delete_comment($link_id, $comment_id) |
|
| 115 | - { |
|
| 116 | - $this->_check_comments_enable($link_id); |
|
| 117 | - |
|
| 118 | - if ($this->request->is_set_post('cancel')) { |
|
| 119 | - $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 120 | - redirect($redirect); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $sql = 'SELECT * |
|
| 12 | + private $captcha; |
|
| 13 | + private $s_comment; |
|
| 14 | + private $s_hidden_fields = []; |
|
| 15 | + |
|
| 16 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 17 | + protected $db; |
|
| 18 | + |
|
| 19 | + /** @var \phpbb\config\config */ |
|
| 20 | + protected $config; |
|
| 21 | + |
|
| 22 | + /** @var \phpbb\template\template */ |
|
| 23 | + protected $template; |
|
| 24 | + |
|
| 25 | + /** @var \phpbb\user */ |
|
| 26 | + protected $user; |
|
| 27 | + |
|
| 28 | + /** @var \phpbb\controller\helper */ |
|
| 29 | + protected $helper; |
|
| 30 | + |
|
| 31 | + /** @var \phpbb\request\request */ |
|
| 32 | + protected $request; |
|
| 33 | + |
|
| 34 | + /** @var \phpbb\auth\auth */ |
|
| 35 | + protected $auth; |
|
| 36 | + |
|
| 37 | + /** @var \phpbb\pagination */ |
|
| 38 | + protected $pagination; |
|
| 39 | + |
|
| 40 | + /** @var \phpbb\captcha\factory */ |
|
| 41 | + protected $captcha_factory; |
|
| 42 | + |
|
| 43 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 44 | + protected $categorie; |
|
| 45 | + |
|
| 46 | + /** @var \ernadoo\phpbbdirectory\core\comment */ |
|
| 47 | + protected $comment; |
|
| 48 | + |
|
| 49 | + /** @var string phpBB root path */ |
|
| 50 | + protected $root_path; |
|
| 51 | + |
|
| 52 | + /** @var string phpEx */ |
|
| 53 | + protected $php_ext; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Constructor. |
|
| 57 | + * |
|
| 58 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 59 | + * @param \phpbb\config\config $config Config object |
|
| 60 | + * @param \phpbb\template\template $template Template object |
|
| 61 | + * @param \phpbb\user $user User object |
|
| 62 | + * @param \phpbb\controller\helper $helper Controller helper object |
|
| 63 | + * @param \phpbb\request\request $request Request object |
|
| 64 | + * @param \phpbb\auth\auth $auth Auth object |
|
| 65 | + * @param \phpbb\pagination $pagination Pagination object |
|
| 66 | + * @param \phpbb\captcha\factory $captcha_factory Captcha object |
|
| 67 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 68 | + * @param \ernadoo\phpbbdirectory\core\comment $comment PhpBB Directory extension comment object |
|
| 69 | + * @param string $root_path phpBB root path |
|
| 70 | + * @param string $php_ext phpEx |
|
| 71 | + */ |
|
| 72 | + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \phpbb\captcha\factory $captcha_factory, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\comment $comment, $root_path, $php_ext) |
|
| 73 | + { |
|
| 74 | + $this->db = $db; |
|
| 75 | + $this->config = $config; |
|
| 76 | + $this->template = $template; |
|
| 77 | + $this->user = $user; |
|
| 78 | + $this->helper = $helper; |
|
| 79 | + $this->request = $request; |
|
| 80 | + $this->auth = $auth; |
|
| 81 | + $this->pagination = $pagination; |
|
| 82 | + $this->captcha_factory = $captcha_factory; |
|
| 83 | + $this->categorie = $categorie; |
|
| 84 | + $this->comment = $comment; |
|
| 85 | + $this->root_path = $root_path; |
|
| 86 | + $this->php_ext = $php_ext; |
|
| 87 | + |
|
| 88 | + $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 89 | + $user->add_lang(['ucp', 'posting']); |
|
| 90 | + |
|
| 91 | + $this->template->assign_vars([ |
|
| 92 | + 'S_PHPBB_DIRECTORY' => true, |
|
| 93 | + 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 94 | + 'S_SIMPLE_MESSAGE' => true, |
|
| 95 | + ]); |
|
| 96 | + |
|
| 97 | + // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. |
|
| 98 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 99 | + $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); |
|
| 100 | + $this->captcha->init(CONFIRM_POST); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Populate form when an error occurred. |
|
| 106 | + * |
|
| 107 | + * @param int $link_id The link ID |
|
| 108 | + * @param int $comment_id The comment ID |
|
| 109 | + * |
|
| 110 | + * @throws \phpbb\exception\http_exception |
|
| 111 | + * |
|
| 112 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 113 | + */ |
|
| 114 | + public function delete_comment($link_id, $comment_id) |
|
| 115 | + { |
|
| 116 | + $this->_check_comments_enable($link_id); |
|
| 117 | + |
|
| 118 | + if ($this->request->is_set_post('cancel')) { |
|
| 119 | + $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 120 | + redirect($redirect); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $sql = 'SELECT * |
|
| 124 | 124 | FROM '.DIR_COMMENT_TABLE.' |
| 125 | 125 | WHERE comment_id = '.(int) $comment_id; |
| 126 | - $result = $this->db->sql_query($sql); |
|
| 127 | - $value = $this->db->sql_fetchrow($result); |
|
| 128 | - |
|
| 129 | - if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_delete_comment_dir') && (!$this->auth->acl_get('u_delete_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) { |
|
| 130 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if (confirm_box(true)) { |
|
| 134 | - $this->comment->del($link_id, $comment_id); |
|
| 135 | - |
|
| 136 | - $meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 137 | - meta_refresh(3, $meta_info); |
|
| 138 | - $message = $this->user->lang['DIR_COMMENT_DELETE_OK']; |
|
| 139 | - $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 140 | - |
|
| 141 | - return $this->helper->message($message); |
|
| 142 | - } else { |
|
| 143 | - confirm_box(false, 'DIR_COMMENT_DELETE'); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Edit a comment. |
|
| 149 | - * |
|
| 150 | - * @param int $link_id The category ID |
|
| 151 | - * @param int $comment_id The comment ID |
|
| 152 | - * |
|
| 153 | - * @throws \phpbb\exception\http_exception |
|
| 154 | - * |
|
| 155 | - * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 156 | - */ |
|
| 157 | - public function edit_comment($link_id, $comment_id) |
|
| 158 | - { |
|
| 159 | - $this->_check_comments_enable($link_id); |
|
| 160 | - |
|
| 161 | - $sql = 'SELECT * |
|
| 126 | + $result = $this->db->sql_query($sql); |
|
| 127 | + $value = $this->db->sql_fetchrow($result); |
|
| 128 | + |
|
| 129 | + if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_delete_comment_dir') && (!$this->auth->acl_get('u_delete_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) { |
|
| 130 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if (confirm_box(true)) { |
|
| 134 | + $this->comment->del($link_id, $comment_id); |
|
| 135 | + |
|
| 136 | + $meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 137 | + meta_refresh(3, $meta_info); |
|
| 138 | + $message = $this->user->lang['DIR_COMMENT_DELETE_OK']; |
|
| 139 | + $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 140 | + |
|
| 141 | + return $this->helper->message($message); |
|
| 142 | + } else { |
|
| 143 | + confirm_box(false, 'DIR_COMMENT_DELETE'); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Edit a comment. |
|
| 149 | + * |
|
| 150 | + * @param int $link_id The category ID |
|
| 151 | + * @param int $comment_id The comment ID |
|
| 152 | + * |
|
| 153 | + * @throws \phpbb\exception\http_exception |
|
| 154 | + * |
|
| 155 | + * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 156 | + */ |
|
| 157 | + public function edit_comment($link_id, $comment_id) |
|
| 158 | + { |
|
| 159 | + $this->_check_comments_enable($link_id); |
|
| 160 | + |
|
| 161 | + $sql = 'SELECT * |
|
| 162 | 162 | FROM '.DIR_COMMENT_TABLE.' |
| 163 | 163 | WHERE comment_id = '.(int) $comment_id; |
| 164 | - $result = $this->db->sql_query($sql); |
|
| 165 | - $value = $this->db->sql_fetchrow($result); |
|
| 166 | - |
|
| 167 | - if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_edit_comment_dir') && (!$this->auth->acl_get('u_edit_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) { |
|
| 168 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - $comment_text = generate_text_for_edit($value['comment_text'], $value['comment_uid'], $value['comment_flags']); |
|
| 172 | - $this->s_comment = $comment_text['text']; |
|
| 173 | - |
|
| 174 | - $submit = $this->request->is_set_post('update_comment') ? true : false; |
|
| 175 | - |
|
| 176 | - // If form is done |
|
| 177 | - if ($submit) { |
|
| 178 | - return $this->_data_processing($link_id, $comment_id, 'edit'); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return $this->view($link_id, 1, 'edit'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Post a new comment. |
|
| 186 | - * |
|
| 187 | - * @param int $link_id The category ID |
|
| 188 | - * |
|
| 189 | - * @throws \phpbb\exception\http_exception |
|
| 190 | - * |
|
| 191 | - * @return null |
|
| 192 | - */ |
|
| 193 | - public function new_comment($link_id) |
|
| 194 | - { |
|
| 195 | - $this->_check_comments_enable($link_id); |
|
| 196 | - |
|
| 197 | - if (!$this->auth->acl_get('u_comment_dir')) { |
|
| 198 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - $submit = $this->request->is_set_post('submit_comment') ? true : false; |
|
| 202 | - $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 203 | - |
|
| 204 | - // If form is done |
|
| 205 | - if ($submit || $refresh) { |
|
| 206 | - return $this->_data_processing($link_id); |
|
| 207 | - } else { |
|
| 208 | - $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 209 | - redirect($redirect); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Display popup comment. |
|
| 215 | - * |
|
| 216 | - * @param int $link_id The category ID |
|
| 217 | - * @param int $page Page number taken from the URL |
|
| 218 | - * @param string $mode add|edit |
|
| 219 | - * |
|
| 220 | - * @throws \phpbb\exception\http_exception |
|
| 221 | - * |
|
| 222 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 223 | - */ |
|
| 224 | - public function view($link_id, $page, $mode = 'new') |
|
| 225 | - { |
|
| 226 | - $this->_check_comments_enable($link_id); |
|
| 227 | - |
|
| 228 | - $comment_id = $this->request->variable('c', 0); |
|
| 229 | - $view = $this->request->variable('view', ''); |
|
| 230 | - $start = ($page - 1) * $this->config['dir_comments_per_page']; |
|
| 231 | - |
|
| 232 | - $this->s_hidden_fields = array_merge($this->s_hidden_fields, ['page' => $page]); |
|
| 233 | - |
|
| 234 | - $this->_populate_form($link_id, $mode); |
|
| 235 | - |
|
| 236 | - $sql = 'SELECT COUNT(comment_id) AS nb_comments |
|
| 164 | + $result = $this->db->sql_query($sql); |
|
| 165 | + $value = $this->db->sql_fetchrow($result); |
|
| 166 | + |
|
| 167 | + if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_edit_comment_dir') && (!$this->auth->acl_get('u_edit_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) { |
|
| 168 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + $comment_text = generate_text_for_edit($value['comment_text'], $value['comment_uid'], $value['comment_flags']); |
|
| 172 | + $this->s_comment = $comment_text['text']; |
|
| 173 | + |
|
| 174 | + $submit = $this->request->is_set_post('update_comment') ? true : false; |
|
| 175 | + |
|
| 176 | + // If form is done |
|
| 177 | + if ($submit) { |
|
| 178 | + return $this->_data_processing($link_id, $comment_id, 'edit'); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return $this->view($link_id, 1, 'edit'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Post a new comment. |
|
| 186 | + * |
|
| 187 | + * @param int $link_id The category ID |
|
| 188 | + * |
|
| 189 | + * @throws \phpbb\exception\http_exception |
|
| 190 | + * |
|
| 191 | + * @return null |
|
| 192 | + */ |
|
| 193 | + public function new_comment($link_id) |
|
| 194 | + { |
|
| 195 | + $this->_check_comments_enable($link_id); |
|
| 196 | + |
|
| 197 | + if (!$this->auth->acl_get('u_comment_dir')) { |
|
| 198 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + $submit = $this->request->is_set_post('submit_comment') ? true : false; |
|
| 202 | + $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 203 | + |
|
| 204 | + // If form is done |
|
| 205 | + if ($submit || $refresh) { |
|
| 206 | + return $this->_data_processing($link_id); |
|
| 207 | + } else { |
|
| 208 | + $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 209 | + redirect($redirect); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Display popup comment. |
|
| 215 | + * |
|
| 216 | + * @param int $link_id The category ID |
|
| 217 | + * @param int $page Page number taken from the URL |
|
| 218 | + * @param string $mode add|edit |
|
| 219 | + * |
|
| 220 | + * @throws \phpbb\exception\http_exception |
|
| 221 | + * |
|
| 222 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 223 | + */ |
|
| 224 | + public function view($link_id, $page, $mode = 'new') |
|
| 225 | + { |
|
| 226 | + $this->_check_comments_enable($link_id); |
|
| 227 | + |
|
| 228 | + $comment_id = $this->request->variable('c', 0); |
|
| 229 | + $view = $this->request->variable('view', ''); |
|
| 230 | + $start = ($page - 1) * $this->config['dir_comments_per_page']; |
|
| 231 | + |
|
| 232 | + $this->s_hidden_fields = array_merge($this->s_hidden_fields, ['page' => $page]); |
|
| 233 | + |
|
| 234 | + $this->_populate_form($link_id, $mode); |
|
| 235 | + |
|
| 236 | + $sql = 'SELECT COUNT(comment_id) AS nb_comments |
|
| 237 | 237 | FROM '.DIR_COMMENT_TABLE.' |
| 238 | 238 | WHERE comment_link_id = '.(int) $link_id; |
| 239 | - $result = $this->db->sql_query($sql); |
|
| 240 | - $nb_comments = (int) $this->db->sql_fetchfield('nb_comments'); |
|
| 241 | - $this->db->sql_freeresult($result); |
|
| 242 | - |
|
| 243 | - // Make sure $start is set to the last page if it exceeds the amount |
|
| 244 | - $start = $this->pagination->validate_start($start, $this->config['dir_comments_per_page'], $nb_comments); |
|
| 245 | - |
|
| 246 | - $sql_array = [ |
|
| 247 | - 'SELECT' => 'a.comment_id, a.comment_user_id, a. comment_user_ip, a.comment_date, a.comment_text, a.comment_uid, a.comment_bitfield, a.comment_flags, u.username, u.user_id, u.user_colour, z.foe', |
|
| 248 | - 'FROM' => [ |
|
| 249 | - DIR_COMMENT_TABLE => 'a', ], |
|
| 250 | - 'LEFT_JOIN' => [ |
|
| 251 | - [ |
|
| 252 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 253 | - 'ON' => 'a.comment_user_id = u.user_id', |
|
| 254 | - ], |
|
| 255 | - [ |
|
| 256 | - 'FROM' => [ZEBRA_TABLE => 'z'], |
|
| 257 | - 'ON' => 'z.user_id = '.$this->user->data['user_id'].' AND z.zebra_id = a.comment_user_id', |
|
| 258 | - ], |
|
| 259 | - ], |
|
| 260 | - 'WHERE' => 'a.comment_link_id = '.(int) $link_id, |
|
| 261 | - 'ORDER_BY' => 'a.comment_date DESC', ]; |
|
| 262 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 263 | - $result = $this->db->sql_query_limit($sql, $this->config['dir_comments_per_page'], $start); |
|
| 264 | - |
|
| 265 | - $have_result = false; |
|
| 266 | - |
|
| 267 | - while ($comments = $this->db->sql_fetchrow($result)) { |
|
| 268 | - $have_result = true; |
|
| 269 | - |
|
| 270 | - $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_comment_dir') || ( |
|
| 271 | - $this->user->data['user_id'] == $comments['comment_user_id'] && |
|
| 272 | - $this->auth->acl_get('u_edit_comment_dir') |
|
| 273 | - ))); |
|
| 274 | - |
|
| 275 | - $delete_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_comment_dir') || ( |
|
| 276 | - $this->user->data['user_id'] == $comments['comment_user_id'] && |
|
| 277 | - $this->auth->acl_get('u_delete_comment_dir') |
|
| 278 | - ))); |
|
| 279 | - |
|
| 280 | - $this->template->assign_block_vars('comment', [ |
|
| 281 | - 'MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), |
|
| 282 | - 'S_USER' => get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), |
|
| 283 | - 'S_USER_IP' => $comments['comment_user_ip'], |
|
| 284 | - 'S_DATE' => $this->user->format_date($comments['comment_date']), |
|
| 285 | - 'S_COMMENT' => generate_text_for_display($comments['comment_text'], $comments['comment_uid'], $comments['comment_bitfield'], $comments['comment_flags']), |
|
| 286 | - 'S_ID' => $comments['comment_id'], |
|
| 287 | - |
|
| 288 | - 'U_EDIT' => ($edit_allowed) ? $this->helper->route('ernadoo_phpbbdirectory_comment_edit_controller', ['link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id']]) : '', |
|
| 289 | - 'U_DELETE' => ($delete_allowed) ? $this->helper->route('ernadoo_phpbbdirectory_comment_delete_controller', ['link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'], '_referer' => $this->helper->get_current_url()]) : '', |
|
| 290 | - |
|
| 291 | - 'S_IGNORE_POST' => ($comments['foe'] && ($view != 'show' || $comment_id != $comments['comment_id'])) ? true : false, |
|
| 292 | - 'L_IGNORE_POST' => ($comments['foe']) ? $this->user->lang('POST_BY_FOE', get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), '<a href="'.$this->helper->url('directory/link/'.$link_id.'/comment'.(($page > 1) ? '/'.$page : '').'?view=show#c'.(int) $comments['comment_id']).'">', '</a>') : '', |
|
| 293 | - 'L_POST_DISPLAY' => ($comments['foe']) ? $this->user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="'.$comments['comment_id'].'" href="'.$this->helper->url('directory/link/'.$link_id.'/comment'.(($page > 1) ? '/'.$page : '').'?c='.(int) $comments['comment_id'].'&view=show#c'.(int) $comments['comment_id']).'">', '</a>') : '', |
|
| 294 | - |
|
| 295 | - 'S_INFO' => $this->auth->acl_get('m_info'), |
|
| 296 | - ]); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - $base_url = [ |
|
| 300 | - 'routes' => 'ernadoo_phpbbdirectory_comment_view_controller', |
|
| 301 | - 'params' => ['link_id' => (int) $link_id], |
|
| 302 | - ]; |
|
| 303 | - |
|
| 304 | - $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_comments, $this->config['dir_comments_per_page'], $start); |
|
| 305 | - |
|
| 306 | - $this->template->assign_vars([ |
|
| 307 | - 'TOTAL_COMMENTS' => $this->user->lang('DIR_NB_COMMS', (int) $nb_comments), |
|
| 308 | - 'S_HAVE_RESULT' => $have_result ? true : false, |
|
| 309 | - ]); |
|
| 310 | - |
|
| 311 | - return $this->helper->render('comments.html', $this->user->lang['DIR_COMMENT_TITLE']); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * Routine. |
|
| 316 | - * |
|
| 317 | - * @param int $link_id The link ID |
|
| 318 | - * @param int $comment_id The comment ID |
|
| 319 | - * @param string $mode new|edit |
|
| 320 | - * |
|
| 321 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 322 | - */ |
|
| 323 | - private function _data_processing($link_id, $comment_id = 0, $mode = 'new') |
|
| 324 | - { |
|
| 325 | - if (!check_form_key('dir_form_comment')) { |
|
| 326 | - return $this->helper->message('FORM_INVALID'); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - $this->s_comment = $this->request->variable('message', '', true); |
|
| 330 | - |
|
| 331 | - if (!function_exists('validate_data')) { |
|
| 332 | - include $this->root_path.'includes/functions_user.'.$this->php_ext; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - $error = validate_data( |
|
| 336 | - [ |
|
| 337 | - 'reply' => $this->s_comment, ], |
|
| 338 | - [ |
|
| 339 | - 'reply' => [ |
|
| 340 | - ['string', false, 1, $this->config['dir_length_comments']], |
|
| 341 | - ], |
|
| 342 | - ] |
|
| 343 | - ); |
|
| 344 | - |
|
| 345 | - $error = array_map([$this->user, 'lang'], $error); |
|
| 346 | - |
|
| 347 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 348 | - $vc_response = $this->captcha->validate(); |
|
| 349 | - if ($vc_response !== false) { |
|
| 350 | - $error[] = $vc_response; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) { |
|
| 354 | - $error[] = $this->user->lang['TOO_MANY_ADDS']; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - if (!$error) { |
|
| 359 | - $uid = $bitfield = $flags = ''; |
|
| 360 | - generate_text_for_storage($this->s_comment, $uid, $bitfield, $flags, (bool) $this->config['dir_allow_bbcode'], (bool) $this->config['dir_allow_links'], (bool) $this->config['dir_allow_smilies']); |
|
| 361 | - |
|
| 362 | - $data_edit = [ |
|
| 363 | - 'comment_text' => $this->s_comment, |
|
| 364 | - 'comment_uid' => $uid, |
|
| 365 | - 'comment_flags' => $flags, |
|
| 366 | - 'comment_bitfield' => $bitfield, |
|
| 367 | - ]; |
|
| 368 | - |
|
| 369 | - if ($mode == 'edit') { |
|
| 370 | - $this->comment->edit($data_edit, $comment_id); |
|
| 371 | - } else { |
|
| 372 | - $data_add = [ |
|
| 373 | - 'comment_link_id' => (int) $link_id, |
|
| 374 | - 'comment_date' => time(), |
|
| 375 | - 'comment_user_id' => $this->user->data['user_id'], |
|
| 376 | - 'comment_user_ip' => $this->user->ip, |
|
| 377 | - ]; |
|
| 378 | - |
|
| 379 | - $data_add = array_merge($data_edit, $data_add); |
|
| 380 | - |
|
| 381 | - $this->comment->add($data_add); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - $meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 385 | - meta_refresh(3, $meta_info); |
|
| 386 | - $message = $this->user->lang['DIR_'.strtoupper($mode).'_COMMENT_OK']; |
|
| 387 | - $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 388 | - |
|
| 389 | - return $this->helper->message($message); |
|
| 390 | - } else { |
|
| 391 | - $this->template->assign_vars([ |
|
| 392 | - 'ERROR' => (count($error)) ? implode('<br />', $error) : '', |
|
| 393 | - ]); |
|
| 394 | - |
|
| 395 | - return $this->view($link_id, $this->request->variable('page', 1), $mode); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Check if comments are enable in a category. |
|
| 401 | - * |
|
| 402 | - * @param int $link_id The link ID |
|
| 403 | - * |
|
| 404 | - * @throws \phpbb\exception\http_exception |
|
| 405 | - * |
|
| 406 | - * @return null Retun null if comments are allowed, http_exception if not |
|
| 407 | - */ |
|
| 408 | - private function _check_comments_enable($link_id) |
|
| 409 | - { |
|
| 410 | - $sql = 'SELECT link_cat |
|
| 239 | + $result = $this->db->sql_query($sql); |
|
| 240 | + $nb_comments = (int) $this->db->sql_fetchfield('nb_comments'); |
|
| 241 | + $this->db->sql_freeresult($result); |
|
| 242 | + |
|
| 243 | + // Make sure $start is set to the last page if it exceeds the amount |
|
| 244 | + $start = $this->pagination->validate_start($start, $this->config['dir_comments_per_page'], $nb_comments); |
|
| 245 | + |
|
| 246 | + $sql_array = [ |
|
| 247 | + 'SELECT' => 'a.comment_id, a.comment_user_id, a. comment_user_ip, a.comment_date, a.comment_text, a.comment_uid, a.comment_bitfield, a.comment_flags, u.username, u.user_id, u.user_colour, z.foe', |
|
| 248 | + 'FROM' => [ |
|
| 249 | + DIR_COMMENT_TABLE => 'a', ], |
|
| 250 | + 'LEFT_JOIN' => [ |
|
| 251 | + [ |
|
| 252 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 253 | + 'ON' => 'a.comment_user_id = u.user_id', |
|
| 254 | + ], |
|
| 255 | + [ |
|
| 256 | + 'FROM' => [ZEBRA_TABLE => 'z'], |
|
| 257 | + 'ON' => 'z.user_id = '.$this->user->data['user_id'].' AND z.zebra_id = a.comment_user_id', |
|
| 258 | + ], |
|
| 259 | + ], |
|
| 260 | + 'WHERE' => 'a.comment_link_id = '.(int) $link_id, |
|
| 261 | + 'ORDER_BY' => 'a.comment_date DESC', ]; |
|
| 262 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 263 | + $result = $this->db->sql_query_limit($sql, $this->config['dir_comments_per_page'], $start); |
|
| 264 | + |
|
| 265 | + $have_result = false; |
|
| 266 | + |
|
| 267 | + while ($comments = $this->db->sql_fetchrow($result)) { |
|
| 268 | + $have_result = true; |
|
| 269 | + |
|
| 270 | + $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_comment_dir') || ( |
|
| 271 | + $this->user->data['user_id'] == $comments['comment_user_id'] && |
|
| 272 | + $this->auth->acl_get('u_edit_comment_dir') |
|
| 273 | + ))); |
|
| 274 | + |
|
| 275 | + $delete_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_comment_dir') || ( |
|
| 276 | + $this->user->data['user_id'] == $comments['comment_user_id'] && |
|
| 277 | + $this->auth->acl_get('u_delete_comment_dir') |
|
| 278 | + ))); |
|
| 279 | + |
|
| 280 | + $this->template->assign_block_vars('comment', [ |
|
| 281 | + 'MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), |
|
| 282 | + 'S_USER' => get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), |
|
| 283 | + 'S_USER_IP' => $comments['comment_user_ip'], |
|
| 284 | + 'S_DATE' => $this->user->format_date($comments['comment_date']), |
|
| 285 | + 'S_COMMENT' => generate_text_for_display($comments['comment_text'], $comments['comment_uid'], $comments['comment_bitfield'], $comments['comment_flags']), |
|
| 286 | + 'S_ID' => $comments['comment_id'], |
|
| 287 | + |
|
| 288 | + 'U_EDIT' => ($edit_allowed) ? $this->helper->route('ernadoo_phpbbdirectory_comment_edit_controller', ['link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id']]) : '', |
|
| 289 | + 'U_DELETE' => ($delete_allowed) ? $this->helper->route('ernadoo_phpbbdirectory_comment_delete_controller', ['link_id' => (int) $link_id, 'comment_id' => (int) $comments['comment_id'], '_referer' => $this->helper->get_current_url()]) : '', |
|
| 290 | + |
|
| 291 | + 'S_IGNORE_POST' => ($comments['foe'] && ($view != 'show' || $comment_id != $comments['comment_id'])) ? true : false, |
|
| 292 | + 'L_IGNORE_POST' => ($comments['foe']) ? $this->user->lang('POST_BY_FOE', get_username_string('full', $comments['comment_user_id'], $comments['username'], $comments['user_colour']), '<a href="'.$this->helper->url('directory/link/'.$link_id.'/comment'.(($page > 1) ? '/'.$page : '').'?view=show#c'.(int) $comments['comment_id']).'">', '</a>') : '', |
|
| 293 | + 'L_POST_DISPLAY' => ($comments['foe']) ? $this->user->lang('POST_DISPLAY', '<a class="display_post" data-post-id="'.$comments['comment_id'].'" href="'.$this->helper->url('directory/link/'.$link_id.'/comment'.(($page > 1) ? '/'.$page : '').'?c='.(int) $comments['comment_id'].'&view=show#c'.(int) $comments['comment_id']).'">', '</a>') : '', |
|
| 294 | + |
|
| 295 | + 'S_INFO' => $this->auth->acl_get('m_info'), |
|
| 296 | + ]); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + $base_url = [ |
|
| 300 | + 'routes' => 'ernadoo_phpbbdirectory_comment_view_controller', |
|
| 301 | + 'params' => ['link_id' => (int) $link_id], |
|
| 302 | + ]; |
|
| 303 | + |
|
| 304 | + $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $nb_comments, $this->config['dir_comments_per_page'], $start); |
|
| 305 | + |
|
| 306 | + $this->template->assign_vars([ |
|
| 307 | + 'TOTAL_COMMENTS' => $this->user->lang('DIR_NB_COMMS', (int) $nb_comments), |
|
| 308 | + 'S_HAVE_RESULT' => $have_result ? true : false, |
|
| 309 | + ]); |
|
| 310 | + |
|
| 311 | + return $this->helper->render('comments.html', $this->user->lang['DIR_COMMENT_TITLE']); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * Routine. |
|
| 316 | + * |
|
| 317 | + * @param int $link_id The link ID |
|
| 318 | + * @param int $comment_id The comment ID |
|
| 319 | + * @param string $mode new|edit |
|
| 320 | + * |
|
| 321 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 322 | + */ |
|
| 323 | + private function _data_processing($link_id, $comment_id = 0, $mode = 'new') |
|
| 324 | + { |
|
| 325 | + if (!check_form_key('dir_form_comment')) { |
|
| 326 | + return $this->helper->message('FORM_INVALID'); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + $this->s_comment = $this->request->variable('message', '', true); |
|
| 330 | + |
|
| 331 | + if (!function_exists('validate_data')) { |
|
| 332 | + include $this->root_path.'includes/functions_user.'.$this->php_ext; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + $error = validate_data( |
|
| 336 | + [ |
|
| 337 | + 'reply' => $this->s_comment, ], |
|
| 338 | + [ |
|
| 339 | + 'reply' => [ |
|
| 340 | + ['string', false, 1, $this->config['dir_length_comments']], |
|
| 341 | + ], |
|
| 342 | + ] |
|
| 343 | + ); |
|
| 344 | + |
|
| 345 | + $error = array_map([$this->user, 'lang'], $error); |
|
| 346 | + |
|
| 347 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 348 | + $vc_response = $this->captcha->validate(); |
|
| 349 | + if ($vc_response !== false) { |
|
| 350 | + $error[] = $vc_response; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) { |
|
| 354 | + $error[] = $this->user->lang['TOO_MANY_ADDS']; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + if (!$error) { |
|
| 359 | + $uid = $bitfield = $flags = ''; |
|
| 360 | + generate_text_for_storage($this->s_comment, $uid, $bitfield, $flags, (bool) $this->config['dir_allow_bbcode'], (bool) $this->config['dir_allow_links'], (bool) $this->config['dir_allow_smilies']); |
|
| 361 | + |
|
| 362 | + $data_edit = [ |
|
| 363 | + 'comment_text' => $this->s_comment, |
|
| 364 | + 'comment_uid' => $uid, |
|
| 365 | + 'comment_flags' => $flags, |
|
| 366 | + 'comment_bitfield' => $bitfield, |
|
| 367 | + ]; |
|
| 368 | + |
|
| 369 | + if ($mode == 'edit') { |
|
| 370 | + $this->comment->edit($data_edit, $comment_id); |
|
| 371 | + } else { |
|
| 372 | + $data_add = [ |
|
| 373 | + 'comment_link_id' => (int) $link_id, |
|
| 374 | + 'comment_date' => time(), |
|
| 375 | + 'comment_user_id' => $this->user->data['user_id'], |
|
| 376 | + 'comment_user_ip' => $this->user->ip, |
|
| 377 | + ]; |
|
| 378 | + |
|
| 379 | + $data_add = array_merge($data_edit, $data_add); |
|
| 380 | + |
|
| 381 | + $this->comment->add($data_add); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + $meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]); |
|
| 385 | + meta_refresh(3, $meta_info); |
|
| 386 | + $message = $this->user->lang['DIR_'.strtoupper($mode).'_COMMENT_OK']; |
|
| 387 | + $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 388 | + |
|
| 389 | + return $this->helper->message($message); |
|
| 390 | + } else { |
|
| 391 | + $this->template->assign_vars([ |
|
| 392 | + 'ERROR' => (count($error)) ? implode('<br />', $error) : '', |
|
| 393 | + ]); |
|
| 394 | + |
|
| 395 | + return $this->view($link_id, $this->request->variable('page', 1), $mode); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Check if comments are enable in a category. |
|
| 401 | + * |
|
| 402 | + * @param int $link_id The link ID |
|
| 403 | + * |
|
| 404 | + * @throws \phpbb\exception\http_exception |
|
| 405 | + * |
|
| 406 | + * @return null Retun null if comments are allowed, http_exception if not |
|
| 407 | + */ |
|
| 408 | + private function _check_comments_enable($link_id) |
|
| 409 | + { |
|
| 410 | + $sql = 'SELECT link_cat |
|
| 411 | 411 | FROM '.DIR_LINK_TABLE.' |
| 412 | 412 | WHERE link_id = '.(int) $link_id; |
| 413 | - $result = $this->db->sql_query($sql); |
|
| 414 | - $cat_id = (int) $this->db->sql_fetchfield('link_cat'); |
|
| 415 | - $this->db->sql_freeresult($result); |
|
| 416 | - |
|
| 417 | - if ($cat_id) { |
|
| 418 | - $this->categorie->get($cat_id); |
|
| 419 | - |
|
| 420 | - if (!$this->categorie->data['cat_allow_comments']) { |
|
| 421 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 422 | - } |
|
| 423 | - } else { |
|
| 424 | - throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * Populate form when an error occurred. |
|
| 430 | - * |
|
| 431 | - * @param int $link_id The link ID |
|
| 432 | - * @param string $mode add|edit |
|
| 433 | - * |
|
| 434 | - * @return null |
|
| 435 | - */ |
|
| 436 | - private function _populate_form($link_id, $mode) |
|
| 437 | - { |
|
| 438 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode != 'edit') { |
|
| 439 | - $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields()); |
|
| 440 | - |
|
| 441 | - $this->template->assign_vars([ |
|
| 442 | - 'S_CONFIRM_CODE' => true, |
|
| 443 | - 'CAPTCHA_TEMPLATE' => $this->captcha->get_template(), |
|
| 444 | - ]); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if (!function_exists('generate_smilies')) { |
|
| 448 | - include $this->root_path.'includes/functions_posting.'.$this->php_ext; |
|
| 449 | - } |
|
| 450 | - if (!function_exists('display_custom_bbcodes')) { |
|
| 451 | - include $this->root_path.'includes/functions_display.'.$this->php_ext; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - generate_smilies('inline', 0); |
|
| 455 | - display_custom_bbcodes(); |
|
| 456 | - add_form_key('dir_form_comment'); |
|
| 457 | - |
|
| 458 | - $this->template->assign_vars([ |
|
| 459 | - 'S_AUTH_COMM' => $this->auth->acl_get('u_comment_dir'), |
|
| 460 | - |
|
| 461 | - 'BBCODE_STATUS' => ($this->config['dir_allow_bbcode']) ? $this->user->lang('BBCODE_IS_ON', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>'), |
|
| 462 | - 'IMG_STATUS' => ($this->config['dir_allow_bbcode']) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], |
|
| 463 | - 'SMILIES_STATUS' => ($this->config['dir_allow_smilies']) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], |
|
| 464 | - 'URL_STATUS' => ($this->config['dir_allow_links']) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], |
|
| 465 | - 'FLASH_STATUS' => ($this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash']) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], |
|
| 466 | - |
|
| 467 | - 'L_DIR_REPLY_EXP' => $this->user->lang('DIR_REPLY_EXP', $this->config['dir_length_comments']), |
|
| 468 | - |
|
| 469 | - 'S_COMMENT' => isset($this->s_comment) ? $this->s_comment : '', |
|
| 470 | - |
|
| 471 | - 'S_BBCODE_ALLOWED' => (bool) $this->config['dir_allow_bbcode'], |
|
| 472 | - 'S_BBCODE_IMG' => (bool) $this->config['dir_allow_bbcode'], |
|
| 473 | - 'S_BBCODE_FLASH' => ($this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash']) ? true : false, |
|
| 474 | - 'S_BBCODE_QUOTE' => true, |
|
| 475 | - 'S_LINKS_ALLOWED' => (bool) $this->config['dir_allow_links'], |
|
| 476 | - 'S_SMILIES_ALLOWED' => (bool) $this->config['dir_allow_smilies'], |
|
| 477 | - |
|
| 478 | - 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields), |
|
| 479 | - 'S_BUTTON_NAME' => ($mode == 'edit') ? 'update_comment' : 'submit_comment', |
|
| 480 | - 'S_POST_ACTION' => ($mode == 'edit') ? '' : $this->helper->route('ernadoo_phpbbdirectory_comment_new_controller', ['link_id' => (int) $link_id]), |
|
| 481 | - ]); |
|
| 482 | - } |
|
| 413 | + $result = $this->db->sql_query($sql); |
|
| 414 | + $cat_id = (int) $this->db->sql_fetchfield('link_cat'); |
|
| 415 | + $this->db->sql_freeresult($result); |
|
| 416 | + |
|
| 417 | + if ($cat_id) { |
|
| 418 | + $this->categorie->get($cat_id); |
|
| 419 | + |
|
| 420 | + if (!$this->categorie->data['cat_allow_comments']) { |
|
| 421 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 422 | + } |
|
| 423 | + } else { |
|
| 424 | + throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * Populate form when an error occurred. |
|
| 430 | + * |
|
| 431 | + * @param int $link_id The link ID |
|
| 432 | + * @param string $mode add|edit |
|
| 433 | + * |
|
| 434 | + * @return null |
|
| 435 | + */ |
|
| 436 | + private function _populate_form($link_id, $mode) |
|
| 437 | + { |
|
| 438 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode != 'edit') { |
|
| 439 | + $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields()); |
|
| 440 | + |
|
| 441 | + $this->template->assign_vars([ |
|
| 442 | + 'S_CONFIRM_CODE' => true, |
|
| 443 | + 'CAPTCHA_TEMPLATE' => $this->captcha->get_template(), |
|
| 444 | + ]); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if (!function_exists('generate_smilies')) { |
|
| 448 | + include $this->root_path.'includes/functions_posting.'.$this->php_ext; |
|
| 449 | + } |
|
| 450 | + if (!function_exists('display_custom_bbcodes')) { |
|
| 451 | + include $this->root_path.'includes/functions_display.'.$this->php_ext; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + generate_smilies('inline', 0); |
|
| 455 | + display_custom_bbcodes(); |
|
| 456 | + add_form_key('dir_form_comment'); |
|
| 457 | + |
|
| 458 | + $this->template->assign_vars([ |
|
| 459 | + 'S_AUTH_COMM' => $this->auth->acl_get('u_comment_dir'), |
|
| 460 | + |
|
| 461 | + 'BBCODE_STATUS' => ($this->config['dir_allow_bbcode']) ? $this->user->lang('BBCODE_IS_ON', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>'), |
|
| 462 | + 'IMG_STATUS' => ($this->config['dir_allow_bbcode']) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], |
|
| 463 | + 'SMILIES_STATUS' => ($this->config['dir_allow_smilies']) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], |
|
| 464 | + 'URL_STATUS' => ($this->config['dir_allow_links']) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], |
|
| 465 | + 'FLASH_STATUS' => ($this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash']) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], |
|
| 466 | + |
|
| 467 | + 'L_DIR_REPLY_EXP' => $this->user->lang('DIR_REPLY_EXP', $this->config['dir_length_comments']), |
|
| 468 | + |
|
| 469 | + 'S_COMMENT' => isset($this->s_comment) ? $this->s_comment : '', |
|
| 470 | + |
|
| 471 | + 'S_BBCODE_ALLOWED' => (bool) $this->config['dir_allow_bbcode'], |
|
| 472 | + 'S_BBCODE_IMG' => (bool) $this->config['dir_allow_bbcode'], |
|
| 473 | + 'S_BBCODE_FLASH' => ($this->config['dir_allow_bbcode'] && $this->config['dir_allow_flash']) ? true : false, |
|
| 474 | + 'S_BBCODE_QUOTE' => true, |
|
| 475 | + 'S_LINKS_ALLOWED' => (bool) $this->config['dir_allow_links'], |
|
| 476 | + 'S_SMILIES_ALLOWED' => (bool) $this->config['dir_allow_smilies'], |
|
| 477 | + |
|
| 478 | + 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields), |
|
| 479 | + 'S_BUTTON_NAME' => ($mode == 'edit') ? 'update_comment' : 'submit_comment', |
|
| 480 | + 'S_POST_ACTION' => ($mode == 'edit') ? '' : $this->helper->route('ernadoo_phpbbdirectory_comment_new_controller', ['link_id' => (int) $link_id]), |
|
| 481 | + ]); |
|
| 482 | + } |
|
| 483 | 483 | } |
@@ -9,1025 +9,1025 @@ |
||
| 9 | 9 | |
| 10 | 10 | class cat |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\cache\service */ |
|
| 13 | - protected $cache; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 16 | - protected $db; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\controller\helper */ |
|
| 19 | - protected $helper; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\log\log */ |
|
| 22 | - protected $phpbb_log; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\request\request */ |
|
| 25 | - protected $request; |
|
| 26 | - |
|
| 27 | - /** @var \phpbb\template\template */ |
|
| 28 | - protected $template; |
|
| 29 | - |
|
| 30 | - /** @var \phpbb\user */ |
|
| 31 | - protected $user; |
|
| 32 | - |
|
| 33 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 34 | - protected $categorie; |
|
| 35 | - |
|
| 36 | - /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 37 | - protected $dir_helper; |
|
| 38 | - |
|
| 39 | - /** @var \ernadoo\phpbbdirectory\core\nestedset_category */ |
|
| 40 | - protected $nestedset_category; |
|
| 41 | - |
|
| 42 | - /** @var string Custom form action */ |
|
| 43 | - protected $u_action; |
|
| 44 | - |
|
| 45 | - /** @var string */ |
|
| 46 | - private $action; |
|
| 47 | - |
|
| 48 | - /** @var array */ |
|
| 49 | - private $cat_data = []; |
|
| 50 | - |
|
| 51 | - /** @var int */ |
|
| 52 | - private $cat_id; |
|
| 53 | - |
|
| 54 | - /** @var array */ |
|
| 55 | - private $errors; |
|
| 56 | - |
|
| 57 | - /** @var string */ |
|
| 58 | - private $form_key; |
|
| 59 | - |
|
| 60 | - /** @var int */ |
|
| 61 | - private $parent_id; |
|
| 62 | - |
|
| 63 | - /** @var bool */ |
|
| 64 | - private $update; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Constructor. |
|
| 68 | - * |
|
| 69 | - * @param \phpbb\cache\service $cache Cache object |
|
| 70 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | - * @param \phpbb\controller\helper $helper Helper object |
|
| 72 | - * @param \phpbb\log\log $log Log object |
|
| 73 | - * @param \phpbb\request\request $request Request object |
|
| 74 | - * @param \phpbb\template\template $template Template object |
|
| 75 | - * @param \phpbb\user $user User object |
|
| 76 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 77 | - * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 78 | - * @param \ernadoo\phpbbdirectory\core\nestedset_category $nestedset_category PhpBB Directory extension nestedset object |
|
| 79 | - */ |
|
| 80 | - public function __construct(\phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\log\log $log, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\helper $dir_helper, \ernadoo\phpbbdirectory\core\nestedset_category $nestedset_category) |
|
| 81 | - { |
|
| 82 | - $this->cache = $cache; |
|
| 83 | - $this->db = $db; |
|
| 84 | - $this->helper = $helper; |
|
| 85 | - $this->phpbb_log = $log; |
|
| 86 | - $this->request = $request; |
|
| 87 | - $this->template = $template; |
|
| 88 | - $this->user = $user; |
|
| 89 | - $this->categorie = $categorie; |
|
| 90 | - $this->dir_helper = $dir_helper; |
|
| 91 | - $this->nestedset_category = $nestedset_category; |
|
| 92 | - |
|
| 93 | - $this->form_key = 'acp_dir_cat'; |
|
| 94 | - add_form_key($this->form_key); |
|
| 95 | - |
|
| 96 | - $this->action = $this->request->variable('action', ''); |
|
| 97 | - $this->cat_id = $request->variable('c', 0); |
|
| 98 | - $this->parent_id = $request->variable('parent_id', 0); |
|
| 99 | - $this->update = ($this->request->is_set_post('update')) ? true : false; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Initialize defaults data for add page. |
|
| 104 | - * |
|
| 105 | - * @return null |
|
| 106 | - */ |
|
| 107 | - public function action_add() |
|
| 108 | - { |
|
| 109 | - $this->cat_id = $this->parent_id; |
|
| 110 | - $parents_list = $this->categorie->make_cat_select($this->parent_id); |
|
| 111 | - |
|
| 112 | - // Fill categorie data with default values |
|
| 113 | - if (!$this->update) { |
|
| 114 | - $this->cat_data = [ |
|
| 115 | - 'parent_id' => $this->parent_id, |
|
| 116 | - 'cat_name' => $this->request->variable('cat_name', '', true), |
|
| 117 | - 'cat_desc' => '', |
|
| 118 | - 'cat_icon' => '', |
|
| 119 | - 'cat_allow_comments' => true, |
|
| 120 | - 'cat_allow_votes' => true, |
|
| 121 | - 'cat_must_describe' => true, |
|
| 122 | - 'cat_count_all' => false, |
|
| 123 | - 'cat_validate' => false, |
|
| 124 | - 'enable_icons' => false, |
|
| 125 | - |
|
| 126 | - 'display_subcat_list' => true, |
|
| 127 | - |
|
| 128 | - 'cat_link_back' => false, |
|
| 129 | - 'cat_cron_enable' => false, |
|
| 130 | - 'cat_cron_freq' => 7, |
|
| 131 | - 'cat_cron_nb_check' => 1, |
|
| 132 | - ]; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - $this->_display_cat_form($parents_list); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Display deleting page. |
|
| 140 | - * |
|
| 141 | - * @return null |
|
| 142 | - */ |
|
| 143 | - public function action_delete() |
|
| 144 | - { |
|
| 145 | - if (!$this->cat_id) { |
|
| 146 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $this->cat_data = $this->_get_cat_info($this->cat_id); |
|
| 150 | - |
|
| 151 | - $subcats_id = []; |
|
| 152 | - $subcats = $this->nestedset_category->get_subtree_data($this->cat_id); |
|
| 153 | - |
|
| 154 | - foreach ($subcats as $row) { |
|
| 155 | - $subcats_id[] = $row['cat_id']; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $cat_list = $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $subcats_id); |
|
| 159 | - |
|
| 160 | - $sql = 'SELECT cat_id |
|
| 12 | + /** @var \phpbb\cache\service */ |
|
| 13 | + protected $cache; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 16 | + protected $db; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\controller\helper */ |
|
| 19 | + protected $helper; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\log\log */ |
|
| 22 | + protected $phpbb_log; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\request\request */ |
|
| 25 | + protected $request; |
|
| 26 | + |
|
| 27 | + /** @var \phpbb\template\template */ |
|
| 28 | + protected $template; |
|
| 29 | + |
|
| 30 | + /** @var \phpbb\user */ |
|
| 31 | + protected $user; |
|
| 32 | + |
|
| 33 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 34 | + protected $categorie; |
|
| 35 | + |
|
| 36 | + /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 37 | + protected $dir_helper; |
|
| 38 | + |
|
| 39 | + /** @var \ernadoo\phpbbdirectory\core\nestedset_category */ |
|
| 40 | + protected $nestedset_category; |
|
| 41 | + |
|
| 42 | + /** @var string Custom form action */ |
|
| 43 | + protected $u_action; |
|
| 44 | + |
|
| 45 | + /** @var string */ |
|
| 46 | + private $action; |
|
| 47 | + |
|
| 48 | + /** @var array */ |
|
| 49 | + private $cat_data = []; |
|
| 50 | + |
|
| 51 | + /** @var int */ |
|
| 52 | + private $cat_id; |
|
| 53 | + |
|
| 54 | + /** @var array */ |
|
| 55 | + private $errors; |
|
| 56 | + |
|
| 57 | + /** @var string */ |
|
| 58 | + private $form_key; |
|
| 59 | + |
|
| 60 | + /** @var int */ |
|
| 61 | + private $parent_id; |
|
| 62 | + |
|
| 63 | + /** @var bool */ |
|
| 64 | + private $update; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Constructor. |
|
| 68 | + * |
|
| 69 | + * @param \phpbb\cache\service $cache Cache object |
|
| 70 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | + * @param \phpbb\controller\helper $helper Helper object |
|
| 72 | + * @param \phpbb\log\log $log Log object |
|
| 73 | + * @param \phpbb\request\request $request Request object |
|
| 74 | + * @param \phpbb\template\template $template Template object |
|
| 75 | + * @param \phpbb\user $user User object |
|
| 76 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 77 | + * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 78 | + * @param \ernadoo\phpbbdirectory\core\nestedset_category $nestedset_category PhpBB Directory extension nestedset object |
|
| 79 | + */ |
|
| 80 | + public function __construct(\phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, \phpbb\controller\helper $helper, \phpbb\log\log $log, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\helper $dir_helper, \ernadoo\phpbbdirectory\core\nestedset_category $nestedset_category) |
|
| 81 | + { |
|
| 82 | + $this->cache = $cache; |
|
| 83 | + $this->db = $db; |
|
| 84 | + $this->helper = $helper; |
|
| 85 | + $this->phpbb_log = $log; |
|
| 86 | + $this->request = $request; |
|
| 87 | + $this->template = $template; |
|
| 88 | + $this->user = $user; |
|
| 89 | + $this->categorie = $categorie; |
|
| 90 | + $this->dir_helper = $dir_helper; |
|
| 91 | + $this->nestedset_category = $nestedset_category; |
|
| 92 | + |
|
| 93 | + $this->form_key = 'acp_dir_cat'; |
|
| 94 | + add_form_key($this->form_key); |
|
| 95 | + |
|
| 96 | + $this->action = $this->request->variable('action', ''); |
|
| 97 | + $this->cat_id = $request->variable('c', 0); |
|
| 98 | + $this->parent_id = $request->variable('parent_id', 0); |
|
| 99 | + $this->update = ($this->request->is_set_post('update')) ? true : false; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Initialize defaults data for add page. |
|
| 104 | + * |
|
| 105 | + * @return null |
|
| 106 | + */ |
|
| 107 | + public function action_add() |
|
| 108 | + { |
|
| 109 | + $this->cat_id = $this->parent_id; |
|
| 110 | + $parents_list = $this->categorie->make_cat_select($this->parent_id); |
|
| 111 | + |
|
| 112 | + // Fill categorie data with default values |
|
| 113 | + if (!$this->update) { |
|
| 114 | + $this->cat_data = [ |
|
| 115 | + 'parent_id' => $this->parent_id, |
|
| 116 | + 'cat_name' => $this->request->variable('cat_name', '', true), |
|
| 117 | + 'cat_desc' => '', |
|
| 118 | + 'cat_icon' => '', |
|
| 119 | + 'cat_allow_comments' => true, |
|
| 120 | + 'cat_allow_votes' => true, |
|
| 121 | + 'cat_must_describe' => true, |
|
| 122 | + 'cat_count_all' => false, |
|
| 123 | + 'cat_validate' => false, |
|
| 124 | + 'enable_icons' => false, |
|
| 125 | + |
|
| 126 | + 'display_subcat_list' => true, |
|
| 127 | + |
|
| 128 | + 'cat_link_back' => false, |
|
| 129 | + 'cat_cron_enable' => false, |
|
| 130 | + 'cat_cron_freq' => 7, |
|
| 131 | + 'cat_cron_nb_check' => 1, |
|
| 132 | + ]; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + $this->_display_cat_form($parents_list); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Display deleting page. |
|
| 140 | + * |
|
| 141 | + * @return null |
|
| 142 | + */ |
|
| 143 | + public function action_delete() |
|
| 144 | + { |
|
| 145 | + if (!$this->cat_id) { |
|
| 146 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $this->cat_data = $this->_get_cat_info($this->cat_id); |
|
| 150 | + |
|
| 151 | + $subcats_id = []; |
|
| 152 | + $subcats = $this->nestedset_category->get_subtree_data($this->cat_id); |
|
| 153 | + |
|
| 154 | + foreach ($subcats as $row) { |
|
| 155 | + $subcats_id[] = $row['cat_id']; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $cat_list = $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $subcats_id); |
|
| 159 | + |
|
| 160 | + $sql = 'SELECT cat_id |
|
| 161 | 161 | FROM '.DIR_CAT_TABLE.' |
| 162 | 162 | WHERE cat_id <> '.(int) $this->cat_id; |
| 163 | - $result = $this->db->sql_query_limit($sql, 1); |
|
| 164 | - |
|
| 165 | - if ($this->db->sql_fetchrow($result)) { |
|
| 166 | - $this->template->assign_vars([ |
|
| 167 | - 'S_MOVE_DIR_CAT_OPTIONS' => $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $subcats_id), ] |
|
| 168 | - ); |
|
| 169 | - } |
|
| 170 | - $this->db->sql_freeresult($result); |
|
| 171 | - |
|
| 172 | - $parent_id = ($this->parent_id == $this->cat_id) ? 0 : $this->parent_id; |
|
| 173 | - |
|
| 174 | - $this->template->assign_vars([ |
|
| 175 | - 'S_DELETE_DIR_CAT' => true, |
|
| 176 | - 'U_ACTION' => $this->u_action."&parent_id={$parent_id}&action=delete&c=$this->cat_id", |
|
| 177 | - 'U_BACK' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 178 | - |
|
| 179 | - 'DIR_CAT_NAME' => $this->cat_data['cat_name'], |
|
| 180 | - 'S_HAS_SUBCATS' => ($this->cat_data['right_id'] - $this->cat_data['left_id'] > 1) ? true : false, |
|
| 181 | - 'S_CATS_LIST' => $cat_list, |
|
| 182 | - 'S_ERROR' => (count($this->errors)) ? true : false, |
|
| 183 | - 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', ] |
|
| 184 | - ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Initialize data for edit page. |
|
| 189 | - * |
|
| 190 | - * @return null |
|
| 191 | - */ |
|
| 192 | - public function action_edit() |
|
| 193 | - { |
|
| 194 | - $row = $this->_get_cat_info($this->cat_id); |
|
| 195 | - |
|
| 196 | - if (!$this->update) { |
|
| 197 | - $this->cat_data = $row; |
|
| 198 | - } else { |
|
| 199 | - $this->cat_data['left_id'] = $row['left_id']; |
|
| 200 | - $this->cat_data['right_id'] = $row['right_id']; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // Make sure no direct child categories are able to be selected as parents. |
|
| 204 | - $exclude_cats = []; |
|
| 205 | - foreach ($this->nestedset_category->get_subtree_data($this->cat_id) as $row2) { |
|
| 206 | - $exclude_cats[] = $row2['cat_id']; |
|
| 207 | - } |
|
| 208 | - $parents_list = $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $exclude_cats); |
|
| 209 | - |
|
| 210 | - $this->_display_cat_form($parents_list); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Move order categories. |
|
| 215 | - * |
|
| 216 | - * @return null |
|
| 217 | - */ |
|
| 218 | - public function action_move() |
|
| 219 | - { |
|
| 220 | - if (!$this->cat_id) { |
|
| 221 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - $sql = 'SELECT cat_id, cat_name, parent_id, left_id, right_id |
|
| 163 | + $result = $this->db->sql_query_limit($sql, 1); |
|
| 164 | + |
|
| 165 | + if ($this->db->sql_fetchrow($result)) { |
|
| 166 | + $this->template->assign_vars([ |
|
| 167 | + 'S_MOVE_DIR_CAT_OPTIONS' => $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $subcats_id), ] |
|
| 168 | + ); |
|
| 169 | + } |
|
| 170 | + $this->db->sql_freeresult($result); |
|
| 171 | + |
|
| 172 | + $parent_id = ($this->parent_id == $this->cat_id) ? 0 : $this->parent_id; |
|
| 173 | + |
|
| 174 | + $this->template->assign_vars([ |
|
| 175 | + 'S_DELETE_DIR_CAT' => true, |
|
| 176 | + 'U_ACTION' => $this->u_action."&parent_id={$parent_id}&action=delete&c=$this->cat_id", |
|
| 177 | + 'U_BACK' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 178 | + |
|
| 179 | + 'DIR_CAT_NAME' => $this->cat_data['cat_name'], |
|
| 180 | + 'S_HAS_SUBCATS' => ($this->cat_data['right_id'] - $this->cat_data['left_id'] > 1) ? true : false, |
|
| 181 | + 'S_CATS_LIST' => $cat_list, |
|
| 182 | + 'S_ERROR' => (count($this->errors)) ? true : false, |
|
| 183 | + 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', ] |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Initialize data for edit page. |
|
| 189 | + * |
|
| 190 | + * @return null |
|
| 191 | + */ |
|
| 192 | + public function action_edit() |
|
| 193 | + { |
|
| 194 | + $row = $this->_get_cat_info($this->cat_id); |
|
| 195 | + |
|
| 196 | + if (!$this->update) { |
|
| 197 | + $this->cat_data = $row; |
|
| 198 | + } else { |
|
| 199 | + $this->cat_data['left_id'] = $row['left_id']; |
|
| 200 | + $this->cat_data['right_id'] = $row['right_id']; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // Make sure no direct child categories are able to be selected as parents. |
|
| 204 | + $exclude_cats = []; |
|
| 205 | + foreach ($this->nestedset_category->get_subtree_data($this->cat_id) as $row2) { |
|
| 206 | + $exclude_cats[] = $row2['cat_id']; |
|
| 207 | + } |
|
| 208 | + $parents_list = $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $exclude_cats); |
|
| 209 | + |
|
| 210 | + $this->_display_cat_form($parents_list); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Move order categories. |
|
| 215 | + * |
|
| 216 | + * @return null |
|
| 217 | + */ |
|
| 218 | + public function action_move() |
|
| 219 | + { |
|
| 220 | + if (!$this->cat_id) { |
|
| 221 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + $sql = 'SELECT cat_id, cat_name, parent_id, left_id, right_id |
|
| 225 | 225 | FROM '.DIR_CAT_TABLE.' |
| 226 | 226 | WHERE cat_id = '.(int) $this->cat_id; |
| 227 | - $result = $this->db->sql_query($sql); |
|
| 228 | - $row = $this->db->sql_fetchrow($result); |
|
| 229 | - $this->db->sql_freeresult($result); |
|
| 230 | - |
|
| 231 | - if (!$row) { |
|
| 232 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - try { |
|
| 236 | - $move_cat_name = $this->nestedset_category->{$this->action}($this->cat_id); |
|
| 237 | - } catch (\Exception $e) { |
|
| 238 | - trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - if ($move_cat_name !== false) { |
|
| 242 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_'.strtoupper($this->action), time(), [$row['cat_name'], $move_cat_name]); |
|
| 243 | - $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - if ($this->request->is_ajax()) { |
|
| 247 | - $json_response = new \phpbb\json_response(); |
|
| 248 | - $json_response->send(['success' => ($move_cat_name !== false)]); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Display progress bar for syncinc categories. |
|
| 254 | - * |
|
| 255 | - * @return null |
|
| 256 | - */ |
|
| 257 | - public function action_progress_bar() |
|
| 258 | - { |
|
| 259 | - $start = $this->request->variable('start', 0); |
|
| 260 | - $total = $this->request->variable('total', 0); |
|
| 261 | - |
|
| 262 | - adm_page_header($this->user->lang['SYNC_IN_PROGRESS']); |
|
| 263 | - |
|
| 264 | - $this->template->set_filenames([ |
|
| 265 | - 'body' => 'progress_bar.html', ] |
|
| 266 | - ); |
|
| 267 | - |
|
| 268 | - $this->template->assign_vars([ |
|
| 269 | - 'L_PROGRESS' => $this->user->lang['SYNC_IN_PROGRESS'], |
|
| 270 | - 'L_PROGRESS_EXPLAIN' => ($start && $total) ? $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', $start, $total) : $this->user->lang['SYNC_IN_PROGRESS'], ] |
|
| 271 | - ); |
|
| 272 | - |
|
| 273 | - adm_page_footer(); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Get link's ID interval for _sync_dir_links(). |
|
| 278 | - * |
|
| 279 | - * @return null |
|
| 280 | - */ |
|
| 281 | - public function action_sync() |
|
| 282 | - { |
|
| 283 | - if (!$this->cat_id) { |
|
| 284 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - @set_time_limit(0); |
|
| 288 | - |
|
| 289 | - $sql = 'SELECT cat_name, cat_links |
|
| 227 | + $result = $this->db->sql_query($sql); |
|
| 228 | + $row = $this->db->sql_fetchrow($result); |
|
| 229 | + $this->db->sql_freeresult($result); |
|
| 230 | + |
|
| 231 | + if (!$row) { |
|
| 232 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + try { |
|
| 236 | + $move_cat_name = $this->nestedset_category->{$this->action}($this->cat_id); |
|
| 237 | + } catch (\Exception $e) { |
|
| 238 | + trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + if ($move_cat_name !== false) { |
|
| 242 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_'.strtoupper($this->action), time(), [$row['cat_name'], $move_cat_name]); |
|
| 243 | + $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + if ($this->request->is_ajax()) { |
|
| 247 | + $json_response = new \phpbb\json_response(); |
|
| 248 | + $json_response->send(['success' => ($move_cat_name !== false)]); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Display progress bar for syncinc categories. |
|
| 254 | + * |
|
| 255 | + * @return null |
|
| 256 | + */ |
|
| 257 | + public function action_progress_bar() |
|
| 258 | + { |
|
| 259 | + $start = $this->request->variable('start', 0); |
|
| 260 | + $total = $this->request->variable('total', 0); |
|
| 261 | + |
|
| 262 | + adm_page_header($this->user->lang['SYNC_IN_PROGRESS']); |
|
| 263 | + |
|
| 264 | + $this->template->set_filenames([ |
|
| 265 | + 'body' => 'progress_bar.html', ] |
|
| 266 | + ); |
|
| 267 | + |
|
| 268 | + $this->template->assign_vars([ |
|
| 269 | + 'L_PROGRESS' => $this->user->lang['SYNC_IN_PROGRESS'], |
|
| 270 | + 'L_PROGRESS_EXPLAIN' => ($start && $total) ? $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', $start, $total) : $this->user->lang['SYNC_IN_PROGRESS'], ] |
|
| 271 | + ); |
|
| 272 | + |
|
| 273 | + adm_page_footer(); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Get link's ID interval for _sync_dir_links(). |
|
| 278 | + * |
|
| 279 | + * @return null |
|
| 280 | + */ |
|
| 281 | + public function action_sync() |
|
| 282 | + { |
|
| 283 | + if (!$this->cat_id) { |
|
| 284 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + @set_time_limit(0); |
|
| 288 | + |
|
| 289 | + $sql = 'SELECT cat_name, cat_links |
|
| 290 | 290 | FROM '.DIR_CAT_TABLE.' |
| 291 | 291 | WHERE cat_id = '.(int) $this->cat_id; |
| 292 | - $result = $this->db->sql_query($sql); |
|
| 293 | - $row = $this->db->sql_fetchrow($result); |
|
| 294 | - $this->db->sql_freeresult($result); |
|
| 292 | + $result = $this->db->sql_query($sql); |
|
| 293 | + $row = $this->db->sql_fetchrow($result); |
|
| 294 | + $this->db->sql_freeresult($result); |
|
| 295 | 295 | |
| 296 | - if (!$row) { |
|
| 297 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 298 | - } |
|
| 296 | + if (!$row) { |
|
| 297 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - $sql = 'SELECT MIN(link_id) as min_link_id, MAX(link_id) as max_link_id |
|
| 300 | + $sql = 'SELECT MIN(link_id) as min_link_id, MAX(link_id) as max_link_id |
|
| 301 | 301 | FROM '.DIR_LINK_TABLE.' |
| 302 | 302 | WHERE link_cat = '.(int) $this->cat_id.' |
| 303 | 303 | AND link_active = 1'; |
| 304 | - $result = $this->db->sql_query($sql); |
|
| 305 | - $row2 = $this->db->sql_fetchrow($result); |
|
| 306 | - $this->db->sql_freeresult($result); |
|
| 304 | + $result = $this->db->sql_query($sql); |
|
| 305 | + $row2 = $this->db->sql_fetchrow($result); |
|
| 306 | + $this->db->sql_freeresult($result); |
|
| 307 | 307 | |
| 308 | - // Typecast to int if there is no data available |
|
| 309 | - $row2['min_link_id'] = (int) $row2['min_link_id']; |
|
| 310 | - $row2['max_link_id'] = (int) $row2['max_link_id']; |
|
| 308 | + // Typecast to int if there is no data available |
|
| 309 | + $row2['min_link_id'] = (int) $row2['min_link_id']; |
|
| 310 | + $row2['max_link_id'] = (int) $row2['max_link_id']; |
|
| 311 | 311 | |
| 312 | - $start = $this->request->variable('start', $row2['min_link_id']); |
|
| 312 | + $start = $this->request->variable('start', $row2['min_link_id']); |
|
| 313 | 313 | |
| 314 | - $batch_size = 200; |
|
| 315 | - $end = $start + $batch_size; |
|
| 314 | + $batch_size = 200; |
|
| 315 | + $end = $start + $batch_size; |
|
| 316 | 316 | |
| 317 | - // Sync all links in batch mode... |
|
| 318 | - $this->_sync_dir_links($start, $end); |
|
| 317 | + // Sync all links in batch mode... |
|
| 318 | + $this->_sync_dir_links($start, $end); |
|
| 319 | 319 | |
| 320 | - if ($end < $row2['max_link_id']) { |
|
| 321 | - // We really need to find a way of showing statistics... no progress here |
|
| 322 | - $sql = 'SELECT COUNT(link_id) as num_links |
|
| 320 | + if ($end < $row2['max_link_id']) { |
|
| 321 | + // We really need to find a way of showing statistics... no progress here |
|
| 322 | + $sql = 'SELECT COUNT(link_id) as num_links |
|
| 323 | 323 | FROM '.DIR_LINK_TABLE.' |
| 324 | 324 | WHERE link_cat = '.(int) $this->cat_id.' |
| 325 | 325 | AND link_active = 1 |
| 326 | 326 | AND link_id BETWEEN '.$start.' AND '.$end; |
| 327 | - $result = $this->db->sql_query($sql); |
|
| 328 | - $links_done = $this->request->variable('links_done', 0) + (int) $this->db->sql_fetchfield('num_links'); |
|
| 329 | - $this->db->sql_freeresult($result); |
|
| 330 | - |
|
| 331 | - $start += $batch_size; |
|
| 332 | - |
|
| 333 | - $url = $this->u_action."&parent_id={$this->parent_id}&c=$this->cat_id&action=sync&start=$start&links_done=$links_done&total={$row['cat_links']}"; |
|
| 334 | - |
|
| 335 | - meta_refresh(0, $url); |
|
| 336 | - |
|
| 337 | - $this->template->assign_vars([ |
|
| 338 | - 'U_PROGRESS_BAR' => $this->u_action."&action=progress_bar&start=$links_done&total={$row['cat_links']}", |
|
| 339 | - 'UA_PROGRESS_BAR' => addslashes($this->u_action."&action=progress_bar&start=$links_done&total={$row['cat_links']}"), |
|
| 340 | - 'S_CONTINUE_SYNC' => true, |
|
| 341 | - 'L_PROGRESS_EXPLAIN' => $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', $links_done, $row['cat_links']), ] |
|
| 342 | - ); |
|
| 343 | - |
|
| 344 | - return; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - $url = $this->u_action."&parent_id={$this->parent_id}&c=$this->cat_id&action=sync_cat"; |
|
| 348 | - meta_refresh(0, $url); |
|
| 349 | - |
|
| 350 | - $this->template->assign_vars([ |
|
| 351 | - 'U_PROGRESS_BAR' => $this->u_action.'&action=progress_bar', |
|
| 352 | - 'UA_PROGRESS_BAR' => addslashes($this->u_action.'&action=progress_bar'), |
|
| 353 | - 'S_CONTINUE_SYNC' => true, |
|
| 354 | - 'L_PROGRESS_EXPLAIN' => $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', 0, $row['cat_links']), ] |
|
| 355 | - ); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * Sync category data. |
|
| 360 | - * |
|
| 361 | - * @return null |
|
| 362 | - */ |
|
| 363 | - public function action_sync_cat() |
|
| 364 | - { |
|
| 365 | - $sql = 'SELECT cat_name |
|
| 327 | + $result = $this->db->sql_query($sql); |
|
| 328 | + $links_done = $this->request->variable('links_done', 0) + (int) $this->db->sql_fetchfield('num_links'); |
|
| 329 | + $this->db->sql_freeresult($result); |
|
| 330 | + |
|
| 331 | + $start += $batch_size; |
|
| 332 | + |
|
| 333 | + $url = $this->u_action."&parent_id={$this->parent_id}&c=$this->cat_id&action=sync&start=$start&links_done=$links_done&total={$row['cat_links']}"; |
|
| 334 | + |
|
| 335 | + meta_refresh(0, $url); |
|
| 336 | + |
|
| 337 | + $this->template->assign_vars([ |
|
| 338 | + 'U_PROGRESS_BAR' => $this->u_action."&action=progress_bar&start=$links_done&total={$row['cat_links']}", |
|
| 339 | + 'UA_PROGRESS_BAR' => addslashes($this->u_action."&action=progress_bar&start=$links_done&total={$row['cat_links']}"), |
|
| 340 | + 'S_CONTINUE_SYNC' => true, |
|
| 341 | + 'L_PROGRESS_EXPLAIN' => $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', $links_done, $row['cat_links']), ] |
|
| 342 | + ); |
|
| 343 | + |
|
| 344 | + return; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + $url = $this->u_action."&parent_id={$this->parent_id}&c=$this->cat_id&action=sync_cat"; |
|
| 348 | + meta_refresh(0, $url); |
|
| 349 | + |
|
| 350 | + $this->template->assign_vars([ |
|
| 351 | + 'U_PROGRESS_BAR' => $this->u_action.'&action=progress_bar', |
|
| 352 | + 'UA_PROGRESS_BAR' => addslashes($this->u_action.'&action=progress_bar'), |
|
| 353 | + 'S_CONTINUE_SYNC' => true, |
|
| 354 | + 'L_PROGRESS_EXPLAIN' => $this->user->lang('SYNC_IN_PROGRESS_EXPLAIN', 0, $row['cat_links']), ] |
|
| 355 | + ); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * Sync category data. |
|
| 360 | + * |
|
| 361 | + * @return null |
|
| 362 | + */ |
|
| 363 | + public function action_sync_cat() |
|
| 364 | + { |
|
| 365 | + $sql = 'SELECT cat_name |
|
| 366 | 366 | FROM '.DIR_CAT_TABLE.' |
| 367 | 367 | WHERE cat_id = '.(int) $this->cat_id; |
| 368 | - $result = $this->db->sql_query($sql); |
|
| 369 | - $row = $this->db->sql_fetchrow($result); |
|
| 370 | - $this->db->sql_freeresult($result); |
|
| 371 | - |
|
| 372 | - if (!$row) { |
|
| 373 | - trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - $this->_sync_dir_cat($this->cat_id); |
|
| 377 | - |
|
| 378 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_SYNC', time(), [$row['cat_name']]); |
|
| 379 | - $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 380 | - |
|
| 381 | - $this->template->assign_var('L_DIR_CAT_RESYNCED', $this->user->lang('DIR_CAT_RESYNCED', $row['cat_name'])); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * Display categories page. |
|
| 386 | - * |
|
| 387 | - * @return null |
|
| 388 | - */ |
|
| 389 | - public function display_cats() |
|
| 390 | - { |
|
| 391 | - // Default management page |
|
| 392 | - if (!$this->parent_id) { |
|
| 393 | - $navigation = $this->user->lang['DIR_INDEX']; |
|
| 394 | - } else { |
|
| 395 | - $navigation = '<a href="'.$this->u_action.'">'.$this->user->lang['DIR_INDEX'].'</a>'; |
|
| 396 | - |
|
| 397 | - $cats_nav = $this->nestedset_category->get_path_data($this->parent_id); |
|
| 398 | - |
|
| 399 | - foreach ($cats_nav as $row) { |
|
| 400 | - if ($row['cat_id'] == $this->parent_id) { |
|
| 401 | - $navigation .= ' -> '.$row['cat_name']; |
|
| 402 | - } else { |
|
| 403 | - $navigation .= ' -> <a href="'.$this->u_action.'&parent_id='.$row['cat_id'].'">'.$row['cat_name'].'</a>'; |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - // Jumpbox |
|
| 409 | - $cat_box = $this->categorie->make_cat_select($this->parent_id); |
|
| 410 | - |
|
| 411 | - if ($this->action == 'sync' || $this->action == 'sync_cat') { |
|
| 412 | - $this->template->assign_var('S_RESYNCED', true); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - $sql = 'SELECT cat_id, parent_id, right_id, left_id, cat_name, cat_icon, cat_desc_uid, cat_desc_bitfield, cat_desc, cat_desc_options, cat_links |
|
| 368 | + $result = $this->db->sql_query($sql); |
|
| 369 | + $row = $this->db->sql_fetchrow($result); |
|
| 370 | + $this->db->sql_freeresult($result); |
|
| 371 | + |
|
| 372 | + if (!$row) { |
|
| 373 | + trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id), E_USER_WARNING); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + $this->_sync_dir_cat($this->cat_id); |
|
| 377 | + |
|
| 378 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_SYNC', time(), [$row['cat_name']]); |
|
| 379 | + $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 380 | + |
|
| 381 | + $this->template->assign_var('L_DIR_CAT_RESYNCED', $this->user->lang('DIR_CAT_RESYNCED', $row['cat_name'])); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * Display categories page. |
|
| 386 | + * |
|
| 387 | + * @return null |
|
| 388 | + */ |
|
| 389 | + public function display_cats() |
|
| 390 | + { |
|
| 391 | + // Default management page |
|
| 392 | + if (!$this->parent_id) { |
|
| 393 | + $navigation = $this->user->lang['DIR_INDEX']; |
|
| 394 | + } else { |
|
| 395 | + $navigation = '<a href="'.$this->u_action.'">'.$this->user->lang['DIR_INDEX'].'</a>'; |
|
| 396 | + |
|
| 397 | + $cats_nav = $this->nestedset_category->get_path_data($this->parent_id); |
|
| 398 | + |
|
| 399 | + foreach ($cats_nav as $row) { |
|
| 400 | + if ($row['cat_id'] == $this->parent_id) { |
|
| 401 | + $navigation .= ' -> '.$row['cat_name']; |
|
| 402 | + } else { |
|
| 403 | + $navigation .= ' -> <a href="'.$this->u_action.'&parent_id='.$row['cat_id'].'">'.$row['cat_name'].'</a>'; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + // Jumpbox |
|
| 409 | + $cat_box = $this->categorie->make_cat_select($this->parent_id); |
|
| 410 | + |
|
| 411 | + if ($this->action == 'sync' || $this->action == 'sync_cat') { |
|
| 412 | + $this->template->assign_var('S_RESYNCED', true); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + $sql = 'SELECT cat_id, parent_id, right_id, left_id, cat_name, cat_icon, cat_desc_uid, cat_desc_bitfield, cat_desc, cat_desc_options, cat_links |
|
| 416 | 416 | FROM '.DIR_CAT_TABLE.' |
| 417 | 417 | WHERE parent_id = '.(int) $this->parent_id.' |
| 418 | 418 | ORDER BY left_id'; |
| 419 | - $result = $this->db->sql_query($sql); |
|
| 420 | - |
|
| 421 | - if ($row = $this->db->sql_fetchrow($result)) { |
|
| 422 | - do { |
|
| 423 | - $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="'.$this->user->lang['DIR_SUBCAT'].'" />' : '<img src="images/icon_folder.gif" alt="'.$this->user->lang['FOLDER'].'" />'; |
|
| 424 | - |
|
| 425 | - $url = $this->u_action."&parent_id=$this->parent_id&c={$row['cat_id']}"; |
|
| 426 | - |
|
| 427 | - $this->template->assign_block_vars('cats', [ |
|
| 428 | - 'FOLDER_IMAGE' => $folder_image, |
|
| 429 | - 'CAT_IMAGE' => ($row['cat_icon']) ? '<img src="'.$this->dir_helper->get_img_path('icons', $row['cat_icon']).'" alt="" />' : '', |
|
| 430 | - 'CAT_NAME' => $row['cat_name'], |
|
| 431 | - 'CAT_DESCRIPTION' => generate_text_for_display($row['cat_desc'], $row['cat_desc_uid'], $row['cat_desc_bitfield'], $row['cat_desc_options']), |
|
| 432 | - 'CAT_LINKS' => $row['cat_links'], |
|
| 433 | - |
|
| 434 | - 'U_CAT' => $this->u_action.'&parent_id='.$row['cat_id'], |
|
| 435 | - 'U_MOVE_UP' => $url.'&action=move_up', |
|
| 436 | - 'U_MOVE_DOWN' => $url.'&action=move_down', |
|
| 437 | - 'U_EDIT' => $url.'&action=edit', |
|
| 438 | - 'U_DELETE' => $url.'&action=delete', |
|
| 439 | - 'U_SYNC' => $url.'&action=sync', ] |
|
| 440 | - ); |
|
| 441 | - } while ($row = $this->db->sql_fetchrow($result)); |
|
| 442 | - } elseif ($this->parent_id) { |
|
| 443 | - $row = $this->_get_cat_info($this->parent_id); |
|
| 444 | - |
|
| 445 | - $url = $this->u_action.'&parent_id='.$this->parent_id.'&c='.$row['cat_id']; |
|
| 446 | - |
|
| 447 | - $this->template->assign_vars([ |
|
| 448 | - 'S_NO_CATS' => true, |
|
| 449 | - |
|
| 450 | - 'U_EDIT' => $url.'&action=edit', |
|
| 451 | - 'U_DELETE' => $url.'&action=delete', |
|
| 452 | - 'U_SYNC' => $url.'&action=sync', ] |
|
| 453 | - ); |
|
| 454 | - } |
|
| 455 | - $this->db->sql_freeresult($result); |
|
| 456 | - |
|
| 457 | - $this->template->assign_vars([ |
|
| 458 | - 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', |
|
| 459 | - 'NAVIGATION' => $navigation, |
|
| 460 | - 'CAT_BOX' => $cat_box, |
|
| 461 | - 'U_SEL_ACTION' => $this->u_action, |
|
| 462 | - 'U_ACTION' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 463 | - |
|
| 464 | - 'U_PROGRESS_BAR' => $this->u_action.'&action=progress_bar', |
|
| 465 | - 'UA_PROGRESS_BAR' => addslashes($this->u_action.'&action=progress_bar'), |
|
| 466 | - ]); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Set page url. |
|
| 471 | - * |
|
| 472 | - * @param string $u_action Custom form action |
|
| 473 | - * |
|
| 474 | - * @return null |
|
| 475 | - */ |
|
| 476 | - public function set_page_url($u_action) |
|
| 477 | - { |
|
| 478 | - $this->u_action = $u_action; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - /** |
|
| 482 | - * Update cat table. |
|
| 483 | - * |
|
| 484 | - * @return null |
|
| 485 | - */ |
|
| 486 | - public function update() |
|
| 487 | - { |
|
| 488 | - if (!check_form_key($this->form_key)) { |
|
| 489 | - $this->update = false; |
|
| 490 | - $this->errors[] = $this->user->lang['FORM_INVALID']; |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - switch ($this->action) { |
|
| 494 | - case 'delete': |
|
| 495 | - $action_subcats = $this->request->variable('action_subcats', ''); |
|
| 496 | - $subcats_to_id = $this->request->variable('subcats_to_id', 0); |
|
| 497 | - $action_links = $this->request->variable('action_links', ''); |
|
| 498 | - $links_to_id = $this->request->variable('links_to_id', 0); |
|
| 499 | - |
|
| 500 | - try { |
|
| 501 | - $this->errors = $this->_delete_cat($action_links, $action_subcats, $links_to_id, $subcats_to_id); |
|
| 502 | - } catch (\Exception $e) { |
|
| 503 | - trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - if (count($this->errors)) { |
|
| 507 | - break; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 511 | - |
|
| 512 | - trigger_error($this->user->lang['DIR_CAT_DELETED'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id)); |
|
| 513 | - |
|
| 514 | - break; |
|
| 515 | - |
|
| 516 | - case 'edit': |
|
| 517 | - $this->cat_data = [ |
|
| 518 | - 'cat_id' => $this->cat_id, |
|
| 519 | - ]; |
|
| 520 | - // No break here |
|
| 521 | - case 'add': |
|
| 522 | - |
|
| 523 | - $this->cat_data += [ |
|
| 524 | - 'parent_id' => $this->request->variable('cat_parent_id', (int) $this->parent_id), |
|
| 525 | - 'cat_parents' => '', |
|
| 526 | - 'cat_name' => $this->request->variable('cat_name', '', true), |
|
| 527 | - 'cat_desc' => $this->request->variable('cat_desc', '', true), |
|
| 528 | - 'cat_desc_uid' => '', |
|
| 529 | - 'cat_desc_options' => 7, |
|
| 530 | - 'cat_desc_bitfield' => '', |
|
| 531 | - 'cat_icon' => $this->request->variable('cat_icon', ''), |
|
| 532 | - 'display_subcat_list' => $this->request->variable('display_on_index', false), |
|
| 533 | - 'cat_allow_comments' => $this->request->variable('allow_comments', 1), |
|
| 534 | - 'cat_allow_votes' => $this->request->variable('allow_votes', 1), |
|
| 535 | - 'cat_must_describe' => $this->request->variable('must_describe', 1), |
|
| 536 | - 'cat_count_all' => $this->request->variable('count_all', 0), |
|
| 537 | - 'cat_validate' => $this->request->variable('validate', 0), |
|
| 538 | - 'cat_link_back' => $this->request->variable('link_back', 0), |
|
| 539 | - 'cat_cron_enable' => $this->request->variable('cron_enable', 0), |
|
| 540 | - 'cat_cron_freq' => $this->request->variable('cron_every', 7), |
|
| 541 | - 'cat_cron_nb_check' => $this->request->variable('nb_check', 1), |
|
| 542 | - ]; |
|
| 543 | - |
|
| 544 | - // Get data for cat description if specified |
|
| 545 | - if ($this->cat_data['cat_desc']) { |
|
| 546 | - generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_parse_bbcode', false), $this->request->variable('desc_parse_urls', false), $this->request->variable('desc_parse_smilies', false)); |
|
| 547 | - } |
|
| 548 | - |
|
| 549 | - try { |
|
| 550 | - $this->errors = $this->_update_cat_data(); |
|
| 551 | - } catch (\Exception $e) { |
|
| 552 | - trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - if (!count($this->errors)) { |
|
| 556 | - $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 557 | - |
|
| 558 | - $message = ($this->action == 'add') ? $this->user->lang['DIR_CAT_CREATED'] : $this->user->lang['DIR_CAT_UPDATED']; |
|
| 559 | - |
|
| 560 | - trigger_error($message.adm_back_link($this->u_action.'&parent_id='.$this->parent_id)); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - break; |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Display form. |
|
| 569 | - * |
|
| 570 | - * @param string $parents_list Drop-down list |
|
| 571 | - * |
|
| 572 | - * @return null |
|
| 573 | - */ |
|
| 574 | - private function _display_cat_form($parents_list) |
|
| 575 | - { |
|
| 576 | - $dir_cat_desc_data = [ |
|
| 577 | - 'text' => $this->cat_data['cat_desc'], |
|
| 578 | - 'allow_bbcode' => true, |
|
| 579 | - 'allow_smilies' => true, |
|
| 580 | - 'allow_urls' => true, |
|
| 581 | - ]; |
|
| 582 | - |
|
| 583 | - // Parse desciption if specified |
|
| 584 | - if ($this->cat_data['cat_desc']) { |
|
| 585 | - if (!isset($this->cat_data['cat_desc_uid'])) { |
|
| 586 | - // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... |
|
| 587 | - $this->cat_data['cat_desc_uid'] = ''; |
|
| 588 | - $this->cat_data['cat_desc_bitfield'] = ''; |
|
| 589 | - $this->cat_data['cat_desc_options'] = 0; |
|
| 590 | - |
|
| 591 | - generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_allow_bbcode', false), $this->request->variable('desc_allow_urls', false), $this->request->variable('desc_allow_smilies', false)); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - // decode... |
|
| 595 | - $dir_cat_desc_data = generate_text_for_edit($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_options']); |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - $this->template->assign_vars([ |
|
| 599 | - 'S_EDIT_CAT' => true, |
|
| 600 | - 'S_ERROR' => (count($this->errors)) ? true : false, |
|
| 601 | - 'S_CAT_PARENT_ID' => $this->cat_data['parent_id'], |
|
| 602 | - 'S_ADD_ACTION' => ($this->action == 'add') ? true : false, |
|
| 603 | - |
|
| 604 | - 'U_BACK' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 605 | - 'U_EDIT_ACTION' => $this->u_action."&parent_id={$this->parent_id}&action=$this->action&c=$this->cat_id", |
|
| 606 | - |
|
| 607 | - 'L_TITLE' => $this->user->lang['DIR_'.strtoupper($this->action).'_CAT'], |
|
| 608 | - 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', |
|
| 609 | - 'ICON_IMAGE' => ($this->cat_data['cat_icon']) ? $this->dir_helper->get_img_path('icons', $this->cat_data['cat_icon']) : 'images/spacer.gif', |
|
| 610 | - |
|
| 611 | - 'DIR_ICON_PATH' => $this->dir_helper->get_img_path('icons'), |
|
| 612 | - 'DIR_CAT_NAME' => $this->cat_data['cat_name'], |
|
| 613 | - 'DIR_CAT_DESC' => $dir_cat_desc_data['text'], |
|
| 614 | - |
|
| 615 | - 'S_DESC_BBCODE_CHECKED' => ($dir_cat_desc_data['allow_bbcode']) ? true : false, |
|
| 616 | - 'S_DESC_SMILIES_CHECKED' => ($dir_cat_desc_data['allow_smilies']) ? true : false, |
|
| 617 | - 'S_DESC_URLS_CHECKED' => ($dir_cat_desc_data['allow_urls']) ? true : false, |
|
| 618 | - 'S_DISPLAY_SUBCAT_LIST' => ($this->cat_data['display_subcat_list']) ? true : false, |
|
| 619 | - 'S_PARENT_OPTIONS' => $parents_list, |
|
| 620 | - 'S_ICON_OPTIONS' => $this->_get_dir_icon_list($this->dir_helper->get_img_path('icons'), $this->cat_data['cat_icon']), |
|
| 621 | - 'S_ALLOW_COMMENTS' => ($this->cat_data['cat_allow_comments']) ? true : false, |
|
| 622 | - 'S_ALLOW_VOTES' => ($this->cat_data['cat_allow_votes']) ? true : false, |
|
| 623 | - 'S_MUST_DESCRIBE' => ($this->cat_data['cat_must_describe']) ? true : false, |
|
| 624 | - 'S_COUNT_ALL' => ($this->cat_data['cat_count_all']) ? true : false, |
|
| 625 | - 'S_VALIDATE' => ($this->cat_data['cat_validate']) ? true : false, |
|
| 626 | - |
|
| 627 | - 'DIR_CRON_EVERY' => $this->cat_data['cat_cron_freq'], |
|
| 628 | - 'DIR_NEXT_CRON_ACTION' => !empty($this->cat_data['cat_cron_next']) ? $this->user->format_date($this->cat_data['cat_cron_next']) : '-', |
|
| 629 | - 'DIR_CRON_NB_CHECK' => $this->cat_data['cat_cron_nb_check'], |
|
| 630 | - |
|
| 631 | - 'S_LINK_BACK' => ($this->cat_data['cat_link_back']) ? true : false, |
|
| 632 | - 'S_CRON_ENABLE' => ($this->cat_data['cat_cron_enable']) ? true : false, |
|
| 633 | - |
|
| 634 | - 'U_DATE' => $this->helper->route('ernadoo_phpbbdirectory_ajax_controller'), |
|
| 635 | - ]); |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * Get category details. |
|
| 640 | - * |
|
| 641 | - * @param int $cat_id The category ID |
|
| 642 | - * |
|
| 643 | - * @return array |
|
| 644 | - */ |
|
| 645 | - private function _get_cat_info($cat_id) |
|
| 646 | - { |
|
| 647 | - $sql = 'SELECT cat_id, parent_id, right_id, left_id, cat_desc, cat_desc_uid, cat_desc_options, cat_icon, cat_name, display_subcat_list, cat_allow_comments, cat_allow_votes, cat_must_describe, cat_count_all, cat_validate, cat_cron_freq, cat_cron_nb_check, cat_link_back, cat_cron_enable, cat_cron_next |
|
| 419 | + $result = $this->db->sql_query($sql); |
|
| 420 | + |
|
| 421 | + if ($row = $this->db->sql_fetchrow($result)) { |
|
| 422 | + do { |
|
| 423 | + $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="'.$this->user->lang['DIR_SUBCAT'].'" />' : '<img src="images/icon_folder.gif" alt="'.$this->user->lang['FOLDER'].'" />'; |
|
| 424 | + |
|
| 425 | + $url = $this->u_action."&parent_id=$this->parent_id&c={$row['cat_id']}"; |
|
| 426 | + |
|
| 427 | + $this->template->assign_block_vars('cats', [ |
|
| 428 | + 'FOLDER_IMAGE' => $folder_image, |
|
| 429 | + 'CAT_IMAGE' => ($row['cat_icon']) ? '<img src="'.$this->dir_helper->get_img_path('icons', $row['cat_icon']).'" alt="" />' : '', |
|
| 430 | + 'CAT_NAME' => $row['cat_name'], |
|
| 431 | + 'CAT_DESCRIPTION' => generate_text_for_display($row['cat_desc'], $row['cat_desc_uid'], $row['cat_desc_bitfield'], $row['cat_desc_options']), |
|
| 432 | + 'CAT_LINKS' => $row['cat_links'], |
|
| 433 | + |
|
| 434 | + 'U_CAT' => $this->u_action.'&parent_id='.$row['cat_id'], |
|
| 435 | + 'U_MOVE_UP' => $url.'&action=move_up', |
|
| 436 | + 'U_MOVE_DOWN' => $url.'&action=move_down', |
|
| 437 | + 'U_EDIT' => $url.'&action=edit', |
|
| 438 | + 'U_DELETE' => $url.'&action=delete', |
|
| 439 | + 'U_SYNC' => $url.'&action=sync', ] |
|
| 440 | + ); |
|
| 441 | + } while ($row = $this->db->sql_fetchrow($result)); |
|
| 442 | + } elseif ($this->parent_id) { |
|
| 443 | + $row = $this->_get_cat_info($this->parent_id); |
|
| 444 | + |
|
| 445 | + $url = $this->u_action.'&parent_id='.$this->parent_id.'&c='.$row['cat_id']; |
|
| 446 | + |
|
| 447 | + $this->template->assign_vars([ |
|
| 448 | + 'S_NO_CATS' => true, |
|
| 449 | + |
|
| 450 | + 'U_EDIT' => $url.'&action=edit', |
|
| 451 | + 'U_DELETE' => $url.'&action=delete', |
|
| 452 | + 'U_SYNC' => $url.'&action=sync', ] |
|
| 453 | + ); |
|
| 454 | + } |
|
| 455 | + $this->db->sql_freeresult($result); |
|
| 456 | + |
|
| 457 | + $this->template->assign_vars([ |
|
| 458 | + 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', |
|
| 459 | + 'NAVIGATION' => $navigation, |
|
| 460 | + 'CAT_BOX' => $cat_box, |
|
| 461 | + 'U_SEL_ACTION' => $this->u_action, |
|
| 462 | + 'U_ACTION' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 463 | + |
|
| 464 | + 'U_PROGRESS_BAR' => $this->u_action.'&action=progress_bar', |
|
| 465 | + 'UA_PROGRESS_BAR' => addslashes($this->u_action.'&action=progress_bar'), |
|
| 466 | + ]); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + /** |
|
| 470 | + * Set page url. |
|
| 471 | + * |
|
| 472 | + * @param string $u_action Custom form action |
|
| 473 | + * |
|
| 474 | + * @return null |
|
| 475 | + */ |
|
| 476 | + public function set_page_url($u_action) |
|
| 477 | + { |
|
| 478 | + $this->u_action = $u_action; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + /** |
|
| 482 | + * Update cat table. |
|
| 483 | + * |
|
| 484 | + * @return null |
|
| 485 | + */ |
|
| 486 | + public function update() |
|
| 487 | + { |
|
| 488 | + if (!check_form_key($this->form_key)) { |
|
| 489 | + $this->update = false; |
|
| 490 | + $this->errors[] = $this->user->lang['FORM_INVALID']; |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + switch ($this->action) { |
|
| 494 | + case 'delete': |
|
| 495 | + $action_subcats = $this->request->variable('action_subcats', ''); |
|
| 496 | + $subcats_to_id = $this->request->variable('subcats_to_id', 0); |
|
| 497 | + $action_links = $this->request->variable('action_links', ''); |
|
| 498 | + $links_to_id = $this->request->variable('links_to_id', 0); |
|
| 499 | + |
|
| 500 | + try { |
|
| 501 | + $this->errors = $this->_delete_cat($action_links, $action_subcats, $links_to_id, $subcats_to_id); |
|
| 502 | + } catch (\Exception $e) { |
|
| 503 | + trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + if (count($this->errors)) { |
|
| 507 | + break; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 511 | + |
|
| 512 | + trigger_error($this->user->lang['DIR_CAT_DELETED'].adm_back_link($this->u_action.'&parent_id='.$this->parent_id)); |
|
| 513 | + |
|
| 514 | + break; |
|
| 515 | + |
|
| 516 | + case 'edit': |
|
| 517 | + $this->cat_data = [ |
|
| 518 | + 'cat_id' => $this->cat_id, |
|
| 519 | + ]; |
|
| 520 | + // No break here |
|
| 521 | + case 'add': |
|
| 522 | + |
|
| 523 | + $this->cat_data += [ |
|
| 524 | + 'parent_id' => $this->request->variable('cat_parent_id', (int) $this->parent_id), |
|
| 525 | + 'cat_parents' => '', |
|
| 526 | + 'cat_name' => $this->request->variable('cat_name', '', true), |
|
| 527 | + 'cat_desc' => $this->request->variable('cat_desc', '', true), |
|
| 528 | + 'cat_desc_uid' => '', |
|
| 529 | + 'cat_desc_options' => 7, |
|
| 530 | + 'cat_desc_bitfield' => '', |
|
| 531 | + 'cat_icon' => $this->request->variable('cat_icon', ''), |
|
| 532 | + 'display_subcat_list' => $this->request->variable('display_on_index', false), |
|
| 533 | + 'cat_allow_comments' => $this->request->variable('allow_comments', 1), |
|
| 534 | + 'cat_allow_votes' => $this->request->variable('allow_votes', 1), |
|
| 535 | + 'cat_must_describe' => $this->request->variable('must_describe', 1), |
|
| 536 | + 'cat_count_all' => $this->request->variable('count_all', 0), |
|
| 537 | + 'cat_validate' => $this->request->variable('validate', 0), |
|
| 538 | + 'cat_link_back' => $this->request->variable('link_back', 0), |
|
| 539 | + 'cat_cron_enable' => $this->request->variable('cron_enable', 0), |
|
| 540 | + 'cat_cron_freq' => $this->request->variable('cron_every', 7), |
|
| 541 | + 'cat_cron_nb_check' => $this->request->variable('nb_check', 1), |
|
| 542 | + ]; |
|
| 543 | + |
|
| 544 | + // Get data for cat description if specified |
|
| 545 | + if ($this->cat_data['cat_desc']) { |
|
| 546 | + generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_parse_bbcode', false), $this->request->variable('desc_parse_urls', false), $this->request->variable('desc_parse_smilies', false)); |
|
| 547 | + } |
|
| 548 | + |
|
| 549 | + try { |
|
| 550 | + $this->errors = $this->_update_cat_data(); |
|
| 551 | + } catch (\Exception $e) { |
|
| 552 | + trigger_error($e->getMessage(), E_USER_WARNING); |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + if (!count($this->errors)) { |
|
| 556 | + $this->cache->destroy('sql', DIR_CAT_TABLE); |
|
| 557 | + |
|
| 558 | + $message = ($this->action == 'add') ? $this->user->lang['DIR_CAT_CREATED'] : $this->user->lang['DIR_CAT_UPDATED']; |
|
| 559 | + |
|
| 560 | + trigger_error($message.adm_back_link($this->u_action.'&parent_id='.$this->parent_id)); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + break; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Display form. |
|
| 569 | + * |
|
| 570 | + * @param string $parents_list Drop-down list |
|
| 571 | + * |
|
| 572 | + * @return null |
|
| 573 | + */ |
|
| 574 | + private function _display_cat_form($parents_list) |
|
| 575 | + { |
|
| 576 | + $dir_cat_desc_data = [ |
|
| 577 | + 'text' => $this->cat_data['cat_desc'], |
|
| 578 | + 'allow_bbcode' => true, |
|
| 579 | + 'allow_smilies' => true, |
|
| 580 | + 'allow_urls' => true, |
|
| 581 | + ]; |
|
| 582 | + |
|
| 583 | + // Parse desciption if specified |
|
| 584 | + if ($this->cat_data['cat_desc']) { |
|
| 585 | + if (!isset($this->cat_data['cat_desc_uid'])) { |
|
| 586 | + // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value... |
|
| 587 | + $this->cat_data['cat_desc_uid'] = ''; |
|
| 588 | + $this->cat_data['cat_desc_bitfield'] = ''; |
|
| 589 | + $this->cat_data['cat_desc_options'] = 0; |
|
| 590 | + |
|
| 591 | + generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_allow_bbcode', false), $this->request->variable('desc_allow_urls', false), $this->request->variable('desc_allow_smilies', false)); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + // decode... |
|
| 595 | + $dir_cat_desc_data = generate_text_for_edit($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_options']); |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + $this->template->assign_vars([ |
|
| 599 | + 'S_EDIT_CAT' => true, |
|
| 600 | + 'S_ERROR' => (count($this->errors)) ? true : false, |
|
| 601 | + 'S_CAT_PARENT_ID' => $this->cat_data['parent_id'], |
|
| 602 | + 'S_ADD_ACTION' => ($this->action == 'add') ? true : false, |
|
| 603 | + |
|
| 604 | + 'U_BACK' => $this->u_action.'&parent_id='.$this->parent_id, |
|
| 605 | + 'U_EDIT_ACTION' => $this->u_action."&parent_id={$this->parent_id}&action=$this->action&c=$this->cat_id", |
|
| 606 | + |
|
| 607 | + 'L_TITLE' => $this->user->lang['DIR_'.strtoupper($this->action).'_CAT'], |
|
| 608 | + 'ERROR_MSG' => (count($this->errors)) ? implode('<br />', $this->errors) : '', |
|
| 609 | + 'ICON_IMAGE' => ($this->cat_data['cat_icon']) ? $this->dir_helper->get_img_path('icons', $this->cat_data['cat_icon']) : 'images/spacer.gif', |
|
| 610 | + |
|
| 611 | + 'DIR_ICON_PATH' => $this->dir_helper->get_img_path('icons'), |
|
| 612 | + 'DIR_CAT_NAME' => $this->cat_data['cat_name'], |
|
| 613 | + 'DIR_CAT_DESC' => $dir_cat_desc_data['text'], |
|
| 614 | + |
|
| 615 | + 'S_DESC_BBCODE_CHECKED' => ($dir_cat_desc_data['allow_bbcode']) ? true : false, |
|
| 616 | + 'S_DESC_SMILIES_CHECKED' => ($dir_cat_desc_data['allow_smilies']) ? true : false, |
|
| 617 | + 'S_DESC_URLS_CHECKED' => ($dir_cat_desc_data['allow_urls']) ? true : false, |
|
| 618 | + 'S_DISPLAY_SUBCAT_LIST' => ($this->cat_data['display_subcat_list']) ? true : false, |
|
| 619 | + 'S_PARENT_OPTIONS' => $parents_list, |
|
| 620 | + 'S_ICON_OPTIONS' => $this->_get_dir_icon_list($this->dir_helper->get_img_path('icons'), $this->cat_data['cat_icon']), |
|
| 621 | + 'S_ALLOW_COMMENTS' => ($this->cat_data['cat_allow_comments']) ? true : false, |
|
| 622 | + 'S_ALLOW_VOTES' => ($this->cat_data['cat_allow_votes']) ? true : false, |
|
| 623 | + 'S_MUST_DESCRIBE' => ($this->cat_data['cat_must_describe']) ? true : false, |
|
| 624 | + 'S_COUNT_ALL' => ($this->cat_data['cat_count_all']) ? true : false, |
|
| 625 | + 'S_VALIDATE' => ($this->cat_data['cat_validate']) ? true : false, |
|
| 626 | + |
|
| 627 | + 'DIR_CRON_EVERY' => $this->cat_data['cat_cron_freq'], |
|
| 628 | + 'DIR_NEXT_CRON_ACTION' => !empty($this->cat_data['cat_cron_next']) ? $this->user->format_date($this->cat_data['cat_cron_next']) : '-', |
|
| 629 | + 'DIR_CRON_NB_CHECK' => $this->cat_data['cat_cron_nb_check'], |
|
| 630 | + |
|
| 631 | + 'S_LINK_BACK' => ($this->cat_data['cat_link_back']) ? true : false, |
|
| 632 | + 'S_CRON_ENABLE' => ($this->cat_data['cat_cron_enable']) ? true : false, |
|
| 633 | + |
|
| 634 | + 'U_DATE' => $this->helper->route('ernadoo_phpbbdirectory_ajax_controller'), |
|
| 635 | + ]); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * Get category details. |
|
| 640 | + * |
|
| 641 | + * @param int $cat_id The category ID |
|
| 642 | + * |
|
| 643 | + * @return array |
|
| 644 | + */ |
|
| 645 | + private function _get_cat_info($cat_id) |
|
| 646 | + { |
|
| 647 | + $sql = 'SELECT cat_id, parent_id, right_id, left_id, cat_desc, cat_desc_uid, cat_desc_options, cat_icon, cat_name, display_subcat_list, cat_allow_comments, cat_allow_votes, cat_must_describe, cat_count_all, cat_validate, cat_cron_freq, cat_cron_nb_check, cat_link_back, cat_cron_enable, cat_cron_next |
|
| 648 | 648 | FROM '.DIR_CAT_TABLE.' |
| 649 | 649 | WHERE cat_id = '.(int) $cat_id; |
| 650 | - $result = $this->db->sql_query($sql); |
|
| 651 | - $row = $this->db->sql_fetchrow($result); |
|
| 652 | - $this->db->sql_freeresult($result); |
|
| 653 | - |
|
| 654 | - if (!$row) { |
|
| 655 | - trigger_error('DIR_ERROR_NO_CATS', E_USER_ERROR); |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - return $row; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - /** |
|
| 662 | - * Update category data. |
|
| 663 | - * |
|
| 664 | - * @return array |
|
| 665 | - */ |
|
| 666 | - private function _update_cat_data() |
|
| 667 | - { |
|
| 668 | - if (!$this->cat_data['cat_name']) { |
|
| 669 | - $this->errors[] = $this->user->lang['DIR_CAT_NAME_EMPTY']; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - if (utf8_strlen($this->cat_data['cat_desc']) > 4000) { |
|
| 673 | - $this->errors[] = $this->user->lang['DIR_CAT_DESC_TOO_LONG']; |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - if (($this->cat_data['cat_cron_enable'] && $this->cat_data['cat_cron_freq'] <= 0) || $this->cat_data['cat_cron_nb_check'] < 0) { |
|
| 677 | - $this->errors[] = $this->user->lang['DIR_CAT_DATA_NEGATIVE']; |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - // Unset data that are not database fields |
|
| 681 | - $cat_data_sql = $this->cat_data; |
|
| 682 | - |
|
| 683 | - // What are we going to do tonight Brain? The same thing we do everynight, |
|
| 684 | - // try to take over the world ... or decide whether to continue update |
|
| 685 | - // and if so, whether it's a new cat/link or an existing one |
|
| 686 | - if (count($this->errors)) { |
|
| 687 | - return $this->errors; |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - if (!$cat_data_sql['cat_link_back']) { |
|
| 691 | - $cat_data_sql['cat_cron_enable'] = 0; |
|
| 692 | - $cat_data_sql['cat_cron_next'] = 0; |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - if (!$cat_data_sql['parent_id']) { |
|
| 696 | - $cat_data_sql['display_subcat_list'] = 0; |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - // no cat_id means we're creating a new categorie |
|
| 700 | - if (!isset($cat_data_sql['cat_id'])) { |
|
| 701 | - if ($cat_data_sql['cat_cron_enable']) { |
|
| 702 | - $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - $this->cat_data = $this->nestedset_category->insert($cat_data_sql); |
|
| 706 | - |
|
| 707 | - if ($cat_data_sql['parent_id']) { |
|
| 708 | - $this->nestedset_category->change_parent($this->cat_data['cat_id'], $cat_data_sql['parent_id']); |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_ADD', time(), [$this->cat_data['cat_name']]); |
|
| 712 | - } else { |
|
| 713 | - $row = $this->_get_cat_info($cat_data_sql['cat_id']); |
|
| 714 | - |
|
| 715 | - if ($row['parent_id'] != $cat_data_sql['parent_id']) { |
|
| 716 | - $this->nestedset_category->change_parent($cat_data_sql['cat_id'], $cat_data_sql['parent_id']); |
|
| 717 | - } |
|
| 718 | - |
|
| 719 | - if ($cat_data_sql['cat_cron_enable'] && ($row['cat_cron_freq'] != $cat_data_sql['cat_cron_freq'] || !$row['cat_cron_enable'])) { |
|
| 720 | - $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400; |
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - if ($row['cat_name'] != $cat_data_sql['cat_name']) { |
|
| 724 | - // the cat name has changed, clear the parents list of all categories (for safety) |
|
| 725 | - $sql = 'UPDATE '.DIR_CAT_TABLE." |
|
| 650 | + $result = $this->db->sql_query($sql); |
|
| 651 | + $row = $this->db->sql_fetchrow($result); |
|
| 652 | + $this->db->sql_freeresult($result); |
|
| 653 | + |
|
| 654 | + if (!$row) { |
|
| 655 | + trigger_error('DIR_ERROR_NO_CATS', E_USER_ERROR); |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + return $row; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + /** |
|
| 662 | + * Update category data. |
|
| 663 | + * |
|
| 664 | + * @return array |
|
| 665 | + */ |
|
| 666 | + private function _update_cat_data() |
|
| 667 | + { |
|
| 668 | + if (!$this->cat_data['cat_name']) { |
|
| 669 | + $this->errors[] = $this->user->lang['DIR_CAT_NAME_EMPTY']; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + if (utf8_strlen($this->cat_data['cat_desc']) > 4000) { |
|
| 673 | + $this->errors[] = $this->user->lang['DIR_CAT_DESC_TOO_LONG']; |
|
| 674 | + } |
|
| 675 | + |
|
| 676 | + if (($this->cat_data['cat_cron_enable'] && $this->cat_data['cat_cron_freq'] <= 0) || $this->cat_data['cat_cron_nb_check'] < 0) { |
|
| 677 | + $this->errors[] = $this->user->lang['DIR_CAT_DATA_NEGATIVE']; |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + // Unset data that are not database fields |
|
| 681 | + $cat_data_sql = $this->cat_data; |
|
| 682 | + |
|
| 683 | + // What are we going to do tonight Brain? The same thing we do everynight, |
|
| 684 | + // try to take over the world ... or decide whether to continue update |
|
| 685 | + // and if so, whether it's a new cat/link or an existing one |
|
| 686 | + if (count($this->errors)) { |
|
| 687 | + return $this->errors; |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + if (!$cat_data_sql['cat_link_back']) { |
|
| 691 | + $cat_data_sql['cat_cron_enable'] = 0; |
|
| 692 | + $cat_data_sql['cat_cron_next'] = 0; |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + if (!$cat_data_sql['parent_id']) { |
|
| 696 | + $cat_data_sql['display_subcat_list'] = 0; |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + // no cat_id means we're creating a new categorie |
|
| 700 | + if (!isset($cat_data_sql['cat_id'])) { |
|
| 701 | + if ($cat_data_sql['cat_cron_enable']) { |
|
| 702 | + $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + $this->cat_data = $this->nestedset_category->insert($cat_data_sql); |
|
| 706 | + |
|
| 707 | + if ($cat_data_sql['parent_id']) { |
|
| 708 | + $this->nestedset_category->change_parent($this->cat_data['cat_id'], $cat_data_sql['parent_id']); |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_ADD', time(), [$this->cat_data['cat_name']]); |
|
| 712 | + } else { |
|
| 713 | + $row = $this->_get_cat_info($cat_data_sql['cat_id']); |
|
| 714 | + |
|
| 715 | + if ($row['parent_id'] != $cat_data_sql['parent_id']) { |
|
| 716 | + $this->nestedset_category->change_parent($cat_data_sql['cat_id'], $cat_data_sql['parent_id']); |
|
| 717 | + } |
|
| 718 | + |
|
| 719 | + if ($cat_data_sql['cat_cron_enable'] && ($row['cat_cron_freq'] != $cat_data_sql['cat_cron_freq'] || !$row['cat_cron_enable'])) { |
|
| 720 | + $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400; |
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + if ($row['cat_name'] != $cat_data_sql['cat_name']) { |
|
| 724 | + // the cat name has changed, clear the parents list of all categories (for safety) |
|
| 725 | + $sql = 'UPDATE '.DIR_CAT_TABLE." |
|
| 726 | 726 | SET cat_parents = ''"; |
| 727 | - $this->db->sql_query($sql); |
|
| 728 | - } |
|
| 727 | + $this->db->sql_query($sql); |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | - // Setting the cat id to the categorie id is not really received well by some dbs. ;) |
|
| 731 | - unset($cat_data_sql['cat_id']); |
|
| 730 | + // Setting the cat id to the categorie id is not really received well by some dbs. ;) |
|
| 731 | + unset($cat_data_sql['cat_id']); |
|
| 732 | 732 | |
| 733 | - $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 733 | + $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 734 | 734 | SET '.$this->db->sql_build_array('UPDATE', $cat_data_sql).' |
| 735 | 735 | WHERE cat_id = '.(int) $this->cat_id; |
| 736 | - $this->db->sql_query($sql); |
|
| 737 | - |
|
| 738 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_EDIT', time(), [$this->cat_data['cat_name']]); |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - return $this->errors; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Remove complete category. |
|
| 746 | - * |
|
| 747 | - * @param string $action_links Action for categories links |
|
| 748 | - * @param string $action_subcats Action for sub-categories |
|
| 749 | - * @param int $links_to_id New category ID for links |
|
| 750 | - * @param int $subcats_to_id New category ID for sub-categories |
|
| 751 | - * |
|
| 752 | - * @return array |
|
| 753 | - */ |
|
| 754 | - private function _delete_cat($action_links = 'delete', $action_subcats = 'delete', $links_to_id = 0, $subcats_to_id = 0) |
|
| 755 | - { |
|
| 756 | - $this->cat_data = $this->_get_cat_info($this->cat_id); |
|
| 757 | - |
|
| 758 | - $log_action_links = $log_action_cats = $links_to_name = $subcats_to_name = ''; |
|
| 759 | - |
|
| 760 | - if ($action_links == 'delete') { |
|
| 761 | - $log_action_links = 'LINKS'; |
|
| 762 | - $this->errors = array_merge($this->errors, $this->_delete_cat_content()); |
|
| 763 | - } elseif ($action_links == 'move') { |
|
| 764 | - if (!$links_to_id) { |
|
| 765 | - $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT']; |
|
| 766 | - } else { |
|
| 767 | - $log_action_links = 'MOVE_LINKS'; |
|
| 768 | - |
|
| 769 | - $sql = 'SELECT cat_name |
|
| 736 | + $this->db->sql_query($sql); |
|
| 737 | + |
|
| 738 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_EDIT', time(), [$this->cat_data['cat_name']]); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + return $this->errors; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Remove complete category. |
|
| 746 | + * |
|
| 747 | + * @param string $action_links Action for categories links |
|
| 748 | + * @param string $action_subcats Action for sub-categories |
|
| 749 | + * @param int $links_to_id New category ID for links |
|
| 750 | + * @param int $subcats_to_id New category ID for sub-categories |
|
| 751 | + * |
|
| 752 | + * @return array |
|
| 753 | + */ |
|
| 754 | + private function _delete_cat($action_links = 'delete', $action_subcats = 'delete', $links_to_id = 0, $subcats_to_id = 0) |
|
| 755 | + { |
|
| 756 | + $this->cat_data = $this->_get_cat_info($this->cat_id); |
|
| 757 | + |
|
| 758 | + $log_action_links = $log_action_cats = $links_to_name = $subcats_to_name = ''; |
|
| 759 | + |
|
| 760 | + if ($action_links == 'delete') { |
|
| 761 | + $log_action_links = 'LINKS'; |
|
| 762 | + $this->errors = array_merge($this->errors, $this->_delete_cat_content()); |
|
| 763 | + } elseif ($action_links == 'move') { |
|
| 764 | + if (!$links_to_id) { |
|
| 765 | + $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT']; |
|
| 766 | + } else { |
|
| 767 | + $log_action_links = 'MOVE_LINKS'; |
|
| 768 | + |
|
| 769 | + $sql = 'SELECT cat_name |
|
| 770 | 770 | FROM '.DIR_CAT_TABLE.' |
| 771 | 771 | WHERE cat_id = '.(int) $links_to_id; |
| 772 | - $result = $this->db->sql_query($sql); |
|
| 773 | - $row = $this->db->sql_fetchrow($result); |
|
| 774 | - $this->db->sql_freeresult($result); |
|
| 775 | - |
|
| 776 | - if (!$row) { |
|
| 777 | - throw new \OutOfBoundsException('DIR_NO_CAT'); |
|
| 778 | - } else { |
|
| 779 | - $links_to_name = $row['cat_name']; |
|
| 780 | - $this->_move_cat_content($this->cat_id, $links_to_id); |
|
| 781 | - } |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - if (count($this->errors)) { |
|
| 786 | - return $this->errors; |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - if ($action_subcats == 'delete') { |
|
| 790 | - $log_action_cats = 'CATS'; |
|
| 791 | - } elseif ($action_subcats == 'move') { |
|
| 792 | - if (!$subcats_to_id) { |
|
| 793 | - $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT']; |
|
| 794 | - } else { |
|
| 795 | - $log_action_cats = 'MOVE_CATS'; |
|
| 796 | - |
|
| 797 | - $subcats_to_name = $row['cat_name']; |
|
| 798 | - $this->nestedset_category->move_children($this->cat_id, $subcats_to_id); |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - if (count($this->errors)) { |
|
| 803 | - return $this->errors; |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - $this->nestedset_category->delete($this->cat_id); |
|
| 807 | - |
|
| 808 | - $log_action = implode('_', [$log_action_links, $log_action_cats]); |
|
| 809 | - |
|
| 810 | - switch ($log_action) { |
|
| 811 | - case 'MOVE_LINKS_MOVE_CATS': |
|
| 812 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS_MOVE_CATS', time(), [$links_to_name, $subcats_to_name, $this->cat_data['cat_name']]); |
|
| 813 | - break; |
|
| 814 | - |
|
| 815 | - case 'MOVE_LINKS_CATS': |
|
| 816 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS_CATS', time(), [$links_to_name, $this->cat_data['cat_name']]); |
|
| 817 | - break; |
|
| 818 | - |
|
| 819 | - case 'LINKS_MOVE_CATS': |
|
| 820 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS_MOVE_CATS', time(), [$subcats_to_name, $this->cat_data['cat_name']]); |
|
| 821 | - break; |
|
| 822 | - |
|
| 823 | - case '_MOVE_CATS': |
|
| 824 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_CATS', time(), [$subcats_to_name, $this->cat_data['cat_name']]); |
|
| 825 | - break; |
|
| 826 | - |
|
| 827 | - case 'MOVE_LINKS_': |
|
| 828 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS', time(), [$links_to_name, $this->cat_data['cat_name']]); |
|
| 829 | - break; |
|
| 830 | - |
|
| 831 | - case 'LINKS_CATS': |
|
| 832 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS_CATS', time(), [$this->cat_data['cat_name']]); |
|
| 833 | - break; |
|
| 834 | - |
|
| 835 | - case '_CATS': |
|
| 836 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_CATS', time(), [$this->cat_data['cat_name']]); |
|
| 837 | - break; |
|
| 838 | - |
|
| 839 | - case 'LINKS_': |
|
| 840 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS', time(), [$this->cat_data['cat_name']]); |
|
| 841 | - break; |
|
| 842 | - |
|
| 843 | - default: |
|
| 844 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_CAT', time(), [$this->cat_data['cat_name']]); |
|
| 845 | - break; |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - return $this->errors; |
|
| 849 | - } |
|
| 850 | - |
|
| 851 | - /** |
|
| 852 | - * Move category content from one to another forum. |
|
| 853 | - * |
|
| 854 | - * @param int $from_id |
|
| 855 | - * @param int $to_id |
|
| 856 | - * |
|
| 857 | - * @return null |
|
| 858 | - */ |
|
| 859 | - private function _move_cat_content($from_id, $to_id) |
|
| 860 | - { |
|
| 861 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 772 | + $result = $this->db->sql_query($sql); |
|
| 773 | + $row = $this->db->sql_fetchrow($result); |
|
| 774 | + $this->db->sql_freeresult($result); |
|
| 775 | + |
|
| 776 | + if (!$row) { |
|
| 777 | + throw new \OutOfBoundsException('DIR_NO_CAT'); |
|
| 778 | + } else { |
|
| 779 | + $links_to_name = $row['cat_name']; |
|
| 780 | + $this->_move_cat_content($this->cat_id, $links_to_id); |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + if (count($this->errors)) { |
|
| 786 | + return $this->errors; |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + if ($action_subcats == 'delete') { |
|
| 790 | + $log_action_cats = 'CATS'; |
|
| 791 | + } elseif ($action_subcats == 'move') { |
|
| 792 | + if (!$subcats_to_id) { |
|
| 793 | + $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT']; |
|
| 794 | + } else { |
|
| 795 | + $log_action_cats = 'MOVE_CATS'; |
|
| 796 | + |
|
| 797 | + $subcats_to_name = $row['cat_name']; |
|
| 798 | + $this->nestedset_category->move_children($this->cat_id, $subcats_to_id); |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + if (count($this->errors)) { |
|
| 803 | + return $this->errors; |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + $this->nestedset_category->delete($this->cat_id); |
|
| 807 | + |
|
| 808 | + $log_action = implode('_', [$log_action_links, $log_action_cats]); |
|
| 809 | + |
|
| 810 | + switch ($log_action) { |
|
| 811 | + case 'MOVE_LINKS_MOVE_CATS': |
|
| 812 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS_MOVE_CATS', time(), [$links_to_name, $subcats_to_name, $this->cat_data['cat_name']]); |
|
| 813 | + break; |
|
| 814 | + |
|
| 815 | + case 'MOVE_LINKS_CATS': |
|
| 816 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS_CATS', time(), [$links_to_name, $this->cat_data['cat_name']]); |
|
| 817 | + break; |
|
| 818 | + |
|
| 819 | + case 'LINKS_MOVE_CATS': |
|
| 820 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS_MOVE_CATS', time(), [$subcats_to_name, $this->cat_data['cat_name']]); |
|
| 821 | + break; |
|
| 822 | + |
|
| 823 | + case '_MOVE_CATS': |
|
| 824 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_CATS', time(), [$subcats_to_name, $this->cat_data['cat_name']]); |
|
| 825 | + break; |
|
| 826 | + |
|
| 827 | + case 'MOVE_LINKS_': |
|
| 828 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS', time(), [$links_to_name, $this->cat_data['cat_name']]); |
|
| 829 | + break; |
|
| 830 | + |
|
| 831 | + case 'LINKS_CATS': |
|
| 832 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS_CATS', time(), [$this->cat_data['cat_name']]); |
|
| 833 | + break; |
|
| 834 | + |
|
| 835 | + case '_CATS': |
|
| 836 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_CATS', time(), [$this->cat_data['cat_name']]); |
|
| 837 | + break; |
|
| 838 | + |
|
| 839 | + case 'LINKS_': |
|
| 840 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_LINKS', time(), [$this->cat_data['cat_name']]); |
|
| 841 | + break; |
|
| 842 | + |
|
| 843 | + default: |
|
| 844 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_CAT', time(), [$this->cat_data['cat_name']]); |
|
| 845 | + break; |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + return $this->errors; |
|
| 849 | + } |
|
| 850 | + |
|
| 851 | + /** |
|
| 852 | + * Move category content from one to another forum. |
|
| 853 | + * |
|
| 854 | + * @param int $from_id |
|
| 855 | + * @param int $to_id |
|
| 856 | + * |
|
| 857 | + * @return null |
|
| 858 | + */ |
|
| 859 | + private function _move_cat_content($from_id, $to_id) |
|
| 860 | + { |
|
| 861 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 862 | 862 | SET link_cat = '.(int) $to_id.' |
| 863 | 863 | WHERE link_cat = '.(int) $from_id; |
| 864 | - $this->db->sql_query($sql); |
|
| 864 | + $this->db->sql_query($sql); |
|
| 865 | 865 | |
| 866 | - $sql = 'DELETE FROM '.DIR_WATCH_TABLE.' |
|
| 866 | + $sql = 'DELETE FROM '.DIR_WATCH_TABLE.' |
|
| 867 | 867 | WHERE cat_id = '.(int) $from_id; |
| 868 | - $this->db->sql_query($sql); |
|
| 869 | - |
|
| 870 | - $this->_sync_dir_cat($to_id); |
|
| 871 | - } |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * Delete category content. |
|
| 875 | - * |
|
| 876 | - * @return array |
|
| 877 | - */ |
|
| 878 | - private function _delete_cat_content() |
|
| 879 | - { |
|
| 880 | - $this->db->sql_transaction('begin'); |
|
| 881 | - |
|
| 882 | - // Before we remove anything we make sure we are able to adjust the post counts later. ;) |
|
| 883 | - $sql = 'SELECT link_id, link_banner |
|
| 868 | + $this->db->sql_query($sql); |
|
| 869 | + |
|
| 870 | + $this->_sync_dir_cat($to_id); |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * Delete category content. |
|
| 875 | + * |
|
| 876 | + * @return array |
|
| 877 | + */ |
|
| 878 | + private function _delete_cat_content() |
|
| 879 | + { |
|
| 880 | + $this->db->sql_transaction('begin'); |
|
| 881 | + |
|
| 882 | + // Before we remove anything we make sure we are able to adjust the post counts later. ;) |
|
| 883 | + $sql = 'SELECT link_id, link_banner |
|
| 884 | 884 | FROM '.DIR_LINK_TABLE.' |
| 885 | 885 | WHERE link_cat = '.(int) $this->cat_id; |
| 886 | - $result = $this->db->sql_query($sql); |
|
| 887 | - |
|
| 888 | - $link_ids = []; |
|
| 889 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 890 | - $link_ids[] = $row['link_id']; |
|
| 891 | - |
|
| 892 | - if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 893 | - $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner'])); |
|
| 894 | - |
|
| 895 | - if (file_exists($banner_img)) { |
|
| 896 | - @unlink($banner_img); |
|
| 897 | - } |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - $this->db->sql_freeresult($result); |
|
| 901 | - |
|
| 902 | - if (count($link_ids)) { |
|
| 903 | - // Delete links datas |
|
| 904 | - $link_datas_ary = [ |
|
| 905 | - DIR_COMMENT_TABLE => 'comment_link_id', |
|
| 906 | - DIR_VOTE_TABLE => 'vote_link_id', |
|
| 907 | - ]; |
|
| 908 | - |
|
| 909 | - foreach ($link_datas_ary as $table => $field) { |
|
| 910 | - $this->db->sql_query("DELETE FROM $table WHERE ".$this->db->sql_in_set($field, $link_ids)); |
|
| 911 | - } |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - // Delete cats datas |
|
| 915 | - $cat_datas_ary = [ |
|
| 916 | - DIR_LINK_TABLE => 'link_cat', |
|
| 917 | - DIR_WATCH_TABLE => 'cat_id', |
|
| 918 | - ]; |
|
| 919 | - |
|
| 920 | - foreach ($cat_datas_ary as $table => $field) { |
|
| 921 | - $this->db->sql_query("DELETE FROM $table WHERE $field = ".(int) $this->cat_id); |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - $this->db->sql_transaction('commit'); |
|
| 925 | - |
|
| 926 | - return []; |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - /** |
|
| 930 | - * Update links counter. |
|
| 931 | - * |
|
| 932 | - * @param int $cat_id The category ID |
|
| 933 | - * |
|
| 934 | - * @return null |
|
| 935 | - */ |
|
| 936 | - private function _sync_dir_cat($cat_id) |
|
| 937 | - { |
|
| 938 | - $sql = 'SELECT COUNT(link_id) AS num_links |
|
| 886 | + $result = $this->db->sql_query($sql); |
|
| 887 | + |
|
| 888 | + $link_ids = []; |
|
| 889 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 890 | + $link_ids[] = $row['link_id']; |
|
| 891 | + |
|
| 892 | + if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 893 | + $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner'])); |
|
| 894 | + |
|
| 895 | + if (file_exists($banner_img)) { |
|
| 896 | + @unlink($banner_img); |
|
| 897 | + } |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + $this->db->sql_freeresult($result); |
|
| 901 | + |
|
| 902 | + if (count($link_ids)) { |
|
| 903 | + // Delete links datas |
|
| 904 | + $link_datas_ary = [ |
|
| 905 | + DIR_COMMENT_TABLE => 'comment_link_id', |
|
| 906 | + DIR_VOTE_TABLE => 'vote_link_id', |
|
| 907 | + ]; |
|
| 908 | + |
|
| 909 | + foreach ($link_datas_ary as $table => $field) { |
|
| 910 | + $this->db->sql_query("DELETE FROM $table WHERE ".$this->db->sql_in_set($field, $link_ids)); |
|
| 911 | + } |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + // Delete cats datas |
|
| 915 | + $cat_datas_ary = [ |
|
| 916 | + DIR_LINK_TABLE => 'link_cat', |
|
| 917 | + DIR_WATCH_TABLE => 'cat_id', |
|
| 918 | + ]; |
|
| 919 | + |
|
| 920 | + foreach ($cat_datas_ary as $table => $field) { |
|
| 921 | + $this->db->sql_query("DELETE FROM $table WHERE $field = ".(int) $this->cat_id); |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + $this->db->sql_transaction('commit'); |
|
| 925 | + |
|
| 926 | + return []; |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + /** |
|
| 930 | + * Update links counter. |
|
| 931 | + * |
|
| 932 | + * @param int $cat_id The category ID |
|
| 933 | + * |
|
| 934 | + * @return null |
|
| 935 | + */ |
|
| 936 | + private function _sync_dir_cat($cat_id) |
|
| 937 | + { |
|
| 938 | + $sql = 'SELECT COUNT(link_id) AS num_links |
|
| 939 | 939 | FROM '.DIR_LINK_TABLE.' |
| 940 | 940 | WHERE link_cat = '.(int) $cat_id.' |
| 941 | 941 | AND link_active = 1'; |
| 942 | - $result = $this->db->sql_query($sql); |
|
| 943 | - $total_links = (int) $this->db->sql_fetchfield('num_links'); |
|
| 944 | - $this->db->sql_freeresult($result); |
|
| 942 | + $result = $this->db->sql_query($sql); |
|
| 943 | + $total_links = (int) $this->db->sql_fetchfield('num_links'); |
|
| 944 | + $this->db->sql_freeresult($result); |
|
| 945 | 945 | |
| 946 | - $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 946 | + $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 947 | 947 | SET cat_links = '.$total_links.' |
| 948 | 948 | WHERE cat_id = '.(int) $cat_id; |
| 949 | - $this->db->sql_query($sql); |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - /** |
|
| 953 | - * Update link data (note, vote, comment). |
|
| 954 | - * |
|
| 955 | - * @param int $start |
|
| 956 | - * @param int $stop |
|
| 957 | - * |
|
| 958 | - * @return null |
|
| 959 | - */ |
|
| 960 | - private function _sync_dir_links($start, $stop) |
|
| 961 | - { |
|
| 962 | - $sql_ary = [ |
|
| 963 | - 'link_comment' => 0, |
|
| 964 | - 'link_note' => 0, |
|
| 965 | - 'link_vote' => 0, |
|
| 966 | - ]; |
|
| 967 | - |
|
| 968 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 949 | + $this->db->sql_query($sql); |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + /** |
|
| 953 | + * Update link data (note, vote, comment). |
|
| 954 | + * |
|
| 955 | + * @param int $start |
|
| 956 | + * @param int $stop |
|
| 957 | + * |
|
| 958 | + * @return null |
|
| 959 | + */ |
|
| 960 | + private function _sync_dir_links($start, $stop) |
|
| 961 | + { |
|
| 962 | + $sql_ary = [ |
|
| 963 | + 'link_comment' => 0, |
|
| 964 | + 'link_note' => 0, |
|
| 965 | + 'link_vote' => 0, |
|
| 966 | + ]; |
|
| 967 | + |
|
| 968 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 969 | 969 | SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
| 970 | 970 | WHERE link_id BETWEEN '.(int) $start.' AND '.(int) $stop; |
| 971 | - $this->db->sql_query($sql); |
|
| 971 | + $this->db->sql_query($sql); |
|
| 972 | 972 | |
| 973 | - $sql = 'SELECT vote_link_id, COUNT(vote_note) AS nb_vote, SUM(vote_note) AS total FROM '.DIR_VOTE_TABLE.' |
|
| 973 | + $sql = 'SELECT vote_link_id, COUNT(vote_note) AS nb_vote, SUM(vote_note) AS total FROM '.DIR_VOTE_TABLE.' |
|
| 974 | 974 | WHERE vote_link_id BETWEEN '.(int) $start.' AND '.(int) $stop.' |
| 975 | 975 | GROUP BY vote_link_id'; |
| 976 | - $result = $this->db->sql_query($sql); |
|
| 977 | - while ($tmp = $this->db->sql_fetchrow($result)) { |
|
| 978 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 976 | + $result = $this->db->sql_query($sql); |
|
| 977 | + while ($tmp = $this->db->sql_fetchrow($result)) { |
|
| 978 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 979 | 979 | SET link_note = '.(int) $tmp['total'].', link_vote = '.(int) $tmp['nb_vote'].' |
| 980 | 980 | WHERE link_id = '.(int) $tmp['vote_link_id']; |
| 981 | - $this->db->sql_query($sql); |
|
| 982 | - } |
|
| 983 | - $this->db->sql_freeresult($result); |
|
| 981 | + $this->db->sql_query($sql); |
|
| 982 | + } |
|
| 983 | + $this->db->sql_freeresult($result); |
|
| 984 | 984 | |
| 985 | - $sql = 'SELECT comment_link_id, COUNT(comment_id) AS nb_comment |
|
| 985 | + $sql = 'SELECT comment_link_id, COUNT(comment_id) AS nb_comment |
|
| 986 | 986 | FROM '.DIR_COMMENT_TABLE.' |
| 987 | 987 | WHERE comment_link_id BETWEEN '.(int) $start.' AND '.(int) $stop.' |
| 988 | 988 | GROUP BY comment_link_id'; |
| 989 | - $result = $this->db->sql_query($sql); |
|
| 990 | - while ($tmp = $this->db->sql_fetchrow($result)) { |
|
| 991 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 989 | + $result = $this->db->sql_query($sql); |
|
| 990 | + while ($tmp = $this->db->sql_fetchrow($result)) { |
|
| 991 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 992 | 992 | SET link_comment = '.(int) $tmp['nb_comment'].' |
| 993 | 993 | WHERE link_id = '.(int) $tmp['comment_link_id']; |
| 994 | - $this->db->sql_query($sql); |
|
| 995 | - } |
|
| 996 | - $this->db->sql_freeresult($result); |
|
| 997 | - } |
|
| 998 | - |
|
| 999 | - /** |
|
| 1000 | - * Display icons drop-down list. |
|
| 1001 | - * |
|
| 1002 | - * @param string $icons_path |
|
| 1003 | - * @param string $img_selected |
|
| 1004 | - * |
|
| 1005 | - * @return string |
|
| 1006 | - */ |
|
| 1007 | - private function _get_dir_icon_list($icons_path, $img_selected) |
|
| 1008 | - { |
|
| 1009 | - $imglist = filelist($icons_path, ''); |
|
| 1010 | - $filename_list = '<option value="">----------</option>'; |
|
| 1011 | - |
|
| 1012 | - foreach ($imglist as $path => $img_ary) { |
|
| 1013 | - sort($img_ary); |
|
| 1014 | - |
|
| 1015 | - foreach ($img_ary as $img) { |
|
| 1016 | - $img = $path.$img; |
|
| 1017 | - $selected = ''; |
|
| 1018 | - |
|
| 1019 | - if (strlen($img) > 255) { |
|
| 1020 | - continue; |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - if ($img == $img_selected) { |
|
| 1024 | - $selected = ' selected="selected"'; |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $filename_list .= '<option value="'.htmlspecialchars($img).'"'.$selected.'>'.$img.'</option>'; |
|
| 1028 | - } |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - return $filename_list; |
|
| 1032 | - } |
|
| 994 | + $this->db->sql_query($sql); |
|
| 995 | + } |
|
| 996 | + $this->db->sql_freeresult($result); |
|
| 997 | + } |
|
| 998 | + |
|
| 999 | + /** |
|
| 1000 | + * Display icons drop-down list. |
|
| 1001 | + * |
|
| 1002 | + * @param string $icons_path |
|
| 1003 | + * @param string $img_selected |
|
| 1004 | + * |
|
| 1005 | + * @return string |
|
| 1006 | + */ |
|
| 1007 | + private function _get_dir_icon_list($icons_path, $img_selected) |
|
| 1008 | + { |
|
| 1009 | + $imglist = filelist($icons_path, ''); |
|
| 1010 | + $filename_list = '<option value="">----------</option>'; |
|
| 1011 | + |
|
| 1012 | + foreach ($imglist as $path => $img_ary) { |
|
| 1013 | + sort($img_ary); |
|
| 1014 | + |
|
| 1015 | + foreach ($img_ary as $img) { |
|
| 1016 | + $img = $path.$img; |
|
| 1017 | + $selected = ''; |
|
| 1018 | + |
|
| 1019 | + if (strlen($img) > 255) { |
|
| 1020 | + continue; |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + if ($img == $img_selected) { |
|
| 1024 | + $selected = ' selected="selected"'; |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $filename_list .= '<option value="'.htmlspecialchars($img).'"'.$selected.'>'.$img.'</option>'; |
|
| 1028 | + } |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + return $filename_list; |
|
| 1032 | + } |
|
| 1033 | 1033 | } |
@@ -9,294 +9,294 @@ |
||
| 9 | 9 | |
| 10 | 10 | class main |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | - protected $db; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\request\request */ |
|
| 16 | - protected $request; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\template\template */ |
|
| 19 | - protected $template; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\user */ |
|
| 22 | - protected $user; |
|
| 23 | - |
|
| 24 | - /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 25 | - protected $dir_helper; |
|
| 26 | - |
|
| 27 | - /** @var string Custom form action */ |
|
| 28 | - protected $u_action; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Constructor. |
|
| 32 | - * |
|
| 33 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 34 | - * @param \phpbb\request\request $request Request object |
|
| 35 | - * @param \phpbb\template\template $template Template object |
|
| 36 | - * @param \phpbb\user $user User object |
|
| 37 | - * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 38 | - */ |
|
| 39 | - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\helper $dir_helper) |
|
| 40 | - { |
|
| 41 | - $this->db = $db; |
|
| 42 | - $this->template = $template; |
|
| 43 | - $this->user = $user; |
|
| 44 | - $this->request = $request; |
|
| 45 | - $this->dir_helper = $dir_helper; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Display confirm box. |
|
| 50 | - * |
|
| 51 | - * @param string $action Requested action |
|
| 52 | - * |
|
| 53 | - * @return null |
|
| 54 | - */ |
|
| 55 | - public function display_confirm($action) |
|
| 56 | - { |
|
| 57 | - switch ($action) { |
|
| 58 | - case 'votes': |
|
| 59 | - $confirm = true; |
|
| 60 | - $confirm_lang = 'DIR_RESET_VOTES_CONFIRM'; |
|
| 61 | - break; |
|
| 62 | - |
|
| 63 | - case 'comments': |
|
| 64 | - $confirm = true; |
|
| 65 | - $confirm_lang = 'DIR_RESET_COMMENTS_CONFIRM'; |
|
| 66 | - break; |
|
| 67 | - |
|
| 68 | - case 'clicks': |
|
| 69 | - $confirm = true; |
|
| 70 | - $confirm_lang = 'DIR_RESET_CLICKS_CONFIRM'; |
|
| 71 | - break; |
|
| 72 | - |
|
| 73 | - case 'orphans': |
|
| 74 | - $confirm = true; |
|
| 75 | - $confirm_lang = 'DIR_DELETE_ORPHANS'; |
|
| 76 | - break; |
|
| 77 | - |
|
| 78 | - default: |
|
| 79 | - $confirm = false; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - if ($confirm) { |
|
| 83 | - confirm_box(false, $this->user->lang[$confirm_lang], build_hidden_fields([ |
|
| 84 | - 'action' => $action, |
|
| 85 | - ])); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Display phpBB Directory statistics. |
|
| 91 | - * |
|
| 92 | - * @return null |
|
| 93 | - */ |
|
| 94 | - public function display_stats() |
|
| 95 | - { |
|
| 96 | - // Count number of categories |
|
| 97 | - $sql = 'SELECT COUNT(cat_id) AS nb_cats |
|
| 12 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | + protected $db; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\request\request */ |
|
| 16 | + protected $request; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\template\template */ |
|
| 19 | + protected $template; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\user */ |
|
| 22 | + protected $user; |
|
| 23 | + |
|
| 24 | + /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 25 | + protected $dir_helper; |
|
| 26 | + |
|
| 27 | + /** @var string Custom form action */ |
|
| 28 | + protected $u_action; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Constructor. |
|
| 32 | + * |
|
| 33 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 34 | + * @param \phpbb\request\request $request Request object |
|
| 35 | + * @param \phpbb\template\template $template Template object |
|
| 36 | + * @param \phpbb\user $user User object |
|
| 37 | + * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 38 | + */ |
|
| 39 | + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\helper $dir_helper) |
|
| 40 | + { |
|
| 41 | + $this->db = $db; |
|
| 42 | + $this->template = $template; |
|
| 43 | + $this->user = $user; |
|
| 44 | + $this->request = $request; |
|
| 45 | + $this->dir_helper = $dir_helper; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Display confirm box. |
|
| 50 | + * |
|
| 51 | + * @param string $action Requested action |
|
| 52 | + * |
|
| 53 | + * @return null |
|
| 54 | + */ |
|
| 55 | + public function display_confirm($action) |
|
| 56 | + { |
|
| 57 | + switch ($action) { |
|
| 58 | + case 'votes': |
|
| 59 | + $confirm = true; |
|
| 60 | + $confirm_lang = 'DIR_RESET_VOTES_CONFIRM'; |
|
| 61 | + break; |
|
| 62 | + |
|
| 63 | + case 'comments': |
|
| 64 | + $confirm = true; |
|
| 65 | + $confirm_lang = 'DIR_RESET_COMMENTS_CONFIRM'; |
|
| 66 | + break; |
|
| 67 | + |
|
| 68 | + case 'clicks': |
|
| 69 | + $confirm = true; |
|
| 70 | + $confirm_lang = 'DIR_RESET_CLICKS_CONFIRM'; |
|
| 71 | + break; |
|
| 72 | + |
|
| 73 | + case 'orphans': |
|
| 74 | + $confirm = true; |
|
| 75 | + $confirm_lang = 'DIR_DELETE_ORPHANS'; |
|
| 76 | + break; |
|
| 77 | + |
|
| 78 | + default: |
|
| 79 | + $confirm = false; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + if ($confirm) { |
|
| 83 | + confirm_box(false, $this->user->lang[$confirm_lang], build_hidden_fields([ |
|
| 84 | + 'action' => $action, |
|
| 85 | + ])); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Display phpBB Directory statistics. |
|
| 91 | + * |
|
| 92 | + * @return null |
|
| 93 | + */ |
|
| 94 | + public function display_stats() |
|
| 95 | + { |
|
| 96 | + // Count number of categories |
|
| 97 | + $sql = 'SELECT COUNT(cat_id) AS nb_cats |
|
| 98 | 98 | FROM '.DIR_CAT_TABLE; |
| 99 | - $result = $this->db->sql_query($sql); |
|
| 100 | - $total_cats = (int) $this->db->sql_fetchfield('nb_cats'); |
|
| 101 | - $this->db->sql_freeresult($result); |
|
| 99 | + $result = $this->db->sql_query($sql); |
|
| 100 | + $total_cats = (int) $this->db->sql_fetchfield('nb_cats'); |
|
| 101 | + $this->db->sql_freeresult($result); |
|
| 102 | 102 | |
| 103 | - // Cont number of links |
|
| 104 | - $sql = 'SELECT link_id, link_active |
|
| 103 | + // Cont number of links |
|
| 104 | + $sql = 'SELECT link_id, link_active |
|
| 105 | 105 | FROM '.DIR_LINK_TABLE; |
| 106 | - $result = $this->db->sql_query($sql); |
|
| 107 | - $total_links = $waiting_links = 0; |
|
| 108 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 109 | - $total_links++; |
|
| 110 | - |
|
| 111 | - if (!$row['link_active']) { |
|
| 112 | - $waiting_links++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - $this->db->sql_freeresult($result); |
|
| 116 | - |
|
| 117 | - // Comments number calculating |
|
| 118 | - $sql = 'SELECT COUNT(comment_id) AS nb_comments |
|
| 106 | + $result = $this->db->sql_query($sql); |
|
| 107 | + $total_links = $waiting_links = 0; |
|
| 108 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 109 | + $total_links++; |
|
| 110 | + |
|
| 111 | + if (!$row['link_active']) { |
|
| 112 | + $waiting_links++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + $this->db->sql_freeresult($result); |
|
| 116 | + |
|
| 117 | + // Comments number calculating |
|
| 118 | + $sql = 'SELECT COUNT(comment_id) AS nb_comments |
|
| 119 | 119 | FROM '.DIR_COMMENT_TABLE; |
| 120 | - $result = $this->db->sql_query($sql); |
|
| 121 | - $total_comments = (int) $this->db->sql_fetchfield('nb_comments'); |
|
| 122 | - $this->db->sql_freeresult($result); |
|
| 120 | + $result = $this->db->sql_query($sql); |
|
| 121 | + $total_comments = (int) $this->db->sql_fetchfield('nb_comments'); |
|
| 122 | + $this->db->sql_freeresult($result); |
|
| 123 | 123 | |
| 124 | - // Votes number calculating |
|
| 125 | - $sql = 'SELECT COUNT(vote_id) AS nb_votes |
|
| 124 | + // Votes number calculating |
|
| 125 | + $sql = 'SELECT COUNT(vote_id) AS nb_votes |
|
| 126 | 126 | FROM '.DIR_VOTE_TABLE; |
| 127 | - $result = $this->db->sql_query($sql); |
|
| 128 | - $total_votes = (int) $this->db->sql_fetchfield('nb_votes'); |
|
| 129 | - $this->db->sql_freeresult($result); |
|
| 127 | + $result = $this->db->sql_query($sql); |
|
| 128 | + $total_votes = (int) $this->db->sql_fetchfield('nb_votes'); |
|
| 129 | + $this->db->sql_freeresult($result); |
|
| 130 | 130 | |
| 131 | - // Click number calculating |
|
| 132 | - $sql = 'SELECT SUM(link_view) AS nb_clicks |
|
| 131 | + // Click number calculating |
|
| 132 | + $sql = 'SELECT SUM(link_view) AS nb_clicks |
|
| 133 | 133 | FROM '.DIR_LINK_TABLE; |
| 134 | - $result = $this->db->sql_query($sql); |
|
| 135 | - $total_clicks = (int) $this->db->sql_fetchfield('nb_clicks'); |
|
| 136 | - $this->db->sql_freeresult($result); |
|
| 137 | - |
|
| 138 | - $banners_dir_size = 0; |
|
| 139 | - |
|
| 140 | - $banners_path = $this->dir_helper->get_banner_path(); |
|
| 141 | - |
|
| 142 | - if ($banners_dir = @opendir($banners_path)) { |
|
| 143 | - while (($file = readdir($banners_dir)) !== false) { |
|
| 144 | - if ($file[0] != '.' && $file[0] != '..' && strpos($file, 'index.') === false && strpos($file, '.db') === false) { |
|
| 145 | - $banners_dir_size += filesize($banners_path.$file); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - closedir($banners_dir); |
|
| 149 | - |
|
| 150 | - $banners_dir_size = get_formatted_filesize($banners_dir_size); |
|
| 151 | - } else { |
|
| 152 | - // Couldn't open banners dir. |
|
| 153 | - $banners_dir_size = $this->user->lang['NOT_AVAILABLE']; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $total_orphan = $this->_orphan_files(); |
|
| 157 | - |
|
| 158 | - $this->template->assign_vars([ |
|
| 159 | - 'U_ACTION' => $this->u_action, |
|
| 160 | - |
|
| 161 | - 'TOTAL_CATS' => $total_cats, |
|
| 162 | - 'TOTAL_LINKS' => $total_links - $waiting_links, |
|
| 163 | - 'WAITING_LINKS' => $waiting_links, |
|
| 164 | - 'TOTAL_COMMENTS' => $total_comments, |
|
| 165 | - 'TOTAL_VOTES' => $total_votes, |
|
| 166 | - 'TOTAL_CLICKS' => $total_clicks, |
|
| 167 | - 'TOTAL_ORPHANS' => $total_orphan, |
|
| 168 | - 'BANNERS_DIR_SIZE' => $banners_dir_size, |
|
| 169 | - ]); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Execute action requested. |
|
| 174 | - * |
|
| 175 | - * @param string $action Requested action |
|
| 176 | - * |
|
| 177 | - * @return null |
|
| 178 | - */ |
|
| 179 | - public function exec_action($action) |
|
| 180 | - { |
|
| 181 | - switch ($action) { |
|
| 182 | - case 'votes': |
|
| 183 | - switch ($this->db->get_sql_layer()) { |
|
| 184 | - case 'sqlite': |
|
| 185 | - case 'firebird': |
|
| 186 | - $this->db->sql_query('DELETE FROM '.DIR_VOTE_TABLE); |
|
| 187 | - break; |
|
| 188 | - |
|
| 189 | - default: |
|
| 190 | - $this->db->sql_query('TRUNCATE TABLE '.DIR_VOTE_TABLE); |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 134 | + $result = $this->db->sql_query($sql); |
|
| 135 | + $total_clicks = (int) $this->db->sql_fetchfield('nb_clicks'); |
|
| 136 | + $this->db->sql_freeresult($result); |
|
| 137 | + |
|
| 138 | + $banners_dir_size = 0; |
|
| 139 | + |
|
| 140 | + $banners_path = $this->dir_helper->get_banner_path(); |
|
| 141 | + |
|
| 142 | + if ($banners_dir = @opendir($banners_path)) { |
|
| 143 | + while (($file = readdir($banners_dir)) !== false) { |
|
| 144 | + if ($file[0] != '.' && $file[0] != '..' && strpos($file, 'index.') === false && strpos($file, '.db') === false) { |
|
| 145 | + $banners_dir_size += filesize($banners_path.$file); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + closedir($banners_dir); |
|
| 149 | + |
|
| 150 | + $banners_dir_size = get_formatted_filesize($banners_dir_size); |
|
| 151 | + } else { |
|
| 152 | + // Couldn't open banners dir. |
|
| 153 | + $banners_dir_size = $this->user->lang['NOT_AVAILABLE']; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $total_orphan = $this->_orphan_files(); |
|
| 157 | + |
|
| 158 | + $this->template->assign_vars([ |
|
| 159 | + 'U_ACTION' => $this->u_action, |
|
| 160 | + |
|
| 161 | + 'TOTAL_CATS' => $total_cats, |
|
| 162 | + 'TOTAL_LINKS' => $total_links - $waiting_links, |
|
| 163 | + 'WAITING_LINKS' => $waiting_links, |
|
| 164 | + 'TOTAL_COMMENTS' => $total_comments, |
|
| 165 | + 'TOTAL_VOTES' => $total_votes, |
|
| 166 | + 'TOTAL_CLICKS' => $total_clicks, |
|
| 167 | + 'TOTAL_ORPHANS' => $total_orphan, |
|
| 168 | + 'BANNERS_DIR_SIZE' => $banners_dir_size, |
|
| 169 | + ]); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Execute action requested. |
|
| 174 | + * |
|
| 175 | + * @param string $action Requested action |
|
| 176 | + * |
|
| 177 | + * @return null |
|
| 178 | + */ |
|
| 179 | + public function exec_action($action) |
|
| 180 | + { |
|
| 181 | + switch ($action) { |
|
| 182 | + case 'votes': |
|
| 183 | + switch ($this->db->get_sql_layer()) { |
|
| 184 | + case 'sqlite': |
|
| 185 | + case 'firebird': |
|
| 186 | + $this->db->sql_query('DELETE FROM '.DIR_VOTE_TABLE); |
|
| 187 | + break; |
|
| 188 | + |
|
| 189 | + default: |
|
| 190 | + $this->db->sql_query('TRUNCATE TABLE '.DIR_VOTE_TABLE); |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 195 | 195 | SET link_vote = 0, link_note = 0'; |
| 196 | - $this->db->sql_query($sql); |
|
| 197 | - |
|
| 198 | - if ($this->request->is_ajax()) { |
|
| 199 | - trigger_error('DIR_RESET_VOTES_SUCCESS'); |
|
| 200 | - } |
|
| 201 | - break; |
|
| 202 | - |
|
| 203 | - case 'comments': |
|
| 204 | - switch ($this->db->get_sql_layer()) { |
|
| 205 | - case 'sqlite': |
|
| 206 | - case 'firebird': |
|
| 207 | - $this->db->sql_query('DELETE FROM '.DIR_COMMENT_TABLE); |
|
| 208 | - break; |
|
| 209 | - |
|
| 210 | - default: |
|
| 211 | - $this->db->sql_query('TRUNCATE TABLE '.DIR_COMMENT_TABLE); |
|
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 196 | + $this->db->sql_query($sql); |
|
| 197 | + |
|
| 198 | + if ($this->request->is_ajax()) { |
|
| 199 | + trigger_error('DIR_RESET_VOTES_SUCCESS'); |
|
| 200 | + } |
|
| 201 | + break; |
|
| 202 | + |
|
| 203 | + case 'comments': |
|
| 204 | + switch ($this->db->get_sql_layer()) { |
|
| 205 | + case 'sqlite': |
|
| 206 | + case 'firebird': |
|
| 207 | + $this->db->sql_query('DELETE FROM '.DIR_COMMENT_TABLE); |
|
| 208 | + break; |
|
| 209 | + |
|
| 210 | + default: |
|
| 211 | + $this->db->sql_query('TRUNCATE TABLE '.DIR_COMMENT_TABLE); |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 216 | 216 | SET link_comment = 0'; |
| 217 | - $this->db->sql_query($sql); |
|
| 217 | + $this->db->sql_query($sql); |
|
| 218 | 218 | |
| 219 | - if ($this->request->is_ajax()) { |
|
| 220 | - trigger_error('DIR_RESET_COMMENTS_SUCCESS'); |
|
| 221 | - } |
|
| 219 | + if ($this->request->is_ajax()) { |
|
| 220 | + trigger_error('DIR_RESET_COMMENTS_SUCCESS'); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - break; |
|
| 223 | + break; |
|
| 224 | 224 | |
| 225 | - case 'clicks': |
|
| 226 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 225 | + case 'clicks': |
|
| 226 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 227 | 227 | SET link_view = 0'; |
| 228 | - $this->db->sql_query($sql); |
|
| 229 | - |
|
| 230 | - if ($this->request->is_ajax()) { |
|
| 231 | - trigger_error('DIR_RESET_CLICKS_SUCCESS'); |
|
| 232 | - } |
|
| 233 | - break; |
|
| 234 | - |
|
| 235 | - case 'orphans': |
|
| 236 | - $this->_orphan_files(true); |
|
| 237 | - |
|
| 238 | - if ($this->request->is_ajax()) { |
|
| 239 | - trigger_error('DIR_DELETE_ORPHANS_SUCCESS'); |
|
| 240 | - } |
|
| 241 | - break; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Set page url. |
|
| 247 | - * |
|
| 248 | - * @param string $u_action Custom form action |
|
| 249 | - * |
|
| 250 | - * @return null |
|
| 251 | - */ |
|
| 252 | - public function set_page_url($u_action) |
|
| 253 | - { |
|
| 254 | - $this->u_action = $u_action; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Get orphan banners. |
|
| 259 | - * |
|
| 260 | - * @param bool $delete True if we want to delete banners, else false |
|
| 261 | - * |
|
| 262 | - * @return null|int Number of orphan files, else null |
|
| 263 | - */ |
|
| 264 | - private function _orphan_files($delete = false) |
|
| 265 | - { |
|
| 266 | - $banner_path = $this->dir_helper->get_banner_path(); |
|
| 267 | - $imglist = filelist($banner_path); |
|
| 268 | - $physical_files = $logical_files = $orphan_files = []; |
|
| 269 | - |
|
| 270 | - if (!empty($imglist[''])) { |
|
| 271 | - $imglist = array_values($imglist); |
|
| 272 | - $imglist = $imglist[0]; |
|
| 273 | - |
|
| 274 | - foreach ($imglist as $img) { |
|
| 275 | - $physical_files[] = $img; |
|
| 276 | - } |
|
| 277 | - $sql = 'SELECT link_banner FROM '.DIR_LINK_TABLE.' |
|
| 228 | + $this->db->sql_query($sql); |
|
| 229 | + |
|
| 230 | + if ($this->request->is_ajax()) { |
|
| 231 | + trigger_error('DIR_RESET_CLICKS_SUCCESS'); |
|
| 232 | + } |
|
| 233 | + break; |
|
| 234 | + |
|
| 235 | + case 'orphans': |
|
| 236 | + $this->_orphan_files(true); |
|
| 237 | + |
|
| 238 | + if ($this->request->is_ajax()) { |
|
| 239 | + trigger_error('DIR_DELETE_ORPHANS_SUCCESS'); |
|
| 240 | + } |
|
| 241 | + break; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Set page url. |
|
| 247 | + * |
|
| 248 | + * @param string $u_action Custom form action |
|
| 249 | + * |
|
| 250 | + * @return null |
|
| 251 | + */ |
|
| 252 | + public function set_page_url($u_action) |
|
| 253 | + { |
|
| 254 | + $this->u_action = $u_action; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Get orphan banners. |
|
| 259 | + * |
|
| 260 | + * @param bool $delete True if we want to delete banners, else false |
|
| 261 | + * |
|
| 262 | + * @return null|int Number of orphan files, else null |
|
| 263 | + */ |
|
| 264 | + private function _orphan_files($delete = false) |
|
| 265 | + { |
|
| 266 | + $banner_path = $this->dir_helper->get_banner_path(); |
|
| 267 | + $imglist = filelist($banner_path); |
|
| 268 | + $physical_files = $logical_files = $orphan_files = []; |
|
| 269 | + |
|
| 270 | + if (!empty($imglist[''])) { |
|
| 271 | + $imglist = array_values($imglist); |
|
| 272 | + $imglist = $imglist[0]; |
|
| 273 | + |
|
| 274 | + foreach ($imglist as $img) { |
|
| 275 | + $physical_files[] = $img; |
|
| 276 | + } |
|
| 277 | + $sql = 'SELECT link_banner FROM '.DIR_LINK_TABLE.' |
|
| 278 | 278 | WHERE link_banner <> \'\''; |
| 279 | - $result = $this->db->sql_query($sql); |
|
| 280 | - |
|
| 281 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 282 | - if (!preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 283 | - $logical_files[] = basename($row['link_banner']); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - $this->db->sql_freeresult($result); |
|
| 287 | - |
|
| 288 | - $orphan_files = array_diff($physical_files, $logical_files); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (!$delete) { |
|
| 292 | - return count($orphan_files); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $dh = @opendir($banner_path); |
|
| 296 | - while (($file = readdir($dh)) !== false) { |
|
| 297 | - if (in_array($file, $orphan_files)) { |
|
| 298 | - @unlink($this->dir_helper->get_banner_path($file)); |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 279 | + $result = $this->db->sql_query($sql); |
|
| 280 | + |
|
| 281 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 282 | + if (!preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 283 | + $logical_files[] = basename($row['link_banner']); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + $this->db->sql_freeresult($result); |
|
| 287 | + |
|
| 288 | + $orphan_files = array_diff($physical_files, $logical_files); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (!$delete) { |
|
| 292 | + return count($orphan_files); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $dh = @opendir($banner_path); |
|
| 296 | + while (($file = readdir($dh)) !== false) { |
|
| 297 | + if (in_array($file, $orphan_files)) { |
|
| 298 | + @unlink($this->dir_helper->get_banner_path($file)); |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | 302 | } |
@@ -9,216 +9,216 @@ |
||
| 9 | 9 | |
| 10 | 10 | class settings |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\config\config */ |
|
| 13 | - protected $config; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\log\log */ |
|
| 16 | - protected $log; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\request\request */ |
|
| 19 | - protected $request; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\template\template */ |
|
| 22 | - protected $template; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\user */ |
|
| 25 | - protected $user; |
|
| 26 | - |
|
| 27 | - /** @var string Custom form action */ |
|
| 28 | - protected $u_action; |
|
| 29 | - |
|
| 30 | - /** @var array */ |
|
| 31 | - private $new_config; |
|
| 32 | - |
|
| 33 | - /** @var array */ |
|
| 34 | - private $display_vars; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Constructor. |
|
| 38 | - * |
|
| 39 | - * @param \phpbb\config\config $config Config object |
|
| 40 | - * @param \phpbb\log\log $log Log object |
|
| 41 | - * @param \phpbb\request\request $request Request object |
|
| 42 | - * @param \phpbb\template\template $template Template object |
|
| 43 | - * @param \phpbb\user $user User object |
|
| 44 | - */ |
|
| 45 | - public function __construct(\phpbb\config\config $config, \phpbb\log\log $log, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user) |
|
| 46 | - { |
|
| 47 | - $this->config = $config; |
|
| 48 | - $this->log = $log; |
|
| 49 | - $this->template = $template; |
|
| 50 | - $this->user = $user; |
|
| 51 | - $this->request = $request; |
|
| 52 | - |
|
| 53 | - $this->_generate_config(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Display config page. |
|
| 58 | - * |
|
| 59 | - * @return null |
|
| 60 | - */ |
|
| 61 | - public function display_config() |
|
| 62 | - { |
|
| 63 | - // Output relevant page |
|
| 64 | - foreach ($this->display_vars['vars'] as $config_key => $vars) { |
|
| 65 | - if (!is_array($vars) && strpos($config_key, 'legend') === false) { |
|
| 66 | - continue; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if (strpos($config_key, 'legend') !== false) { |
|
| 70 | - $this->template->assign_block_vars('options', [ |
|
| 71 | - 'S_LEGEND' => true, |
|
| 72 | - 'LEGEND' => (isset($this->user->lang[$vars])) ? $this->user->lang[$vars] : $vars, ] |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - continue; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $type = explode(':', $vars['type']); |
|
| 79 | - |
|
| 80 | - $l_explain = ''; |
|
| 81 | - if ($vars['explain'] && isset($vars['lang_explain'])) { |
|
| 82 | - $l_explain = (isset($this->user->lang[$vars['lang_explain']])) ? $this->user->lang[$vars['lang_explain']] : $vars['lang_explain']; |
|
| 83 | - } elseif ($vars['explain']) { |
|
| 84 | - $l_explain = (isset($this->user->lang[$vars['lang'].'_EXPLAIN'])) ? $this->user->lang[$vars['lang'].'_EXPLAIN'] : ''; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $this->template->assign_block_vars('options', [ |
|
| 88 | - 'KEY' => $config_key, |
|
| 89 | - 'TITLE' => (isset($this->user->lang[$vars['lang']])) ? $this->user->lang[$vars['lang']] : $vars['lang'], |
|
| 90 | - 'S_EXPLAIN' => $vars['explain'], |
|
| 91 | - 'TITLE_EXPLAIN' => $l_explain, |
|
| 92 | - 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars), |
|
| 93 | - ]); |
|
| 94 | - |
|
| 95 | - unset($this->display_vars['vars'][$config_key]); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Validate config vars and update config table if needed. |
|
| 101 | - * |
|
| 102 | - * @return null |
|
| 103 | - */ |
|
| 104 | - public function process() |
|
| 105 | - { |
|
| 106 | - $submit = ($this->request->is_set_post('submit')) ? true : false; |
|
| 107 | - |
|
| 108 | - $this->new_config = $this->config; |
|
| 109 | - $cfg_array = ($this->request->is_set('config')) ? $this->request->variable('config', ['' => ''], true) : $this->new_config; |
|
| 110 | - $error = []; |
|
| 111 | - |
|
| 112 | - // We validate the complete config if whished |
|
| 113 | - validate_config_vars($this->display_vars['vars'], $cfg_array, $error); |
|
| 114 | - |
|
| 115 | - // Do not write values if there is an error |
|
| 116 | - if (count($error)) { |
|
| 117 | - $submit = false; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... |
|
| 121 | - foreach ($this->display_vars['vars'] as $config_name => $null) { |
|
| 122 | - if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { |
|
| 123 | - continue; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; |
|
| 127 | - |
|
| 128 | - if ($config_name == 'dir_banner_filesize') { |
|
| 129 | - $size_var = $this->request->variable($config_name, ''); |
|
| 130 | - $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ($submit) { |
|
| 134 | - $this->config->set($config_name, $config_value); |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($submit) { |
|
| 139 | - $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'DIR_CONFIG_SETTINGS'); |
|
| 140 | - |
|
| 141 | - trigger_error($this->user->lang['CONFIG_UPDATED'].adm_back_link($this->u_action)); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $this->template->assign_vars([ |
|
| 145 | - 'L_TITLE' => $this->user->lang[$this->display_vars['title']], |
|
| 146 | - 'L_TITLE_EXPLAIN' => $this->user->lang[$this->display_vars['title'].'_EXPLAIN'], |
|
| 147 | - |
|
| 148 | - 'S_ERROR' => (count($error)) ? true : false, |
|
| 149 | - 'ERROR_MSG' => implode('<br />', $error), |
|
| 150 | - |
|
| 151 | - 'U_ACTION' => $this->u_action, ] |
|
| 152 | - ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Set page url. |
|
| 157 | - * |
|
| 158 | - * @param string $u_action Custom form action |
|
| 159 | - * |
|
| 160 | - * @return null |
|
| 161 | - */ |
|
| 162 | - public function set_page_url($u_action) |
|
| 163 | - { |
|
| 164 | - $this->u_action = $u_action; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Build config matrice. |
|
| 169 | - * |
|
| 170 | - * @return null |
|
| 171 | - */ |
|
| 172 | - private function _generate_config() |
|
| 173 | - { |
|
| 174 | - $this->display_vars = [ |
|
| 175 | - 'title' => 'ACP_DIRECTORY_SETTINGS', |
|
| 176 | - 'vars' => [ |
|
| 177 | - 'legend1' => 'DIR_PARAM', |
|
| 178 | - |
|
| 179 | - 'dir_banner_width' => '', |
|
| 180 | - 'dir_banner_height' => '', |
|
| 181 | - |
|
| 182 | - 'dir_mail' => ['lang' => 'DIR_MAIL_VALIDATION', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 183 | - 'dir_activ_checkurl' => ['lang' => 'DIR_ACTIVE_CHECK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 184 | - 'dir_activ_flag' => ['lang' => 'DIR_ACTIV_FLAG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 185 | - 'dir_activ_rss' => ['lang' => 'DIR_ACTIV_RSS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 186 | - 'dir_activ_pagerank' => ['lang' => 'DIR_ACTIV_PAGERANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 187 | - 'dir_show' => ['lang' => 'DIR_SHOW', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false], |
|
| 188 | - 'dir_length_describe' => ['lang' => 'DIR_MAX_DESC', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 189 | - 'dir_new_time' => ['lang' => 'DIR_NEW_TIME', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => true], |
|
| 190 | - 'dir_default_order' => ['lang' => 'DIR_DEFAULT_ORDER', 'validate' => 'string', 'type' => 'select', 'explain' => true, 'method' => 'get_order_list', 'params' => ['{CONFIG_VALUE}']], |
|
| 191 | - |
|
| 192 | - 'legend2' => 'DIR_RECENT_GUEST', |
|
| 193 | - 'dir_recent_block' => ['lang' => 'DIR_RECENT_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 194 | - 'dir_recent_rows' => ['lang' => 'DIR_RECENT_ROWS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 195 | - 'dir_recent_columns' => ['lang' => 'DIR_RECENT_COLUMNS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 196 | - 'dir_recent_exclude' => ['lang' => 'DIR_RECENT_EXCLUDE', 'validate' => 'string', 'type' => 'text:6:99', 'explain' => true], |
|
| 197 | - |
|
| 198 | - 'legend3' => 'DIR_ADD_GUEST', |
|
| 199 | - 'dir_visual_confirm' => ['lang' => 'DIR_VISUAL_CONFIRM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 200 | - 'dir_visual_confirm_max_attempts' => ['lang' => 'DIR_MAX_ADD_ATTEMPTS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true], |
|
| 201 | - |
|
| 202 | - 'legend4' => 'DIR_THUMB_PARAM', |
|
| 203 | - 'dir_activ_thumb' => ['lang' => 'DIR_ACTIVE_THUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 204 | - 'dir_activ_thumb_remote' => ['lang' => 'DIR_ACTIVE_THUMB_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 205 | - 'dir_thumb_service' => ['lang' => 'DIR_THUMB_SERVICE', 'validate' => 'string', 'type' => 'select', 'explain' => true, 'method' => 'get_thumb_service_list', 'params' => ['{CONFIG_VALUE}']], |
|
| 206 | - 'dir_thumb_service_reverse' => ['lang' => 'DIR_THUMB_SERVICE_REVERSE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 207 | - |
|
| 208 | - 'legend5' => 'DIR_COMM_PARAM', |
|
| 209 | - 'dir_allow_bbcode' => ['lang' => 'DIR_ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 210 | - 'dir_allow_flash' => ['lang' => 'DIR_ALLOW_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 211 | - 'dir_allow_links' => ['lang' => 'DIR_ALLOW_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 212 | - 'dir_allow_smilies' => ['lang' => 'DIR_ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 213 | - 'dir_length_comments' => ['lang' => 'DIR_LENGTH_COMMENTS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => true], |
|
| 214 | - 'dir_comments_per_page' => ['lang' => 'DIR_COMM_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false], |
|
| 215 | - |
|
| 216 | - 'legend6' => 'DIR_BANN_PARAM', |
|
| 217 | - 'dir_activ_banner' => ['lang' => 'DIR_ACTIV_BANNER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 218 | - 'dir_banner' => ['lang' => 'DIR_MAX_BANN', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' '.$this->user->lang['PIXEL']], |
|
| 219 | - 'dir_banner_filesize' => ['lang' => 'DIR_MAX_SIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true], |
|
| 220 | - 'dir_storage_banner' => ['lang' => 'DIR_STORAGE_BANNER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 221 | - ], |
|
| 222 | - ]; |
|
| 223 | - } |
|
| 12 | + /** @var \phpbb\config\config */ |
|
| 13 | + protected $config; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\log\log */ |
|
| 16 | + protected $log; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\request\request */ |
|
| 19 | + protected $request; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\template\template */ |
|
| 22 | + protected $template; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\user */ |
|
| 25 | + protected $user; |
|
| 26 | + |
|
| 27 | + /** @var string Custom form action */ |
|
| 28 | + protected $u_action; |
|
| 29 | + |
|
| 30 | + /** @var array */ |
|
| 31 | + private $new_config; |
|
| 32 | + |
|
| 33 | + /** @var array */ |
|
| 34 | + private $display_vars; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Constructor. |
|
| 38 | + * |
|
| 39 | + * @param \phpbb\config\config $config Config object |
|
| 40 | + * @param \phpbb\log\log $log Log object |
|
| 41 | + * @param \phpbb\request\request $request Request object |
|
| 42 | + * @param \phpbb\template\template $template Template object |
|
| 43 | + * @param \phpbb\user $user User object |
|
| 44 | + */ |
|
| 45 | + public function __construct(\phpbb\config\config $config, \phpbb\log\log $log, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user) |
|
| 46 | + { |
|
| 47 | + $this->config = $config; |
|
| 48 | + $this->log = $log; |
|
| 49 | + $this->template = $template; |
|
| 50 | + $this->user = $user; |
|
| 51 | + $this->request = $request; |
|
| 52 | + |
|
| 53 | + $this->_generate_config(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Display config page. |
|
| 58 | + * |
|
| 59 | + * @return null |
|
| 60 | + */ |
|
| 61 | + public function display_config() |
|
| 62 | + { |
|
| 63 | + // Output relevant page |
|
| 64 | + foreach ($this->display_vars['vars'] as $config_key => $vars) { |
|
| 65 | + if (!is_array($vars) && strpos($config_key, 'legend') === false) { |
|
| 66 | + continue; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if (strpos($config_key, 'legend') !== false) { |
|
| 70 | + $this->template->assign_block_vars('options', [ |
|
| 71 | + 'S_LEGEND' => true, |
|
| 72 | + 'LEGEND' => (isset($this->user->lang[$vars])) ? $this->user->lang[$vars] : $vars, ] |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + continue; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $type = explode(':', $vars['type']); |
|
| 79 | + |
|
| 80 | + $l_explain = ''; |
|
| 81 | + if ($vars['explain'] && isset($vars['lang_explain'])) { |
|
| 82 | + $l_explain = (isset($this->user->lang[$vars['lang_explain']])) ? $this->user->lang[$vars['lang_explain']] : $vars['lang_explain']; |
|
| 83 | + } elseif ($vars['explain']) { |
|
| 84 | + $l_explain = (isset($this->user->lang[$vars['lang'].'_EXPLAIN'])) ? $this->user->lang[$vars['lang'].'_EXPLAIN'] : ''; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $this->template->assign_block_vars('options', [ |
|
| 88 | + 'KEY' => $config_key, |
|
| 89 | + 'TITLE' => (isset($this->user->lang[$vars['lang']])) ? $this->user->lang[$vars['lang']] : $vars['lang'], |
|
| 90 | + 'S_EXPLAIN' => $vars['explain'], |
|
| 91 | + 'TITLE_EXPLAIN' => $l_explain, |
|
| 92 | + 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars), |
|
| 93 | + ]); |
|
| 94 | + |
|
| 95 | + unset($this->display_vars['vars'][$config_key]); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Validate config vars and update config table if needed. |
|
| 101 | + * |
|
| 102 | + * @return null |
|
| 103 | + */ |
|
| 104 | + public function process() |
|
| 105 | + { |
|
| 106 | + $submit = ($this->request->is_set_post('submit')) ? true : false; |
|
| 107 | + |
|
| 108 | + $this->new_config = $this->config; |
|
| 109 | + $cfg_array = ($this->request->is_set('config')) ? $this->request->variable('config', ['' => ''], true) : $this->new_config; |
|
| 110 | + $error = []; |
|
| 111 | + |
|
| 112 | + // We validate the complete config if whished |
|
| 113 | + validate_config_vars($this->display_vars['vars'], $cfg_array, $error); |
|
| 114 | + |
|
| 115 | + // Do not write values if there is an error |
|
| 116 | + if (count($error)) { |
|
| 117 | + $submit = false; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... |
|
| 121 | + foreach ($this->display_vars['vars'] as $config_name => $null) { |
|
| 122 | + if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { |
|
| 123 | + continue; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; |
|
| 127 | + |
|
| 128 | + if ($config_name == 'dir_banner_filesize') { |
|
| 129 | + $size_var = $this->request->variable($config_name, ''); |
|
| 130 | + $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ($submit) { |
|
| 134 | + $this->config->set($config_name, $config_value); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($submit) { |
|
| 139 | + $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'DIR_CONFIG_SETTINGS'); |
|
| 140 | + |
|
| 141 | + trigger_error($this->user->lang['CONFIG_UPDATED'].adm_back_link($this->u_action)); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $this->template->assign_vars([ |
|
| 145 | + 'L_TITLE' => $this->user->lang[$this->display_vars['title']], |
|
| 146 | + 'L_TITLE_EXPLAIN' => $this->user->lang[$this->display_vars['title'].'_EXPLAIN'], |
|
| 147 | + |
|
| 148 | + 'S_ERROR' => (count($error)) ? true : false, |
|
| 149 | + 'ERROR_MSG' => implode('<br />', $error), |
|
| 150 | + |
|
| 151 | + 'U_ACTION' => $this->u_action, ] |
|
| 152 | + ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Set page url. |
|
| 157 | + * |
|
| 158 | + * @param string $u_action Custom form action |
|
| 159 | + * |
|
| 160 | + * @return null |
|
| 161 | + */ |
|
| 162 | + public function set_page_url($u_action) |
|
| 163 | + { |
|
| 164 | + $this->u_action = $u_action; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Build config matrice. |
|
| 169 | + * |
|
| 170 | + * @return null |
|
| 171 | + */ |
|
| 172 | + private function _generate_config() |
|
| 173 | + { |
|
| 174 | + $this->display_vars = [ |
|
| 175 | + 'title' => 'ACP_DIRECTORY_SETTINGS', |
|
| 176 | + 'vars' => [ |
|
| 177 | + 'legend1' => 'DIR_PARAM', |
|
| 178 | + |
|
| 179 | + 'dir_banner_width' => '', |
|
| 180 | + 'dir_banner_height' => '', |
|
| 181 | + |
|
| 182 | + 'dir_mail' => ['lang' => 'DIR_MAIL_VALIDATION', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 183 | + 'dir_activ_checkurl' => ['lang' => 'DIR_ACTIVE_CHECK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 184 | + 'dir_activ_flag' => ['lang' => 'DIR_ACTIV_FLAG', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 185 | + 'dir_activ_rss' => ['lang' => 'DIR_ACTIV_RSS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 186 | + 'dir_activ_pagerank' => ['lang' => 'DIR_ACTIV_PAGERANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 187 | + 'dir_show' => ['lang' => 'DIR_SHOW', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false], |
|
| 188 | + 'dir_length_describe' => ['lang' => 'DIR_MAX_DESC', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 189 | + 'dir_new_time' => ['lang' => 'DIR_NEW_TIME', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => true], |
|
| 190 | + 'dir_default_order' => ['lang' => 'DIR_DEFAULT_ORDER', 'validate' => 'string', 'type' => 'select', 'explain' => true, 'method' => 'get_order_list', 'params' => ['{CONFIG_VALUE}']], |
|
| 191 | + |
|
| 192 | + 'legend2' => 'DIR_RECENT_GUEST', |
|
| 193 | + 'dir_recent_block' => ['lang' => 'DIR_RECENT_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 194 | + 'dir_recent_rows' => ['lang' => 'DIR_RECENT_ROWS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 195 | + 'dir_recent_columns' => ['lang' => 'DIR_RECENT_COLUMNS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => false], |
|
| 196 | + 'dir_recent_exclude' => ['lang' => 'DIR_RECENT_EXCLUDE', 'validate' => 'string', 'type' => 'text:6:99', 'explain' => true], |
|
| 197 | + |
|
| 198 | + 'legend3' => 'DIR_ADD_GUEST', |
|
| 199 | + 'dir_visual_confirm' => ['lang' => 'DIR_VISUAL_CONFIRM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 200 | + 'dir_visual_confirm_max_attempts' => ['lang' => 'DIR_MAX_ADD_ATTEMPTS', 'validate' => 'int:0:9999', 'type' => 'number:0:9999', 'explain' => true], |
|
| 201 | + |
|
| 202 | + 'legend4' => 'DIR_THUMB_PARAM', |
|
| 203 | + 'dir_activ_thumb' => ['lang' => 'DIR_ACTIVE_THUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 204 | + 'dir_activ_thumb_remote' => ['lang' => 'DIR_ACTIVE_THUMB_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 205 | + 'dir_thumb_service' => ['lang' => 'DIR_THUMB_SERVICE', 'validate' => 'string', 'type' => 'select', 'explain' => true, 'method' => 'get_thumb_service_list', 'params' => ['{CONFIG_VALUE}']], |
|
| 206 | + 'dir_thumb_service_reverse' => ['lang' => 'DIR_THUMB_SERVICE_REVERSE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 207 | + |
|
| 208 | + 'legend5' => 'DIR_COMM_PARAM', |
|
| 209 | + 'dir_allow_bbcode' => ['lang' => 'DIR_ALLOW_BBCODE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 210 | + 'dir_allow_flash' => ['lang' => 'DIR_ALLOW_FLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 211 | + 'dir_allow_links' => ['lang' => 'DIR_ALLOW_LINKS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 212 | + 'dir_allow_smilies' => ['lang' => 'DIR_ALLOW_SMILIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 213 | + 'dir_length_comments' => ['lang' => 'DIR_LENGTH_COMMENTS', 'validate' => 'int:1:999', 'type' => 'number:1:999', 'explain' => true], |
|
| 214 | + 'dir_comments_per_page' => ['lang' => 'DIR_COMM_PER_PAGE', 'validate' => 'int:1:9999', 'type' => 'number:1:9999', 'explain' => false], |
|
| 215 | + |
|
| 216 | + 'legend6' => 'DIR_BANN_PARAM', |
|
| 217 | + 'dir_activ_banner' => ['lang' => 'DIR_ACTIV_BANNER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], |
|
| 218 | + 'dir_banner' => ['lang' => 'DIR_MAX_BANN', 'validate' => 'int:0', 'type' => 'dimension:0', 'explain' => true, 'append' => ' '.$this->user->lang['PIXEL']], |
|
| 219 | + 'dir_banner_filesize' => ['lang' => 'DIR_MAX_SIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true], |
|
| 220 | + 'dir_storage_banner' => ['lang' => 'DIR_STORAGE_BANNER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], |
|
| 221 | + ], |
|
| 222 | + ]; |
|
| 223 | + } |
|
| 224 | 224 | } |
@@ -9,406 +9,406 @@ |
||
| 9 | 9 | |
| 10 | 10 | class validation |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\config\config */ |
|
| 13 | - protected $config; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 16 | - protected $db; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\pagination */ |
|
| 19 | - protected $pagination; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\log\log */ |
|
| 22 | - protected $phpbb_log; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\notification\manager */ |
|
| 25 | - protected $notification; |
|
| 26 | - |
|
| 27 | - /** @var \phpbb\request\request */ |
|
| 28 | - protected $request; |
|
| 29 | - |
|
| 30 | - /** @var \phpbb\template\template */ |
|
| 31 | - protected $template; |
|
| 32 | - |
|
| 33 | - /** @var \phpbb\user */ |
|
| 34 | - protected $user; |
|
| 35 | - |
|
| 36 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 37 | - protected $categorie; |
|
| 38 | - |
|
| 39 | - /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 40 | - protected $dir_helper; |
|
| 41 | - |
|
| 42 | - /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 43 | - protected $link; |
|
| 44 | - |
|
| 45 | - /** @var string phpBB root path */ |
|
| 46 | - protected $root_path; |
|
| 47 | - |
|
| 48 | - /** @var string phpEx */ |
|
| 49 | - protected $php_ext; |
|
| 50 | - |
|
| 51 | - /** @var string Custom form action */ |
|
| 52 | - protected $u_action; |
|
| 53 | - |
|
| 54 | - /** @var string */ |
|
| 55 | - private $action; |
|
| 56 | - |
|
| 57 | - /** @var array */ |
|
| 58 | - private $affected_link_name = []; |
|
| 59 | - |
|
| 60 | - /** @var array */ |
|
| 61 | - private $cat_data = []; |
|
| 62 | - |
|
| 63 | - /** @var array */ |
|
| 64 | - private $links_data; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Constructor. |
|
| 68 | - * |
|
| 69 | - * @param \phpbb\config\config $config Config object |
|
| 70 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | - * @param \phpbb\pagination $pagination Pagination object |
|
| 72 | - * @param \phpbb\log\log $log Log object |
|
| 73 | - * @param \phpbb\notification\manager $notification Notification object |
|
| 74 | - * @param \phpbb\request\request $request Request object |
|
| 75 | - * @param \phpbb\template\template $template Template object |
|
| 76 | - * @param \phpbb\user $user User object |
|
| 77 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 78 | - * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 79 | - * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 80 | - * @param string $root_path phpBB root path |
|
| 81 | - * @param string $php_ext phpEx |
|
| 82 | - */ |
|
| 83 | - public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\pagination $pagination, \phpbb\log\log $log, \phpbb\notification\manager $notification, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\helper $dir_helper, \ernadoo\phpbbdirectory\core\link $link, $root_path, $php_ext) |
|
| 84 | - { |
|
| 85 | - $this->config = $config; |
|
| 86 | - $this->db = $db; |
|
| 87 | - $this->pagination = $pagination; |
|
| 88 | - $this->phpbb_log = $log; |
|
| 89 | - $this->notification = $notification; |
|
| 90 | - $this->request = $request; |
|
| 91 | - $this->template = $template; |
|
| 92 | - $this->user = $user; |
|
| 93 | - $this->categorie = $categorie; |
|
| 94 | - $this->dir_helper = $dir_helper; |
|
| 95 | - $this->link = $link; |
|
| 96 | - $this->root_path = $root_path; |
|
| 97 | - $this->php_ext = $php_ext; |
|
| 98 | - |
|
| 99 | - $this->action = $this->request->variable('action', ''); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Display confirm box. |
|
| 104 | - * |
|
| 105 | - * @param array $mark Website selected for (dis)approval |
|
| 106 | - * |
|
| 107 | - * @return null |
|
| 108 | - */ |
|
| 109 | - public function display_confirm($mark) |
|
| 110 | - { |
|
| 111 | - $s_hidden_fields = [ |
|
| 112 | - 'action' => $this->action, |
|
| 113 | - 'link_id' => $mark, |
|
| 114 | - 'start' => $this->request->variable('start', 0), |
|
| 115 | - ]; |
|
| 116 | - confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Display website list for (dis)approval. |
|
| 121 | - * |
|
| 122 | - * @return null |
|
| 123 | - */ |
|
| 124 | - public function display_websites() |
|
| 125 | - { |
|
| 126 | - global $phpbb_admin_path; |
|
| 127 | - |
|
| 128 | - // Sort keys |
|
| 129 | - $sort_days = $this->request->variable('st', 0); |
|
| 130 | - $sort_key = $this->request->variable('sk', 't'); |
|
| 131 | - $sort_dir = $this->request->variable('sd', 'd'); |
|
| 132 | - |
|
| 133 | - // Number of entries to display |
|
| 134 | - $per_page = $this->request->variable('links_per_page', (int) $this->config['dir_show']); |
|
| 135 | - |
|
| 136 | - $start = $this->request->variable('start', 0); |
|
| 137 | - |
|
| 138 | - // Categorie ordering options |
|
| 139 | - $limit_days = [0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 140 | - $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME']]; |
|
| 141 | - $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id']]; |
|
| 142 | - |
|
| 143 | - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 144 | - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
| 145 | - |
|
| 146 | - // Define where and sort sql for use in displaying logs |
|
| 147 | - $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; |
|
| 148 | - $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
| 149 | - |
|
| 150 | - if (is_array($sort_by_sql[$sort_key])) { |
|
| 151 | - $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction; |
|
| 152 | - } else { |
|
| 153 | - $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $sql = 'SELECT COUNT(1) AS total_links |
|
| 12 | + /** @var \phpbb\config\config */ |
|
| 13 | + protected $config; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 16 | + protected $db; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\pagination */ |
|
| 19 | + protected $pagination; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\log\log */ |
|
| 22 | + protected $phpbb_log; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\notification\manager */ |
|
| 25 | + protected $notification; |
|
| 26 | + |
|
| 27 | + /** @var \phpbb\request\request */ |
|
| 28 | + protected $request; |
|
| 29 | + |
|
| 30 | + /** @var \phpbb\template\template */ |
|
| 31 | + protected $template; |
|
| 32 | + |
|
| 33 | + /** @var \phpbb\user */ |
|
| 34 | + protected $user; |
|
| 35 | + |
|
| 36 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 37 | + protected $categorie; |
|
| 38 | + |
|
| 39 | + /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 40 | + protected $dir_helper; |
|
| 41 | + |
|
| 42 | + /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 43 | + protected $link; |
|
| 44 | + |
|
| 45 | + /** @var string phpBB root path */ |
|
| 46 | + protected $root_path; |
|
| 47 | + |
|
| 48 | + /** @var string phpEx */ |
|
| 49 | + protected $php_ext; |
|
| 50 | + |
|
| 51 | + /** @var string Custom form action */ |
|
| 52 | + protected $u_action; |
|
| 53 | + |
|
| 54 | + /** @var string */ |
|
| 55 | + private $action; |
|
| 56 | + |
|
| 57 | + /** @var array */ |
|
| 58 | + private $affected_link_name = []; |
|
| 59 | + |
|
| 60 | + /** @var array */ |
|
| 61 | + private $cat_data = []; |
|
| 62 | + |
|
| 63 | + /** @var array */ |
|
| 64 | + private $links_data; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Constructor. |
|
| 68 | + * |
|
| 69 | + * @param \phpbb\config\config $config Config object |
|
| 70 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | + * @param \phpbb\pagination $pagination Pagination object |
|
| 72 | + * @param \phpbb\log\log $log Log object |
|
| 73 | + * @param \phpbb\notification\manager $notification Notification object |
|
| 74 | + * @param \phpbb\request\request $request Request object |
|
| 75 | + * @param \phpbb\template\template $template Template object |
|
| 76 | + * @param \phpbb\user $user User object |
|
| 77 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 78 | + * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 79 | + * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 80 | + * @param string $root_path phpBB root path |
|
| 81 | + * @param string $php_ext phpEx |
|
| 82 | + */ |
|
| 83 | + public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\pagination $pagination, \phpbb\log\log $log, \phpbb\notification\manager $notification, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\helper $dir_helper, \ernadoo\phpbbdirectory\core\link $link, $root_path, $php_ext) |
|
| 84 | + { |
|
| 85 | + $this->config = $config; |
|
| 86 | + $this->db = $db; |
|
| 87 | + $this->pagination = $pagination; |
|
| 88 | + $this->phpbb_log = $log; |
|
| 89 | + $this->notification = $notification; |
|
| 90 | + $this->request = $request; |
|
| 91 | + $this->template = $template; |
|
| 92 | + $this->user = $user; |
|
| 93 | + $this->categorie = $categorie; |
|
| 94 | + $this->dir_helper = $dir_helper; |
|
| 95 | + $this->link = $link; |
|
| 96 | + $this->root_path = $root_path; |
|
| 97 | + $this->php_ext = $php_ext; |
|
| 98 | + |
|
| 99 | + $this->action = $this->request->variable('action', ''); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Display confirm box. |
|
| 104 | + * |
|
| 105 | + * @param array $mark Website selected for (dis)approval |
|
| 106 | + * |
|
| 107 | + * @return null |
|
| 108 | + */ |
|
| 109 | + public function display_confirm($mark) |
|
| 110 | + { |
|
| 111 | + $s_hidden_fields = [ |
|
| 112 | + 'action' => $this->action, |
|
| 113 | + 'link_id' => $mark, |
|
| 114 | + 'start' => $this->request->variable('start', 0), |
|
| 115 | + ]; |
|
| 116 | + confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Display website list for (dis)approval. |
|
| 121 | + * |
|
| 122 | + * @return null |
|
| 123 | + */ |
|
| 124 | + public function display_websites() |
|
| 125 | + { |
|
| 126 | + global $phpbb_admin_path; |
|
| 127 | + |
|
| 128 | + // Sort keys |
|
| 129 | + $sort_days = $this->request->variable('st', 0); |
|
| 130 | + $sort_key = $this->request->variable('sk', 't'); |
|
| 131 | + $sort_dir = $this->request->variable('sd', 'd'); |
|
| 132 | + |
|
| 133 | + // Number of entries to display |
|
| 134 | + $per_page = $this->request->variable('links_per_page', (int) $this->config['dir_show']); |
|
| 135 | + |
|
| 136 | + $start = $this->request->variable('start', 0); |
|
| 137 | + |
|
| 138 | + // Categorie ordering options |
|
| 139 | + $limit_days = [0 => $this->user->lang['SEE_ALL'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 140 | + $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME']]; |
|
| 141 | + $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id']]; |
|
| 142 | + |
|
| 143 | + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 144 | + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
| 145 | + |
|
| 146 | + // Define where and sort sql for use in displaying logs |
|
| 147 | + $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; |
|
| 148 | + $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
| 149 | + |
|
| 150 | + if (is_array($sort_by_sql[$sort_key])) { |
|
| 151 | + $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction; |
|
| 152 | + } else { |
|
| 153 | + $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $sql = 'SELECT COUNT(1) AS total_links |
|
| 157 | 157 | FROM '.DIR_LINK_TABLE.' |
| 158 | 158 | WHERE link_active = 0'. |
| 159 | - (($sql_where) ? " AND link_time >= $sql_where" : ''); |
|
| 160 | - $result = $this->db->sql_query($sql); |
|
| 161 | - $total_links = (int) $this->db->sql_fetchfield('total_links'); |
|
| 162 | - $this->db->sql_freeresult($result); |
|
| 163 | - |
|
| 164 | - // Make sure $start is set to the last page if it exceeds the amount |
|
| 165 | - $start = $this->pagination->validate_start($start, $per_page, $total_links); |
|
| 166 | - |
|
| 167 | - $sql_array = [ |
|
| 168 | - 'SELECT' => 'l.link_id, l.link_name, l.link_url, l.link_description, l.link_cat, l.link_user_id, l.link_guest_email, l.link_uid, l.link_bitfield, l.link_flags, l.link_banner, l.link_time, c.cat_name, u.user_id, u.username, u.user_colour', |
|
| 169 | - 'FROM' => [ |
|
| 170 | - DIR_LINK_TABLE => 'l', ], |
|
| 171 | - 'LEFT_JOIN' => [ |
|
| 172 | - [ |
|
| 173 | - 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 174 | - 'ON' => 'c.cat_id = l.link_cat', |
|
| 175 | - ], |
|
| 176 | - [ |
|
| 177 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 178 | - 'ON' => 'u.user_id = l.link_user_id', |
|
| 179 | - ], |
|
| 180 | - ], |
|
| 181 | - 'WHERE' => 'l.link_active = 0'.(($sql_where) ? " AND l.link_time >= $sql_where" : ''), |
|
| 182 | - 'ORDER_BY' => $sql_sort_order, ]; |
|
| 183 | - |
|
| 184 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 185 | - $result = $this->db->sql_query_limit($sql, $per_page, $start); |
|
| 186 | - |
|
| 187 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 188 | - $s_banner = $this->link->display_bann($row); |
|
| 189 | - |
|
| 190 | - $username = ($row['link_user_id'] == ANONYMOUS) ? $row['link_guest_email'] : $row['username']; |
|
| 191 | - |
|
| 192 | - $link_row = [ |
|
| 193 | - 'LINK_URL' => $row['link_url'], |
|
| 194 | - 'LINK_NAME' => $row['link_name'], |
|
| 195 | - 'LINK_DESC' => generate_text_for_display($row['link_description'], $row['link_uid'], $row['link_bitfield'], $row['link_flags']), |
|
| 196 | - 'L_DIR_USER_PROP' => $this->user->lang('DIR_USER_PROP', get_username_string('full', $row['link_user_id'], $username, $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$this->php_ext", 'i=users&mode=overview')), '<select name=c'.$row['link_id'].'>'.$this->categorie->make_cat_select((int) $row['link_cat']).'</select>', $this->user->format_date($row['link_time'])), |
|
| 197 | - 'BANNER' => $s_banner, |
|
| 198 | - 'LINK_ID' => $row['link_id'], |
|
| 199 | - |
|
| 200 | - ]; |
|
| 201 | - $this->template->assign_block_vars('linkrow', $link_row); |
|
| 202 | - } |
|
| 203 | - $this->db->sql_freeresult($result); |
|
| 204 | - |
|
| 205 | - $option_ary = ['approved' => 'DIR_LINK_ACTIVATE', 'disapproved' => 'DIR_LINK_DELETE']; |
|
| 206 | - |
|
| 207 | - $base_url = $this->u_action."&$u_sort_param&links_per_page=$per_page"; |
|
| 208 | - $this->pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_links, $per_page, $start); |
|
| 209 | - |
|
| 210 | - $this->template->assign_vars([ |
|
| 211 | - 'S_LINKS_OPTIONS' => build_select($option_ary), |
|
| 212 | - |
|
| 213 | - 'S_LIMIT_DAYS' => $s_limit_days, |
|
| 214 | - 'S_SORT_KEY' => $s_sort_key, |
|
| 215 | - 'S_SORT_DIR' => $s_sort_dir, |
|
| 216 | - 'LINKS_PER_PAGE' => $per_page, |
|
| 217 | - |
|
| 218 | - 'U_ACTION' => $this->u_action."&$u_sort_param&links_per_page=$per_page&start=$start", |
|
| 219 | - ]); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Get link's information and call appropriate action. |
|
| 224 | - * |
|
| 225 | - * @param array $mark Website selected for (dis)approval |
|
| 226 | - * |
|
| 227 | - * @return null |
|
| 228 | - */ |
|
| 229 | - public function exec_action($mark) |
|
| 230 | - { |
|
| 231 | - $this->_get_infos_links($mark); |
|
| 232 | - |
|
| 233 | - switch ($this->action) { |
|
| 234 | - case 'approved': |
|
| 235 | - $this->_action_approved(); |
|
| 236 | - break; |
|
| 237 | - |
|
| 238 | - case 'disapproved': |
|
| 239 | - $this->_action_disapproved(); |
|
| 240 | - break; |
|
| 241 | - |
|
| 242 | - default: |
|
| 243 | - return; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_LINK_'.strtoupper($this->action), time(), [implode(', ', $this->affected_link_name)]); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Notify users which had submitted their websites. |
|
| 251 | - * |
|
| 252 | - * @return null |
|
| 253 | - */ |
|
| 254 | - public function notifiy_submiters() |
|
| 255 | - { |
|
| 256 | - if (!class_exists('messenger')) { |
|
| 257 | - include $this->root_path.'includes/functions_messenger.'.$this->php_ext; |
|
| 258 | - } |
|
| 259 | - $messenger = new \messenger(false); |
|
| 260 | - |
|
| 261 | - foreach ($this->links_data as $row) { |
|
| 262 | - $this->notification->mark_notifications_read('ernadoo.phpbbdirectory.notification.type.directory_website_in_queue', (int) $row['link_id'], false); |
|
| 263 | - |
|
| 264 | - // New notification system can't send mail to an anonymous user with an email adress storage in another table than phpbb_users |
|
| 265 | - if ($row['link_user_id'] == ANONYMOUS) { |
|
| 266 | - $username = $email = $row['link_guest_email']; |
|
| 267 | - |
|
| 268 | - $messenger->template('@ernadoo_phpbbdirectory/directory_website_'.$this->action, $row['user_lang']); |
|
| 269 | - $messenger->to($email, $username); |
|
| 270 | - |
|
| 271 | - $messenger->assign_vars([ |
|
| 272 | - 'USERNAME' => htmlspecialchars_decode($username), |
|
| 273 | - 'LINK_NAME' => $row['link_name'], |
|
| 274 | - ]); |
|
| 275 | - |
|
| 276 | - $messenger->send(NOTIFY_EMAIL); |
|
| 277 | - } else { |
|
| 278 | - $notification_data = [ |
|
| 279 | - 'user_from' => (int) $row['link_user_id'], |
|
| 280 | - 'link_id' => (int) $row['link_id'], |
|
| 281 | - 'link_name' => $row['link_name'], |
|
| 282 | - 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), |
|
| 283 | - 'cat_id' => (int) $row['link_cat'], |
|
| 284 | - ]; |
|
| 285 | - |
|
| 286 | - $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_'.$this->action, $notification_data); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Set page url. |
|
| 293 | - * |
|
| 294 | - * @param string $u_action Custom form action |
|
| 295 | - * |
|
| 296 | - * @return null |
|
| 297 | - */ |
|
| 298 | - public function set_page_url($u_action) |
|
| 299 | - { |
|
| 300 | - $this->u_action = $u_action; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Approve action. |
|
| 305 | - * |
|
| 306 | - * @return null |
|
| 307 | - */ |
|
| 308 | - private function _action_approved() |
|
| 309 | - { |
|
| 310 | - foreach ($this->links_data as $row) { |
|
| 311 | - $this->_notify_suscribers($row); |
|
| 312 | - |
|
| 313 | - $sql_ary = [ |
|
| 314 | - 'link_active' => 1, |
|
| 315 | - 'link_time' => time(), |
|
| 316 | - 'link_cat' => (int) $row['link_cat'], |
|
| 317 | - ]; |
|
| 318 | - |
|
| 319 | - $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 159 | + (($sql_where) ? " AND link_time >= $sql_where" : ''); |
|
| 160 | + $result = $this->db->sql_query($sql); |
|
| 161 | + $total_links = (int) $this->db->sql_fetchfield('total_links'); |
|
| 162 | + $this->db->sql_freeresult($result); |
|
| 163 | + |
|
| 164 | + // Make sure $start is set to the last page if it exceeds the amount |
|
| 165 | + $start = $this->pagination->validate_start($start, $per_page, $total_links); |
|
| 166 | + |
|
| 167 | + $sql_array = [ |
|
| 168 | + 'SELECT' => 'l.link_id, l.link_name, l.link_url, l.link_description, l.link_cat, l.link_user_id, l.link_guest_email, l.link_uid, l.link_bitfield, l.link_flags, l.link_banner, l.link_time, c.cat_name, u.user_id, u.username, u.user_colour', |
|
| 169 | + 'FROM' => [ |
|
| 170 | + DIR_LINK_TABLE => 'l', ], |
|
| 171 | + 'LEFT_JOIN' => [ |
|
| 172 | + [ |
|
| 173 | + 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 174 | + 'ON' => 'c.cat_id = l.link_cat', |
|
| 175 | + ], |
|
| 176 | + [ |
|
| 177 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 178 | + 'ON' => 'u.user_id = l.link_user_id', |
|
| 179 | + ], |
|
| 180 | + ], |
|
| 181 | + 'WHERE' => 'l.link_active = 0'.(($sql_where) ? " AND l.link_time >= $sql_where" : ''), |
|
| 182 | + 'ORDER_BY' => $sql_sort_order, ]; |
|
| 183 | + |
|
| 184 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 185 | + $result = $this->db->sql_query_limit($sql, $per_page, $start); |
|
| 186 | + |
|
| 187 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 188 | + $s_banner = $this->link->display_bann($row); |
|
| 189 | + |
|
| 190 | + $username = ($row['link_user_id'] == ANONYMOUS) ? $row['link_guest_email'] : $row['username']; |
|
| 191 | + |
|
| 192 | + $link_row = [ |
|
| 193 | + 'LINK_URL' => $row['link_url'], |
|
| 194 | + 'LINK_NAME' => $row['link_name'], |
|
| 195 | + 'LINK_DESC' => generate_text_for_display($row['link_description'], $row['link_uid'], $row['link_bitfield'], $row['link_flags']), |
|
| 196 | + 'L_DIR_USER_PROP' => $this->user->lang('DIR_USER_PROP', get_username_string('full', $row['link_user_id'], $username, $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$this->php_ext", 'i=users&mode=overview')), '<select name=c'.$row['link_id'].'>'.$this->categorie->make_cat_select((int) $row['link_cat']).'</select>', $this->user->format_date($row['link_time'])), |
|
| 197 | + 'BANNER' => $s_banner, |
|
| 198 | + 'LINK_ID' => $row['link_id'], |
|
| 199 | + |
|
| 200 | + ]; |
|
| 201 | + $this->template->assign_block_vars('linkrow', $link_row); |
|
| 202 | + } |
|
| 203 | + $this->db->sql_freeresult($result); |
|
| 204 | + |
|
| 205 | + $option_ary = ['approved' => 'DIR_LINK_ACTIVATE', 'disapproved' => 'DIR_LINK_DELETE']; |
|
| 206 | + |
|
| 207 | + $base_url = $this->u_action."&$u_sort_param&links_per_page=$per_page"; |
|
| 208 | + $this->pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_links, $per_page, $start); |
|
| 209 | + |
|
| 210 | + $this->template->assign_vars([ |
|
| 211 | + 'S_LINKS_OPTIONS' => build_select($option_ary), |
|
| 212 | + |
|
| 213 | + 'S_LIMIT_DAYS' => $s_limit_days, |
|
| 214 | + 'S_SORT_KEY' => $s_sort_key, |
|
| 215 | + 'S_SORT_DIR' => $s_sort_dir, |
|
| 216 | + 'LINKS_PER_PAGE' => $per_page, |
|
| 217 | + |
|
| 218 | + 'U_ACTION' => $this->u_action."&$u_sort_param&links_per_page=$per_page&start=$start", |
|
| 219 | + ]); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Get link's information and call appropriate action. |
|
| 224 | + * |
|
| 225 | + * @param array $mark Website selected for (dis)approval |
|
| 226 | + * |
|
| 227 | + * @return null |
|
| 228 | + */ |
|
| 229 | + public function exec_action($mark) |
|
| 230 | + { |
|
| 231 | + $this->_get_infos_links($mark); |
|
| 232 | + |
|
| 233 | + switch ($this->action) { |
|
| 234 | + case 'approved': |
|
| 235 | + $this->_action_approved(); |
|
| 236 | + break; |
|
| 237 | + |
|
| 238 | + case 'disapproved': |
|
| 239 | + $this->_action_disapproved(); |
|
| 240 | + break; |
|
| 241 | + |
|
| 242 | + default: |
|
| 243 | + return; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_LINK_'.strtoupper($this->action), time(), [implode(', ', $this->affected_link_name)]); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Notify users which had submitted their websites. |
|
| 251 | + * |
|
| 252 | + * @return null |
|
| 253 | + */ |
|
| 254 | + public function notifiy_submiters() |
|
| 255 | + { |
|
| 256 | + if (!class_exists('messenger')) { |
|
| 257 | + include $this->root_path.'includes/functions_messenger.'.$this->php_ext; |
|
| 258 | + } |
|
| 259 | + $messenger = new \messenger(false); |
|
| 260 | + |
|
| 261 | + foreach ($this->links_data as $row) { |
|
| 262 | + $this->notification->mark_notifications_read('ernadoo.phpbbdirectory.notification.type.directory_website_in_queue', (int) $row['link_id'], false); |
|
| 263 | + |
|
| 264 | + // New notification system can't send mail to an anonymous user with an email adress storage in another table than phpbb_users |
|
| 265 | + if ($row['link_user_id'] == ANONYMOUS) { |
|
| 266 | + $username = $email = $row['link_guest_email']; |
|
| 267 | + |
|
| 268 | + $messenger->template('@ernadoo_phpbbdirectory/directory_website_'.$this->action, $row['user_lang']); |
|
| 269 | + $messenger->to($email, $username); |
|
| 270 | + |
|
| 271 | + $messenger->assign_vars([ |
|
| 272 | + 'USERNAME' => htmlspecialchars_decode($username), |
|
| 273 | + 'LINK_NAME' => $row['link_name'], |
|
| 274 | + ]); |
|
| 275 | + |
|
| 276 | + $messenger->send(NOTIFY_EMAIL); |
|
| 277 | + } else { |
|
| 278 | + $notification_data = [ |
|
| 279 | + 'user_from' => (int) $row['link_user_id'], |
|
| 280 | + 'link_id' => (int) $row['link_id'], |
|
| 281 | + 'link_name' => $row['link_name'], |
|
| 282 | + 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), |
|
| 283 | + 'cat_id' => (int) $row['link_cat'], |
|
| 284 | + ]; |
|
| 285 | + |
|
| 286 | + $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website_'.$this->action, $notification_data); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Set page url. |
|
| 293 | + * |
|
| 294 | + * @param string $u_action Custom form action |
|
| 295 | + * |
|
| 296 | + * @return null |
|
| 297 | + */ |
|
| 298 | + public function set_page_url($u_action) |
|
| 299 | + { |
|
| 300 | + $this->u_action = $u_action; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Approve action. |
|
| 305 | + * |
|
| 306 | + * @return null |
|
| 307 | + */ |
|
| 308 | + private function _action_approved() |
|
| 309 | + { |
|
| 310 | + foreach ($this->links_data as $row) { |
|
| 311 | + $this->_notify_suscribers($row); |
|
| 312 | + |
|
| 313 | + $sql_ary = [ |
|
| 314 | + 'link_active' => 1, |
|
| 315 | + 'link_time' => time(), |
|
| 316 | + 'link_cat' => (int) $row['link_cat'], |
|
| 317 | + ]; |
|
| 318 | + |
|
| 319 | + $sql = 'UPDATE '.DIR_LINK_TABLE.' |
|
| 320 | 320 | SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
| 321 | 321 | WHERE link_id = '.(int) $row['link_id']; |
| 322 | - $this->db->sql_query($sql); |
|
| 323 | - } |
|
| 322 | + $this->db->sql_query($sql); |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - foreach ($this->cat_data as $cat_id => $count) { |
|
| 326 | - $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 325 | + foreach ($this->cat_data as $cat_id => $count) { |
|
| 326 | + $sql = 'UPDATE '.DIR_CAT_TABLE.' |
|
| 327 | 327 | SET cat_links = cat_links + '.$count.' |
| 328 | 328 | WHERE cat_id = '.(int) $cat_id; |
| 329 | - $this->db->sql_query($sql); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Disapprove action. |
|
| 335 | - * |
|
| 336 | - * @return null |
|
| 337 | - */ |
|
| 338 | - private function _action_disapproved() |
|
| 339 | - { |
|
| 340 | - foreach ($this->links_data as $row) { |
|
| 341 | - if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 342 | - $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner'])); |
|
| 343 | - |
|
| 344 | - if (file_exists($banner_img)) { |
|
| 345 | - @unlink($banner_img); |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - $sql = 'DELETE FROM '.DIR_LINK_TABLE.' WHERE link_id = '.(int) $row['link_id']; |
|
| 350 | - $this->db->sql_query($sql); |
|
| 351 | - } |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Get informations about links selected. |
|
| 356 | - * |
|
| 357 | - * @param $mark Website selected for (dis)approval |
|
| 358 | - * |
|
| 359 | - * @return null |
|
| 360 | - */ |
|
| 361 | - private function _get_infos_links($mark) |
|
| 362 | - { |
|
| 363 | - $sql_array = [ |
|
| 364 | - 'SELECT' => 'a.link_id, a.link_name, a.link_url, a.link_description, a.link_banner, a.link_user_id, a.link_guest_email, u.username, u.user_email, u.user_lang, u.user_notify_type, c.cat_id, c.cat_name', |
|
| 365 | - 'FROM' => [ |
|
| 366 | - DIR_LINK_TABLE => 'a', ], |
|
| 367 | - 'LEFT_JOIN' => [ |
|
| 368 | - [ |
|
| 369 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 370 | - 'ON' => 'u.user_id = a.link_user_id', |
|
| 371 | - ], |
|
| 372 | - [ |
|
| 373 | - 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 374 | - 'ON' => 'a.link_cat = c.cat_id', |
|
| 375 | - ], |
|
| 376 | - ], |
|
| 377 | - 'WHERE' => $this->db->sql_in_set('a.link_id', $mark), ]; |
|
| 378 | - |
|
| 379 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 380 | - $result = $this->db->sql_query($sql); |
|
| 381 | - |
|
| 382 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 383 | - $row['link_cat'] = $this->request->variable('c'.$row['link_id'], (int) $row['cat_id']); |
|
| 384 | - |
|
| 385 | - $this->links_data[] = $row; |
|
| 386 | - |
|
| 387 | - $this->affected_link_name[] = $row['link_name']; |
|
| 388 | - |
|
| 389 | - $this->cat_data[$row['link_cat']] = isset($this->cat_data[$row['link_cat']]) ? $this->cat_data[$row['link_cat']] + 1 : 1; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Notify users which watch categories. |
|
| 395 | - * |
|
| 396 | - * @param $row Informations about website |
|
| 397 | - * |
|
| 398 | - * @return null |
|
| 399 | - */ |
|
| 400 | - private function _notify_suscribers($row) |
|
| 401 | - { |
|
| 402 | - $notification_data = [ |
|
| 403 | - 'user_from' => (int) $row['link_user_id'], |
|
| 404 | - 'link_id' => (int) $row['link_id'], |
|
| 405 | - 'link_name' => $row['link_name'], |
|
| 406 | - 'link_url' => $row['link_url'], |
|
| 407 | - 'link_description' => preg_replace('/(\[.*?\])(.*?)(\[\/.*?\])/si', '\\1', $row['link_description']), |
|
| 408 | - 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), |
|
| 409 | - 'cat_id' => (int) $row['link_cat'], |
|
| 410 | - ]; |
|
| 411 | - |
|
| 412 | - $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website', $notification_data); |
|
| 413 | - } |
|
| 329 | + $this->db->sql_query($sql); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * Disapprove action. |
|
| 335 | + * |
|
| 336 | + * @return null |
|
| 337 | + */ |
|
| 338 | + private function _action_disapproved() |
|
| 339 | + { |
|
| 340 | + foreach ($this->links_data as $row) { |
|
| 341 | + if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) { |
|
| 342 | + $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner'])); |
|
| 343 | + |
|
| 344 | + if (file_exists($banner_img)) { |
|
| 345 | + @unlink($banner_img); |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + $sql = 'DELETE FROM '.DIR_LINK_TABLE.' WHERE link_id = '.(int) $row['link_id']; |
|
| 350 | + $this->db->sql_query($sql); |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Get informations about links selected. |
|
| 356 | + * |
|
| 357 | + * @param $mark Website selected for (dis)approval |
|
| 358 | + * |
|
| 359 | + * @return null |
|
| 360 | + */ |
|
| 361 | + private function _get_infos_links($mark) |
|
| 362 | + { |
|
| 363 | + $sql_array = [ |
|
| 364 | + 'SELECT' => 'a.link_id, a.link_name, a.link_url, a.link_description, a.link_banner, a.link_user_id, a.link_guest_email, u.username, u.user_email, u.user_lang, u.user_notify_type, c.cat_id, c.cat_name', |
|
| 365 | + 'FROM' => [ |
|
| 366 | + DIR_LINK_TABLE => 'a', ], |
|
| 367 | + 'LEFT_JOIN' => [ |
|
| 368 | + [ |
|
| 369 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 370 | + 'ON' => 'u.user_id = a.link_user_id', |
|
| 371 | + ], |
|
| 372 | + [ |
|
| 373 | + 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 374 | + 'ON' => 'a.link_cat = c.cat_id', |
|
| 375 | + ], |
|
| 376 | + ], |
|
| 377 | + 'WHERE' => $this->db->sql_in_set('a.link_id', $mark), ]; |
|
| 378 | + |
|
| 379 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 380 | + $result = $this->db->sql_query($sql); |
|
| 381 | + |
|
| 382 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 383 | + $row['link_cat'] = $this->request->variable('c'.$row['link_id'], (int) $row['cat_id']); |
|
| 384 | + |
|
| 385 | + $this->links_data[] = $row; |
|
| 386 | + |
|
| 387 | + $this->affected_link_name[] = $row['link_name']; |
|
| 388 | + |
|
| 389 | + $this->cat_data[$row['link_cat']] = isset($this->cat_data[$row['link_cat']]) ? $this->cat_data[$row['link_cat']] + 1 : 1; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Notify users which watch categories. |
|
| 395 | + * |
|
| 396 | + * @param $row Informations about website |
|
| 397 | + * |
|
| 398 | + * @return null |
|
| 399 | + */ |
|
| 400 | + private function _notify_suscribers($row) |
|
| 401 | + { |
|
| 402 | + $notification_data = [ |
|
| 403 | + 'user_from' => (int) $row['link_user_id'], |
|
| 404 | + 'link_id' => (int) $row['link_id'], |
|
| 405 | + 'link_name' => $row['link_name'], |
|
| 406 | + 'link_url' => $row['link_url'], |
|
| 407 | + 'link_description' => preg_replace('/(\[.*?\])(.*?)(\[\/.*?\])/si', '\\1', $row['link_description']), |
|
| 408 | + 'cat_name' => \ernadoo\phpbbdirectory\core\categorie::getname((int) $row['link_cat']), |
|
| 409 | + 'cat_id' => (int) $row['link_cat'], |
|
| 410 | + ]; |
|
| 411 | + |
|
| 412 | + $this->notification->add_notifications('ernadoo.phpbbdirectory.notification.type.directory_website', $notification_data); |
|
| 413 | + } |
|
| 414 | 414 | } |
@@ -9,330 +9,330 @@ |
||
| 9 | 9 | |
| 10 | 10 | class search |
| 11 | 11 | { |
| 12 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | - protected $db; |
|
| 14 | - |
|
| 15 | - /** @var \phpbb\config\config */ |
|
| 16 | - protected $config; |
|
| 17 | - |
|
| 18 | - /** @var \phpbb\template\template */ |
|
| 19 | - protected $template; |
|
| 20 | - |
|
| 21 | - /** @var \phpbb\user */ |
|
| 22 | - protected $user; |
|
| 23 | - |
|
| 24 | - /** @var \phpbb\controller\helper */ |
|
| 25 | - protected $helper; |
|
| 26 | - |
|
| 27 | - /** @var \phpbb\request\request */ |
|
| 28 | - protected $request; |
|
| 29 | - |
|
| 30 | - /** @var \phpbb\auth\auth */ |
|
| 31 | - protected $auth; |
|
| 32 | - |
|
| 33 | - /** @var \phpbb\pagination */ |
|
| 34 | - protected $pagination; |
|
| 35 | - |
|
| 36 | - /** @var \ernadoo\phpbbdirectory\search\fulltext_directory */ |
|
| 37 | - protected $search; |
|
| 38 | - |
|
| 39 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 40 | - protected $categorie; |
|
| 41 | - |
|
| 42 | - /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 43 | - protected $link; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Constructor. |
|
| 47 | - * |
|
| 48 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 49 | - * @param \phpbb\config\config $config Config object |
|
| 50 | - * @param \phpbb\template\template $template Template object |
|
| 51 | - * @param \phpbb\user $user User object |
|
| 52 | - * @param \phpbb\controller\helper $helper Controller helper object |
|
| 53 | - * @param \phpbb\request\request $request Request object |
|
| 54 | - * @param \phpbb\auth\auth $auth Auth object |
|
| 55 | - * @param \phpbb\pagination $pagination Pagination object |
|
| 56 | - * @param \ernadoo\phpbbdirectory\search\fulltext_directory $search PhpBB Directory extension search object |
|
| 57 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 58 | - * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 59 | - */ |
|
| 60 | - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\search\fulltext_directory $search, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link) |
|
| 61 | - { |
|
| 62 | - $this->db = $db; |
|
| 63 | - $this->config = $config; |
|
| 64 | - $this->template = $template; |
|
| 65 | - $this->user = $user; |
|
| 66 | - $this->helper = $helper; |
|
| 67 | - $this->request = $request; |
|
| 68 | - $this->auth = $auth; |
|
| 69 | - $this->pagination = $pagination; |
|
| 70 | - $this->search = $search; |
|
| 71 | - $this->categorie = $categorie; |
|
| 72 | - $this->link = $link; |
|
| 73 | - |
|
| 74 | - $this->user->add_lang_ext('ernadoo/phpbbdirectory', ['directory']); |
|
| 75 | - $this->user->add_lang('search'); |
|
| 76 | - |
|
| 77 | - $this->template->assign_vars([ |
|
| 78 | - 'S_PHPBB_DIRECTORY' => true, |
|
| 79 | - 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 80 | - ]); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Search controller. |
|
| 85 | - * |
|
| 86 | - * @param int $page Page number taken from the URL |
|
| 87 | - * |
|
| 88 | - * @throws \phpbb\exception\http_exception |
|
| 89 | - * |
|
| 90 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 91 | - */ |
|
| 92 | - public function main($page) |
|
| 93 | - { |
|
| 94 | - if (!$this->auth->acl_get('u_search_dir')) { |
|
| 95 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $cat_id = $this->request->variable('cat_id', 0); |
|
| 99 | - $keywords = $this->request->variable('keywords', '', true); |
|
| 100 | - $search_terms = $this->request->variable('terms', 'all'); |
|
| 101 | - $search_category = $this->request->variable('cid', [0]); |
|
| 102 | - $search_fields = $this->request->variable('sf', 'all'); |
|
| 103 | - $search_child = $this->request->variable('sc', true); |
|
| 104 | - $sort_days = $this->request->variable('st', 0); |
|
| 105 | - $sort_key = $this->request->variable('sk', 't'); |
|
| 106 | - $sort_dir = $this->request->variable('sd', 'd'); |
|
| 107 | - $start = ($page - 1) * (int) $this->config['dir_show']; |
|
| 108 | - |
|
| 109 | - $default_sort_days = 0; |
|
| 110 | - $default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1); |
|
| 111 | - $default_sort_dir = (string) substr($this->config['dir_default_order'], 2); |
|
| 112 | - |
|
| 113 | - // Categorie ordering options |
|
| 114 | - $limit_days = [0 => $this->user->lang['ALL_RESULTS'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 115 | - $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']]; |
|
| 116 | - $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view']; |
|
| 117 | - |
|
| 118 | - if ($this->config['dir_activ_pagerank']) { |
|
| 119 | - $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER']; |
|
| 120 | - $sort_by_sql['p'] = 'l.link_pagerank'; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 124 | - gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
| 125 | - |
|
| 126 | - $u_sort_param = ($sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir) ? [] : ['sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir]; |
|
| 127 | - |
|
| 128 | - /* |
|
| 12 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 13 | + protected $db; |
|
| 14 | + |
|
| 15 | + /** @var \phpbb\config\config */ |
|
| 16 | + protected $config; |
|
| 17 | + |
|
| 18 | + /** @var \phpbb\template\template */ |
|
| 19 | + protected $template; |
|
| 20 | + |
|
| 21 | + /** @var \phpbb\user */ |
|
| 22 | + protected $user; |
|
| 23 | + |
|
| 24 | + /** @var \phpbb\controller\helper */ |
|
| 25 | + protected $helper; |
|
| 26 | + |
|
| 27 | + /** @var \phpbb\request\request */ |
|
| 28 | + protected $request; |
|
| 29 | + |
|
| 30 | + /** @var \phpbb\auth\auth */ |
|
| 31 | + protected $auth; |
|
| 32 | + |
|
| 33 | + /** @var \phpbb\pagination */ |
|
| 34 | + protected $pagination; |
|
| 35 | + |
|
| 36 | + /** @var \ernadoo\phpbbdirectory\search\fulltext_directory */ |
|
| 37 | + protected $search; |
|
| 38 | + |
|
| 39 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 40 | + protected $categorie; |
|
| 41 | + |
|
| 42 | + /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 43 | + protected $link; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Constructor. |
|
| 47 | + * |
|
| 48 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 49 | + * @param \phpbb\config\config $config Config object |
|
| 50 | + * @param \phpbb\template\template $template Template object |
|
| 51 | + * @param \phpbb\user $user User object |
|
| 52 | + * @param \phpbb\controller\helper $helper Controller helper object |
|
| 53 | + * @param \phpbb\request\request $request Request object |
|
| 54 | + * @param \phpbb\auth\auth $auth Auth object |
|
| 55 | + * @param \phpbb\pagination $pagination Pagination object |
|
| 56 | + * @param \ernadoo\phpbbdirectory\search\fulltext_directory $search PhpBB Directory extension search object |
|
| 57 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 58 | + * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 59 | + */ |
|
| 60 | + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\search\fulltext_directory $search, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link) |
|
| 61 | + { |
|
| 62 | + $this->db = $db; |
|
| 63 | + $this->config = $config; |
|
| 64 | + $this->template = $template; |
|
| 65 | + $this->user = $user; |
|
| 66 | + $this->helper = $helper; |
|
| 67 | + $this->request = $request; |
|
| 68 | + $this->auth = $auth; |
|
| 69 | + $this->pagination = $pagination; |
|
| 70 | + $this->search = $search; |
|
| 71 | + $this->categorie = $categorie; |
|
| 72 | + $this->link = $link; |
|
| 73 | + |
|
| 74 | + $this->user->add_lang_ext('ernadoo/phpbbdirectory', ['directory']); |
|
| 75 | + $this->user->add_lang('search'); |
|
| 76 | + |
|
| 77 | + $this->template->assign_vars([ |
|
| 78 | + 'S_PHPBB_DIRECTORY' => true, |
|
| 79 | + 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 80 | + ]); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Search controller. |
|
| 85 | + * |
|
| 86 | + * @param int $page Page number taken from the URL |
|
| 87 | + * |
|
| 88 | + * @throws \phpbb\exception\http_exception |
|
| 89 | + * |
|
| 90 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 91 | + */ |
|
| 92 | + public function main($page) |
|
| 93 | + { |
|
| 94 | + if (!$this->auth->acl_get('u_search_dir')) { |
|
| 95 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $cat_id = $this->request->variable('cat_id', 0); |
|
| 99 | + $keywords = $this->request->variable('keywords', '', true); |
|
| 100 | + $search_terms = $this->request->variable('terms', 'all'); |
|
| 101 | + $search_category = $this->request->variable('cid', [0]); |
|
| 102 | + $search_fields = $this->request->variable('sf', 'all'); |
|
| 103 | + $search_child = $this->request->variable('sc', true); |
|
| 104 | + $sort_days = $this->request->variable('st', 0); |
|
| 105 | + $sort_key = $this->request->variable('sk', 't'); |
|
| 106 | + $sort_dir = $this->request->variable('sd', 'd'); |
|
| 107 | + $start = ($page - 1) * (int) $this->config['dir_show']; |
|
| 108 | + |
|
| 109 | + $default_sort_days = 0; |
|
| 110 | + $default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1); |
|
| 111 | + $default_sort_dir = (string) substr($this->config['dir_default_order'], 2); |
|
| 112 | + |
|
| 113 | + // Categorie ordering options |
|
| 114 | + $limit_days = [0 => $this->user->lang['ALL_RESULTS'], 1 => $this->user->lang['1_DAY'], 7 => $this->user->lang['7_DAYS'], 14 => $this->user->lang['2_WEEKS'], 30 => $this->user->lang['1_MONTH'], 90 => $this->user->lang['3_MONTHS'], 180 => $this->user->lang['6_MONTHS'], 365 => $this->user->lang['1_YEAR']]; |
|
| 115 | + $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' => $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']]; |
|
| 116 | + $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view']; |
|
| 117 | + |
|
| 118 | + if ($this->config['dir_activ_pagerank']) { |
|
| 119 | + $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER']; |
|
| 120 | + $sort_by_sql['p'] = 'l.link_pagerank'; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
|
| 124 | + gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
| 125 | + |
|
| 126 | + $u_sort_param = ($sort_days === $default_sort_days && $sort_key == $default_sort_key && $sort_dir == $default_sort_dir) ? [] : ['sort_days' => $sort_days, 'sort_key' => $sort_key, 'sort_dir' => $sort_dir]; |
|
| 127 | + |
|
| 128 | + /* |
|
| 129 | 129 | ** search form submited |
| 130 | 130 | */ |
| 131 | - if ($this->request->is_set_post('submit') || $keywords) { |
|
| 132 | - // clear arrays |
|
| 133 | - $id_ary = $u_search = []; |
|
| 134 | - $keywords_ary = ($keywords) ? explode(' ', $keywords) : []; |
|
| 135 | - |
|
| 136 | - if (!count($keywords_ary)) { |
|
| 137 | - return $this->helper->message('DIR_ERROR_KEYWORD'); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - $ex_cid_ary = $this->_get_exclude_categories($search_category, $search_child); |
|
| 141 | - |
|
| 142 | - $total_match_count = $this->search->keyword_search($keywords_ary, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_cid_ary, $cat_id, $id_ary, $start, $this->config['dir_show']); |
|
| 143 | - |
|
| 144 | - $l_search_matches = $this->user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count); |
|
| 145 | - |
|
| 146 | - if (count($id_ary)) { |
|
| 147 | - $sql_where = $this->db->sql_in_set('l.link_id', $id_ary); |
|
| 148 | - } else { |
|
| 149 | - return $this->helper->message('DIR_SEARCH_NO_RESULT'); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // A single wildcard will make the search results look ugly |
|
| 153 | - $hilit = phpbb_clean_search_string(str_replace(['+', '-', '|', '(', ')', '"'], ' ', $keywords)); |
|
| 154 | - $hilit = str_replace(' ', '|', $hilit); |
|
| 155 | - |
|
| 156 | - $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); |
|
| 157 | - |
|
| 158 | - ($u_hilit) ? $u_search['keywords'] = urlencode(htmlspecialchars_decode($keywords)) : ''; |
|
| 159 | - ($search_terms != 'all') ? $u_search['terms'] = $search_terms : ''; |
|
| 160 | - ($cat_id) ? $u_search['cat_id'] = $cat_id : ''; |
|
| 161 | - ($search_category) ? $u_search['cid'] = $search_category : ''; |
|
| 162 | - (!$search_child) ? $u_search['sc'] = 0 : ''; |
|
| 163 | - ($search_fields != 'all') ? $u_search['sf'] = $search_fields : ''; |
|
| 164 | - |
|
| 165 | - $base_url = [ |
|
| 166 | - 'routes' => 'ernadoo_phpbbdirectory_search_controller', |
|
| 167 | - 'params' => array_merge($u_search, $u_sort_param), |
|
| 168 | - ]; |
|
| 169 | - |
|
| 170 | - $u_search = $this->helper->route('ernadoo_phpbbdirectory_search_controller', array_merge($u_search, $u_sort_param)); |
|
| 171 | - |
|
| 172 | - $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $total_match_count, $this->config['dir_show'], $start); |
|
| 173 | - |
|
| 174 | - $this->template->assign_vars([ |
|
| 175 | - 'SEARCH_MATCHES' => $l_search_matches, |
|
| 176 | - 'SEARCH_WORDS' => $keywords, |
|
| 177 | - |
|
| 178 | - 'TOTAL_MATCHES' => $total_match_count, |
|
| 179 | - |
|
| 180 | - 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 181 | - 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 182 | - 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 183 | - 'S_SEARCH_ACTION' => $u_search, |
|
| 184 | - |
|
| 185 | - 'U_DIR_SEARCH' => $this->helper->route('ernadoo_phpbbdirectory_search_controller'), |
|
| 186 | - 'U_SEARCH_WORDS' => $u_search, |
|
| 187 | - ]); |
|
| 188 | - |
|
| 189 | - if ($cat_id) { |
|
| 190 | - $this->template->assign_vars([ |
|
| 191 | - 'SEARCH_CATEGORY' => $this->user->lang('RETURN_TO', \ernadoo\phpbbdirectory\core\categorie::getname((int) $cat_id)), |
|
| 192 | - 'U_SEARCH_CATEGORY' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]), |
|
| 193 | - ]); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - if ($sql_where) { |
|
| 197 | - $sql_array = [ |
|
| 198 | - 'SELECT' => 'l.link_name, l.link_description, l.link_url, l.link_uid, l.link_bitfield, l.link_flags, l.link_view, l.link_user_id, l.link_time, l.link_comment, l.link_flag, l.link_id, l.link_thumb, l.link_banner, c.cat_name, u.user_id, u.username, u.user_colour', |
|
| 199 | - 'FROM' => [ |
|
| 200 | - DIR_LINK_TABLE => 'l', ], |
|
| 201 | - 'LEFT_JOIN' => [ |
|
| 202 | - [ |
|
| 203 | - 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 204 | - 'ON' => 'l.link_cat = c.cat_id', |
|
| 205 | - ], |
|
| 206 | - [ |
|
| 207 | - 'FROM' => [USERS_TABLE => 'u'], |
|
| 208 | - 'ON' => 'u.user_id = l.link_user_id', |
|
| 209 | - ], |
|
| 210 | - ], |
|
| 211 | - 'WHERE' => $sql_where, ]; |
|
| 212 | - |
|
| 213 | - $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 214 | - $result = $this->db->sql_query($sql); |
|
| 215 | - |
|
| 216 | - $rowset = $this->db->sql_fetchrowset($result); |
|
| 217 | - |
|
| 218 | - if (count($rowset)) { |
|
| 219 | - if ($hilit) { |
|
| 220 | - // Remove bad highlights |
|
| 221 | - $hilit_array = array_filter(explode('|', $hilit), 'strlen'); |
|
| 222 | - foreach ($hilit_array as $key => $value) { |
|
| 223 | - $hilit_array[$key] = phpbb_clean_search_string($value); |
|
| 224 | - $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#')); |
|
| 225 | - $hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]); |
|
| 226 | - } |
|
| 227 | - $hilit = implode('|', $hilit_array); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - foreach ($rowset as $data) { |
|
| 231 | - $s_banner = $this->link->display_bann($data); |
|
| 232 | - $s_thumb = $this->link->display_thumb($data); |
|
| 233 | - $s_flag = $this->link->display_flag($data); |
|
| 234 | - |
|
| 235 | - $data['link_description'] = generate_text_for_display($data['link_description'], $data['link_uid'], $data['link_bitfield'], $data['link_flags']); |
|
| 236 | - |
|
| 237 | - if ($hilit) { |
|
| 238 | - $data['link_name'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_name']); |
|
| 239 | - $data['link_description'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_description']); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - $this->template->assign_block_vars('results', [ |
|
| 243 | - 'S_SITE' => $data['link_name'], |
|
| 244 | - 'S_DESCRIPTION' => $data['link_description'], |
|
| 245 | - 'S_COUNT' => $data['link_view'], |
|
| 246 | - 'S_CAT' => $data['cat_name'], |
|
| 247 | - 'S_USER' => get_username_string('full', $data['link_user_id'], $data['username'], $data['user_colour']), |
|
| 248 | - 'S_TIME' => ($data['link_time'] != 0) ? $this->user->format_date($data['link_time']) : '', |
|
| 249 | - 'S_COMMENT' => $data['link_comment'], |
|
| 250 | - |
|
| 251 | - 'THUMB' => '<img src="'.$s_thumb.'" alt="'.$this->user->lang['DIR_THUMB'].'" title="'.$data['link_name'].'"/>', |
|
| 252 | - 'IMG_BANNER' => $s_banner, |
|
| 253 | - 'IMG_FLAG' => $s_flag, |
|
| 254 | - 'ON_CLICK' => "onclick=\"window.open('".$this->helper->route('ernadoo_phpbbdirectory_view_controller', ['link_id' => (int) $data['link_id']])."'); return false;\"", |
|
| 255 | - |
|
| 256 | - 'L_DIR_SEARCH_NB_CLICKS' => $this->user->lang('DIR_SEARCH_NB_CLICKS', (int) $data['link_view']), |
|
| 257 | - 'L_DIR_SEARCH_NB_COMMS' => $this->user->lang('DIR_SEARCH_NB_COMMS', (int) $data['link_comment']), |
|
| 258 | - |
|
| 259 | - 'U_COMMENT' => $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $data['link_id']]), |
|
| 260 | - 'U_SITE' => $data['link_url'], |
|
| 261 | - 'LINK_ID' => $data['link_id'], |
|
| 262 | - ]); |
|
| 263 | - |
|
| 264 | - if ($s_banner) { |
|
| 265 | - $this->template->assign_block_vars('results.banner', []); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - if ($this->config['dir_activ_flag']) { |
|
| 269 | - $this->template->assign_block_vars('results.switch_dir_flag', []); |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - unset($rowset); |
|
| 273 | - |
|
| 274 | - return $this->helper->render('search_results.html', $this->user->lang['DIR_MAKE_SEARCH']); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - $s_catlist = $this->categorie->make_cat_select(); |
|
| 280 | - |
|
| 281 | - if (!$s_catlist) { |
|
| 282 | - return $this->helper->message('NO_SEARCH'); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - $this->template->assign_vars([ |
|
| 286 | - 'S_POST_ACTION' => build_url(true), |
|
| 287 | - 'S_KEYWORD' => $keywords, |
|
| 288 | - 'S_CATLIST' => $s_catlist, |
|
| 289 | - 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 290 | - 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 291 | - 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 292 | - ]); |
|
| 293 | - |
|
| 294 | - return $this->helper->render('search_body.html', $this->user->lang['DIR_MAKE_SEARCH']); |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * @param array $search_category |
|
| 299 | - * @param bool $search_child |
|
| 300 | - * |
|
| 301 | - * @return array Categories to exclude from search |
|
| 302 | - */ |
|
| 303 | - private function _get_exclude_categories(&$search_category, $search_child) |
|
| 304 | - { |
|
| 305 | - $sql = 'SELECT cat_id, parent_id, right_id |
|
| 131 | + if ($this->request->is_set_post('submit') || $keywords) { |
|
| 132 | + // clear arrays |
|
| 133 | + $id_ary = $u_search = []; |
|
| 134 | + $keywords_ary = ($keywords) ? explode(' ', $keywords) : []; |
|
| 135 | + |
|
| 136 | + if (!count($keywords_ary)) { |
|
| 137 | + return $this->helper->message('DIR_ERROR_KEYWORD'); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + $ex_cid_ary = $this->_get_exclude_categories($search_category, $search_child); |
|
| 141 | + |
|
| 142 | + $total_match_count = $this->search->keyword_search($keywords_ary, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_cid_ary, $cat_id, $id_ary, $start, $this->config['dir_show']); |
|
| 143 | + |
|
| 144 | + $l_search_matches = $this->user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count); |
|
| 145 | + |
|
| 146 | + if (count($id_ary)) { |
|
| 147 | + $sql_where = $this->db->sql_in_set('l.link_id', $id_ary); |
|
| 148 | + } else { |
|
| 149 | + return $this->helper->message('DIR_SEARCH_NO_RESULT'); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // A single wildcard will make the search results look ugly |
|
| 153 | + $hilit = phpbb_clean_search_string(str_replace(['+', '-', '|', '(', ')', '"'], ' ', $keywords)); |
|
| 154 | + $hilit = str_replace(' ', '|', $hilit); |
|
| 155 | + |
|
| 156 | + $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); |
|
| 157 | + |
|
| 158 | + ($u_hilit) ? $u_search['keywords'] = urlencode(htmlspecialchars_decode($keywords)) : ''; |
|
| 159 | + ($search_terms != 'all') ? $u_search['terms'] = $search_terms : ''; |
|
| 160 | + ($cat_id) ? $u_search['cat_id'] = $cat_id : ''; |
|
| 161 | + ($search_category) ? $u_search['cid'] = $search_category : ''; |
|
| 162 | + (!$search_child) ? $u_search['sc'] = 0 : ''; |
|
| 163 | + ($search_fields != 'all') ? $u_search['sf'] = $search_fields : ''; |
|
| 164 | + |
|
| 165 | + $base_url = [ |
|
| 166 | + 'routes' => 'ernadoo_phpbbdirectory_search_controller', |
|
| 167 | + 'params' => array_merge($u_search, $u_sort_param), |
|
| 168 | + ]; |
|
| 169 | + |
|
| 170 | + $u_search = $this->helper->route('ernadoo_phpbbdirectory_search_controller', array_merge($u_search, $u_sort_param)); |
|
| 171 | + |
|
| 172 | + $this->pagination->generate_template_pagination($base_url, 'pagination', 'page', $total_match_count, $this->config['dir_show'], $start); |
|
| 173 | + |
|
| 174 | + $this->template->assign_vars([ |
|
| 175 | + 'SEARCH_MATCHES' => $l_search_matches, |
|
| 176 | + 'SEARCH_WORDS' => $keywords, |
|
| 177 | + |
|
| 178 | + 'TOTAL_MATCHES' => $total_match_count, |
|
| 179 | + |
|
| 180 | + 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 181 | + 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 182 | + 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 183 | + 'S_SEARCH_ACTION' => $u_search, |
|
| 184 | + |
|
| 185 | + 'U_DIR_SEARCH' => $this->helper->route('ernadoo_phpbbdirectory_search_controller'), |
|
| 186 | + 'U_SEARCH_WORDS' => $u_search, |
|
| 187 | + ]); |
|
| 188 | + |
|
| 189 | + if ($cat_id) { |
|
| 190 | + $this->template->assign_vars([ |
|
| 191 | + 'SEARCH_CATEGORY' => $this->user->lang('RETURN_TO', \ernadoo\phpbbdirectory\core\categorie::getname((int) $cat_id)), |
|
| 192 | + 'U_SEARCH_CATEGORY' => $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]), |
|
| 193 | + ]); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + if ($sql_where) { |
|
| 197 | + $sql_array = [ |
|
| 198 | + 'SELECT' => 'l.link_name, l.link_description, l.link_url, l.link_uid, l.link_bitfield, l.link_flags, l.link_view, l.link_user_id, l.link_time, l.link_comment, l.link_flag, l.link_id, l.link_thumb, l.link_banner, c.cat_name, u.user_id, u.username, u.user_colour', |
|
| 199 | + 'FROM' => [ |
|
| 200 | + DIR_LINK_TABLE => 'l', ], |
|
| 201 | + 'LEFT_JOIN' => [ |
|
| 202 | + [ |
|
| 203 | + 'FROM' => [DIR_CAT_TABLE => 'c'], |
|
| 204 | + 'ON' => 'l.link_cat = c.cat_id', |
|
| 205 | + ], |
|
| 206 | + [ |
|
| 207 | + 'FROM' => [USERS_TABLE => 'u'], |
|
| 208 | + 'ON' => 'u.user_id = l.link_user_id', |
|
| 209 | + ], |
|
| 210 | + ], |
|
| 211 | + 'WHERE' => $sql_where, ]; |
|
| 212 | + |
|
| 213 | + $sql = $this->db->sql_build_query('SELECT', $sql_array); |
|
| 214 | + $result = $this->db->sql_query($sql); |
|
| 215 | + |
|
| 216 | + $rowset = $this->db->sql_fetchrowset($result); |
|
| 217 | + |
|
| 218 | + if (count($rowset)) { |
|
| 219 | + if ($hilit) { |
|
| 220 | + // Remove bad highlights |
|
| 221 | + $hilit_array = array_filter(explode('|', $hilit), 'strlen'); |
|
| 222 | + foreach ($hilit_array as $key => $value) { |
|
| 223 | + $hilit_array[$key] = phpbb_clean_search_string($value); |
|
| 224 | + $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#')); |
|
| 225 | + $hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]); |
|
| 226 | + } |
|
| 227 | + $hilit = implode('|', $hilit_array); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + foreach ($rowset as $data) { |
|
| 231 | + $s_banner = $this->link->display_bann($data); |
|
| 232 | + $s_thumb = $this->link->display_thumb($data); |
|
| 233 | + $s_flag = $this->link->display_flag($data); |
|
| 234 | + |
|
| 235 | + $data['link_description'] = generate_text_for_display($data['link_description'], $data['link_uid'], $data['link_bitfield'], $data['link_flags']); |
|
| 236 | + |
|
| 237 | + if ($hilit) { |
|
| 238 | + $data['link_name'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_name']); |
|
| 239 | + $data['link_description'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_description']); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + $this->template->assign_block_vars('results', [ |
|
| 243 | + 'S_SITE' => $data['link_name'], |
|
| 244 | + 'S_DESCRIPTION' => $data['link_description'], |
|
| 245 | + 'S_COUNT' => $data['link_view'], |
|
| 246 | + 'S_CAT' => $data['cat_name'], |
|
| 247 | + 'S_USER' => get_username_string('full', $data['link_user_id'], $data['username'], $data['user_colour']), |
|
| 248 | + 'S_TIME' => ($data['link_time'] != 0) ? $this->user->format_date($data['link_time']) : '', |
|
| 249 | + 'S_COMMENT' => $data['link_comment'], |
|
| 250 | + |
|
| 251 | + 'THUMB' => '<img src="'.$s_thumb.'" alt="'.$this->user->lang['DIR_THUMB'].'" title="'.$data['link_name'].'"/>', |
|
| 252 | + 'IMG_BANNER' => $s_banner, |
|
| 253 | + 'IMG_FLAG' => $s_flag, |
|
| 254 | + 'ON_CLICK' => "onclick=\"window.open('".$this->helper->route('ernadoo_phpbbdirectory_view_controller', ['link_id' => (int) $data['link_id']])."'); return false;\"", |
|
| 255 | + |
|
| 256 | + 'L_DIR_SEARCH_NB_CLICKS' => $this->user->lang('DIR_SEARCH_NB_CLICKS', (int) $data['link_view']), |
|
| 257 | + 'L_DIR_SEARCH_NB_COMMS' => $this->user->lang('DIR_SEARCH_NB_COMMS', (int) $data['link_comment']), |
|
| 258 | + |
|
| 259 | + 'U_COMMENT' => $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $data['link_id']]), |
|
| 260 | + 'U_SITE' => $data['link_url'], |
|
| 261 | + 'LINK_ID' => $data['link_id'], |
|
| 262 | + ]); |
|
| 263 | + |
|
| 264 | + if ($s_banner) { |
|
| 265 | + $this->template->assign_block_vars('results.banner', []); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + if ($this->config['dir_activ_flag']) { |
|
| 269 | + $this->template->assign_block_vars('results.switch_dir_flag', []); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + unset($rowset); |
|
| 273 | + |
|
| 274 | + return $this->helper->render('search_results.html', $this->user->lang['DIR_MAKE_SEARCH']); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + $s_catlist = $this->categorie->make_cat_select(); |
|
| 280 | + |
|
| 281 | + if (!$s_catlist) { |
|
| 282 | + return $this->helper->message('NO_SEARCH'); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + $this->template->assign_vars([ |
|
| 286 | + 'S_POST_ACTION' => build_url(true), |
|
| 287 | + 'S_KEYWORD' => $keywords, |
|
| 288 | + 'S_CATLIST' => $s_catlist, |
|
| 289 | + 'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
| 290 | + 'S_SELECT_SORT_KEY' => $s_sort_key, |
|
| 291 | + 'S_SELECT_SORT_DAYS' => $s_limit_days, |
|
| 292 | + ]); |
|
| 293 | + |
|
| 294 | + return $this->helper->render('search_body.html', $this->user->lang['DIR_MAKE_SEARCH']); |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * @param array $search_category |
|
| 299 | + * @param bool $search_child |
|
| 300 | + * |
|
| 301 | + * @return array Categories to exclude from search |
|
| 302 | + */ |
|
| 303 | + private function _get_exclude_categories(&$search_category, $search_child) |
|
| 304 | + { |
|
| 305 | + $sql = 'SELECT cat_id, parent_id, right_id |
|
| 306 | 306 | FROM '.DIR_CAT_TABLE.' |
| 307 | 307 | ORDER BY left_id'; |
| 308 | - $result = $this->db->sql_query($sql); |
|
| 309 | - |
|
| 310 | - $right_id = 0; |
|
| 311 | - $reset_search_category = true; |
|
| 312 | - $ex_cid_ary = []; |
|
| 313 | - |
|
| 314 | - while ($row = $this->db->sql_fetchrow($result)) { |
|
| 315 | - if (count($search_category)) { |
|
| 316 | - if ($search_child) { |
|
| 317 | - if (in_array($row['cat_id'], $search_category) && $row['right_id'] > $right_id) { |
|
| 318 | - $right_id = (int) $row['right_id']; |
|
| 319 | - } elseif ($row['right_id'] < $right_id) { |
|
| 320 | - continue; |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - if (!in_array($row['cat_id'], $search_category)) { |
|
| 325 | - $ex_cid_ary[] = (int) $row['cat_id']; |
|
| 326 | - $reset_search_category = false; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - $this->db->sql_freeresult($result); |
|
| 331 | - |
|
| 332 | - if ($reset_search_category) { |
|
| 333 | - $search_category = []; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return $ex_cid_ary; |
|
| 337 | - } |
|
| 308 | + $result = $this->db->sql_query($sql); |
|
| 309 | + |
|
| 310 | + $right_id = 0; |
|
| 311 | + $reset_search_category = true; |
|
| 312 | + $ex_cid_ary = []; |
|
| 313 | + |
|
| 314 | + while ($row = $this->db->sql_fetchrow($result)) { |
|
| 315 | + if (count($search_category)) { |
|
| 316 | + if ($search_child) { |
|
| 317 | + if (in_array($row['cat_id'], $search_category) && $row['right_id'] > $right_id) { |
|
| 318 | + $right_id = (int) $row['right_id']; |
|
| 319 | + } elseif ($row['right_id'] < $right_id) { |
|
| 320 | + continue; |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + if (!in_array($row['cat_id'], $search_category)) { |
|
| 325 | + $ex_cid_ary[] = (int) $row['cat_id']; |
|
| 326 | + $reset_search_category = false; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + $this->db->sql_freeresult($result); |
|
| 331 | + |
|
| 332 | + if ($reset_search_category) { |
|
| 333 | + $search_category = []; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + return $ex_cid_ary; |
|
| 337 | + } |
|
| 338 | 338 | } |
@@ -12,602 +12,602 @@ |
||
| 12 | 12 | |
| 13 | 13 | class links |
| 14 | 14 | { |
| 15 | - private $link_user_id; |
|
| 16 | - private $site_name; |
|
| 17 | - private $url; |
|
| 18 | - private $description; |
|
| 19 | - private $guest_email; |
|
| 20 | - private $rss; |
|
| 21 | - private $banner; |
|
| 22 | - private $back; |
|
| 23 | - private $flag; |
|
| 24 | - |
|
| 25 | - private $captcha; |
|
| 26 | - private $s_hidden_fields = []; |
|
| 27 | - |
|
| 28 | - /** @var \phpbb\db\driver\driver_interface */ |
|
| 29 | - protected $db; |
|
| 30 | - |
|
| 31 | - /** @var \phpbb\config\config */ |
|
| 32 | - protected $config; |
|
| 33 | - |
|
| 34 | - /** @var \phpbb\template\template */ |
|
| 35 | - protected $template; |
|
| 36 | - |
|
| 37 | - /** @var \phpbb\user */ |
|
| 38 | - protected $user; |
|
| 39 | - |
|
| 40 | - /** @var \phpbb\controller\helper */ |
|
| 41 | - protected $helper; |
|
| 42 | - |
|
| 43 | - /** @var \phpbb\request\request */ |
|
| 44 | - protected $request; |
|
| 45 | - |
|
| 46 | - /** @var \phpbb\auth\auth */ |
|
| 47 | - protected $auth; |
|
| 48 | - |
|
| 49 | - /** @var \phpbb\captcha\factory */ |
|
| 50 | - protected $captcha_factory; |
|
| 51 | - |
|
| 52 | - /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 53 | - protected $categorie; |
|
| 54 | - |
|
| 55 | - /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 56 | - protected $link; |
|
| 57 | - |
|
| 58 | - /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 59 | - protected $dir_helper; |
|
| 60 | - |
|
| 61 | - /** @var string phpBB root path */ |
|
| 62 | - protected $root_path; |
|
| 63 | - |
|
| 64 | - /** @var string phpEx */ |
|
| 65 | - protected $php_ext; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Constructor. |
|
| 69 | - * |
|
| 70 | - * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | - * @param \phpbb\config\config $config Config object |
|
| 72 | - * @param \phpbb\template\template $template Template object |
|
| 73 | - * @param \phpbb\user $user User object |
|
| 74 | - * @param \phpbb\controller\helper $helper Controller helper object |
|
| 75 | - * @param \phpbb\request\request $request Request object |
|
| 76 | - * @param \phpbb\auth\auth $auth Auth object |
|
| 77 | - * @param \phpbb\captcha\factory $captcha_factory Captcha object |
|
| 78 | - * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 79 | - * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 80 | - * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 81 | - * @param string $root_path phpBB root path |
|
| 82 | - * @param string $php_ext phpEx |
|
| 83 | - */ |
|
| 84 | - public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\captcha\factory $captcha_factory, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link, \ernadoo\phpbbdirectory\core\helper $dir_helper, $root_path, $php_ext) |
|
| 85 | - { |
|
| 86 | - $this->db = $db; |
|
| 87 | - $this->config = $config; |
|
| 88 | - $this->template = $template; |
|
| 89 | - $this->user = $user; |
|
| 90 | - $this->helper = $helper; |
|
| 91 | - $this->request = $request; |
|
| 92 | - $this->auth = $auth; |
|
| 93 | - $this->captcha_factory = $captcha_factory; |
|
| 94 | - $this->categorie = $categorie; |
|
| 95 | - $this->link = $link; |
|
| 96 | - $this->dir_helper = $dir_helper; |
|
| 97 | - $this->root_path = $root_path; |
|
| 98 | - $this->php_ext = $php_ext; |
|
| 99 | - |
|
| 100 | - $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 101 | - |
|
| 102 | - $this->template->assign_vars([ |
|
| 103 | - 'S_PHPBB_DIRECTORY' => true, |
|
| 104 | - 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 105 | - ]); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Delete a link. |
|
| 110 | - * |
|
| 111 | - * @param int $cat_id The category ID |
|
| 112 | - * @param int $link_id The link ID |
|
| 113 | - * |
|
| 114 | - * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 115 | - */ |
|
| 116 | - public function delete_link($cat_id, $link_id) |
|
| 117 | - { |
|
| 118 | - if ($this->request->is_set_post('cancel')) { |
|
| 119 | - $redirect = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 120 | - redirect($redirect); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $sql = 'SELECT link_user_id |
|
| 15 | + private $link_user_id; |
|
| 16 | + private $site_name; |
|
| 17 | + private $url; |
|
| 18 | + private $description; |
|
| 19 | + private $guest_email; |
|
| 20 | + private $rss; |
|
| 21 | + private $banner; |
|
| 22 | + private $back; |
|
| 23 | + private $flag; |
|
| 24 | + |
|
| 25 | + private $captcha; |
|
| 26 | + private $s_hidden_fields = []; |
|
| 27 | + |
|
| 28 | + /** @var \phpbb\db\driver\driver_interface */ |
|
| 29 | + protected $db; |
|
| 30 | + |
|
| 31 | + /** @var \phpbb\config\config */ |
|
| 32 | + protected $config; |
|
| 33 | + |
|
| 34 | + /** @var \phpbb\template\template */ |
|
| 35 | + protected $template; |
|
| 36 | + |
|
| 37 | + /** @var \phpbb\user */ |
|
| 38 | + protected $user; |
|
| 39 | + |
|
| 40 | + /** @var \phpbb\controller\helper */ |
|
| 41 | + protected $helper; |
|
| 42 | + |
|
| 43 | + /** @var \phpbb\request\request */ |
|
| 44 | + protected $request; |
|
| 45 | + |
|
| 46 | + /** @var \phpbb\auth\auth */ |
|
| 47 | + protected $auth; |
|
| 48 | + |
|
| 49 | + /** @var \phpbb\captcha\factory */ |
|
| 50 | + protected $captcha_factory; |
|
| 51 | + |
|
| 52 | + /** @var \ernadoo\phpbbdirectory\core\categorie */ |
|
| 53 | + protected $categorie; |
|
| 54 | + |
|
| 55 | + /** @var \ernadoo\phpbbdirectory\core\link */ |
|
| 56 | + protected $link; |
|
| 57 | + |
|
| 58 | + /** @var \ernadoo\phpbbdirectory\core\helper */ |
|
| 59 | + protected $dir_helper; |
|
| 60 | + |
|
| 61 | + /** @var string phpBB root path */ |
|
| 62 | + protected $root_path; |
|
| 63 | + |
|
| 64 | + /** @var string phpEx */ |
|
| 65 | + protected $php_ext; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Constructor. |
|
| 69 | + * |
|
| 70 | + * @param \phpbb\db\driver\driver_interface $db Database object |
|
| 71 | + * @param \phpbb\config\config $config Config object |
|
| 72 | + * @param \phpbb\template\template $template Template object |
|
| 73 | + * @param \phpbb\user $user User object |
|
| 74 | + * @param \phpbb\controller\helper $helper Controller helper object |
|
| 75 | + * @param \phpbb\request\request $request Request object |
|
| 76 | + * @param \phpbb\auth\auth $auth Auth object |
|
| 77 | + * @param \phpbb\captcha\factory $captcha_factory Captcha object |
|
| 78 | + * @param \ernadoo\phpbbdirectory\core\categorie $categorie PhpBB Directory extension categorie object |
|
| 79 | + * @param \ernadoo\phpbbdirectory\core\link $link PhpBB Directory extension link object |
|
| 80 | + * @param \ernadoo\phpbbdirectory\core\helper $dir_helper PhpBB Directory extension helper object |
|
| 81 | + * @param string $root_path phpBB root path |
|
| 82 | + * @param string $php_ext phpEx |
|
| 83 | + */ |
|
| 84 | + public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\captcha\factory $captcha_factory, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link, \ernadoo\phpbbdirectory\core\helper $dir_helper, $root_path, $php_ext) |
|
| 85 | + { |
|
| 86 | + $this->db = $db; |
|
| 87 | + $this->config = $config; |
|
| 88 | + $this->template = $template; |
|
| 89 | + $this->user = $user; |
|
| 90 | + $this->helper = $helper; |
|
| 91 | + $this->request = $request; |
|
| 92 | + $this->auth = $auth; |
|
| 93 | + $this->captcha_factory = $captcha_factory; |
|
| 94 | + $this->categorie = $categorie; |
|
| 95 | + $this->link = $link; |
|
| 96 | + $this->dir_helper = $dir_helper; |
|
| 97 | + $this->root_path = $root_path; |
|
| 98 | + $this->php_ext = $php_ext; |
|
| 99 | + |
|
| 100 | + $this->user->add_lang_ext('ernadoo/phpbbdirectory', 'directory'); |
|
| 101 | + |
|
| 102 | + $this->template->assign_vars([ |
|
| 103 | + 'S_PHPBB_DIRECTORY' => true, |
|
| 104 | + 'DIRECTORY_TRANSLATION_INFO' => (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '', |
|
| 105 | + ]); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Delete a link. |
|
| 110 | + * |
|
| 111 | + * @param int $cat_id The category ID |
|
| 112 | + * @param int $link_id The link ID |
|
| 113 | + * |
|
| 114 | + * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 115 | + */ |
|
| 116 | + public function delete_link($cat_id, $link_id) |
|
| 117 | + { |
|
| 118 | + if ($this->request->is_set_post('cancel')) { |
|
| 119 | + $redirect = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 120 | + redirect($redirect); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $sql = 'SELECT link_user_id |
|
| 124 | 124 | FROM '.DIR_LINK_TABLE.' |
| 125 | 125 | WHERE link_id = '.(int) $link_id; |
| 126 | - $result = $this->db->sql_query($sql); |
|
| 127 | - $link_data = $this->db->sql_fetchrow($result); |
|
| 128 | - |
|
| 129 | - if (empty($link_data)) { |
|
| 130 | - throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $link_data['link_user_id'] && $this->auth->acl_get('u_delete_dir'))); |
|
| 134 | - |
|
| 135 | - if (!$delete_allowed) { |
|
| 136 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - if (confirm_box(true)) { |
|
| 140 | - $this->link->del($cat_id, $link_id); |
|
| 141 | - |
|
| 142 | - $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 143 | - meta_refresh(3, $meta_info); |
|
| 144 | - $message = $this->user->lang['DIR_DELETE_OK'].'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>'); |
|
| 145 | - |
|
| 146 | - return $this->helper->message($message); |
|
| 147 | - } else { |
|
| 148 | - confirm_box(false, 'DIR_DELETE_SITE'); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Edit a link. |
|
| 154 | - * |
|
| 155 | - * @param int $cat_id The category ID |
|
| 156 | - * @param int $link_id The link ID |
|
| 157 | - * |
|
| 158 | - * @throws \phpbb\exception\http_exception |
|
| 159 | - * |
|
| 160 | - * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 161 | - */ |
|
| 162 | - public function edit_link($cat_id, $link_id) |
|
| 163 | - { |
|
| 164 | - $sql = 'SELECT link_user_id |
|
| 126 | + $result = $this->db->sql_query($sql); |
|
| 127 | + $link_data = $this->db->sql_fetchrow($result); |
|
| 128 | + |
|
| 129 | + if (empty($link_data)) { |
|
| 130 | + throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $link_data['link_user_id'] && $this->auth->acl_get('u_delete_dir'))); |
|
| 134 | + |
|
| 135 | + if (!$delete_allowed) { |
|
| 136 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + if (confirm_box(true)) { |
|
| 140 | + $this->link->del($cat_id, $link_id); |
|
| 141 | + |
|
| 142 | + $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 143 | + meta_refresh(3, $meta_info); |
|
| 144 | + $message = $this->user->lang['DIR_DELETE_OK'].'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>'); |
|
| 145 | + |
|
| 146 | + return $this->helper->message($message); |
|
| 147 | + } else { |
|
| 148 | + confirm_box(false, 'DIR_DELETE_SITE'); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Edit a link. |
|
| 154 | + * |
|
| 155 | + * @param int $cat_id The category ID |
|
| 156 | + * @param int $link_id The link ID |
|
| 157 | + * |
|
| 158 | + * @throws \phpbb\exception\http_exception |
|
| 159 | + * |
|
| 160 | + * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 161 | + */ |
|
| 162 | + public function edit_link($cat_id, $link_id) |
|
| 163 | + { |
|
| 164 | + $sql = 'SELECT link_user_id |
|
| 165 | 165 | FROM '.DIR_LINK_TABLE.' |
| 166 | 166 | WHERE link_id = '.(int) $link_id; |
| 167 | - $result = $this->db->sql_query($sql); |
|
| 168 | - $link_data = $this->db->sql_fetchrow($result); |
|
| 169 | - $this->link_user_id = (int) $link_data['link_user_id']; |
|
| 170 | - |
|
| 171 | - $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == (int) $link_data['link_user_id'] && $this->auth->acl_get('u_edit_dir')))); |
|
| 172 | - |
|
| 173 | - if (!$edit_allowed) { |
|
| 174 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $cat_id = $this->request->variable('id', $cat_id); |
|
| 178 | - $submit = $this->request->is_set_post('submit') ? true : false; |
|
| 179 | - $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 180 | - $title = $this->user->lang['DIR_EDIT_SITE']; |
|
| 181 | - |
|
| 182 | - $this->template->assign_block_vars('dir_navlinks', [ |
|
| 183 | - 'FORUM_NAME' => $title, |
|
| 184 | - 'U_VIEW_FORUM' => $this->helper->route('ernadoo_phpbbdirectory_edit_controller', ['cat_id' => (int) $cat_id, 'link_id' => $link_id]), |
|
| 185 | - ]); |
|
| 186 | - |
|
| 187 | - $this->categorie->get($cat_id); |
|
| 188 | - |
|
| 189 | - // If form is done |
|
| 190 | - if ($submit || $refresh) { |
|
| 191 | - if (false != ($result = $this->_data_processing($cat_id, $link_id, 'edit'))) { |
|
| 192 | - return $result; |
|
| 193 | - } |
|
| 194 | - } else { |
|
| 195 | - $sql = 'SELECT link_id, link_uid, link_flags, link_bitfield, link_cat, link_url, link_description, link_guest_email, link_name, link_rss, link_back, link_banner, link_flag, link_cat, link_time |
|
| 167 | + $result = $this->db->sql_query($sql); |
|
| 168 | + $link_data = $this->db->sql_fetchrow($result); |
|
| 169 | + $this->link_user_id = (int) $link_data['link_user_id']; |
|
| 170 | + |
|
| 171 | + $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == (int) $link_data['link_user_id'] && $this->auth->acl_get('u_edit_dir')))); |
|
| 172 | + |
|
| 173 | + if (!$edit_allowed) { |
|
| 174 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $cat_id = $this->request->variable('id', $cat_id); |
|
| 178 | + $submit = $this->request->is_set_post('submit') ? true : false; |
|
| 179 | + $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 180 | + $title = $this->user->lang['DIR_EDIT_SITE']; |
|
| 181 | + |
|
| 182 | + $this->template->assign_block_vars('dir_navlinks', [ |
|
| 183 | + 'FORUM_NAME' => $title, |
|
| 184 | + 'U_VIEW_FORUM' => $this->helper->route('ernadoo_phpbbdirectory_edit_controller', ['cat_id' => (int) $cat_id, 'link_id' => $link_id]), |
|
| 185 | + ]); |
|
| 186 | + |
|
| 187 | + $this->categorie->get($cat_id); |
|
| 188 | + |
|
| 189 | + // If form is done |
|
| 190 | + if ($submit || $refresh) { |
|
| 191 | + if (false != ($result = $this->_data_processing($cat_id, $link_id, 'edit'))) { |
|
| 192 | + return $result; |
|
| 193 | + } |
|
| 194 | + } else { |
|
| 195 | + $sql = 'SELECT link_id, link_uid, link_flags, link_bitfield, link_cat, link_url, link_description, link_guest_email, link_name, link_rss, link_back, link_banner, link_flag, link_cat, link_time |
|
| 196 | 196 | FROM '.DIR_LINK_TABLE.' |
| 197 | 197 | WHERE link_id = '.(int) $link_id; |
| 198 | - $result = $this->db->sql_query($sql); |
|
| 199 | - |
|
| 200 | - $site = $this->db->sql_fetchrow($result); |
|
| 201 | - |
|
| 202 | - if (empty($site['link_id'])) { |
|
| 203 | - throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - $this->s_hidden_fields = [ |
|
| 207 | - 'old_cat_id' => $site['link_cat'], |
|
| 208 | - 'old_banner' => $site['link_banner'], |
|
| 209 | - ]; |
|
| 210 | - |
|
| 211 | - $site_description = generate_text_for_edit($site['link_description'], $site['link_uid'], $site['link_flags']); |
|
| 212 | - $site['link_banner'] = (preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $site['link_banner'])) ? $site['link_banner'] : ''; |
|
| 213 | - |
|
| 214 | - $this->url = $site['link_url']; |
|
| 215 | - $this->site_name = $site['link_name']; |
|
| 216 | - $this->description = $site_description['text']; |
|
| 217 | - $this->guest_email = $site['link_guest_email']; |
|
| 218 | - $this->rss = $site['link_rss']; |
|
| 219 | - $this->banner = $site['link_banner']; |
|
| 220 | - $this->back = $site['link_back']; |
|
| 221 | - $this->flag = $site['link_flag']; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - $this->_populate_form($cat_id, 'edit', $title); |
|
| 225 | - |
|
| 226 | - return $this->helper->render('add_site.html', $title); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Display add form. |
|
| 231 | - * |
|
| 232 | - * @param int $cat_id The category ID |
|
| 233 | - * |
|
| 234 | - * @throws \phpbb\exception\http_exception |
|
| 235 | - * |
|
| 236 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 237 | - */ |
|
| 238 | - public function new_link($cat_id) |
|
| 239 | - { |
|
| 240 | - if (!$this->auth->acl_get('u_submit_dir')) { |
|
| 241 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - $cat_id = $this->request->variable('id', $cat_id); |
|
| 245 | - $submit = $this->request->is_set_post('submit') ? true : false; |
|
| 246 | - $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 247 | - $title = $this->user->lang['DIR_NEW_SITE']; |
|
| 248 | - |
|
| 249 | - $this->template->assign_block_vars('dir_navlinks', [ |
|
| 250 | - 'FORUM_NAME' => $title, |
|
| 251 | - 'U_VIEW_FORUM' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', ['cat_id' => (int) $cat_id]), |
|
| 252 | - ]); |
|
| 253 | - |
|
| 254 | - $this->categorie->get($cat_id); |
|
| 255 | - |
|
| 256 | - // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. |
|
| 257 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 258 | - $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); |
|
| 259 | - $this->captcha->init(CONFIRM_POST); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - // If form is done |
|
| 263 | - if ($submit || $refresh) { |
|
| 264 | - if (false != ($result = $this->_data_processing($cat_id))) { |
|
| 265 | - return $result; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - $this->_populate_form($cat_id, 'new', $title); |
|
| 270 | - |
|
| 271 | - return $this->helper->render('add_site.html', $title); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * View link controller. |
|
| 276 | - * |
|
| 277 | - * @param int $link_id The link ID |
|
| 278 | - * |
|
| 279 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 280 | - */ |
|
| 281 | - public function view_link($link_id) |
|
| 282 | - { |
|
| 283 | - return $this->link->view($link_id); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Vote for a link. |
|
| 288 | - * |
|
| 289 | - * @param int $cat_id The category ID |
|
| 290 | - * @param int $link_id The link ID |
|
| 291 | - * |
|
| 292 | - * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 293 | - */ |
|
| 294 | - public function vote_link($cat_id, $link_id) |
|
| 295 | - { |
|
| 296 | - $this->categorie->get($cat_id); |
|
| 297 | - |
|
| 298 | - if (!$this->auth->acl_get('u_vote_dir') || !$this->categorie->data['cat_allow_votes']) { |
|
| 299 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $data = [ |
|
| 303 | - 'vote_link_id' => (int) $link_id, |
|
| 304 | - 'vote_user_id' => (int) $this->user->data['user_id'], |
|
| 305 | - ]; |
|
| 306 | - |
|
| 307 | - // We check if user had already vot for this website. |
|
| 308 | - $sql = 'SELECT vote_link_id |
|
| 198 | + $result = $this->db->sql_query($sql); |
|
| 199 | + |
|
| 200 | + $site = $this->db->sql_fetchrow($result); |
|
| 201 | + |
|
| 202 | + if (empty($site['link_id'])) { |
|
| 203 | + throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS'); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + $this->s_hidden_fields = [ |
|
| 207 | + 'old_cat_id' => $site['link_cat'], |
|
| 208 | + 'old_banner' => $site['link_banner'], |
|
| 209 | + ]; |
|
| 210 | + |
|
| 211 | + $site_description = generate_text_for_edit($site['link_description'], $site['link_uid'], $site['link_flags']); |
|
| 212 | + $site['link_banner'] = (preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $site['link_banner'])) ? $site['link_banner'] : ''; |
|
| 213 | + |
|
| 214 | + $this->url = $site['link_url']; |
|
| 215 | + $this->site_name = $site['link_name']; |
|
| 216 | + $this->description = $site_description['text']; |
|
| 217 | + $this->guest_email = $site['link_guest_email']; |
|
| 218 | + $this->rss = $site['link_rss']; |
|
| 219 | + $this->banner = $site['link_banner']; |
|
| 220 | + $this->back = $site['link_back']; |
|
| 221 | + $this->flag = $site['link_flag']; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + $this->_populate_form($cat_id, 'edit', $title); |
|
| 225 | + |
|
| 226 | + return $this->helper->render('add_site.html', $title); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Display add form. |
|
| 231 | + * |
|
| 232 | + * @param int $cat_id The category ID |
|
| 233 | + * |
|
| 234 | + * @throws \phpbb\exception\http_exception |
|
| 235 | + * |
|
| 236 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 237 | + */ |
|
| 238 | + public function new_link($cat_id) |
|
| 239 | + { |
|
| 240 | + if (!$this->auth->acl_get('u_submit_dir')) { |
|
| 241 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + $cat_id = $this->request->variable('id', $cat_id); |
|
| 245 | + $submit = $this->request->is_set_post('submit') ? true : false; |
|
| 246 | + $refresh = $this->request->is_set_post('refresh_vc') ? true : false; |
|
| 247 | + $title = $this->user->lang['DIR_NEW_SITE']; |
|
| 248 | + |
|
| 249 | + $this->template->assign_block_vars('dir_navlinks', [ |
|
| 250 | + 'FORUM_NAME' => $title, |
|
| 251 | + 'U_VIEW_FORUM' => $this->helper->route('ernadoo_phpbbdirectory_new_controller', ['cat_id' => (int) $cat_id]), |
|
| 252 | + ]); |
|
| 253 | + |
|
| 254 | + $this->categorie->get($cat_id); |
|
| 255 | + |
|
| 256 | + // The CAPTCHA kicks in here. We can't help that the information gets lost on language change. |
|
| 257 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 258 | + $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']); |
|
| 259 | + $this->captcha->init(CONFIRM_POST); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + // If form is done |
|
| 263 | + if ($submit || $refresh) { |
|
| 264 | + if (false != ($result = $this->_data_processing($cat_id))) { |
|
| 265 | + return $result; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + $this->_populate_form($cat_id, 'new', $title); |
|
| 270 | + |
|
| 271 | + return $this->helper->render('add_site.html', $title); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * View link controller. |
|
| 276 | + * |
|
| 277 | + * @param int $link_id The link ID |
|
| 278 | + * |
|
| 279 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 280 | + */ |
|
| 281 | + public function view_link($link_id) |
|
| 282 | + { |
|
| 283 | + return $this->link->view($link_id); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Vote for a link. |
|
| 288 | + * |
|
| 289 | + * @param int $cat_id The category ID |
|
| 290 | + * @param int $link_id The link ID |
|
| 291 | + * |
|
| 292 | + * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 293 | + */ |
|
| 294 | + public function vote_link($cat_id, $link_id) |
|
| 295 | + { |
|
| 296 | + $this->categorie->get($cat_id); |
|
| 297 | + |
|
| 298 | + if (!$this->auth->acl_get('u_vote_dir') || !$this->categorie->data['cat_allow_votes']) { |
|
| 299 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $data = [ |
|
| 303 | + 'vote_link_id' => (int) $link_id, |
|
| 304 | + 'vote_user_id' => (int) $this->user->data['user_id'], |
|
| 305 | + ]; |
|
| 306 | + |
|
| 307 | + // We check if user had already vot for this website. |
|
| 308 | + $sql = 'SELECT vote_link_id |
|
| 309 | 309 | FROM '.DIR_VOTE_TABLE.' |
| 310 | 310 | WHERE '.$this->db->sql_build_array('SELECT', $data); |
| 311 | - $result = $this->db->sql_query($sql); |
|
| 312 | - $data = $this->db->sql_fetchrow($result); |
|
| 313 | - |
|
| 314 | - if (!empty($data['vote_link_id'])) { |
|
| 315 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_VOTE'); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $this->link->add_vote($link_id); |
|
| 319 | - |
|
| 320 | - $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 321 | - meta_refresh(3, $meta_info); |
|
| 322 | - $message = $this->user->lang['DIR_VOTE_OK'].'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 323 | - |
|
| 324 | - return $this->helper->message($message); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Routine. |
|
| 329 | - * |
|
| 330 | - * @param int $cat_id The category ID |
|
| 331 | - * @param int $link_id The link ID |
|
| 332 | - * @param string $mode add|edit |
|
| 333 | - * |
|
| 334 | - * @throws \phpbb\exception\http_exception |
|
| 335 | - * |
|
| 336 | - * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 337 | - */ |
|
| 338 | - private function _data_processing($cat_id, $link_id = 0, $mode = 'new') |
|
| 339 | - { |
|
| 340 | - if (($mode == 'edit' && !$this->auth->acl_get('m_edit_dir') && !$this->auth->acl_get('u_edit_dir')) || ($mode == 'new' && !$this->auth->acl_get('u_submit_dir'))) { |
|
| 341 | - throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - if (!check_form_key('dir_form')) { |
|
| 345 | - return $this->helper->message('FORM_INVALID'); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - $this->url = $this->request->variable('url', ''); |
|
| 349 | - $this->site_name = $this->request->variable('site_name', '', true); |
|
| 350 | - $this->description = $this->request->variable('description', '', true); |
|
| 351 | - $this->guest_email = $this->request->variable('guest_email', ''); |
|
| 352 | - $this->rss = $this->request->variable('rss', ''); |
|
| 353 | - $this->banner = $this->request->variable('banner', ''); |
|
| 354 | - $this->back = $this->request->variable('back', ''); |
|
| 355 | - $this->flag = $this->request->variable('flag', ''); |
|
| 356 | - |
|
| 357 | - if (!function_exists('validate_data')) { |
|
| 358 | - include $this->root_path.'includes/functions_user.'.$this->php_ext; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - // We define variables to check |
|
| 362 | - $data = [ |
|
| 363 | - 'email' => $this->guest_email, |
|
| 364 | - 'site_name' => $this->site_name, |
|
| 365 | - 'website' => $this->url, |
|
| 366 | - 'description' => $this->description, |
|
| 367 | - 'rss' => $this->rss, |
|
| 368 | - 'banner' => $this->banner, |
|
| 369 | - 'back' => $this->back, |
|
| 370 | - 'cat' => (int) $cat_id, |
|
| 371 | - ]; |
|
| 372 | - |
|
| 373 | - // We define verification type for each variable |
|
| 374 | - $data2 = [ |
|
| 375 | - 'email' => [ |
|
| 376 | - ['string', $this->user->data['is_registered'], 6, 60], |
|
| 377 | - ['user_email', ''], ], |
|
| 378 | - 'site_name' => [ |
|
| 379 | - ['string', false, 1, 100], ], |
|
| 380 | - 'website' => [ |
|
| 381 | - ['string', false, 12, 255], |
|
| 382 | - ['match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i'], ], |
|
| 383 | - 'description' => [ |
|
| 384 | - ['string', !$this->categorie->data['cat_must_describe'], 1, $this->config['dir_length_describe']], ], |
|
| 385 | - 'rss' => [ |
|
| 386 | - ['string', true, 12, 255], |
|
| 387 | - ['match', empty($this->rss), '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i'], ], |
|
| 388 | - 'banner' => [ |
|
| 389 | - ['string', true, 5, 255], ], |
|
| 390 | - 'back' => [ |
|
| 391 | - ['string', !$this->categorie->data['cat_link_back'], 12, 255], |
|
| 392 | - [[$this->link, 'link_back'], true], ], |
|
| 393 | - 'cat' => [ |
|
| 394 | - ['num', '', 1], ], |
|
| 395 | - ]; |
|
| 396 | - |
|
| 397 | - $this->user->add_lang('ucp'); |
|
| 398 | - $error = validate_data($data, $data2); |
|
| 399 | - $error = array_map([$this->user, 'lang'], $error); |
|
| 400 | - |
|
| 401 | - // We check that url have good format |
|
| 402 | - if (preg_match('/^(http|https):\/\//si', $this->url) && $this->config['dir_activ_checkurl'] && !$this->link->checkurl($this->url)) { |
|
| 403 | - $error[] = $this->user->lang['DIR_ERROR_CHECK_URL']; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 407 | - $vc_response = $this->captcha->validate($data); |
|
| 408 | - if ($vc_response !== false) { |
|
| 409 | - $error[] = $vc_response; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) { |
|
| 413 | - $error[] = $this->user->lang['TOO_MANY_ADDS']; |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - if (!$error) { |
|
| 418 | - /* |
|
| 311 | + $result = $this->db->sql_query($sql); |
|
| 312 | + $data = $this->db->sql_fetchrow($result); |
|
| 313 | + |
|
| 314 | + if (!empty($data['vote_link_id'])) { |
|
| 315 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_VOTE'); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $this->link->add_vote($link_id); |
|
| 319 | + |
|
| 320 | + $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 321 | + meta_refresh(3, $meta_info); |
|
| 322 | + $message = $this->user->lang['DIR_VOTE_OK'].'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$meta_info.'">', '</a>'); |
|
| 323 | + |
|
| 324 | + return $this->helper->message($message); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Routine. |
|
| 329 | + * |
|
| 330 | + * @param int $cat_id The category ID |
|
| 331 | + * @param int $link_id The link ID |
|
| 332 | + * @param string $mode add|edit |
|
| 333 | + * |
|
| 334 | + * @throws \phpbb\exception\http_exception |
|
| 335 | + * |
|
| 336 | + * @return null|\Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
| 337 | + */ |
|
| 338 | + private function _data_processing($cat_id, $link_id = 0, $mode = 'new') |
|
| 339 | + { |
|
| 340 | + if (($mode == 'edit' && !$this->auth->acl_get('m_edit_dir') && !$this->auth->acl_get('u_edit_dir')) || ($mode == 'new' && !$this->auth->acl_get('u_submit_dir'))) { |
|
| 341 | + throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + if (!check_form_key('dir_form')) { |
|
| 345 | + return $this->helper->message('FORM_INVALID'); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + $this->url = $this->request->variable('url', ''); |
|
| 349 | + $this->site_name = $this->request->variable('site_name', '', true); |
|
| 350 | + $this->description = $this->request->variable('description', '', true); |
|
| 351 | + $this->guest_email = $this->request->variable('guest_email', ''); |
|
| 352 | + $this->rss = $this->request->variable('rss', ''); |
|
| 353 | + $this->banner = $this->request->variable('banner', ''); |
|
| 354 | + $this->back = $this->request->variable('back', ''); |
|
| 355 | + $this->flag = $this->request->variable('flag', ''); |
|
| 356 | + |
|
| 357 | + if (!function_exists('validate_data')) { |
|
| 358 | + include $this->root_path.'includes/functions_user.'.$this->php_ext; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + // We define variables to check |
|
| 362 | + $data = [ |
|
| 363 | + 'email' => $this->guest_email, |
|
| 364 | + 'site_name' => $this->site_name, |
|
| 365 | + 'website' => $this->url, |
|
| 366 | + 'description' => $this->description, |
|
| 367 | + 'rss' => $this->rss, |
|
| 368 | + 'banner' => $this->banner, |
|
| 369 | + 'back' => $this->back, |
|
| 370 | + 'cat' => (int) $cat_id, |
|
| 371 | + ]; |
|
| 372 | + |
|
| 373 | + // We define verification type for each variable |
|
| 374 | + $data2 = [ |
|
| 375 | + 'email' => [ |
|
| 376 | + ['string', $this->user->data['is_registered'], 6, 60], |
|
| 377 | + ['user_email', ''], ], |
|
| 378 | + 'site_name' => [ |
|
| 379 | + ['string', false, 1, 100], ], |
|
| 380 | + 'website' => [ |
|
| 381 | + ['string', false, 12, 255], |
|
| 382 | + ['match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i'], ], |
|
| 383 | + 'description' => [ |
|
| 384 | + ['string', !$this->categorie->data['cat_must_describe'], 1, $this->config['dir_length_describe']], ], |
|
| 385 | + 'rss' => [ |
|
| 386 | + ['string', true, 12, 255], |
|
| 387 | + ['match', empty($this->rss), '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i'], ], |
|
| 388 | + 'banner' => [ |
|
| 389 | + ['string', true, 5, 255], ], |
|
| 390 | + 'back' => [ |
|
| 391 | + ['string', !$this->categorie->data['cat_link_back'], 12, 255], |
|
| 392 | + [[$this->link, 'link_back'], true], ], |
|
| 393 | + 'cat' => [ |
|
| 394 | + ['num', '', 1], ], |
|
| 395 | + ]; |
|
| 396 | + |
|
| 397 | + $this->user->add_lang('ucp'); |
|
| 398 | + $error = validate_data($data, $data2); |
|
| 399 | + $error = array_map([$this->user, 'lang'], $error); |
|
| 400 | + |
|
| 401 | + // We check that url have good format |
|
| 402 | + if (preg_match('/^(http|https):\/\//si', $this->url) && $this->config['dir_activ_checkurl'] && !$this->link->checkurl($this->url)) { |
|
| 403 | + $error[] = $this->user->lang['DIR_ERROR_CHECK_URL']; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) { |
|
| 407 | + $vc_response = $this->captcha->validate($data); |
|
| 408 | + if ($vc_response !== false) { |
|
| 409 | + $error[] = $vc_response; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) { |
|
| 413 | + $error[] = $this->user->lang['TOO_MANY_ADDS']; |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + if (!$error) { |
|
| 418 | + /* |
|
| 419 | 419 | * No errrors, we execute heavy tasks wich need a valid url |
| 420 | 420 | */ |
| 421 | 421 | |
| 422 | - // Banner |
|
| 423 | - $this->link->banner_process($this->banner, $error); |
|
| 424 | - |
|
| 425 | - // PageRank |
|
| 426 | - $pagerank = $this->link->pagerank_process($this->url); |
|
| 427 | - |
|
| 428 | - // Thumb ;) |
|
| 429 | - $thumb = $this->link->thumb_process($this->url); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - // Still no errors?? So let's go! |
|
| 433 | - if (!$error) { |
|
| 434 | - $this->banner = (!$this->banner && !$this->request->is_set_post('delete_banner')) ? $this->request->variable('old_banner', '') : $this->banner; |
|
| 435 | - $this->url = $this->link->clean_url($this->url); |
|
| 436 | - |
|
| 437 | - $data_edit = [ |
|
| 438 | - 'link_user_id' => $this->link_user_id, |
|
| 439 | - 'link_guest_email' => $this->guest_email, |
|
| 440 | - 'link_name' => $this->site_name, |
|
| 441 | - 'link_url' => $this->url, |
|
| 442 | - 'link_description' => $this->description, |
|
| 443 | - 'link_cat' => (int) $cat_id, |
|
| 444 | - 'link_rss' => $this->rss, |
|
| 445 | - 'link_banner' => $this->banner, |
|
| 446 | - 'link_back' => $this->back, |
|
| 447 | - 'link_uid' => '', |
|
| 448 | - 'link_flags' => 7, |
|
| 449 | - 'link_flag' => $this->flag, |
|
| 450 | - 'link_bitfield' => '', |
|
| 451 | - 'link_pagerank' => (int) $pagerank, |
|
| 452 | - 'link_thumb' => $thumb, |
|
| 453 | - ]; |
|
| 454 | - |
|
| 455 | - if ($this->description) { |
|
| 456 | - generate_text_for_storage($this->description, $data_edit['link_uid'], $data_edit['link_bitfield'], $data_edit['link_flags'], (bool) $this->config['allow_bbcode'], (bool) $this->config['allow_post_links'], (bool) $this->config['allow_smilies']); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - $need_approval = ($this->categorie->need_approval() && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_')) ? true : false; |
|
| 460 | - |
|
| 461 | - if ($mode == 'edit') { |
|
| 462 | - $data_edit['link_cat_old'] = $this->request->variable('old_cat_id', 0); |
|
| 463 | - $this->link->edit($data_edit, $link_id, $need_approval); |
|
| 464 | - } else { |
|
| 465 | - $data_add = [ |
|
| 466 | - 'link_time' => time(), |
|
| 467 | - 'link_view' => 0, |
|
| 468 | - 'link_active' => $need_approval ? false : true, |
|
| 469 | - 'link_user_id' => $this->user->data['user_id'], |
|
| 470 | - ]; |
|
| 471 | - |
|
| 472 | - $data_add = array_merge($data_edit, $data_add); |
|
| 473 | - |
|
| 474 | - $this->link->add($data_add, $need_approval); |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 478 | - meta_refresh(3, $meta_info); |
|
| 479 | - $message = ($need_approval) ? $this->user->lang['DIR_'.strtoupper($mode).'_SITE_ACTIVE'] : $this->user->lang['DIR_'.strtoupper($mode).'_SITE_OK']; |
|
| 480 | - $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>'); |
|
| 481 | - |
|
| 482 | - return $this->helper->message($message); |
|
| 483 | - } else { |
|
| 484 | - if ($mode == 'edit') { |
|
| 485 | - $this->s_hidden_fields = [ |
|
| 486 | - 'old_cat_id' => $this->request->variable('old_cat_id', 0), |
|
| 487 | - 'old_banner' => $this->request->variable('old_banner', ''), |
|
| 488 | - ]; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - $this->template->assign_vars([ |
|
| 492 | - 'ERROR' => (isset($error)) ? implode('<br />', $error) : '', |
|
| 493 | - ]); |
|
| 494 | - } |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * Display a banner. |
|
| 499 | - * |
|
| 500 | - * @param string $banner_img Path to banner file |
|
| 501 | - * |
|
| 502 | - * @return Response object |
|
| 503 | - */ |
|
| 504 | - public function return_banner($banner_img) |
|
| 505 | - { |
|
| 506 | - if (!function_exists('file_gc')) { |
|
| 507 | - include $this->root_path.'includes/functions_download.'.$this->php_ext; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - $file_path = $this->dir_helper->get_banner_path($banner_img); |
|
| 511 | - |
|
| 512 | - if ((@file_exists($file_path) && @is_readable($file_path))) { |
|
| 513 | - $response = new BinaryFileResponse($file_path); |
|
| 514 | - $response->setContentDisposition('inline', $banner_img); |
|
| 515 | - |
|
| 516 | - // Without fileinfo extension, Symfony is unable to guess the mime type |
|
| 517 | - if (!extension_loaded('fileinfo')) { |
|
| 518 | - $image_data = @getimagesize($file_path); |
|
| 519 | - $response->headers->set('Content-Type', image_type_to_mime_type($image_data[2])); |
|
| 520 | - } |
|
| 521 | - } else { |
|
| 522 | - $response = new Response(); |
|
| 523 | - $response->setStatusCode(404); |
|
| 524 | - } |
|
| 525 | - file_gc(false); |
|
| 526 | - |
|
| 527 | - return $response; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * Populate form when an error occurred. |
|
| 532 | - * |
|
| 533 | - * @param int $cat_id The category ID |
|
| 534 | - * @param string $mode add|edit |
|
| 535 | - * @param string $title Page title (depends of $mode) |
|
| 536 | - * |
|
| 537 | - * @return null |
|
| 538 | - */ |
|
| 539 | - private function _populate_form($cat_id, $mode, $title) |
|
| 540 | - { |
|
| 541 | - global $phpbb_extension_manager; |
|
| 542 | - |
|
| 543 | - if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode == 'new') { |
|
| 544 | - $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields()); |
|
| 545 | - |
|
| 546 | - $this->user->add_lang('ucp'); |
|
| 547 | - |
|
| 548 | - $this->template->assign_vars([ |
|
| 549 | - 'CAPTCHA_TEMPLATE' => $this->captcha->get_template(), |
|
| 550 | - ]); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - $this->user->add_lang('posting'); |
|
| 554 | - |
|
| 555 | - if (!function_exists('display_custom_bbcodes')) { |
|
| 556 | - include $this->root_path.'includes/functions_display.'.$this->php_ext; |
|
| 557 | - } |
|
| 558 | - display_custom_bbcodes(); |
|
| 559 | - add_form_key('dir_form'); |
|
| 560 | - |
|
| 561 | - $ext_path = $phpbb_extension_manager->get_extension_path('ernadoo/phpbbdirectory', false); |
|
| 562 | - $flag_path = $ext_path.'images/flags/'; |
|
| 563 | - |
|
| 564 | - $s_guest = (!$this->user->data['is_registered'] || !empty($this->guest_email)); |
|
| 565 | - $s_rss = $this->config['dir_activ_rss']; |
|
| 566 | - $s_banner = $this->config['dir_activ_banner']; |
|
| 567 | - $s_back = $this->categorie->data['cat_link_back']; |
|
| 568 | - $s_flag = $this->config['dir_activ_flag']; |
|
| 569 | - |
|
| 570 | - $this->template->assign_vars([ |
|
| 571 | - 'BBCODE_STATUS' => ($this->config['allow_bbcode']) ? $this->user->lang('BBCODE_IS_ON', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>'), |
|
| 572 | - 'IMG_STATUS' => ($this->config['allow_bbcode']) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], |
|
| 573 | - 'SMILIES_STATUS' => ($this->config['allow_smilies']) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], |
|
| 574 | - 'URL_STATUS' => ($this->config['allow_post_links']) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], |
|
| 575 | - 'FLASH_STATUS' => ($this->config['allow_bbcode'] && $this->config['allow_post_flash']) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], |
|
| 576 | - |
|
| 577 | - 'L_TITLE' => $title, |
|
| 578 | - 'L_DIR_DESCRIPTION_EXP' => $this->user->lang('DIR_DESCRIPTION_EXP', $this->config['dir_length_describe']), |
|
| 579 | - 'L_DIR_SUBMIT_TYPE' => $this->categorie->dir_submit_type($this->categorie->need_approval()), |
|
| 580 | - 'L_DIR_SITE_BANN_EXP' => $this->user->lang('DIR_SITE_BANN_EXP', $this->config['dir_banner_width'], $this->config['dir_banner_height']), |
|
| 581 | - |
|
| 582 | - 'S_GUEST' => $s_guest ? true : false, |
|
| 583 | - 'S_RSS' => $s_rss ? true : false, |
|
| 584 | - 'S_BANNER' => $s_banner ? true : false, |
|
| 585 | - 'S_BACK' => $s_back ? true : false, |
|
| 586 | - 'S_FLAG' => $s_flag ? true : false, |
|
| 587 | - 'S_BBCODE_ALLOWED' => (bool) $this->config['allow_bbcode'], |
|
| 588 | - 'S_BBCODE_IMG' => (bool) $this->config['allow_bbcode'], |
|
| 589 | - 'S_BBCODE_FLASH' => ($this->config['allow_bbcode'] && $this->config['allow_post_flash']) ? true : false, |
|
| 590 | - 'S_BBCODE_QUOTE' => true, |
|
| 591 | - 'S_LINKS_ALLOWED' => (bool) $this->config['allow_post_links'], |
|
| 592 | - |
|
| 593 | - 'DIR_FLAG_PATH' => $flag_path, |
|
| 594 | - 'DIR_FLAG_IMAGE' => $this->flag ? $this->dir_helper->get_img_path('flags', $this->flag) : '', |
|
| 595 | - |
|
| 596 | - 'EDIT_MODE' => ($mode == 'edit') ? true : false, |
|
| 597 | - |
|
| 598 | - 'SITE_NAME' => isset($this->site_name) ? $this->site_name : '', |
|
| 599 | - 'SITE_URL' => isset($this->url) ? $this->url : '', |
|
| 600 | - 'DESCRIPTION' => isset($this->description) ? $this->description : '', |
|
| 601 | - 'GUEST_EMAIL' => isset($this->guest_email) ? $this->guest_email : '', |
|
| 602 | - 'RSS' => isset($this->rss) ? $this->rss : '', |
|
| 603 | - 'BANNER' => isset($this->banner) ? $this->banner : '', |
|
| 604 | - 'BACK' => isset($this->back) ? $this->back : '', |
|
| 605 | - 'S_POST_ACTION' => '', |
|
| 606 | - 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), |
|
| 607 | - 'S_LIST_FLAG' => $this->link->get_dir_flag_list($flag_path, $this->flag), |
|
| 608 | - 'S_DESC_STAR' => (@$this->categorie->data['cat_must_describe']) ? '*' : '', |
|
| 609 | - 'S_ROOT' => $cat_id, |
|
| 610 | - 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields), |
|
| 611 | - ]); |
|
| 612 | - } |
|
| 422 | + // Banner |
|
| 423 | + $this->link->banner_process($this->banner, $error); |
|
| 424 | + |
|
| 425 | + // PageRank |
|
| 426 | + $pagerank = $this->link->pagerank_process($this->url); |
|
| 427 | + |
|
| 428 | + // Thumb ;) |
|
| 429 | + $thumb = $this->link->thumb_process($this->url); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + // Still no errors?? So let's go! |
|
| 433 | + if (!$error) { |
|
| 434 | + $this->banner = (!$this->banner && !$this->request->is_set_post('delete_banner')) ? $this->request->variable('old_banner', '') : $this->banner; |
|
| 435 | + $this->url = $this->link->clean_url($this->url); |
|
| 436 | + |
|
| 437 | + $data_edit = [ |
|
| 438 | + 'link_user_id' => $this->link_user_id, |
|
| 439 | + 'link_guest_email' => $this->guest_email, |
|
| 440 | + 'link_name' => $this->site_name, |
|
| 441 | + 'link_url' => $this->url, |
|
| 442 | + 'link_description' => $this->description, |
|
| 443 | + 'link_cat' => (int) $cat_id, |
|
| 444 | + 'link_rss' => $this->rss, |
|
| 445 | + 'link_banner' => $this->banner, |
|
| 446 | + 'link_back' => $this->back, |
|
| 447 | + 'link_uid' => '', |
|
| 448 | + 'link_flags' => 7, |
|
| 449 | + 'link_flag' => $this->flag, |
|
| 450 | + 'link_bitfield' => '', |
|
| 451 | + 'link_pagerank' => (int) $pagerank, |
|
| 452 | + 'link_thumb' => $thumb, |
|
| 453 | + ]; |
|
| 454 | + |
|
| 455 | + if ($this->description) { |
|
| 456 | + generate_text_for_storage($this->description, $data_edit['link_uid'], $data_edit['link_bitfield'], $data_edit['link_flags'], (bool) $this->config['allow_bbcode'], (bool) $this->config['allow_post_links'], (bool) $this->config['allow_smilies']); |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + $need_approval = ($this->categorie->need_approval() && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_')) ? true : false; |
|
| 460 | + |
|
| 461 | + if ($mode == 'edit') { |
|
| 462 | + $data_edit['link_cat_old'] = $this->request->variable('old_cat_id', 0); |
|
| 463 | + $this->link->edit($data_edit, $link_id, $need_approval); |
|
| 464 | + } else { |
|
| 465 | + $data_add = [ |
|
| 466 | + 'link_time' => time(), |
|
| 467 | + 'link_view' => 0, |
|
| 468 | + 'link_active' => $need_approval ? false : true, |
|
| 469 | + 'link_user_id' => $this->user->data['user_id'], |
|
| 470 | + ]; |
|
| 471 | + |
|
| 472 | + $data_add = array_merge($data_edit, $data_add); |
|
| 473 | + |
|
| 474 | + $this->link->add($data_add, $need_approval); |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]); |
|
| 478 | + meta_refresh(3, $meta_info); |
|
| 479 | + $message = ($need_approval) ? $this->user->lang['DIR_'.strtoupper($mode).'_SITE_ACTIVE'] : $this->user->lang['DIR_'.strtoupper($mode).'_SITE_OK']; |
|
| 480 | + $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>'); |
|
| 481 | + |
|
| 482 | + return $this->helper->message($message); |
|
| 483 | + } else { |
|
| 484 | + if ($mode == 'edit') { |
|
| 485 | + $this->s_hidden_fields = [ |
|
| 486 | + 'old_cat_id' => $this->request->variable('old_cat_id', 0), |
|
| 487 | + 'old_banner' => $this->request->variable('old_banner', ''), |
|
| 488 | + ]; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + $this->template->assign_vars([ |
|
| 492 | + 'ERROR' => (isset($error)) ? implode('<br />', $error) : '', |
|
| 493 | + ]); |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * Display a banner. |
|
| 499 | + * |
|
| 500 | + * @param string $banner_img Path to banner file |
|
| 501 | + * |
|
| 502 | + * @return Response object |
|
| 503 | + */ |
|
| 504 | + public function return_banner($banner_img) |
|
| 505 | + { |
|
| 506 | + if (!function_exists('file_gc')) { |
|
| 507 | + include $this->root_path.'includes/functions_download.'.$this->php_ext; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + $file_path = $this->dir_helper->get_banner_path($banner_img); |
|
| 511 | + |
|
| 512 | + if ((@file_exists($file_path) && @is_readable($file_path))) { |
|
| 513 | + $response = new BinaryFileResponse($file_path); |
|
| 514 | + $response->setContentDisposition('inline', $banner_img); |
|
| 515 | + |
|
| 516 | + // Without fileinfo extension, Symfony is unable to guess the mime type |
|
| 517 | + if (!extension_loaded('fileinfo')) { |
|
| 518 | + $image_data = @getimagesize($file_path); |
|
| 519 | + $response->headers->set('Content-Type', image_type_to_mime_type($image_data[2])); |
|
| 520 | + } |
|
| 521 | + } else { |
|
| 522 | + $response = new Response(); |
|
| 523 | + $response->setStatusCode(404); |
|
| 524 | + } |
|
| 525 | + file_gc(false); |
|
| 526 | + |
|
| 527 | + return $response; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * Populate form when an error occurred. |
|
| 532 | + * |
|
| 533 | + * @param int $cat_id The category ID |
|
| 534 | + * @param string $mode add|edit |
|
| 535 | + * @param string $title Page title (depends of $mode) |
|
| 536 | + * |
|
| 537 | + * @return null |
|
| 538 | + */ |
|
| 539 | + private function _populate_form($cat_id, $mode, $title) |
|
| 540 | + { |
|
| 541 | + global $phpbb_extension_manager; |
|
| 542 | + |
|
| 543 | + if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode == 'new') { |
|
| 544 | + $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields()); |
|
| 545 | + |
|
| 546 | + $this->user->add_lang('ucp'); |
|
| 547 | + |
|
| 548 | + $this->template->assign_vars([ |
|
| 549 | + 'CAPTCHA_TEMPLATE' => $this->captcha->get_template(), |
|
| 550 | + ]); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + $this->user->add_lang('posting'); |
|
| 554 | + |
|
| 555 | + if (!function_exists('display_custom_bbcodes')) { |
|
| 556 | + include $this->root_path.'includes/functions_display.'.$this->php_ext; |
|
| 557 | + } |
|
| 558 | + display_custom_bbcodes(); |
|
| 559 | + add_form_key('dir_form'); |
|
| 560 | + |
|
| 561 | + $ext_path = $phpbb_extension_manager->get_extension_path('ernadoo/phpbbdirectory', false); |
|
| 562 | + $flag_path = $ext_path.'images/flags/'; |
|
| 563 | + |
|
| 564 | + $s_guest = (!$this->user->data['is_registered'] || !empty($this->guest_email)); |
|
| 565 | + $s_rss = $this->config['dir_activ_rss']; |
|
| 566 | + $s_banner = $this->config['dir_activ_banner']; |
|
| 567 | + $s_back = $this->categorie->data['cat_link_back']; |
|
| 568 | + $s_flag = $this->config['dir_activ_flag']; |
|
| 569 | + |
|
| 570 | + $this->template->assign_vars([ |
|
| 571 | + 'BBCODE_STATUS' => ($this->config['allow_bbcode']) ? $this->user->lang('BBCODE_IS_ON', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>') : $this->user->lang('BBCODE_IS_OFF', '<a href="'.append_sid($this->root_path."faq.$this->php_ext", 'mode=bbcode').'">', '</a>'), |
|
| 572 | + 'IMG_STATUS' => ($this->config['allow_bbcode']) ? $this->user->lang['IMAGES_ARE_ON'] : $this->user->lang['IMAGES_ARE_OFF'], |
|
| 573 | + 'SMILIES_STATUS' => ($this->config['allow_smilies']) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], |
|
| 574 | + 'URL_STATUS' => ($this->config['allow_post_links']) ? $this->user->lang['URL_IS_ON'] : $this->user->lang['URL_IS_OFF'], |
|
| 575 | + 'FLASH_STATUS' => ($this->config['allow_bbcode'] && $this->config['allow_post_flash']) ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], |
|
| 576 | + |
|
| 577 | + 'L_TITLE' => $title, |
|
| 578 | + 'L_DIR_DESCRIPTION_EXP' => $this->user->lang('DIR_DESCRIPTION_EXP', $this->config['dir_length_describe']), |
|
| 579 | + 'L_DIR_SUBMIT_TYPE' => $this->categorie->dir_submit_type($this->categorie->need_approval()), |
|
| 580 | + 'L_DIR_SITE_BANN_EXP' => $this->user->lang('DIR_SITE_BANN_EXP', $this->config['dir_banner_width'], $this->config['dir_banner_height']), |
|
| 581 | + |
|
| 582 | + 'S_GUEST' => $s_guest ? true : false, |
|
| 583 | + 'S_RSS' => $s_rss ? true : false, |
|
| 584 | + 'S_BANNER' => $s_banner ? true : false, |
|
| 585 | + 'S_BACK' => $s_back ? true : false, |
|
| 586 | + 'S_FLAG' => $s_flag ? true : false, |
|
| 587 | + 'S_BBCODE_ALLOWED' => (bool) $this->config['allow_bbcode'], |
|
| 588 | + 'S_BBCODE_IMG' => (bool) $this->config['allow_bbcode'], |
|
| 589 | + 'S_BBCODE_FLASH' => ($this->config['allow_bbcode'] && $this->config['allow_post_flash']) ? true : false, |
|
| 590 | + 'S_BBCODE_QUOTE' => true, |
|
| 591 | + 'S_LINKS_ALLOWED' => (bool) $this->config['allow_post_links'], |
|
| 592 | + |
|
| 593 | + 'DIR_FLAG_PATH' => $flag_path, |
|
| 594 | + 'DIR_FLAG_IMAGE' => $this->flag ? $this->dir_helper->get_img_path('flags', $this->flag) : '', |
|
| 595 | + |
|
| 596 | + 'EDIT_MODE' => ($mode == 'edit') ? true : false, |
|
| 597 | + |
|
| 598 | + 'SITE_NAME' => isset($this->site_name) ? $this->site_name : '', |
|
| 599 | + 'SITE_URL' => isset($this->url) ? $this->url : '', |
|
| 600 | + 'DESCRIPTION' => isset($this->description) ? $this->description : '', |
|
| 601 | + 'GUEST_EMAIL' => isset($this->guest_email) ? $this->guest_email : '', |
|
| 602 | + 'RSS' => isset($this->rss) ? $this->rss : '', |
|
| 603 | + 'BANNER' => isset($this->banner) ? $this->banner : '', |
|
| 604 | + 'BACK' => isset($this->back) ? $this->back : '', |
|
| 605 | + 'S_POST_ACTION' => '', |
|
| 606 | + 'S_CATLIST' => $this->categorie->make_cat_select($cat_id), |
|
| 607 | + 'S_LIST_FLAG' => $this->link->get_dir_flag_list($flag_path, $this->flag), |
|
| 608 | + 'S_DESC_STAR' => (@$this->categorie->data['cat_must_describe']) ? '*' : '', |
|
| 609 | + 'S_ROOT' => $cat_id, |
|
| 610 | + 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields), |
|
| 611 | + ]); |
|
| 612 | + } |
|
| 613 | 613 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | * DO NOT CHANGE. |
| 11 | 11 | */ |
| 12 | 12 | if (!defined('IN_PHPBB')) { |
| 13 | - exit; |
|
| 13 | + exit; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | if (empty($lang) || !is_array($lang)) { |
| 17 | - $lang = []; |
|
| 17 | + $lang = []; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | // DEVELOPERS PLEASE NOTE |
@@ -30,166 +30,166 @@ discard block |
||
| 30 | 30 | // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine |
| 31 | 31 | |
| 32 | 32 | $lang = array_merge($lang, [ |
| 33 | - 'DIR_ARE_WATCHING_CAT' => 'Vous êtes désormais abonné à cette catégorie', |
|
| 34 | - 'DIR_BANNER_DISALLOWED_CONTENT' => 'L’envoi a été rejeté car le fichier envoyé a été identifié comme un vecteur éventuel d’attaque.', |
|
| 35 | - 'DIR_BANNER_DISALLOWED_EXTENSION' => 'Ce fichier ne peut pas être affiché car l’extension <strong>%s</strong> n’est pas autorisée.', |
|
| 36 | - 'DIR_BANNER_EMPTY_FILEUPLOAD' => 'Le fichier bannière transféré est vide.', |
|
| 37 | - 'DIR_BANNER_EMPTY_REMOTE_DATA' => 'La bannière indiquée n’a pas pu être transférée car les données distantes semblent être invalides ou corrompues.', |
|
| 38 | - 'DIR_BANNER_IMAGE_FILETYPE_MISMATCH' => 'Type de bannière incorrect: l’extension %1$s était attendue mais l’extension %2$s a été trouvée.', |
|
| 39 | - 'DIR_BANNER_INVALID_FILENAME' => '%s est un nom de fichier invalide.', |
|
| 40 | - 'DIR_BANNER_NOT_UPLOADED' => 'La bannière n’a pas pu être transférée.', |
|
| 41 | - 'DIR_BANNER_PARTIAL_UPLOAD' => 'Le fichier n’a pu être que partiellement transféré.', |
|
| 42 | - 'DIR_BANNER_PHP_SIZE_NA' => 'La taille de la bannière est trop importante.<br />La taille maximum réglée dans php.ini n’a pas pu être déterminée.', |
|
| 43 | - 'DIR_BANNER_PHP_SIZE_OVERRUN' => 'La taille de la bannière trop importante. La taille maximum de transfert autorisée est %d Mo.<br />Notez que ce paramètre est inscrit dans php.ini et ne peut pas être dépassé.', |
|
| 44 | - 'DIR_BANNER_REMOTE_UPLOAD_TIMEOUT' => 'La bannière spécifiée n’a pas été récupérée car la requête a éxpirée.', |
|
| 45 | - 'DIR_BANNER_UNABLE_GET_IMAGE_SIZE' => 'Impossible de déterminer les dimensions de la bannière.', |
|
| 46 | - 'DIR_BANNER_URL_INVALID' => 'L’URL de la bannière est invalide.', |
|
| 47 | - 'DIR_BANNER_URL_NOT_FOUND' => 'Le fichier indiqué est introuvable.', |
|
| 48 | - 'DIR_BANNER_WRONG_FILESIZE' => 'La taille de la bannière doit être comprise entre 0 et %1d %2s.', |
|
| 49 | - 'DIR_BANNER_WRONG_SIZE' => 'La bannière envoyée a une largeur de %3$d pixels et une hauteur de %4$d pixels. Les bannières doivent faire au plus %1$d pixels de large et %2$d pixels de haut.', |
|
| 50 | - 'DIR_BUTTON_NEW_SITE' => 'Nouveau lien', |
|
| 51 | - 'DIR_CAT' => 'Catégorie', |
|
| 52 | - 'DIR_CAT_NAME' => 'Nom de la catégorie', |
|
| 53 | - 'DIR_CAT_TITLE' => 'Catégories de l’annuaire', |
|
| 54 | - 'DIR_CAT_TOOLS' => 'Outils de la catégorie', |
|
| 55 | - 'DIR_CLICK_RETURN_DIR' => 'Cliquez %sici%s pour retourner au sommaire de l’annuaire', |
|
| 56 | - 'DIR_CLICK_RETURN_CAT' => 'Cliquez %sici%s pour retourner dans la catégorie', |
|
| 57 | - 'DIR_CLICK_RETURN_COMMENT' => 'Cliquez %sici%s pour revenir aux commentaires', |
|
| 58 | - 'DIR_COMMENTS_ORDER' => 'Commentaires', |
|
| 59 | - 'DIR_COMMENT_TITLE' => 'Voir/poster un commentaire', |
|
| 60 | - 'DIR_COMMENT_DELETE' => 'Supprimer le commentaire', |
|
| 61 | - 'DIR_COMMENT_DELETE_CONFIRM' => 'Êtes vous certain de vouloir supprimer le commentaire ?', |
|
| 62 | - 'DIR_COMMENT_DELETE_OK' => 'Le commentaire a bien été supprimé.', |
|
| 63 | - 'DIR_COMMENT_EDIT' => 'Modifier le commentaire', |
|
| 64 | - 'DIR_DELETE_BANNER' => 'Supprimer la bannière', |
|
| 65 | - 'DIR_DELETE_OK' => 'Le site a bien été supprimé', |
|
| 66 | - 'DIR_DELETE_SITE' => 'Supprimer le site', |
|
| 67 | - 'DIR_DELETE_SITE_CONFIRM' => 'Êtes vous certain de vouloir supprimer le site ?', |
|
| 68 | - 'DIR_DESCRIPTION' => 'Description', |
|
| 69 | - 'DIR_DESCRIPTION_EXP' => 'Une courte description de votre site, celle-ci ne peut pas dépasser %d caractères.', |
|
| 70 | - 'DIR_DISPLAY_LINKS' => 'Afficher les liens précédents', |
|
| 71 | - 'DIR_EDIT' => 'Modifier', |
|
| 72 | - 'DIR_EDIT_COMMENT_OK' => 'Le commentaire a bien été modifié', |
|
| 73 | - 'DIR_EDIT_SITE' => 'Modifier un site', |
|
| 74 | - 'DIR_EDIT_SITE_ACTIVE' => 'Votre site a bien été modifié, cependant le site n’apparaîtra dans l’annuaire qu’après validation', |
|
| 75 | - 'DIR_EDIT_SITE_OK' => 'Le site a bien été modifié', |
|
| 76 | - 'DIR_ERROR_AUTH_COMM' => 'Vous n’êtes pas autorisé à poster des commentaires', |
|
| 77 | - 'DIR_ERROR_CAT' => 'Impossible de récupérer les données de la catégorie actuelle', |
|
| 78 | - 'DIR_ERROR_CHECK_URL' => 'Cette URL semble injoignable', |
|
| 79 | - 'DIR_ERROR_COMM_LOGGED' => 'Vous devez être connecté pour pouvoir poster un commentaire', |
|
| 80 | - 'DIR_ERROR_KEYWORD' => 'Vous devez entrer des mots clés pour faire une recherche.', |
|
| 81 | - 'DIR_ERROR_NOT_AUTH' => 'Vous n’avez pas l’autorisation requise pour cette opération', |
|
| 82 | - 'DIR_ERROR_NOT_FOUND_BACK' => 'La page spécifiée pour le lien réciproque est introuvable.', |
|
| 83 | - 'DIR_ERROR_NO_CATS' => 'Cette catégorie n’existe pas', |
|
| 84 | - 'DIR_ERROR_NO_LINK' => 'Le site recherché n’existe pas', |
|
| 85 | - 'DIR_ERROR_NO_LINKS' => 'Ce site n’existe pas', |
|
| 86 | - 'DIR_ERROR_NO_LINK_BACK' => 'Le lien réciproque n’a pas été trouvé sur la page que vous avez spécifiée.', |
|
| 87 | - 'DIR_ERROR_SUBMIT_TYPE' => 'Type de données incorrect dans la fonction <em>dir_submit_type</em>', |
|
| 88 | - 'DIR_ERROR_URL' => 'Vous devez entrer une URL valide.', |
|
| 89 | - 'DIR_ERROR_VOTE' => 'Vous avez déjà voté pour ce site', |
|
| 90 | - 'DIR_ERROR_VOTE_LOGGED' => 'Vous devez être connecté pour pouvoir voter', |
|
| 91 | - 'DIR_ERROR_WRONG_DATA_BACK' => 'L’adresse du lien retour doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 92 | - 'DIR_FIELDS' => 'Veuillez remplir les champs marqués d’une *', |
|
| 93 | - 'DIR_FLAG' => 'Drapeau', |
|
| 94 | - 'DIR_FLAG_EXP' => 'Choisissez un drapeaux, qui indiquera la nationalité du site', |
|
| 95 | - 'DIR_FROM_TEN' => '%s/10', |
|
| 96 | - 'DIR_GUEST_EMAIL' => 'Votre adresse e-mail', |
|
| 97 | - 'DIR_MAKE_SEARCH' => 'Rechercher un site', |
|
| 98 | - 'DIR_NAME_ORDER' => 'Nom', |
|
| 99 | - 'DIR_NEW_COMMENT_OK' => 'Votre commentaire a bien été ajouté', |
|
| 100 | - 'DIR_NEW_SITE' => 'Ajouter un site à l’annuaire', |
|
| 101 | - 'DIR_NEW_SITE_ACTIVE' => 'Votre site a bien été ajouté, cependant le site n’apparaîtra dans l’annuaire qu’après validation', |
|
| 102 | - 'DIR_NEW_SITE_OK' => 'Votre site a bien été ajouté à l’annuaire', |
|
| 103 | - 'DIR_NB_CLICKS' => [ |
|
| 104 | - 1 => '%d clic', |
|
| 105 | - 2 => '%d clics', |
|
| 106 | - ], |
|
| 107 | - 'DIR_NB_CLICKS_ORDER' => 'Clics', |
|
| 108 | - 'DIR_NB_COMMS' => [ |
|
| 109 | - 1 => '%d commentaire', |
|
| 110 | - 2 => '%d commentaires', |
|
| 111 | - ], |
|
| 112 | - 'DIR_NB_LINKS' => [ |
|
| 113 | - 1 => '%d lien', |
|
| 114 | - 2 => '%d liens', |
|
| 115 | - ], |
|
| 116 | - 'DIR_NB_VOTES' => [ |
|
| 117 | - 1 => '%d vote', |
|
| 118 | - 2 => '%d votes', |
|
| 119 | - ], |
|
| 120 | - 'DIR_NONE' => 'Aucune', |
|
| 121 | - 'DIR_NOTE' => 'Note', |
|
| 122 | - 'DIR_NO_COMMENT' => 'Il n’y a aucun commentaire sur ce site', |
|
| 123 | - 'DIR_NO_DRAW_CAT' => 'Il n’y a aucune catégorie', |
|
| 124 | - 'DIR_NO_DRAW_LINK' => 'Il n’y a aucun site dans cette catégorie', |
|
| 125 | - 'DIR_NO_NOTE' => 'Aucune', |
|
| 126 | - 'DIR_NOT_WATCHING_CAT' => 'Vous ne surveillez plus cette catégorie', |
|
| 33 | + 'DIR_ARE_WATCHING_CAT' => 'Vous êtes désormais abonné à cette catégorie', |
|
| 34 | + 'DIR_BANNER_DISALLOWED_CONTENT' => 'L’envoi a été rejeté car le fichier envoyé a été identifié comme un vecteur éventuel d’attaque.', |
|
| 35 | + 'DIR_BANNER_DISALLOWED_EXTENSION' => 'Ce fichier ne peut pas être affiché car l’extension <strong>%s</strong> n’est pas autorisée.', |
|
| 36 | + 'DIR_BANNER_EMPTY_FILEUPLOAD' => 'Le fichier bannière transféré est vide.', |
|
| 37 | + 'DIR_BANNER_EMPTY_REMOTE_DATA' => 'La bannière indiquée n’a pas pu être transférée car les données distantes semblent être invalides ou corrompues.', |
|
| 38 | + 'DIR_BANNER_IMAGE_FILETYPE_MISMATCH' => 'Type de bannière incorrect: l’extension %1$s était attendue mais l’extension %2$s a été trouvée.', |
|
| 39 | + 'DIR_BANNER_INVALID_FILENAME' => '%s est un nom de fichier invalide.', |
|
| 40 | + 'DIR_BANNER_NOT_UPLOADED' => 'La bannière n’a pas pu être transférée.', |
|
| 41 | + 'DIR_BANNER_PARTIAL_UPLOAD' => 'Le fichier n’a pu être que partiellement transféré.', |
|
| 42 | + 'DIR_BANNER_PHP_SIZE_NA' => 'La taille de la bannière est trop importante.<br />La taille maximum réglée dans php.ini n’a pas pu être déterminée.', |
|
| 43 | + 'DIR_BANNER_PHP_SIZE_OVERRUN' => 'La taille de la bannière trop importante. La taille maximum de transfert autorisée est %d Mo.<br />Notez que ce paramètre est inscrit dans php.ini et ne peut pas être dépassé.', |
|
| 44 | + 'DIR_BANNER_REMOTE_UPLOAD_TIMEOUT' => 'La bannière spécifiée n’a pas été récupérée car la requête a éxpirée.', |
|
| 45 | + 'DIR_BANNER_UNABLE_GET_IMAGE_SIZE' => 'Impossible de déterminer les dimensions de la bannière.', |
|
| 46 | + 'DIR_BANNER_URL_INVALID' => 'L’URL de la bannière est invalide.', |
|
| 47 | + 'DIR_BANNER_URL_NOT_FOUND' => 'Le fichier indiqué est introuvable.', |
|
| 48 | + 'DIR_BANNER_WRONG_FILESIZE' => 'La taille de la bannière doit être comprise entre 0 et %1d %2s.', |
|
| 49 | + 'DIR_BANNER_WRONG_SIZE' => 'La bannière envoyée a une largeur de %3$d pixels et une hauteur de %4$d pixels. Les bannières doivent faire au plus %1$d pixels de large et %2$d pixels de haut.', |
|
| 50 | + 'DIR_BUTTON_NEW_SITE' => 'Nouveau lien', |
|
| 51 | + 'DIR_CAT' => 'Catégorie', |
|
| 52 | + 'DIR_CAT_NAME' => 'Nom de la catégorie', |
|
| 53 | + 'DIR_CAT_TITLE' => 'Catégories de l’annuaire', |
|
| 54 | + 'DIR_CAT_TOOLS' => 'Outils de la catégorie', |
|
| 55 | + 'DIR_CLICK_RETURN_DIR' => 'Cliquez %sici%s pour retourner au sommaire de l’annuaire', |
|
| 56 | + 'DIR_CLICK_RETURN_CAT' => 'Cliquez %sici%s pour retourner dans la catégorie', |
|
| 57 | + 'DIR_CLICK_RETURN_COMMENT' => 'Cliquez %sici%s pour revenir aux commentaires', |
|
| 58 | + 'DIR_COMMENTS_ORDER' => 'Commentaires', |
|
| 59 | + 'DIR_COMMENT_TITLE' => 'Voir/poster un commentaire', |
|
| 60 | + 'DIR_COMMENT_DELETE' => 'Supprimer le commentaire', |
|
| 61 | + 'DIR_COMMENT_DELETE_CONFIRM' => 'Êtes vous certain de vouloir supprimer le commentaire ?', |
|
| 62 | + 'DIR_COMMENT_DELETE_OK' => 'Le commentaire a bien été supprimé.', |
|
| 63 | + 'DIR_COMMENT_EDIT' => 'Modifier le commentaire', |
|
| 64 | + 'DIR_DELETE_BANNER' => 'Supprimer la bannière', |
|
| 65 | + 'DIR_DELETE_OK' => 'Le site a bien été supprimé', |
|
| 66 | + 'DIR_DELETE_SITE' => 'Supprimer le site', |
|
| 67 | + 'DIR_DELETE_SITE_CONFIRM' => 'Êtes vous certain de vouloir supprimer le site ?', |
|
| 68 | + 'DIR_DESCRIPTION' => 'Description', |
|
| 69 | + 'DIR_DESCRIPTION_EXP' => 'Une courte description de votre site, celle-ci ne peut pas dépasser %d caractères.', |
|
| 70 | + 'DIR_DISPLAY_LINKS' => 'Afficher les liens précédents', |
|
| 71 | + 'DIR_EDIT' => 'Modifier', |
|
| 72 | + 'DIR_EDIT_COMMENT_OK' => 'Le commentaire a bien été modifié', |
|
| 73 | + 'DIR_EDIT_SITE' => 'Modifier un site', |
|
| 74 | + 'DIR_EDIT_SITE_ACTIVE' => 'Votre site a bien été modifié, cependant le site n’apparaîtra dans l’annuaire qu’après validation', |
|
| 75 | + 'DIR_EDIT_SITE_OK' => 'Le site a bien été modifié', |
|
| 76 | + 'DIR_ERROR_AUTH_COMM' => 'Vous n’êtes pas autorisé à poster des commentaires', |
|
| 77 | + 'DIR_ERROR_CAT' => 'Impossible de récupérer les données de la catégorie actuelle', |
|
| 78 | + 'DIR_ERROR_CHECK_URL' => 'Cette URL semble injoignable', |
|
| 79 | + 'DIR_ERROR_COMM_LOGGED' => 'Vous devez être connecté pour pouvoir poster un commentaire', |
|
| 80 | + 'DIR_ERROR_KEYWORD' => 'Vous devez entrer des mots clés pour faire une recherche.', |
|
| 81 | + 'DIR_ERROR_NOT_AUTH' => 'Vous n’avez pas l’autorisation requise pour cette opération', |
|
| 82 | + 'DIR_ERROR_NOT_FOUND_BACK' => 'La page spécifiée pour le lien réciproque est introuvable.', |
|
| 83 | + 'DIR_ERROR_NO_CATS' => 'Cette catégorie n’existe pas', |
|
| 84 | + 'DIR_ERROR_NO_LINK' => 'Le site recherché n’existe pas', |
|
| 85 | + 'DIR_ERROR_NO_LINKS' => 'Ce site n’existe pas', |
|
| 86 | + 'DIR_ERROR_NO_LINK_BACK' => 'Le lien réciproque n’a pas été trouvé sur la page que vous avez spécifiée.', |
|
| 87 | + 'DIR_ERROR_SUBMIT_TYPE' => 'Type de données incorrect dans la fonction <em>dir_submit_type</em>', |
|
| 88 | + 'DIR_ERROR_URL' => 'Vous devez entrer une URL valide.', |
|
| 89 | + 'DIR_ERROR_VOTE' => 'Vous avez déjà voté pour ce site', |
|
| 90 | + 'DIR_ERROR_VOTE_LOGGED' => 'Vous devez être connecté pour pouvoir voter', |
|
| 91 | + 'DIR_ERROR_WRONG_DATA_BACK' => 'L’adresse du lien retour doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 92 | + 'DIR_FIELDS' => 'Veuillez remplir les champs marqués d’une *', |
|
| 93 | + 'DIR_FLAG' => 'Drapeau', |
|
| 94 | + 'DIR_FLAG_EXP' => 'Choisissez un drapeaux, qui indiquera la nationalité du site', |
|
| 95 | + 'DIR_FROM_TEN' => '%s/10', |
|
| 96 | + 'DIR_GUEST_EMAIL' => 'Votre adresse e-mail', |
|
| 97 | + 'DIR_MAKE_SEARCH' => 'Rechercher un site', |
|
| 98 | + 'DIR_NAME_ORDER' => 'Nom', |
|
| 99 | + 'DIR_NEW_COMMENT_OK' => 'Votre commentaire a bien été ajouté', |
|
| 100 | + 'DIR_NEW_SITE' => 'Ajouter un site à l’annuaire', |
|
| 101 | + 'DIR_NEW_SITE_ACTIVE' => 'Votre site a bien été ajouté, cependant le site n’apparaîtra dans l’annuaire qu’après validation', |
|
| 102 | + 'DIR_NEW_SITE_OK' => 'Votre site a bien été ajouté à l’annuaire', |
|
| 103 | + 'DIR_NB_CLICKS' => [ |
|
| 104 | + 1 => '%d clic', |
|
| 105 | + 2 => '%d clics', |
|
| 106 | + ], |
|
| 107 | + 'DIR_NB_CLICKS_ORDER' => 'Clics', |
|
| 108 | + 'DIR_NB_COMMS' => [ |
|
| 109 | + 1 => '%d commentaire', |
|
| 110 | + 2 => '%d commentaires', |
|
| 111 | + ], |
|
| 112 | + 'DIR_NB_LINKS' => [ |
|
| 113 | + 1 => '%d lien', |
|
| 114 | + 2 => '%d liens', |
|
| 115 | + ], |
|
| 116 | + 'DIR_NB_VOTES' => [ |
|
| 117 | + 1 => '%d vote', |
|
| 118 | + 2 => '%d votes', |
|
| 119 | + ], |
|
| 120 | + 'DIR_NONE' => 'Aucune', |
|
| 121 | + 'DIR_NOTE' => 'Note', |
|
| 122 | + 'DIR_NO_COMMENT' => 'Il n’y a aucun commentaire sur ce site', |
|
| 123 | + 'DIR_NO_DRAW_CAT' => 'Il n’y a aucune catégorie', |
|
| 124 | + 'DIR_NO_DRAW_LINK' => 'Il n’y a aucun site dans cette catégorie', |
|
| 125 | + 'DIR_NO_NOTE' => 'Aucune', |
|
| 126 | + 'DIR_NOT_WATCHING_CAT' => 'Vous ne surveillez plus cette catégorie', |
|
| 127 | 127 | |
| 128 | - 'DIR_PAGERANK' => 'Pr', |
|
| 129 | - 'DIR_PAGERANK_NOT_AVAILABLE' => 'n/a', |
|
| 130 | - 'DIR_PR_ORDER' => 'PageRank', |
|
| 131 | - 'DIR_REPLY_EXP' => 'Votre commentaire ne peut pas dépasser %d caractères.', |
|
| 132 | - 'DIR_REPLY_TITLE' => 'Poster un commentaire', |
|
| 133 | - 'DIR_RSS' => 'Flux de', |
|
| 134 | - 'DIR_SEARCH_CATLIST' => 'Chercher dans une catégorie', |
|
| 135 | - 'DIR_SEARCH_DESC_ONLY' => 'Description uniquement', |
|
| 136 | - 'DIR_SEARCH_METHOD' => 'Méthode', |
|
| 137 | - 'DIR_SEARCH_NB_CLICKS' => [ |
|
| 138 | - 1 => 'Clic', |
|
| 139 | - 2 => 'Clics', |
|
| 140 | - ], |
|
| 141 | - 'DIR_SEARCH_NB_COMMS' => [ |
|
| 142 | - 1 => 'Commentaire', |
|
| 143 | - 2 => 'Commentaires', |
|
| 144 | - ], |
|
| 145 | - 'DIR_SEARCH_NO_RESULT' => 'Aucun résultat trouvé pour la recherche', |
|
| 146 | - 'DIR_SEARCH_RESULT' => 'Résultat(s) de la recherche', |
|
| 147 | - 'DIR_SEARCH_SUBCATS' => 'Rechercher dans les sous-catégories', |
|
| 148 | - 'DIR_SEARCH_TITLE_DESC' => 'Nom et description', |
|
| 149 | - 'DIR_SEARCH_TITLE_ONLY' => 'Nom uniquement', |
|
| 150 | - 'DIR_SITE_BACK' => 'URL de votre page où se trouve le lien réciproque', |
|
| 151 | - 'DIR_SITE_BACK_EXPLAIN' => 'Dans cette catégorie, il est demandé que les sites proposés fassent un lien en retour. Veuillez spécifier ici l’url de la page où se trouve le lien en question.', |
|
| 152 | - 'DIR_SITE_BANN' => 'Lier une bannière ', |
|
| 153 | - 'DIR_SITE_BANN_EXP' => 'Vous devez entrer ici l’URL complète de votre bannière. Notez que ce champ n’est pas obligatoire. La taille maximale autorisée est <b>%d x %d</b> pixels, la bannière sera automatiquement redimensionnée si cette taille est dépassée.', |
|
| 154 | - 'DIR_SITE_NAME' => 'Nom du site', |
|
| 155 | - 'DIR_SITE_RSS' => 'Flux RSS', |
|
| 156 | - 'DIR_SITE_RSS_EXPLAIN' => 'Vous avez la possibilité de spécifier l’URL du Flux RSS du site s’il en existe un. Une icône rss apparaitra à coté de votre site, permettant de s’abonner à votre flux.', |
|
| 157 | - 'DIR_SITE_URL' => 'URL', |
|
| 158 | - 'DIR_SOMMAIRE' => 'Sommaire de l’annuaire', |
|
| 159 | - 'DIR_START_WATCHING_CAT' => 'S’abonner à cette catégorie', |
|
| 160 | - 'DIR_STOP_WATCHING_CAT' => 'Se désabonner de cette catégorie', |
|
| 161 | - 'DIR_SUBMIT_TYPE_1' => 'Votre site devra être validé par un administrateur.', |
|
| 162 | - 'DIR_SUBMIT_TYPE_2' => 'Votre site apparaîtra directement dans l’annuaire.', |
|
| 163 | - 'DIR_SUBMIT_TYPE_3' => 'Vous êtes administrateur, votre site sera automatiquement ajouté.', |
|
| 164 | - 'DIR_SUBMIT_TYPE_4' => 'Vous êtes modérateur, votre site sera automatiquement ajouté.', |
|
| 165 | - 'DIR_THUMB' => 'Miniature du site', |
|
| 166 | - 'DIR_USER_PROP' => 'Site proposé par', |
|
| 167 | - 'DIR_VOTE' => 'Voter', |
|
| 168 | - 'DIR_VOTE_OK' => 'Votre vote a bien été pris en compte', |
|
| 169 | - 'DIR_POST' => 'Poster', |
|
| 128 | + 'DIR_PAGERANK' => 'Pr', |
|
| 129 | + 'DIR_PAGERANK_NOT_AVAILABLE' => 'n/a', |
|
| 130 | + 'DIR_PR_ORDER' => 'PageRank', |
|
| 131 | + 'DIR_REPLY_EXP' => 'Votre commentaire ne peut pas dépasser %d caractères.', |
|
| 132 | + 'DIR_REPLY_TITLE' => 'Poster un commentaire', |
|
| 133 | + 'DIR_RSS' => 'Flux de', |
|
| 134 | + 'DIR_SEARCH_CATLIST' => 'Chercher dans une catégorie', |
|
| 135 | + 'DIR_SEARCH_DESC_ONLY' => 'Description uniquement', |
|
| 136 | + 'DIR_SEARCH_METHOD' => 'Méthode', |
|
| 137 | + 'DIR_SEARCH_NB_CLICKS' => [ |
|
| 138 | + 1 => 'Clic', |
|
| 139 | + 2 => 'Clics', |
|
| 140 | + ], |
|
| 141 | + 'DIR_SEARCH_NB_COMMS' => [ |
|
| 142 | + 1 => 'Commentaire', |
|
| 143 | + 2 => 'Commentaires', |
|
| 144 | + ], |
|
| 145 | + 'DIR_SEARCH_NO_RESULT' => 'Aucun résultat trouvé pour la recherche', |
|
| 146 | + 'DIR_SEARCH_RESULT' => 'Résultat(s) de la recherche', |
|
| 147 | + 'DIR_SEARCH_SUBCATS' => 'Rechercher dans les sous-catégories', |
|
| 148 | + 'DIR_SEARCH_TITLE_DESC' => 'Nom et description', |
|
| 149 | + 'DIR_SEARCH_TITLE_ONLY' => 'Nom uniquement', |
|
| 150 | + 'DIR_SITE_BACK' => 'URL de votre page où se trouve le lien réciproque', |
|
| 151 | + 'DIR_SITE_BACK_EXPLAIN' => 'Dans cette catégorie, il est demandé que les sites proposés fassent un lien en retour. Veuillez spécifier ici l’url de la page où se trouve le lien en question.', |
|
| 152 | + 'DIR_SITE_BANN' => 'Lier une bannière ', |
|
| 153 | + 'DIR_SITE_BANN_EXP' => 'Vous devez entrer ici l’URL complète de votre bannière. Notez que ce champ n’est pas obligatoire. La taille maximale autorisée est <b>%d x %d</b> pixels, la bannière sera automatiquement redimensionnée si cette taille est dépassée.', |
|
| 154 | + 'DIR_SITE_NAME' => 'Nom du site', |
|
| 155 | + 'DIR_SITE_RSS' => 'Flux RSS', |
|
| 156 | + 'DIR_SITE_RSS_EXPLAIN' => 'Vous avez la possibilité de spécifier l’URL du Flux RSS du site s’il en existe un. Une icône rss apparaitra à coté de votre site, permettant de s’abonner à votre flux.', |
|
| 157 | + 'DIR_SITE_URL' => 'URL', |
|
| 158 | + 'DIR_SOMMAIRE' => 'Sommaire de l’annuaire', |
|
| 159 | + 'DIR_START_WATCHING_CAT' => 'S’abonner à cette catégorie', |
|
| 160 | + 'DIR_STOP_WATCHING_CAT' => 'Se désabonner de cette catégorie', |
|
| 161 | + 'DIR_SUBMIT_TYPE_1' => 'Votre site devra être validé par un administrateur.', |
|
| 162 | + 'DIR_SUBMIT_TYPE_2' => 'Votre site apparaîtra directement dans l’annuaire.', |
|
| 163 | + 'DIR_SUBMIT_TYPE_3' => 'Vous êtes administrateur, votre site sera automatiquement ajouté.', |
|
| 164 | + 'DIR_SUBMIT_TYPE_4' => 'Vous êtes modérateur, votre site sera automatiquement ajouté.', |
|
| 165 | + 'DIR_THUMB' => 'Miniature du site', |
|
| 166 | + 'DIR_USER_PROP' => 'Site proposé par', |
|
| 167 | + 'DIR_VOTE' => 'Voter', |
|
| 168 | + 'DIR_VOTE_OK' => 'Votre vote a bien été pris en compte', |
|
| 169 | + 'DIR_POST' => 'Poster', |
|
| 170 | 170 | |
| 171 | - 'DIRECTORY_TRANSLATION_INFO' => '', |
|
| 171 | + 'DIRECTORY_TRANSLATION_INFO' => '', |
|
| 172 | 172 | |
| 173 | - 'RECENT_LINKS' => 'Derniers sites ajoutés', |
|
| 173 | + 'RECENT_LINKS' => 'Derniers sites ajoutés', |
|
| 174 | 174 | |
| 175 | - // Ne pas traduire cette ligne! |
|
| 176 | - 'SEED' => 'Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE. Yes, I’m talking to you, scammer.', |
|
| 175 | + // Ne pas traduire cette ligne! |
|
| 176 | + 'SEED' => 'Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE. Yes, I’m talking to you, scammer.', |
|
| 177 | 177 | |
| 178 | - 'TOO_LONG_BACK' => 'L’URL de la page contenant le lien réciproque est trop longue (255 caractères maximum)', |
|
| 179 | - 'TOO_LONG_DESCRIPTION' => 'Votre description est trop longue', |
|
| 180 | - 'TOO_LONG_REPLY' => 'Votre commentaire est trop long', |
|
| 181 | - 'TOO_LONG_RSS' => 'L’URL du flux RSS est trop longue', |
|
| 182 | - 'TOO_LONG_SITE_NAME' => 'Vous avez indiqué un nom de site trop long (100 caractères maximum)', |
|
| 183 | - 'TOO_LONG_URL' => 'Vous avez indiqué une URL trop longue pour ce site (255 caractères maximum)', |
|
| 184 | - 'TOO_MANY_ADDS' => 'Vous avez atteint le nombre maximum de tentatives de soumission. Réessayez plus tard.', |
|
| 185 | - 'TOO_SHORT_BACK' => 'Vous devez indiquer l’URL de la page contenant le lien réciproque', |
|
| 186 | - 'TOO_SHORT_DESCRIPTION' => 'Vous devez entrer une description', |
|
| 187 | - 'TOO_SHORT_REPLY' => 'Votre commentaire est trop court', |
|
| 188 | - 'TOO_SHORT_RSS' => 'L’URL du flux RSS est trop courte', |
|
| 189 | - 'TOO_SHORT_SITE_NAME' => 'Vous devez indiquer un nom pour le site', |
|
| 190 | - 'TOO_SHORT_URL' => 'Vous devez indiquer une URL pour ce site', |
|
| 191 | - 'TOO_SMALL_CAT' => 'Vous devez choisir une catégorie', |
|
| 178 | + 'TOO_LONG_BACK' => 'L’URL de la page contenant le lien réciproque est trop longue (255 caractères maximum)', |
|
| 179 | + 'TOO_LONG_DESCRIPTION' => 'Votre description est trop longue', |
|
| 180 | + 'TOO_LONG_REPLY' => 'Votre commentaire est trop long', |
|
| 181 | + 'TOO_LONG_RSS' => 'L’URL du flux RSS est trop longue', |
|
| 182 | + 'TOO_LONG_SITE_NAME' => 'Vous avez indiqué un nom de site trop long (100 caractères maximum)', |
|
| 183 | + 'TOO_LONG_URL' => 'Vous avez indiqué une URL trop longue pour ce site (255 caractères maximum)', |
|
| 184 | + 'TOO_MANY_ADDS' => 'Vous avez atteint le nombre maximum de tentatives de soumission. Réessayez plus tard.', |
|
| 185 | + 'TOO_SHORT_BACK' => 'Vous devez indiquer l’URL de la page contenant le lien réciproque', |
|
| 186 | + 'TOO_SHORT_DESCRIPTION' => 'Vous devez entrer une description', |
|
| 187 | + 'TOO_SHORT_REPLY' => 'Votre commentaire est trop court', |
|
| 188 | + 'TOO_SHORT_RSS' => 'L’URL du flux RSS est trop courte', |
|
| 189 | + 'TOO_SHORT_SITE_NAME' => 'Vous devez indiquer un nom pour le site', |
|
| 190 | + 'TOO_SHORT_URL' => 'Vous devez indiquer une URL pour ce site', |
|
| 191 | + 'TOO_SMALL_CAT' => 'Vous devez choisir une catégorie', |
|
| 192 | 192 | |
| 193 | - 'WRONG_DATA_RSS' => 'Le flux RSS doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 194 | - 'WRONG_DATA_WEBSITE' => 'L’adresse du site Internet doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 193 | + 'WRONG_DATA_RSS' => 'Le flux RSS doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 194 | + 'WRONG_DATA_WEBSITE' => 'L’adresse du site Internet doit être une URL valide, incluant le protocole. Par exemple http://www.exemple.com/.', |
|
| 195 | 195 | ]); |