From 28d6ed74b90708243be58d6783a338fffc5c14db Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Nov 2010 13:39:52 +0000 Subject: [PATCH] Added permission settings for all blocks; Modified calendar, custom & links module to work with the new permission settings for all blocks; Added language variables for links block; --- .../adm/style/portal/acp_portal_calendar.html | 24 +++++++---- root/adm/style/portal/acp_portal_config.html | 12 ++++++ root/adm/style/portal/acp_portal_custom.html | 23 +++++------ root/adm/style/portal/acp_portal_links.html | 40 +++++++++++------- root/includes/acp/acp_portal.php | 41 ++++++++++++++++++- root/language/en/mods/info_acp_portal.php | 12 +++--- .../en/mods/portal/portal_calendar_module.php | 3 +- .../en/mods/portal/portal_custom_module.php | 2 +- .../en/mods/portal/portal_links_module.php | 10 ++++- .../mods/portal/portal_main_menu_module.php | 4 +- root/portal/modules/portal_calendar.php | 6 +-- root/portal/modules/portal_custom.php | 30 ++++++++------ root/portal/modules/portal_links.php | 4 +- 13 files changed, 148 insertions(+), 63 deletions(-) diff --git a/root/adm/style/portal/acp_portal_calendar.html b/root/adm/style/portal/acp_portal_calendar.html index ff9ea78c..b62eedf3 100644 --- a/root/adm/style/portal/acp_portal_calendar.html +++ b/root/adm/style/portal/acp_portal_calendar.html @@ -72,14 +72,14 @@
-
+
{L_ACP_PORTAL_CALENDAR_PERMISSION_EXP}
- + + +
@@ -107,8 +107,18 @@
{L_MODULE_IMAGE}
+
+

{L_MODULE_PERMISSIONS_EXP}
+
+ +
+
- + @@ -132,7 +142,7 @@

- +

diff --git a/root/adm/style/portal/acp_portal_config.html b/root/adm/style/portal/acp_portal_config.html index 6cab8487..0c989dbb 100644 --- a/root/adm/style/portal/acp_portal_config.html +++ b/root/adm/style/portal/acp_portal_config.html @@ -51,6 +51,18 @@
{L_MODULE_IMAGE}
+ +
+

{L_MODULE_PERMISSIONS_EXP}
+
+ +
+
+ diff --git a/root/adm/style/portal/acp_portal_custom.html b/root/adm/style/portal/acp_portal_custom.html index c164954c..8d069b8b 100644 --- a/root/adm/style/portal/acp_portal_custom.html +++ b/root/adm/style/portal/acp_portal_custom.html @@ -25,6 +25,16 @@
{L_MODULE_IMAGE}
+
+

{L_ACP_PORTAL_CUSTOM_PERMISSION_EXP}
+
+ +
+
@@ -614,19 +624,6 @@ -
-
-
- {L_ACP_PORTAL_CUSTOM_PERMISSION_EXP} -
-
- -
-
{auth_tpl.TPL} diff --git a/root/adm/style/portal/acp_portal_links.html b/root/adm/style/portal/acp_portal_links.html index c753cc9d..6bafd0f6 100644 --- a/root/adm/style/portal/acp_portal_links.html +++ b/root/adm/style/portal/acp_portal_links.html @@ -17,38 +17,38 @@
- {L_ACP_PORTAL_MENU_LINK} + {L_ACP_PORTAL_LINKS}
-
+
-
- {L_ACP_PORTAL_MENU_TYPE_EXP} +
+ {L_ACP_PORTAL_LINK_TYPE_EXP}
- - + +
-
- {L_ACP_PORTAL_MENU_URL_EXP} +
+ {L_ACP_PORTAL_LINK_URL_EXP}
-
- {L_ACP_PORTAL_MENU_PERMISSION_EXP} +
+ {L_ACP_PORTAL_LINK_PERMISSION_EXP}
- + + +
@@ -76,6 +76,18 @@
{L_MODULE_IMAGE}
+ +
+

