diff --git a/config/services.yml b/config/services.yml
index d9bd8c85..cd68b043 100644
--- a/config/services.yml
+++ b/config/services.yml
@@ -40,6 +40,20 @@ services:
tags:
- { name: service_collection, tag: board3.module }
+ board3.module.announcements:
+ class: \board3\portal\modules\announcements
+ arguments:
+ - @auth
+ - @cache
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.php_ext%
+ - %core.root_path%
+ - @user
+ tags:
+ - { name: board3.module }
+
board3.module.stylechanger:
class: \board3\portal\modules\stylechanger
arguments:
diff --git a/migrations/v210_beta1.php b/migrations/v210_beta1.php
index d22558e2..c9a9b109 100644
--- a/migrations/v210_beta1.php
+++ b/migrations/v210_beta1.php
@@ -424,7 +424,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'announcements',
+ 'module_classname' => '\board3\portal\modules\announcements',
'module_column' => 2,
'module_order' => 3,
'module_name' => 'GLOBAL_ANNOUNCEMENTS',
diff --git a/modules/announcements.php b/modules/announcements.php
new file mode 100644
index 00000000..e8382de9
--- /dev/null
+++ b/modules/announcements.php
@@ -0,0 +1,529 @@
+lang}/mods/portal/"
+ */
+ public $language = 'portal_announcements_module';
+
+ /** @var \phpbb\auth\auth */
+ protected $auth;
+
+ /** @var \phpbb\cache\driver */
+ protected $cache;
+
+ /** @var \phpbb\config\config */
+ protected $config;
+
+ /** @var \phpbb\template */
+ protected $template;
+
+ /** @var \phpbb\db\driver */
+ protected $db;
+
+ /** @var php file extension */
+ protected $php_ext;
+
+ /** @var phpbb root path */
+ protected $phpbb_root_path;
+
+ /** @var \phpbb\user */
+ protected $user;
+
+ /**
+ * Construct a stylechanger object
+ *
+ * @param \phpbb\auth\auth $auth phpBB auth service
+ * @param \phpbb\cache\driver $cache phpBB cache driver
+ * @param \phpbb\config\config $config phpBB config
+ * @param \phpbb\template $template phpBB template
+ * @param \phpbb\db\driver $db Database driver
+ * @param string $phpEx php file extension
+ * @param string $phpbb_root_path phpBB root path
+ * @param \phpbb\user $user phpBB user object
+ */
+ public function __construct($auth, $cache, $config, $template, $db, $phpEx, $phpbb_root_path, $user)
+ {
+ $this->auth = $auth;
+ $this->cache = $cache;
+ $this->config = $config;
+ $this->template = $template;
+ $this->db = $db;
+ $this->php_ext = $phpEx;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->user = $user;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_template_center($module_id)
+ {
+ $announcement = request_var('announcement', -1);
+ $announcement = ($announcement > $this->config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement;
+ $start = request_var('ap', 0);
+ $start = ($start < 0) ? 0 : $start;
+
+ // Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
+ $portal_announcement_length = ($announcement < 0) ? $this->config['board3_announcements_length_' . $module_id] : 0;
+ $fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_global_announcements_forum_' . $module_id], $this->config['board3_announcements_permissions_' . $module_id], $this->config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $this->config['board3_announcements_day_' . $module_id], 'announcements', $start, $this->config['board3_announcements_forum_exclude_' . $module_id]);
+
+ // Any announcements present? If not terminate it here.
+ if (sizeof($fetch_news) == 0)
+ {
+ $this->template->assign_block_vars('announcements_center_row', array(
+ 'S_NO_TOPICS' => true,
+ 'S_NOT_LAST' => false
+ ));
+
+ $this->template->assign_var('S_CAN_READ', false);
+ }
+ else
+ {
+ // Count number of posts for announcements archive, considering if permission check is dis- or enabled.
+ if ($this->config['board3_announcements_archive_' . $module_id])
+ {
+ $permissions = $this->config['board3_announcements_permissions_' . $module_id];
+ $forum_from = $this->config['board3_global_announcements_forum_' . $module_id];
+ $forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
+
+ $time = ($this->config['board3_announcements_day_' . $module_id] == 0) ? 0 : $this->config['board3_announcements_day_' . $module_id];
+ $post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400);
+
+ $str_where = '';
+
+ if($permissions == true)
+ {
+ $disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
+ }
+ else
+ {
+ $disallow_access = array();
+ }
+
+ if($this->config['board3_announcements_forum_exclude_' . $module_id] == true)
+ {
+ $disallow_access = array_merge($disallow_access, $forum_from);
+ $forum_from = array();
+ }
+
+ $global_f = 0;
+
+ if(sizeof($forum_from))
+ {
+ $disallow_access = array_diff($forum_from, $disallow_access);
+ if(!sizeof($disallow_access))
+ {
+ return array();
+ }
+
+ foreach($disallow_access as $acc_id)
+ {
+ $str_where .= 'forum_id = ' . (int) $acc_id . ' OR ';
+ if($global_f < 1 && $acc_id > 0)
+ {
+ $global_f = $acc_id;
+ }
+ }
+ }
+ else
+ {
+ foreach($disallow_access as $acc_id)
+ {
+ $str_where .= 'forum_id <> ' . (int) $acc_id . ' AND ';
+ }
+ }
+
+ $str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
+
+ $sql = 'SELECT COUNT(topic_id) AS num_topics
+ FROM ' . TOPICS_TABLE . '
+ WHERE ((topic_type = ' . POST_GLOBAL . ')
+ OR topic_type = ' . POST_ANNOUNCE . ')
+ AND topic_visibility = 1
+ AND topic_moved_id = 0
+ ' . $post_time . '
+ ' . $str_where;
+ $result = $this->db->sql_query($sql);
+ $total_announcements = (int) $this->db->sql_fetchfield('num_topics');
+ $this->db->sql_freeresult($result);
+ }
+
+ $topic_tracking_info = (get_portal_tracking_info($fetch_news));
+
+ if($announcement < 0)
+ // Show the announcements overview
+ {
+ $count = $fetch_news['topic_count'];
+ for ($i = 0; $i < $count; $i++)
+ {
+ if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
+ {
+ $open_bracket = '[ ';
+ $close_bracket = ' ]';
+ $read_full = $this->user->lang['READ_FULL'];
+ }
+ else
+ {
+ $open_bracket = '';
+ $close_bracket = '';
+ $read_full = '';
+ }
+ // unread?
+ $forum_id = $fetch_news[$i]['forum_id'];
+ $topic_id = $fetch_news[$i]['topic_id'];
+ //$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
+ $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
+ $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
+ $read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
+ $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
+
+ if ($this->config['board3_announcements_archive_' . $module_id])
+ {
+ $pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
+ }
+
+ $replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
+ $folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
+ switch ($fetch_news[$i]['topic_type'])
+ {
+ case POST_GLOBAL:
+ $folder = 'global_read';
+ $folder_new = 'global_unread';
+ break;
+ case POST_ANNOUNCE:
+ $folder = 'announce_read';
+ $folder_new = 'announce_unread';
+ break;
+ default:
+ $folder = 'topic_read';
+ $folder_new = 'topic_unread';
+ if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
+ {
+ $folder .= '_hot';
+ $folder_new .= '_hot';
+ }
+ break;
+ }
+
+ if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
+ {
+ $folder .= '_locked';
+ $folder_new .= '_locked';
+ }
+ if ($fetch_news[$i]['topic_type'] == POST_GLOBAL)
+ {
+ $global_announce_list[$fetch_news[$i]['topic_id']] = true;
+ }
+ if ($fetch_news[$i]['topic_posted'])
+ {
+ $folder .= '_mine';
+ $folder_new .= '_mine';
+ }
+ $folder_img = ($unread_topic) ? $folder_new : $folder;
+ $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
+
+ // Grab icons
+ $icons = $this->cache->obtain_icons();
+
+ $this->template->assign_block_vars('announcements_center_row', array(
+ 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
+ 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
+ 'TITLE' => $fetch_news[$i]['topic_title'],
+ 'POSTER' => $fetch_news[$i]['username'],
+ 'POSTER_FULL' => $fetch_news[$i]['username_full'],
+ 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
+ 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
+ 'TIME' => $fetch_news[$i]['topic_time'],
+ 'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']),
+ 'TEXT' => $fetch_news[$i]['post_text'],
+ 'REPLIES' => $fetch_news[$i]['topic_replies'],
+ 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
+ 'A_ID' => $i,
+ 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt),
+ 'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'),
+ 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt],
+ 'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'),
+ 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
+ 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
+ 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
+ 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
+ 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
+ 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
+ 'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'),
+ 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
+ 'U_READ_FULL' => append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", $read_full_url),
+ 'L_READ_FULL' => $read_full,
+ 'OPEN' => $open_bracket,
+ 'CLOSE' => $close_bracket,
+ 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
+ 'S_POLL' => $fetch_news[$i]['poll'],
+ 'S_UNREAD_INFO' => $unread_topic,
+ 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
+ ));
+
+ phpbb_generate_template_pagination($this->template, $view_topic_url, 'announcements_center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true);
+
+
+ if(!empty($fetch_news[$i]['attachments']))
+ {
+ foreach ($fetch_news[$i]['attachments'] as $attachment)
+ {
+ $this->template->assign_block_vars('announcements_center_row.attachment', array(
+ 'DISPLAY_ATTACHMENT' => $attachment)
+ );
+ }
+ }
+ if ($this->config['board3_number_of_announcements_' . $module_id] != 0 && $this->config['board3_announcements_archive_' . $module_id])
+ {
+ $this->template->assign_vars(array(
+ 'AP_PAGINATION' => $pagination,
+ 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
+ 'AP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start))
+ );
+ }
+ }
+ }
+ else
+ // Show "read full" page
+ {
+ $i = $announcement;
+
+ /**
+ * redirect to portal page if the specified announcement does not exist
+ * force #top anchor in order to get rid of the #a anchor
+ */
+ if (!isset($fetch_news[$i]))
+ {
+ redirect(append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, '/portal#top'));
+ }
+
+ $forum_id = $fetch_news[$i]['forum_id'];
+ $topic_id = $fetch_news[$i]['topic_id'];
+ $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
+ $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
+ $open_bracket = '[ ';
+ $close_bracket = ' ]';
+ $read_full = $this->user->lang['BACK'];
+ $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
+
+ $read_full_url = (isset($_GET['ap'])) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "ap=$start#a$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#a$i");
+ $view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
+ if ($this->config['board3_announcements_archive_' . $module_id])
+ {
+ $pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
+ }
+
+ $this->template->assign_block_vars('announcements_center_row', array(
+ 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
+ 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
+ 'TITLE' => $fetch_news[$i]['topic_title'],
+ 'POSTER' => $fetch_news[$i]['username'],
+ 'POSTER_FULL' => $fetch_news[$i]['username_full'],
+ 'TIME' => $fetch_news[$i]['topic_time'],
+ 'TEXT' => $fetch_news[$i]['post_text'],
+ 'REPLIES' => $fetch_news[$i]['topic_replies'],
+ 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
+ 'A_ID' => $i,
+ 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
+ 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
+ 'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
+ 'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
+ 'S_POLL' => $fetch_news[$i]['poll'],
+ 'S_UNREAD_INFO' => $unread_topic,
+ 'U_READ_FULL' => $read_full_url,
+ 'L_READ_FULL' => $read_full,
+ 'OPEN' => $open_bracket,
+ 'CLOSE' => $close_bracket,
+ 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
+ ));
+
+ phpbb_generate_template_pagination($this->template, $view_topic_url, 'announcements_center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true);
+
+ if(!empty($fetch_news[$i]['attachments']))
+ {
+ foreach ($fetch_news[$i]['attachments'] as $attachment)
+ {
+ $this->template->assign_block_vars('announcements_center_row.attachment', array(
+ 'DISPLAY_ATTACHMENT' => $attachment)
+ );
+ }
+ }
+
+ if ($this->config['board3_number_of_announcements_' . $module_id] <> 0 && $this->config['board3_announcements_archive_' . $module_id])
+ {
+ $this->template->assign_vars(array(
+ 'AP_PAGINATION' => $pagination,
+ 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
+ 'AP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start))
+ );
+ }
+ }
+ }
+
+ $topic_icons = false;
+ if(!empty($fetch_news['topic_icons']))
+ {
+ $topic_icons = true;
+ }
+
+ $this->template->assign_vars(array(
+ 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
+ 'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
+ 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'),
+ 'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($this->config['board3_show_announcements_replies_views_' . $module_id]) ? true : false,
+ 'S_TOPIC_ICONS' => $topic_icons,
+ ));
+
+ if ($this->config['board3_announcements_style_' . $module_id])
+ {
+ return 'announcements_center_compact.html';
+ }
+ else
+ {
+ return 'announcements_center.html';
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_template_acp($module_id)
+ {
+ return array(
+ 'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
+ 'vars' => array(
+ 'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
+ 'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
+ 'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
+ 'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
+ 'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
+ 'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true),
+ 'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ ),
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function install($module_id)
+ {
+ set_config('board3_announcements_style_' . $module_id, 0);
+ set_config('board3_number_of_announcements_' . $module_id, 1);
+ set_config('board3_announcements_day_' . $module_id, 0);
+ set_config('board3_announcements_length_' . $module_id, 200);
+ set_config('board3_global_announcements_forum_' . $module_id, '');
+ set_config('board3_announcements_forum_exclude_' . $module_id, 0);
+ set_config('board3_announcements_archive_' . $module_id, 1);
+ set_config('board3_announcements_permissions_' . $module_id, 1);
+ set_config('board3_show_announcements_replies_views_' . $module_id, 1);
+
+ return true;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function uninstall($module_id, $db)
+ {
+ $del_config = array(
+ 'board3_announcements_style_' . $module_id,
+ 'board3_number_of_announcements_' . $module_id,
+ 'board3_announcements_day_' . $module_id,
+ 'board3_announcements_length_' . $module_id,
+ 'board3_global_announcements_forum_' . $module_id,
+ 'board3_announcements_forum_exclude_' . $module_id,
+ 'board3_announcements_archive_' . $module_id,
+ 'board3_announcements_permissions_' . $module_id,
+ 'board3_show_announcements_replies_views_' . $module_id,
+ );
+ $sql = 'DELETE FROM ' . CONFIG_TABLE . '
+ WHERE ' . $db->sql_in_set('config_name', $del_config);
+ return $db->sql_query($sql);
+ }
+
+ /**
+ * Create forum select box
+ *
+ * @param mixed $value Value of input
+ * @param string $key Key name
+ * @param int $module_id Module ID
+ *
+ * @return string Forum select box HTML
+ */
+ public function select_forums($value, $key, $module_id)
+ {
+ $forum_list = make_forum_select(false, false, true, true, true, false, true);
+
+ $selected = array();
+ if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
+ {
+ $selected = explode(',', $this->config[$key]);
+ }
+ // Build forum options
+ $s_forum_options = '';
+
+ return $s_forum_options;
+
+ }
+
+ /**
+ * Store selected forums
+ *
+ * @param string $key Key name
+ * @param int $module_id Module ID
+ *
+ * @return null
+ */
+ public function store_selected_forums($key, $module_id)
+ {
+ // Get selected forums
+ $values = request_var($key, array(0 => ''));
+ $news = implode(',', $values);
+ set_config($key, $news);
+ }
+}
diff --git a/portal/includes/functions.php b/portal/includes/functions.php
index bd13aa78..4627c43c 100644
--- a/portal/includes/functions.php
+++ b/portal/includes/functions.php
@@ -183,15 +183,11 @@ function phpbb_fetch_posts($module_id, $forum_from, $permissions, $number_of_pos
if ($type == 'announcements' && $global_f < 1)
{
- $sql = 'SELECT
- forum_id
- FROM
- ' . FORUMS_TABLE . '
- WHERE
- forum_type = ' . FORUM_POST . '
- ' . str_replace('t.', '', $str_where) . '
- ORDER BY
- forum_id';
+ $sql = 'SELECT forum_id
+ FROM ' . FORUMS_TABLE . '
+ WHERE forum_type = ' . FORUM_POST . '
+ ' . str_replace('t.', '', $str_where) . '
+ ORDER BY forum_id';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
diff --git a/portal/modules/portal_announcements.php b/portal/modules/portal_announcements.php
deleted file mode 100644
index 679a7fd4..00000000
--- a/portal/modules/portal_announcements.php
+++ /dev/null
@@ -1,468 +0,0 @@
-lang}/mods/portal/"
- */
- public $language = 'portal_announcements_module';
-
- public function get_template_center($module_id)
- {
- global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
-
- $announcement = request_var('announcement', -1);
- $announcement = ($announcement > $config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement;
- $start = request_var('ap', 0);
- $start = ($start < 0) ? 0 : $start;
-
- // Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
- $portal_announcement_length = ($announcement < 0) ? $config['board3_announcements_length_' . $module_id] : 0;
- $fetch_news = phpbb_fetch_posts($module_id, $config['board3_global_announcements_forum_' . $module_id], $config['board3_announcements_permissions_' . $module_id], $config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $config['board3_announcements_day_' . $module_id], 'announcements', $start, $config['board3_announcements_forum_exclude_' . $module_id]);
-
- // Any announcements present? If not terminate it here.
- if (sizeof($fetch_news) == 0)
- {
- $template->assign_block_vars('announcements_center_row', array(
- 'S_NO_TOPICS' => true,
- 'S_NOT_LAST' => false
- ));
-
- $template->assign_var('S_CAN_READ', false);
- }
- else
- {
- // Count number of posts for announcements archive, considering if permission check is dis- or enabled.
- if ($config['board3_announcements_archive_' . $module_id])
- {
- $permissions = $config['board3_announcements_permissions_' . $module_id];
- $forum_from = $config['board3_global_announcements_forum_' . $module_id];
- $forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
-
- $time = ($config['board3_announcements_day_' . $module_id] == 0) ? 0 : $config['board3_announcements_day_' . $module_id];
- $post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400);
-
- $str_where = '';
-
- if($permissions == true)
- {
- $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
- }
- else
- {
- $disallow_access = array();
- }
-
- if($config['board3_announcements_forum_exclude_' . $module_id] == true)
- {
- $disallow_access = array_merge($disallow_access, $forum_from);
- $forum_from = array();
- }
-
- $global_f = 0;
-
- if(sizeof($forum_from))
- {
- $disallow_access = array_diff($forum_from, $disallow_access);
- if(!sizeof($disallow_access))
- {
- return array();
- }
-
- foreach($disallow_access as $acc_id)
- {
- $acc_id = (int) $acc_id;
- $str_where .= "forum_id = $acc_id OR ";
- if($global_f < 1 && $acc_id > 0)
- {
- $global_f = $acc_id;
- }
- }
- }
- else
- {
- foreach($disallow_access as $acc_id)
- {
- $acc_id = (int) $acc_id;
- $str_where .= "forum_id <> $acc_id AND ";
- }
- }
-
- $str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
-
- $sql = 'SELECT COUNT(topic_id) AS num_topics
- FROM ' . TOPICS_TABLE . '
- WHERE ((topic_type = ' . POST_GLOBAL . ')
- OR topic_type = ' . POST_ANNOUNCE . ')
- AND topic_visibility = 1
- AND topic_moved_id = 0
- ' . $post_time . '
- ' . $str_where;
- $result = $db->sql_query($sql);
- $total_announcements = (int) $db->sql_fetchfield('num_topics');
- $db->sql_freeresult($result);
- }
-
- $topic_tracking_info = (get_portal_tracking_info($fetch_news));
-
- if($announcement < 0)
- // Show the announcements overview
- {
- $count = $fetch_news['topic_count'];
- for ($i = 0; $i < $count; $i++)
- {
- if(isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true)
- {
- $open_bracket = '[ ';
- $close_bracket = ' ]';
- $read_full = $user->lang['READ_FULL'];
- }
- else
- {
- $open_bracket = '';
- $close_bracket = '';
- $read_full = '';
- }
- // unread?
- $forum_id = $fetch_news[$i]['forum_id'];
- $topic_id = $fetch_news[$i]['topic_id'];
- //$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
- $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
- $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
- $read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i;
- $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
-
- if ($config['board3_announcements_archive_' . $module_id])
- {
- $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
- }
-
- $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
- $folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
- switch ($fetch_news[$i]['topic_type'])
- {
- case POST_GLOBAL:
- $folder = 'global_read';
- $folder_new = 'global_unread';
- break;
- case POST_ANNOUNCE:
- $folder = 'announce_read';
- $folder_new = 'announce_unread';
- break;
- default:
- $folder = 'topic_read';
- $folder_new = 'topic_unread';
- if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
- {
- $folder .= '_hot';
- $folder_new .= '_hot';
- }
- break;
- }
-
- if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED)
- {
- $folder .= '_locked';
- $folder_new .= '_locked';
- }
- if ($fetch_news[$i]['topic_type'] == POST_GLOBAL)
- {
- $global_announce_list[$fetch_news[$i]['topic_id']] = true;
- }
- if ($fetch_news[$i]['topic_posted'])
- {
- $folder .= '_mine';
- $folder_new .= '_mine';
- }
- $folder_img = ($unread_topic) ? $folder_new : $folder;
- $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
-
- // Grab icons
- $icons = $cache->obtain_icons();
-
- $template->assign_block_vars('announcements_center_row', array(
- 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
- 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
- 'TITLE' => $fetch_news[$i]['topic_title'],
- 'POSTER' => $fetch_news[$i]['username'],
- 'POSTER_FULL' => $fetch_news[$i]['username_full'],
- 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
- 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
- 'TIME' => $fetch_news[$i]['topic_time'],
- 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']),
- 'TEXT' => $fetch_news[$i]['post_text'],
- 'REPLIES' => $fetch_news[$i]['topic_replies'],
- 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
- 'A_ID' => $i,
- 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
- 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
- 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
- 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
- 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
- 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
- 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
- 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
- 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
- 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
- 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'),
- 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
- 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
- 'L_READ_FULL' => $read_full,
- 'OPEN' => $open_bracket,
- 'CLOSE' => $close_bracket,
- 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
- 'S_POLL' => $fetch_news[$i]['poll'],
- 'S_UNREAD_INFO' => $unread_topic,
- 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
- 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
- ));
-
- if(!empty($fetch_news[$i]['attachments']))
- {
- foreach ($fetch_news[$i]['attachments'] as $attachment)
- {
- $template->assign_block_vars('announcements_center_row.attachment', array(
- 'DISPLAY_ATTACHMENT' => $attachment)
- );
- }
- }
- if ($config['board3_number_of_announcements_' . $module_id] != 0 && $config['board3_announcements_archive_' . $module_id])
- {
- $template->assign_vars(array(
- 'AP_PAGINATION' => $pagination,
- 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
- 'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
- );
- }
- }
- }
- else
- // Show "read full" page
- {
- $i = $announcement;
-
- /**
- * redirect to portal page if the specified announcement does not exist
- * force #top anchor in order to get rid of the #a anchor
- */
- if (!isset($fetch_news[$i]))
- {
- redirect(append_sid($phpbb_root_path . 'portal.' . $phpEx, '#top'));
- }
-
- $forum_id = $fetch_news[$i]['forum_id'];
- $topic_id = $fetch_news[$i]['topic_id'];
- $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
- $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
- $open_bracket = '[ ';
- $close_bracket = ' ]';
- $read_full = $user->lang['BACK'];
- $real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
-
- $read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i");
- $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
- if ($config['board3_announcements_archive_' . $module_id])
- {
- $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $config['board3_number_of_announcements_' . $module_id], $start, 'announcements');
- }
-
- $template->assign_block_vars('announcements_center_row', array(
- 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
- 'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
- 'TITLE' => $fetch_news[$i]['topic_title'],
- 'POSTER' => $fetch_news[$i]['username'],
- 'POSTER_FULL' => $fetch_news[$i]['username_full'],
- 'TIME' => $fetch_news[$i]['topic_time'],
- 'TEXT' => $fetch_news[$i]['post_text'],
- 'REPLIES' => $fetch_news[$i]['topic_replies'],
- 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
- 'A_ID' => $i,
- 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
- 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
- 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
- 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
- 'S_POLL' => $fetch_news[$i]['poll'],
- 'S_UNREAD_INFO' => $unread_topic,
- 'U_READ_FULL' => $read_full_url,
- 'L_READ_FULL' => $read_full,
- 'OPEN' => $open_bracket,
- 'CLOSE' => $close_bracket,
- 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
- 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
- ));
-
- if(!empty($fetch_news[$i]['attachments']))
- {
- foreach ($fetch_news[$i]['attachments'] as $attachment)
- {
- $template->assign_block_vars('announcements_center_row.attachment', array(
- 'DISPLAY_ATTACHMENT' => $attachment)
- );
- }
- }
-
- if ($config['board3_number_of_announcements_' . $module_id] <> 0 && $config['board3_announcements_archive_' . $module_id])
- {
- $template->assign_vars(array(
- 'AP_PAGINATION' => $pagination,
- 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements),
- 'AP_PAGE_NUMBER' => on_page($total_announcements, $config['board3_number_of_announcements_' . $module_id], $start))
- );
- }
- }
- }
-
- $topic_icons = false;
- if(!empty($fetch_news['topic_icons']))
- {
- $topic_icons = true;
- }
-
- $template->assign_vars(array(
- 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
- 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
- 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
- 'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($config['board3_show_announcements_replies_views_' . $module_id]) ? true : false,
- 'S_TOPIC_ICONS' => $topic_icons,
- ));
-
- if ($config['board3_announcements_style_' . $module_id])
- {
- return 'announcements_center_compact.html';
- }
- else
- {
- return 'announcements_center.html';
- }
- }
-
- public function get_template_acp($module_id)
- {
- return array(
- 'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
- 'vars' => array(
- 'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
- 'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
- 'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
- 'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
- 'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'),
- 'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true),
- 'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- ),
- );
- }
-
- /**
- * API functions
- */
- public function install($module_id)
- {
- set_config('board3_announcements_style_' . $module_id, 0);
- set_config('board3_number_of_announcements_' . $module_id, 1);
- set_config('board3_announcements_day_' . $module_id, 0);
- set_config('board3_announcements_length_' . $module_id, 200);
- set_config('board3_global_announcements_forum_' . $module_id, '');
- set_config('board3_announcements_forum_exclude_' . $module_id, 0);
- set_config('board3_announcements_archive_' . $module_id, 1);
- set_config('board3_announcements_permissions_' . $module_id, 1);
- set_config('board3_show_announcements_replies_views_' . $module_id, 1);
-
- return true;
- }
-
- public function uninstall($module_id, $db)
- {
- $del_config = array(
- 'board3_announcements_style_' . $module_id,
- 'board3_number_of_announcements_' . $module_id,
- 'board3_announcements_day_' . $module_id,
- 'board3_announcements_length_' . $module_id,
- 'board3_global_announcements_forum_' . $module_id,
- 'board3_announcements_forum_exclude_' . $module_id,
- 'board3_announcements_archive_' . $module_id,
- 'board3_announcements_permissions_' . $module_id,
- 'board3_show_announcements_replies_views_' . $module_id,
- );
- $sql = 'DELETE FROM ' . CONFIG_TABLE . '
- WHERE ' . $db->sql_in_set('config_name', $del_config);
- return $db->sql_query($sql);
- }
-
- // Create forum select box
- public function select_forums($value, $key, $module_id)
- {
- global $user, $config;
-
- $forum_list = make_forum_select(false, false, true, true, true, false, true);
-
- $selected = array();
- if(isset($config[$key]) && strlen($config[$key]) > 0)
- {
- $selected = explode(',', $config[$key]);
- }
- // Build forum options
- $s_forum_options = '';
-
- return $s_forum_options;
-
- }
-
- // Store selected forums
- public function store_selected_forums($key, $module_id)
- {
- global $db, $cache;
-
- // Get selected forums
- $values = request_var($key, array(0 => ''));
- $news = implode(',', $values);
- set_config($key, $news);
- }
-}