From b60422cb2ef431e6917e5c94193e687222842e83 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 5 Sep 2010 08:39:44 +0000 Subject: [PATCH] Reverted acp_portal.php back; Added news block; Added function get_portal_tracking_info in order to reduce queries when fetching news and announcements; --- root/includes/acp/acp_portal.php | 3 +- .../en/mods/portal/portal_news_module.php | 70 +++ root/portal/includes/functions.php | 133 +++++ root/portal/modules/portal_announcements.php | 4 +- root/portal/modules/portal_news.php | 455 ++++++++++++++++++ root/portal/modules/portal_user_menu.php | 2 +- .../template/portal/modules/news_center.html | 54 +++ .../portal/modules/news_compact_center.html | 59 +++ 8 files changed, 776 insertions(+), 4 deletions(-) create mode 100644 root/language/en/mods/portal/portal_news_module.php create mode 100644 root/portal/modules/portal_news.php create mode 100644 root/styles/prosilver/template/portal/modules/news_center.html create mode 100644 root/styles/prosilver/template/portal/modules/news_compact_center.html diff --git a/root/includes/acp/acp_portal.php b/root/includes/acp/acp_portal.php index 644a738c..73979106 100644 --- a/root/includes/acp/acp_portal.php +++ b/root/includes/acp/acp_portal.php @@ -404,8 +404,7 @@ class acp_portal $c_class = new $class(); if ($c_class->columns & column_string_const($add_module)) { - $user->add_lang('mods/portal/' . $c_class->language); - $fileinfo[] = $user->lang[$c_class->name]; + $fileinfo[] = substr($class, 7, -7); } } } diff --git a/root/language/en/mods/portal/portal_news_module.php b/root/language/en/mods/portal/portal_news_module.php new file mode 100644 index 00000000..17cbdf4e --- /dev/null +++ b/root/language/en/mods/portal/portal_news_module.php @@ -0,0 +1,70 @@ + 'Latest news', + 'READ_FULL' => 'Read all', + 'NO_NEWS' => 'No news', + 'POSTED_BY' => 'Poster', + 'COMMENTS' => 'Comments', + 'VIEW_COMMENTS' => 'View comments', + 'POST_REPLY' => 'Write comments', + 'TOPIC_VIEWS' => 'Views', + 'JUMP_NEWEST' => 'Jump to newest post', + 'JUMP_FIRST' => 'Jump to first post', + 'JUMP_TO_POST' => 'Jump to post', + 'BACK' => 'Back', + + // ACP + 'ACP_PORTAL_NEWS_SETTINGS' => 'News settings', + 'ACP_PORTAL_NEWS_SETTINGS_EXPLAIN' => 'This is where you customize the news block.', + 'PORTAL_NEWS_STYLE' => 'Compact news block style', + 'PORTAL_NEWS_STYLE_EXPLAIN' => '"Yes" means use the compact style for news. "No" means use the large style (text view).', + 'PORTAL_SHOW_ALL_NEWS' => 'Show all of the articles in this forum', + 'PORTAL_SHOW_ALL_NEWS_EXPLAIN' => 'Includes stickies.', + 'PORTAL_NUMBER_OF_NEWS' => 'Number of news articles on the portal', + 'PORTAL_NUMBER_OF_NEWS_EXPLAIN' => '0 means infinite', + 'PORTAL_NEWS_LENGTH' => 'Max length of news article', + 'PORTAL_NEWS_LENGTH_EXPLAIN' => '0 means infinite', + 'PORTAL_NEWS_FORUM' => 'News Forums', + 'PORTAL_NEWS_FORUM_EXPLAIN' => 'Forum(s) we pull the articles from, leave blank to pull from all forums. If "Exclude forums" is set to "Yes", select the forums you want to exclude.
If "Exclude forums" is set to "No" select the forums you want to see.
Select/Deselect multiple forums by holding CTRL and clicking.', + 'PORTAL_NEWS_EXCLUDE' => 'Exclude forums', + 'PORTAL_NEWS_EXCLUDE_EXPLAIN' => 'Select "Yes" if you want to exlude the selected forums from the news block, and "No" if you want to see only the selected forums in the news block.', + 'PORTAL_NEWS_PERMISSIONS' => 'Enable/disable permissions', + 'PORTAL_NEWS_PERMISSIONS_EXPLAIN' => 'Take forum viewing permissions into account when displaying news', + 'PORTAL_NEWS_SHOW_LAST' => 'Sort in order to the newest posts', + 'PORTAL_NEWS_SHOW_LAST_EXPLAIN' => 'When activated, the newest will be sorted in order to the newest posts. When deactivated, the news will be sorted in order to the newest topic.', + 'PORTAL_NEWS_ARCHIVE' => 'Enable the news archive system', + 'PORTAL_NEWS_ARCHIVE_EXPLAIN' => 'If enabled the news archive system / page numbers will be displayed.', +)); + +?> \ No newline at end of file diff --git a/root/portal/includes/functions.php b/root/portal/includes/functions.php index 1b38e2fd..0c6c60d0 100644 --- a/root/portal/includes/functions.php +++ b/root/portal/includes/functions.php @@ -670,6 +670,139 @@ function add_endtag ($message = '') return $message; } +/** +* get topic tracking info for news +* based on get_complete_tracking_info of phpBB3 +* this should reduce the queries for the news and announcements block +*/ +function get_portal_tracking_info($fetch_news) +{ + global $config, $user; + + $time1 = microtime(); + + $last_read = $topic_ids = $forum_ids = $tracking_info = array(); + + /** + * group everything by the forum IDs + */ + $count = $fetch_news['topic_count']; + for ($i = 0; $i < $count; $i++) + { + $tracking_info[$fetch_news[$i]['forum_id']][] = $fetch_news[$i]['topic_id']; + } + + foreach ($tracking_info as $forum_id => $current_forum) + { + if ($config['load_db_lastread'] && $user->data['is_registered']) + { + global $db; + + $mark_time = array(); + + $sql = 'SELECT topic_id, mark_time + FROM ' . TOPICS_TRACK_TABLE . " + WHERE user_id = {$user->data['user_id']} + AND " . $db->sql_in_set('topic_id', $current_forum); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $last_read[$row['topic_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + + $current_forum = array_diff($current_forum, array_keys($last_read)); + + if (sizeof($topic_ids)) + { + $sql = 'SELECT forum_id, mark_time + FROM ' . FORUMS_TRACK_TABLE . " + WHERE user_id = {$user->data['user_id']} + AND " . $db->sql_in_set('forum_id', $forum_ids); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $mark_time[$row['forum_id']] = $row['mark_time']; + } + $db->sql_freeresult($result); + + $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user->data['user_lastmark']; + + foreach ($topic_ids as $topic_id) + { + $last_read[$topic_id] = $user_lastmark; + } + } + } + else if ($config['load_anon_lastread'] || $user->data['is_registered']) + { + global $tracking_topics; + + if (!isset($tracking_topics) || !sizeof($tracking_topics)) + { + $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); + } + + if (!$user->data['is_registered']) + { + $user_lastmark = (isset($tracking_topics['l'])) ? base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate'] : 0; + } + else + { + $user_lastmark = $user->data['user_lastmark']; + } + + foreach ($topic_ids as $topic_id) + { + $topic_id36 = base_convert($topic_id, 10, 36); + + if (isset($tracking_topics['t'][$topic_id36])) + { + $last_read[$topic_id] = base_convert($tracking_topics['t'][$topic_id36], 36, 10) + $config['board_startdate']; + } + } + + $topic_ids = array_diff($topic_ids, array_keys($last_read)); + + if (sizeof($topic_ids)) + { + $mark_time = array(); + if ($global_announce_list && sizeof($global_announce_list)) + { + if (isset($tracking_topics['f'][0])) + { + $mark_time[0] = base_convert($tracking_topics['f'][0], 36, 10) + $config['board_startdate']; + } + } + + if (isset($tracking_topics['f'][$forum_id])) + { + $mark_time[$forum_id] = base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']; + } + + $user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $user_lastmark; + + foreach ($topic_ids as $topic_id) + { + if ($global_announce_list && isset($global_announce_list[$topic_id])) + { + $last_read[$topic_id] = (isset($mark_time[0])) ? $mark_time[0] : $user_lastmark; + } + else + { + $last_read[$topic_id] = $user_lastmark; + } + } + } + } + } + + return $last_read; +} + // Mini Cal. class calendar { diff --git a/root/portal/modules/portal_announcements.php b/root/portal/modules/portal_announcements.php index ed026f48..3d37505b 100644 --- a/root/portal/modules/portal_announcements.php +++ b/root/portal/modules/portal_announcements.php @@ -141,6 +141,8 @@ class portal_announcements_module $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 @@ -163,7 +165,7 @@ class portal_announcements_module // 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); + //$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; diff --git a/root/portal/modules/portal_news.php b/root/portal/modules/portal_news.php new file mode 100644 index 00000000..001a1c81 --- /dev/null +++ b/root/portal/modules/portal_news.php @@ -0,0 +1,455 @@ +lang}/mods/portal/" + */ + var $language = 'portal_news_module'; + + function get_template_center($module_id) + { + global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path; + + $news = request_var('news', -1); + $news = ($news > $config['board3_news_length'] -1) ? -1 : $news; + $user->add_lang('viewforum'); + $start = request_var('np', 0); + $start = ($start < 0) ? 0 : $start; + + // Fetch news from portal/includes/functions.php with check if "read full" is requested. + $portal_news_length = ($news < 0) ? $config['board3_news_length'] : 0; + $fetch_news = phpbb_fetch_posts($config['board3_news_forum'], $config['board3_news_permissions'], $config['board3_number_of_news'], $portal_news_length, 0, ($config['board3_show_all_news']) ? 'news_all' : 'news', $start, $config['board3_news_exclude']); + + + // Any news present? If not terminate it here. + if (sizeof($fetch_news) == 0) + { + $template->assign_block_vars('news_row', array( + 'S_NO_TOPICS' => true, + 'S_NOT_LAST' => false, + )); + } + else + { + // Count number of posts for news archive, considering if permission check is dis- or enabled. + if ($config['board3_news_archive']) + { + $permissions = $config['board3_news_permissions']; + $forum_from = $config['board3_news_forum']; + + $forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); + + $str_where = ''; + + if($permissions == true) + { + $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); + } + else + { + $disallow_access = array(); + } + + if($config['board3_news_exclude'] == true) + { + $disallow_access = array_merge($disallow_access, $forum_from); + $forum_from = array(); + } + + 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 "; + } + } + 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 (' . trim(substr($str_where, 0, -4)) . ')' : ''; + + $topic_type = ($config['board3_show_all_news']) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; + + $sql = 'SELECT COUNT(topic_id) AS num_topics + FROM ' . TOPICS_TABLE . ' + WHERE ' . $topic_type . ' + AND topic_approved = 1 + AND topic_moved_id = 0 + ' . $str_where; + $result = $db->sql_query($sql); + $total_news = (int) $db->sql_fetchfield('num_topics'); + $db->sql_freeresult($result); + } + + $topic_tracking_info = get_portal_tracking_info($fetch_news); + + if($news < 0) + // Show the news 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']; + $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + + $read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $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_news_archive']) + { + $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news'], $start, ($config['board3_show_all_news']) ? 'news_all' : 'news'); + } + + $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_STICKY: + $folder = 'sticky_read'; + $folder_new = 'sticky_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_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('news_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'], + 'N_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], + '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'] : '', + 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), + '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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), + 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['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('news_row.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + + if ($config['board3_number_of_news'] <> 0 && $config['board3_news_archive']) + { + $template->assign_vars(array( + 'NP_PAGINATION' => $pagination, + 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news), + 'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news'], $start)) + ); + } + } + } + else + // Show "read full" page + { + $i = $news; + $forum_id = $fetch_news[$i]['forum_id']; + $topic_id = $fetch_news[$i]['topic_id']; + $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']; + + $read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$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_news_archive']) + { + $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news'], $start, ($config['board3_show_all_news']) ? 'news_all' : 'news'); + } + + $template->assign_block_vars('news_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'], + 'N_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", '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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['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('news_row.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + + if ($config['board3_number_of_news'] <> 0 && $config['board3_news_archive']) + { + $template->assign_vars(array( + 'NP_PAGINATION' => $pagination, + 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news), + 'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news'], $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_NEWEST_OR_FIRST' => ($config['board3_news_show_last']) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'], + 'POSTED_BY_TEXT' => ($config['board3_news_show_last']) ? $user->lang['LAST_POST'] : $user->lang['POSTED'], + 'S_DISPLAY_NEWS' => true, + 'S_DISPLAY_NEWS_RVS' => ($config['board3_show_news_replies_views']) ? true : false, + 'S_TOPIC_ICONS' => $topic_icons, + )); + + if($config['board3_news_style']) + { + return 'news_compact_center.html'; + } + else + { + return 'news_center.html'; + } + } + + function get_template_acp($module_id) + { + return array( + 'title' => 'ACP_PORTAL_NEWS_SETTINGS', + 'vars' => array( + 'legend1' => 'ACP_PORTAL_NEWS_SETTINGS', + 'board3_news_style' => array('lang' => 'PORTAL_NEWS_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_show_all_news' => array('lang' => 'PORTAL_SHOW_ALL_NEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_number_of_news' => array('lang' => 'PORTAL_NUMBER_OF_NEWS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + 'board3_news_length' => array('lang' => 'PORTAL_NEWS_LENGTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), + 'board3_news_forum' => array('lang' => 'PORTAL_NEWS_FORUM', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_forums', 'submit' => 'store_selected_forums'), + 'board3_news_exclude' => array('lang' => 'PORTAL_NEWS_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_news_show_last' => array('lang' => 'PORTAL_NEWS_SHOW_LAST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_news_archive' => array('lang' => 'PORTAL_NEWS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_news_permissions' => array('lang' => 'PORTAL_NEWS_PERMISSIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'board3_show_news_replies_views' => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + ) + ); + } + + /** + * API functions + */ + function install($module_id) + { + set_config('board3_news_length', 250); + set_config('board3_news_forum', ''); + set_config('board3_news_permissions', 1); + set_config('board3_number_of_news', 5); + set_config('board3_show_all_news', 1); + set_config('board3_news_exclude', 0); + set_config('board3_news_archive', 1); + set_config('board3_news_show_last', 0); + set_config('board3_show_news_replies_views', 1); + set_config('board3_news_style', 1); + return true; + } + + function uninstall($module_id) + { + global $db; + + $del_config = array( + 'board3_news_length', + 'board3_news_forum', + 'board3_news_permissions', + 'board3_number_of_news', + 'board3_show_all_news', + 'board3_news_exclude', + 'board3_news_archive', + 'board3_news_show_last', + 'board3_show_news_replies_views', + 'board3_news_style', + ); + $sql = 'DELETE FROM ' . CONFIG_TABLE . ' + WHERE ' . $db->sql_in_set('config_name', $del_config); + return $db->sql_query($sql); + } + + // Create forum select box + function select_forums($value, $key) + { + 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 + function store_selected_forums($key) + { + global $db, $cache; + + // Get selected extensions + $values = request_var($key, array(0 => '')); + + $news = implode(',', $values); + + set_config($key, $news); + + } +} + +?> \ No newline at end of file diff --git a/root/portal/modules/portal_user_menu.php b/root/portal/modules/portal_user_menu.php index 0db7c775..9b47807b 100644 --- a/root/portal/modules/portal_user_menu.php +++ b/root/portal/modules/portal_user_menu.php @@ -190,7 +190,7 @@ class portal_user_menu_module // nothing - return $db->sql_query($sql); + return true; } } diff --git a/root/styles/prosilver/template/portal/modules/news_center.html b/root/styles/prosilver/template/portal/modules/news_center.html new file mode 100644 index 00000000..b3d6e20e --- /dev/null +++ b/root/styles/prosilver/template/portal/modules/news_center.html @@ -0,0 +1,54 @@ + +{$C_BLOCK_H_L}
{L_LATEST_NEWS}
{$C_BLOCK_H_R} +
+ + +
+
+ {L_NO_NEWS} +
+
+ +
+
+

