From 8b7e6126ad28ce0563bbc0444ea63bbd01e4a2cd Mon Sep 17 00:00:00 2001 From: Ali Faraji Date: Thu, 13 Nov 2014 13:02:26 +0200 Subject: [PATCH] include in loop if f_read is yes --- config/services.yml | 1 + event/listener.php | 11 +++++-- language/fa/info_acp_randomtopics.php | 31 +++++++++++++++++++ language/fa/randomtopics.php | 20 ++++++++++++ .../event/index_body_stat_blocks_before.html | 0 .../event/viewtopic_body_footer_before.html | 0 .../template/randomtopics_body.html | 0 7 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 language/fa/info_acp_randomtopics.php create mode 100644 language/fa/randomtopics.php rename styles/{prosilver => all}/template/event/index_body_stat_blocks_before.html (100%) rename styles/{prosilver => all}/template/event/viewtopic_body_footer_before.html (100%) rename styles/{prosilver => all}/template/randomtopics_body.html (100%) diff --git a/config/services.yml b/config/services.yml index 2762109..c3d8ede 100644 --- a/config/services.yml +++ b/config/services.yml @@ -7,6 +7,7 @@ services: - @config - @dbal.conn - @user + - @auth - %core.root_path% - %core.php_ext% tags: diff --git a/event/listener.php b/event/listener.php index 315d2ad..858ae76 100644 --- a/event/listener.php +++ b/event/listener.php @@ -47,6 +47,9 @@ static public function getSubscribedEvents() /** @var \phpbb\user */ protected $user; + /** @var \phpbb\auth\auth */ + protected $auth; + /** @var string phpBB root path */ protected $root_path; @@ -54,13 +57,14 @@ static public function getSubscribedEvents() protected $phpEx; - public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $root_path, $phpEx) + public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\auth\auth $auth, $root_path, $phpEx) { $this->helper = $helper; $this->template = $template; $this->config = $config; $this->db = $db; $this->user = $user; + $this->auth = $auth; $this->root_path = $root_path; $this->phpEx = $phpEx; } @@ -90,10 +94,11 @@ public function count_posts($id) public function get_topic_list() { - $sql = 'SELECT topic_title, topic_time, topic_views, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time, topic_last_post_id, topic_id, forum_id + $sql = 'SELECT forum_id, topic_title, topic_time, topic_views, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time, topic_last_post_id, topic_id, forum_id FROM ' . TOPICS_TABLE . ' AS data JOIN (SELECT (FLOOR(RAND() * (SELECT MAX(topic_id) FROM '.TOPICS_TABLE.'))) AS random_id) as random - WHERE data.topic_id >= random.random_id '; + WHERE '. $this->db->sql_in_set('forum_id', array_keys($this->auth->acl_getf('f_read', true))) .' + AND data.topic_id >= random.random_id'; $limit = $this->config['rtopics_limit']; $result = $this->db->sql_query_limit($sql, $limit); diff --git a/language/fa/info_acp_randomtopics.php b/language/fa/info_acp_randomtopics.php new file mode 100644 index 0000000..655ed57 --- /dev/null +++ b/language/fa/info_acp_randomtopics.php @@ -0,0 +1,31 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +*/ + +if (!defined('IN_PHPBB')) +{ + exit; +} +if (empty($lang) || !is_array($lang)) +{ + $lang = array(); +} +$lang = array_merge($lang, array( + 'ACP_RANDOMTOPICS' => 'موضوعات اتفاقی', + 'ACP_RANDOMTOPICS_SETTINGS' => 'تنظیمات', + 'ACP_RTOPICS_LIMIT' => 'محدودیت تعداد موضوع', + 'ACP_LIMIT_ACTIVE_EXP' => 'تعداد موضوعی که در لیست نمایش داده شود', + 'ACP_RANDOMTOPICS_TITLE' => 'موضوعات اتفاقی', + 'ACP_RTOPICS_ACTIVE' => 'موضوعات اتفاقی فعال شود؟', + 'ACP_RTOPICS_ACTIVE_EXP' => 'فعال سازی/غیرفعال سازی افزونه', + 'ACP_RTOPICS_SETTING_SAVED' => 'تنظیمات با موفقیت بروز شدند.', + 'ACP_RTOPICS_INDEX' => 'نمایش موضوعات اتفاقی در صفحه اصلی', + 'ACP_RTOPICS_INDEX_EXP' => 'لیست موضوعات اتفاقی در صفحه اصلی نمایش داده خواهند شد.', + 'ACP_RTOPICS_VIEWTOPIC' => 'نمایش موضوعات اتفاقی در صفحه موضوعات', + 'ACP_RTOPICS_VIEWTOPIC_EXP' => 'موضوعات اتفاقی در صفحه موضوعات نمایش داده خواهند شد.', +)); \ No newline at end of file diff --git a/language/fa/randomtopics.php b/language/fa/randomtopics.php new file mode 100644 index 0000000..6d1fffd --- /dev/null +++ b/language/fa/randomtopics.php @@ -0,0 +1,20 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +*/ + +if (!defined('IN_PHPBB')) +{ + exit; +} +if (empty($lang) || !is_array($lang)) +{ + $lang = array(); +} +$lang = array_merge($lang, array( + 'RANDOM_TOPICS' => 'موضوعات اتفاقی', +)); \ No newline at end of file diff --git a/styles/prosilver/template/event/index_body_stat_blocks_before.html b/styles/all/template/event/index_body_stat_blocks_before.html similarity index 100% rename from styles/prosilver/template/event/index_body_stat_blocks_before.html rename to styles/all/template/event/index_body_stat_blocks_before.html diff --git a/styles/prosilver/template/event/viewtopic_body_footer_before.html b/styles/all/template/event/viewtopic_body_footer_before.html similarity index 100% rename from styles/prosilver/template/event/viewtopic_body_footer_before.html rename to styles/all/template/event/viewtopic_body_footer_before.html diff --git a/styles/prosilver/template/randomtopics_body.html b/styles/all/template/randomtopics_body.html similarity index 100% rename from styles/prosilver/template/randomtopics_body.html rename to styles/all/template/randomtopics_body.html