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;
This commit is contained in:
Marc Alexander
2010-11-20 13:39:52 +00:00
parent 7be12e0f43
commit 28d6ed74b9
13 changed files with 148 additions and 63 deletions

View File

@@ -72,14 +72,14 @@
</dl>
<dl>
<dt>
<label for="permission-setting">{L_ACP_PORTAL_CALENDAR_PERMISSION}:</label><br />
<label for="permission-setting-calendar">{L_ACP_PORTAL_CALENDAR_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_CALENDAR_PERMISSION_EXP}</span>
</dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
<select id="permission-setting-calendar" size="10" multiple="multiple" name="permission-setting-calendar[]">
<!-- BEGIN permission_setting_calendar -->
<option value="{permission_setting_calendar.GROUP_ID}"<!-- IF permission_setting_calendar.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting_calendar.GROUP_NAME}</option>
<!-- END permission_setting_calendar -->
</select>
</dd>
</dl>
@@ -107,6 +107,16 @@
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
</fieldset>
<!-- ENDIF -->
<!-- BEGIN options -->
@@ -132,7 +142,7 @@
<fieldset class="tabulated">
<p class="quick">
<input class="button2" name="add" type="submit" value="{L_ADD_LINK}" />
<input class="button2" name="add" type="submit" value="{L_ADD_EVENT}" />
</p>
<table cellspacing="1">

View File

@@ -51,6 +51,18 @@
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
<!-- ENDIF -->
</fieldset>
<!-- ENDIF -->
<!-- BEGIN options -->

View File

@@ -25,6 +25,16 @@
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
<dl>
<dt><label for="permission-setting">{L_ACP_PORTAL_CUSTOM_PERMISSION}:</label><br /><span>{L_ACP_PORTAL_CUSTOM_PERMISSION_EXP}</span></dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
</fieldset>
<!-- ENDIF -->
<!-- IF S_PREVIEW -->
@@ -614,19 +624,6 @@
<label><input onchange="dE('bbcode-buttons', -1)" class="radio" type="radio" value="0" name="custom_use_bbcode"<!-- IF not CUSTOM_USE_BBCODE --> checked="checked"<!-- ENDIF --> />{L_NO}</label>
</dd>
</dl>
<dl>
<dt>
<label for="permission-setting">{L_ACP_PORTAL_CUSTOM_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_CUSTOM_PERMISSION_EXP}</span>
</dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
<!-- IF S_AUTH -->
<!-- BEGIN auth_tpl -->
{auth_tpl.TPL}

View File

@@ -17,38 +17,38 @@
<form id="acp_portal_links" method="post" action="{U_ACTION}">
<fieldset>
<legend>{L_ACP_PORTAL_MENU_LINK}</legend>
<legend>{L_ACP_PORTAL_LINKS}</legend>
<dl>
<dt><label for="link_title">{L_LINK_TITLE}:</label></dt>
<dt><label for="link_title">{L_ACP_PORTAL_LINK_TITLE}:</label></dt>
<dd><input name="link_title" type="text" id="link_title" value="{LINK_TITLE}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="link_type">{L_ACP_PORTAL_MENU_TYPE}:</label><br />
<span>{L_ACP_PORTAL_MENU_TYPE_EXP}</span>
<label for="link_type">{L_ACP_PORTAL_LINK_TYPE}:</label><br />
<span>{L_ACP_PORTAL_LINK_TYPE_EXP}</span>
</dt>
<dd>
<label><input type="radio" class="radio" name="link_type" value="1" id="link_type"<!-- IF S_LINK_IS_INT --> checked="checked"<!-- ENDIF --> />{L_ACP_PORTAL_MENU_INT}</label>
<label><input type="radio" class="radio" name="link_type" value="2"<!-- IF not S_LINK_IS_INT --> checked="checked"<!-- ENDIF --> /> {L_ACP_PORTAL_MENU_EXT}</label>
<label><input type="radio" class="radio" name="link_type" value="1" id="link_type"<!-- IF S_LINK_IS_INT --> checked="checked"<!-- ENDIF --> />{L_ACP_PORTAL_LINK_INT}</label>
<label><input type="radio" class="radio" name="link_type" value="2"<!-- IF not S_LINK_IS_INT --> checked="checked"<!-- ENDIF --> /> {L_ACP_PORTAL_LINK_EXT}</label>
</dd>
</dl>
<dl>
<dt>
<label for="link_url">{L_ACP_PORTAL_MENU_URL}:</label><br />
<span>{L_ACP_PORTAL_MENU_URL_EXP}</span>
<label for="link_url">{L_ACP_PORTAL_LINK_URL}:</label><br />
<span>{L_ACP_PORTAL_LINK_URL_EXP}</span>
</dt>
<dd><input name="link_url" type="text" id="link_url" value="{LINK_URL}" maxlength="255" /></dd>
</dl>
<dl>
<dt>
<label for="permission-setting">{L_ACP_PORTAL_MENU_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_MENU_PERMISSION_EXP}</span>
<label for="permission-setting-link">{L_ACP_PORTAL_LINK_PERMISSION}:</label><br />
<span>{L_ACP_PORTAL_LINK_PERMISSION_EXP}</span>
</dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
<select id="permission-setting-link" size="10" multiple="multiple" name="permission-setting-link[]">
<!-- BEGIN permission_setting_link -->
<option value="{permission_setting_link.GROUP_ID}"<!-- IF permission_setting_link.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting_link.GROUP_NAME}</option>
<!-- END permission_setting_link -->
</select>
</dd>
</dl>
@@ -76,6 +76,18 @@
<dd><input id="module_image" type="text" value="{MODULE_IMAGE}" name="module_image" maxlength="255" size="64" /></dd>
<!-- IF MODULE_IMAGE_SRC --><dd><img src="{MODULE_IMAGE_SRC}" alt="{L_MODULE_IMAGE}" /></dd><!-- ENDIF -->
</dl>
<!-- IF permission_setting -->
<dl>
<dt><label for="permission-setting">{L_MODULE_PERMISSIONS}:</label><br /><span>{L_MODULE_PERMISSIONS_EXP}</span></dt>
<dd>
<select id="permission-setting" size="10" multiple="multiple" name="permission-setting[]">
<!-- BEGIN permission_setting -->
<option value="{permission_setting.GROUP_ID}"<!-- IF permission_setting.SELECTED -->selected="selected"<!-- ENDIF -->>{permission_setting.GROUP_NAME}</option>
<!-- END permission_setting -->
</select>
</dd>
</dl>
<!-- ENDIF -->
</fieldset>
<!-- ENDIF -->

View File

@@ -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

View File

@@ -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, dont select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> 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 arent clickable links.',

View File

@@ -102,6 +102,7 @@ $lang = array_merge($lang, array(
'PORTAL_EVENTS_MANAGE' => 'Manage events',
'NO_EVENT_TITLE' => 'You havent specified a title for the event.',
'NO_EVENT_START' => 'You havent 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.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> 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, dont select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> and clicking.',
// Logs

View File

@@ -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.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> 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, dont select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> 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.',
));

View File

@@ -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:<br />All links should be entered with a http://<br /><br />Internal links:<br />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, dont select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> and clicking.',
));
?>

View File

@@ -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:<br />All links should be entered with a http://<br /><br />Internal links:<br />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.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> 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, dont select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> and clicking.',
));
?>

View File

@@ -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'],

View File

@@ -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)

View File

@@ -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('&amp;', '&', $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'],