Enabling/disabling permissions for news & announcements

(Required translations)
This commit is contained in:
Ice
2008-03-05 12:00:02 +00:00
parent 0a8140d449
commit 7ae7f81c86
8 changed files with 40 additions and 19 deletions

View File

@@ -71,12 +71,13 @@ class acp_portal
'title' => 'ACP_PORTAL_NEWS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_NEWS_SETTINGS',
'portal_news' => array('lang' => 'PORTAL_NEWS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_news_style' => array('lang' => 'PORTAL_NEWS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_show_all_news' => array('lang' => 'PORTAL_SHOW_ALL_NEWS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_number_of_news' => array('lang' => 'PORTAL_NUMBER_OF_NEWS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_news_length' => array('lang' => 'PORTAL_NEWS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_news_forum' => array('lang' => 'PORTAL_NEWS_FORUM' , 'validate' => 'string', 'type' => 'text:10:200', 'explain' => true),
'portal_news' => array('lang' => 'PORTAL_NEWS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_news_style' => array('lang' => 'PORTAL_NEWS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_show_all_news' => array('lang' => 'PORTAL_SHOW_ALL_NEWS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_number_of_news' => array('lang' => 'PORTAL_NUMBER_OF_NEWS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_news_length' => array('lang' => 'PORTAL_NEWS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_news_forum' => array('lang' => 'PORTAL_NEWS_FORUM' , 'validate' => 'string', 'type' => 'text:10:200', 'explain' => true),
'portal_news_permissions' => array('lang' => 'PORTAL_NEWS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
break;
@@ -85,12 +86,13 @@ class acp_portal
'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS',
'portal_announcements' => array('lang' => 'PORTAL_ANNOUNCEMENTS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_announcements_style' => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_number_of_announcements' => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_announcements_day' => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_announcements_length' => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_global_announcements_forum' => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM', 'validate' => 'string', 'type' => 'text:10:200', 'explain' => true),
'portal_announcements' => array('lang' => 'PORTAL_ANNOUNCEMENTS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_announcements_style' => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_number_of_announcements' => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_announcements_day' => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_announcements_length' => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_global_announcements_forum' => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' , 'validate' => 'string', 'type' => 'text:10:200', 'explain' => true),
'portal_announcements_permissions' => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
break;

View File

@@ -1,6 +1,6 @@
<?php
$current_version = '0.2.2';
$current_version = '0.2.3';
// If only checking version, exit.
if( defined('IN_PHPBB') )

View File

@@ -69,5 +69,9 @@ INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_birt
# Version 0.2.2 #
INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_attachments_forum_ids', '');
# Version 0.2.3 #
INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_announcements_permissions', '1');
INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_news_permissions', '1');
# POSTGRES COMMIT #

View File

@@ -10,4 +10,10 @@ $sql_update['0.2.0'] = array(
$sql_update['0.2.2'] = array(
"INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_attachments_forum_ids', '')",
);
$sql_update['0.2.3'] = array(
"INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_announcements_persmissions', '1')",
"INSERT INTO phpbb_portal_config (config_name, config_value) VALUES ('portal_news_persmissions', '1')",
);
?>

View File

@@ -96,6 +96,8 @@ $lang = array_merge($lang, array(
'PORTAL_ANNOUNCEMENTS_LENGTH_EXPLAIN' => '0 means infinite',
'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM' => 'Global global announcements forum ID',
'PORTAL_GLOBAL_ANNOUNCEMENTS_FORUM_EXPLAIN' => 'Forum we pull the articles from, leave blank to pull from all forums, separate by comma for multi-forums, eg. 1,2,5',
'PORTAL_ANNOUNCEMENTS_PERMISSIONS' => 'Enable/disable permissions',
'PORTAL_ANNOUNCEMENTS_PERMISSIONS_EXPLAIN' => 'Take forum viewing permissions into account when displaying announcements',
// news
'ACP_PORTAL_NEWS_INFO' => 'News',
@@ -115,6 +117,8 @@ $lang = array_merge($lang, array(
'PORTAL_NEWS_FORUM_EXPLAIN' => 'Forum we pull the articles from, leave blank to pull from all forums, separate by comma for multi-forums, eg. 1,2,5',
'PORTAL_EXCLUDE_FORUM' => 'Exclude Forum ID',
'PORTAL_EXCLUDE_FORUM_EXPLAIN' => 'Forum we pull the articles from, leave blank to pull from all forums, separate by comma for multi-forums, eg. 1,2,5',
'PORTAL_NEWS_PERMISSIONS' => 'Enable/disable permissions',
'PORTAL_NEWS_PERMISSIONS_EXPLAIN' => 'Take forum viewing permissions into account when displaying news',
// recent topics
'ACP_PORTAL_RECENT_INFO' => 'Recent topics',

View File

@@ -21,7 +21,7 @@ if (!defined('IN_PORTAL'))
$announcement = request_var('announcement', -1);
if($announcement < 0)
{
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements');
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements');
if (count($fetch_news) == 0)
{
@@ -85,7 +85,7 @@ if($announcement < 0)
}
else
{
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_number_of_announcements'], 0, $portal_config['portal_announcements_day'], 'announcements');
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], 0, $portal_config['portal_announcements_day'], 'announcements');
$i = $announcement;
$forum_id = $fetch_news[$i]['forum_id'];

View File

@@ -33,7 +33,7 @@ $template->assign_vars(array(
$news = request_var('news', -1);
if($news < 0)
{
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_number_of_news'], $portal_config['portal_news_length'], 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], $portal_config['portal_news_length'], 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
if (count($fetch_news) == 0)
{
@@ -91,7 +91,7 @@ if($news < 0)
}
else
{
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_number_of_news'], 0, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], 0, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
$i = $news;
$forum_id = $fetch_news[$i]['forum_id'];

View File

@@ -71,7 +71,7 @@ function set_portal_config($config_name, $config_value)
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
// fetch post for news & announce
function phpbb_fetch_posts($forum_from, $number_of_posts, $text_length, $time, $type)
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type)
{
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode;
@@ -83,7 +83,12 @@ function phpbb_fetch_posts($forum_from, $number_of_posts, $text_length, $time, $
$str_where = '';
$allow_access = array_unique(array_keys($auth->acl_getf('f_read', true)));
if( $permissions )
{
$allow_access = array_unique(array_keys($auth->acl_getf('f_read', true)));
} else {
$allow_access = array_unique(array_keys($auth->acl_getf('f_', true)));
}
if( sizeof($allow_access) ){