{NEWEST_POST_IMG}{READ_POST_IMG} {news_row.ATTACH_ICON_IMG} {L_POLL}: {news_row.TITLE}

+ {news_row.PAGINATION} + +
+
+
{news_row.TEXT} +
+ +
+
{L_ATTACHMENTS}
+ +
{news_row.attachment.DISPLAY_ATTACHMENT}
+ +
+ +
+ {L_TOPIC_VIEWS}: {news_row.TOPIC_VIEWS}  •  {L_COMMENTS}: {news_row.REPLIES}  •  {L_POST_REPLY} + {news_row.OPEN}{news_row.L_READ_FULL}{news_row.CLOSE} + +
+ + + +
+ + + + +
+
+
+ + +
+{$C_BLOCK_F_L}{$C_BLOCK_F_R} \ No newline at end of file diff --git a/root/styles/prosilver/template/portal/modules/news_compact_center.html b/root/styles/prosilver/template/portal/modules/news_compact_center.html new file mode 100644 index 00000000..b7c7ad84 --- /dev/null +++ b/root/styles/prosilver/template/portal/modules/news_compact_center.html @@ -0,0 +1,59 @@ + + + +{$C_BLOCK_H_L}
{L_LATEST_NEWS}
{$C_BLOCK_H_R} +
+
+ {L_NO_NEWS} +
+
+{$C_BLOCK_F_L}{$C_BLOCK_F_R} + + + +{$C_BLOCK_H_L} +
style="width: 44%"style="width: 60%">{L_LATEST_NEWS}
+ +
{L_REPLIES}
+
{L_VIEWS}
+ +
{L_LAST_POST}
+ +{$C_BLOCK_H_R} + +{$C_BLOCK_F_L}{$C_BLOCK_F_R} + + + \ No newline at end of file