{L_MODULE_PERMISSIONS_EXP}
+
+ +
+
+
diff --git a/root/includes/acp/acp_portal.php b/root/includes/acp/acp_portal.php index b2a235ad..066242b3 100644 --- a/root/includes/acp/acp_portal.php +++ b/root/includes/acp/acp_portal.php @@ -113,6 +113,26 @@ class acp_portal 'MODULE_IMAGE_SRC' => ($module_data['module_image_src']) ? $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $module_data['module_image_src'] : '', )); + if($module_data['module_classname'] != 'custom') + { + $groups_ary = explode(',', $module_data['module_group_ids']); + + // get group info from database and assign the block vars + $sql = 'SELECT group_id, group_name + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $template->assign_block_vars('permission_setting', array( + 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, + 'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], + 'GROUP_ID' => $row['group_id'], + )); + } + $db->sql_freeresult($result); + } + $template->assign_var('SHOW_MODULE_OPTIONS', true); } } @@ -170,9 +190,28 @@ class acp_portal if ($submit) { + $module_permission = request_var('permission-setting', array(0 => '')); + $groups_ary = array(); + + // get groups and check if the selected groups actually exist + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + ORDER BY group_id ASC'; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $groups_ary[] = $row['group_id']; + } + $db->sql_freeresult($result); + + $module_permission = array_intersect($module_permission, $groups_ary); + $module_permission = implode(',', $module_permission); + + $sql_ary = array( 'module_image_src' => request_var('module_image', ''), 'module_name' => request_var('module_name', '', true), + 'module_group_ids' => $module_permission, ); $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' @@ -182,7 +221,7 @@ class acp_portal $cache->destroy('sql', CONFIG_TABLE); add_log('admin', 'LOG_PORTAL_CONFIG', $user->lang['ACP_PORTAL_' . strtoupper($mode) . '_INFO']); - trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_root_path}/adm/index.$phpEx", 'i=portal&mode=modules') : $this->u_action)); + trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link(($module_id) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", 'i=portal&mode=modules') : $this->u_action)); } // show custom HTML files on the settings page of the modules instead of the standard board3 portal one, if chosen by module diff --git a/root/language/en/mods/info_acp_portal.php b/root/language/en/mods/info_acp_portal.php index 7738b90a..6dfa7f2a 100644 --- a/root/language/en/mods/info_acp_portal.php +++ b/root/language/en/mods/info_acp_portal.php @@ -85,11 +85,13 @@ $lang = array_merge($lang, array( 'SUCCESS_ADD' => 'The module was added successfully.', 'SUCCESS_DELETE' => 'The module was removed successfully.', - 'MODULE_OPTIONS' => 'Module options', - 'MODULE_NAME' => 'Module name', - 'MODULE_NAME_EXP' => 'Enter the name of the Module that should be displayed in the Module configuration.', - 'MODULE_IMAGE' => 'Module image', - 'MODULE_IMAGE_EXP' => 'Enter the filename of the module image. Images need to be in styles/*yourstyle*/theme/images/portal/', + 'MODULE_OPTIONS' => 'Module options', + 'MODULE_NAME' => 'Module name', + 'MODULE_NAME_EXP' => 'Enter the name of the Module that should be displayed in the Module configuration.', + 'MODULE_IMAGE' => 'Module image', + 'MODULE_IMAGE_EXP' => 'Enter the filename of the module image. Images need to be in styles/*yourstyle*/theme/images/portal/', + 'MODULE_PERMISSIONS' => 'Module permissions', + 'MODULE_PERMISSIONS_EXP' => 'Select the groups that should be authorized to view the module. If you want all users to be able to view the module, don’t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', // Manage links 'ACP_EXPRESS_LINKS_EXPLAIN' => 'Using this form you can add, edit, view and delete navigation links on the index page. You can also create special navigation links as categories which aren’t clickable links.', diff --git a/root/language/en/mods/portal/portal_calendar_module.php b/root/language/en/mods/portal/portal_calendar_module.php index 50f82fc6..1ea6a570 100644 --- a/root/language/en/mods/portal/portal_calendar_module.php +++ b/root/language/en/mods/portal/portal_calendar_module.php @@ -102,6 +102,7 @@ $lang = array_merge($lang, array( 'PORTAL_EVENTS_MANAGE' => 'Manage events', 'NO_EVENT_TITLE' => 'You haven’t specified a title for the event.', 'NO_EVENT_START' => 'You haven’t specified a start time for the event.', + 'ADD_EVENT' => 'Add new event', 'EVENT_UPDATED' => 'Event updated successfully.', 'EVENT_ADDED' => 'Event added successfully.', 'NO_EVENT' => 'No event specified.', @@ -123,7 +124,7 @@ $lang = array_merge($lang, array( 'ACP_PORTAL_EVENT_END_TIME_EXP' => 'Enter the time when the event starts. The time has to be in a 24 hour format, i.e. 23:12', 'ACP_PORTAL_CALENDAR_EVENT_START_FIRST' => 'The end of the event has to be after the start of the event.', 'ACP_PORTAL_CALENDAR_PERMISSION' => 'Event permissions', - 'ACP_PORTAL_CALENDAR_PERMISSION_EXP' => 'Select the groups that should be authorized to view the event. If you want all users to be able to view the event, don´t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', + 'ACP_PORTAL_CALENDAR_PERMISSION_EXP' => 'Select the groups that should be authorized to view the event. If you want all users to be able to view the event, don’t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', // Logs diff --git a/root/language/en/mods/portal/portal_custom_module.php b/root/language/en/mods/portal/portal_custom_module.php index 644d7c77..c320a924 100644 --- a/root/language/en/mods/portal/portal_custom_module.php +++ b/root/language/en/mods/portal/portal_custom_module.php @@ -41,7 +41,7 @@ $lang = array_merge($lang, array( 'ACP_PORTAL_CUSTOM_CODE' => 'Custom Block Code', 'ACP_PORTAL_CUSTOM_CODE_EXP' => 'Change the code for the small custom block (HTML or BBCode) here.', 'ACP_PORTAL_CUSTOM_PERMISSION' => 'Custom Block permissions', - 'ACP_PORTAL_CUSTOM_PERMISSION_EXP' => 'Select the groups that should be able to view the custom block. If you want all users to be able to view the custom block, don´t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', + 'ACP_PORTAL_CUSTOM_PERMISSION_EXP' => 'Select the groups that should be able to view the custom block. If you want all users to be able to view the custom block, don’t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', 'ACP_PORTAL_CUSTOM_BBCODE' => 'Activate BBCode for the custom block', 'ACP_PORTAL_CUSTOM_BBCODE_EXP' => 'BBCode could be used in this box. If BBCode is not activated, HTML will be parsed.', )); diff --git a/root/language/en/mods/portal/portal_links_module.php b/root/language/en/mods/portal/portal_links_module.php index 8647275e..b0b384c4 100644 --- a/root/language/en/mods/portal/portal_links_module.php +++ b/root/language/en/mods/portal/portal_links_module.php @@ -37,7 +37,15 @@ $lang = array_merge($lang, array( // ACP 'ACP_PORTAL_LINKS' => 'Link Settings', 'ACP_PORTAL_LINKS_EXP' => 'Customize the links listed in the links block', - // @todo: Add necessary language variables + 'ACP_PORTAL_LINK_TITLE' => 'Title', + 'ACP_PORTAL_LINK_TYPE' => 'Link type', + 'ACP_PORTAL_LINK_TYPE_EXP' => 'If you have a link to a page of your board, choose "Internal link" in order to prevent unwanted logouts.', + 'ACP_PORTAL_LINK_INT' => 'Internal link', + 'ACP_PORTAL_LINK_EXT' => 'External link', + 'ACP_PORTAL_LINK_URL' => 'Link URL', + 'ACP_PORTAL_LINK_URL_EXP' => 'External links:
All links should be entered with a http://

Internal links:
Only enter the php file as link url, i.e. index.php?style=4.', + 'ACP_PORTAL_LINK_PERMISSION' => 'Link permissions', + 'ACP_PORTAL_LINK_PERMISSION_EXP'=> 'Select the groups that should be authorized to view the link. If you want all users to be able to view the link, don’t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', )); ?> \ No newline at end of file diff --git a/root/language/en/mods/portal/portal_main_menu_module.php b/root/language/en/mods/portal/portal_main_menu_module.php index d4fb7bb5..3ca5d771 100644 --- a/root/language/en/mods/portal/portal_main_menu_module.php +++ b/root/language/en/mods/portal/portal_main_menu_module.php @@ -55,10 +55,8 @@ $lang = array_merge($lang, array( 'ACP_PORTAL_MENU_TYPE_EXP' => 'If you have a link to a page of your board, choose "Internal link" in order to prevent unwanted logouts.', 'ACP_PORTAL_MENU_CREATE_CAT' => 'You need to create a category first.', 'ACP_PORTAL_MENU_URL_EXP' => 'External links:
All links should be entered with a http://

Internal links:
Only enter the php file as link url, i.e. index.php?style=4.', - 'ACP_PORTAL_MENU_LINK' => 'Link settings', - 'ACP_PORTAL_MENU_INT_OPTIONS' => 'Internal links options', 'ACP_PORTAL_MENU_PERMISSION' => 'Link permissions', - 'ACP_PORTAL_MENU_PERMISSION_EXP'=> 'Select the groups that should be authorized to view the link. If you want all users to be able to view the link, don´t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', + 'ACP_PORTAL_MENU_PERMISSION_EXP'=> 'Select the groups that should be authorized to view the link. If you want all users to be able to view the link, don’t select anything.
Select/Deselect multiple groups by holding CTRL and clicking.', )); ?> \ No newline at end of file diff --git a/root/portal/modules/portal_calendar.php b/root/portal/modules/portal_calendar.php index 9fd2b2ab..fd0cd8cb 100644 --- a/root/portal/modules/portal_calendar.php +++ b/root/portal/modules/portal_calendar.php @@ -299,7 +299,7 @@ class portal_calendar_module $event_end_time = trim(request_var('event_end_time', '')); $event_all_day = request_var('event_all_day', false); // default to false $event_url = request_var('event_url', ' '); - $event_permission = request_var('permission-setting', array(0 => '')); + $event_permission = request_var('permission-setting-calendar', array(0 => '')); $groups_ary = array(); /* @@ -461,7 +461,7 @@ class portal_calendar_module 'EVENT_START_TIME' => ($action != 'add') ? $user->format_date($events[$link_id]['start_time'], 'G:i') : '', 'EVENT_END_DAY' => ($action != 'add' && ($events[$link_id]['start_time'] - $events[$link_id]['end_time']) != true) ? $user->format_date($events[$link_id]['end_time'], 'Y-m-d') : '', 'EVENT_END_TIME' => ($action != 'add' && ($events[$link_id]['start_time'] - $events[$link_id]['end_time']) != true) ? $user->format_date($events[$link_id]['end_time'], 'G:i') : '', - 'EVENT_ALL_DAY' => ($events[$link_id]['start_time'] - $events[$link_id]['end_time']) ? true : false, + 'EVENT_ALL_DAY' => (isset($events[$link_id]['start_time']) && ($events[$link_id]['start_time'] - $events[$link_id]['end_time'])) ? true : false, 'EVENT_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? $events[$link_id]['url'] : '', //'U_BACK' => $u_action, @@ -479,7 +479,7 @@ class portal_calendar_module $result = $db->sql_query($sql); while($row = $db->sql_fetchrow($result)) { - $template->assign_block_vars('permission_setting', array( + $template->assign_block_vars('permission_setting_calendar', array( 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, 'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'], diff --git a/root/portal/modules/portal_custom.php b/root/portal/modules/portal_custom.php index 5b36081b..05bdacd1 100644 --- a/root/portal/modules/portal_custom.php +++ b/root/portal/modules/portal_custom.php @@ -76,12 +76,15 @@ class portal_custom_module $title = (!empty($config['board3_custom_' . $module_id . '_title'])) ? ((isset($user->lang[$config['board3_custom_' . $module_id . '_title']])) ? $user->lang[$config['board3_custom_' . $module_id . '_title']] : $config['board3_custom_' . $module_id . '_title']) : $user->lang[$this->name]; - return array( - 'template' => 'custom_center.html', - 'title' => $title, - 'code' => $assign_code, - 'image_src' => '', // no image for center blocks - ); + if(!empty($assign_code)) + { + return array( + 'template' => 'custom_center.html', + 'title' => $title, + 'code' => $assign_code, + 'image_src' => '', // no image for center blocks + ); + } } function get_template_side($module_id) @@ -109,12 +112,15 @@ class portal_custom_module $title = (!empty($config['board3_custom_' . $module_id . '_title'])) ? ((isset($user->lang[$config['board3_custom_' . $module_id . '_title']])) ? $user->lang[$config['board3_custom_' . $module_id . '_title']] : $config['board3_custom_' . $module_id . '_title']) : $user->lang[$this->name]; - return array( - 'template' => 'custom_side.html', - 'title' => $title, - 'code' => $assign_code, - 'image_src' => (!empty($config['board3_custom_' . $module_id . '_image_src'])) ? $config['board3_custom_' . $module_id . '_image_src'] : $this->image_src, - ); + if(!empty($assign_code)) + { + return array( + 'template' => 'custom_side.html', + 'title' => $title, + 'code' => $assign_code, + 'image_src' => (!empty($config['board3_custom_' . $module_id . '_image_src'])) ? $config['board3_custom_' . $module_id . '_image_src'] : $this->image_src, + ); + } } function get_template_acp($module_id) diff --git a/root/portal/modules/portal_links.php b/root/portal/modules/portal_links.php index 735e312b..4b982366 100644 --- a/root/portal/modules/portal_links.php +++ b/root/portal/modules/portal_links.php @@ -209,7 +209,7 @@ class portal_links_module $link_type = request_var('link_type', 2); // default to B3_LINK_EXT, no categories in Links block $link_url = request_var('link_url', ' '); $link_url = str_replace('&', '&', $link_url); - $link_permission = request_var('permission-setting', array(0 => '')); + $link_permission = request_var('permission-setting-link', array(0 => '')); $groups_ary = array(); // get groups and check if the selected groups actually exist @@ -370,7 +370,7 @@ class portal_links_module $result = $db->sql_query($sql); while($row = $db->sql_fetchrow($result)) { - $template->assign_block_vars('permission_setting', array( + $template->assign_block_vars('permission_setting_link', array( 'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false, 'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id'],