add context sensitive link to ACL/grant access to top-menu, same is to be happen for cats and preferences itself and preferences in sidebox will be removed

This commit is contained in:
Ralf Becker 2013-10-02 16:29:08 +00:00
parent 3733ef6d4c
commit 6f162f144e
8 changed files with 169 additions and 7 deletions

View File

@ -444,14 +444,15 @@ class admin_acl
'get_rows' => 'admin_acl::get_rows',
'no_cat' => true,
'filter' => !empty($_GET['acl_filter']) ? $_GET['acl_filter'] :
$GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter'],
($GLOBALS['egw_info']['flags']['currentapp'] != 'admin' ? 'other' :
$GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter']),
'filter2' => !empty($_GET['acl_app']) ? $_GET['acl_app'] : '',
'lettersearch' => false,
'order' => 'acl_appname',
'sort' => 'ASC',
'row_id' => 'id',
'account_id' => isset($_GET['account_id']) && (int)$_GET['account_id'] ? (int)(int)$_GET['account_id'] :
$GLOBALS['egw_info']['user']['acount_id'],
$GLOBALS['egw_info']['user']['account_id'],
'actions' => self::get_actions(),
'acl_rights' => $GLOBALS['egw']->hooks->process(array(
'location' => 'acl_rights',

View File

@ -52,8 +52,7 @@ class uiconfig
case 'admin':
case 'addressbook':
case 'calendar':
case 'email':
case 'nntp':
case 'preferences':
/*
Other special apps can go here for now, e.g.:
case 'bogusappname':

View File

@ -1027,6 +1027,11 @@ abstract class egw_framework
));
}
if (($acl = $this->topmenu_acl()))
{
$this->_add_topmenu_item($acl);
}
if($GLOBALS['egw_info']['user']['apps']['manual'] && isset($apps['manual']))
{
$this->_add_topmenu_item(array_merge($apps['manual'],array('title' => lang('Help'))));
@ -1049,6 +1054,32 @@ abstract class egw_framework
$this->_add_topmenu_info_item($vars['quick_add']);
}
/**
* Add ACL link to topmenu using acl_rights-hook to know if an app supports acl
*/
function topmenu_acl()
{
if (!$GLOBALS['egw_info']['user']['apps']['preferences'] ||
$GLOBALS['egw_info']['server']['deny_acl'] && array_intersect(
$GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true),
(array)$GLOBALS['egw_info']['server']['deny_acl']))
{
return; // user has no access to preferences app
}
$apps = $GLOBALS['egw']->hooks->process('acl_rights');
foreach($apps as $app => $rights)
{
if (!$rights) unset($apps[$app]);
}
$apps = array_keys($apps);
return array(
'name' => 'preferences',
'title' => lang('Access'),
'url' => 'javascript:egw_preferences("acl", '.json_encode($apps).')',
);
}
/**
* Add menu items to the topmenu template class to be displayed
*

View File

@ -777,7 +777,7 @@ function dropdown_menu_hack(el)
el.contentOptions [el.contentOptions.length] =
{
"value": el.options[i].value,"text": el.options[i].innerHTML
}
};
if(!el.options[i].selected){el.options[i].removeNode(true);i--;};
}
el.onkeydown = switchMenu;
@ -786,3 +786,37 @@ function dropdown_menu_hack(el)
}
}
/**
* Dummy link handler, which can be overwritten by templates
*
* @param _link
* @param _app
*/
function egw_link_handler(_link, _app)
{
window.location.href = egw_webserverUrl+_link;
}
/**
* Call context / open app specific preferences function
*
* @param string name 'acl', 'prefs', or 'cats'
* @param array apps apps allowing to call that
*/
function egw_preferences(name, apps)
{
var current_app = egw_getAppName();
if ($j.inArray(current_app, apps) == -1)
{
egw_message(egw.lang('Not supported by current application!'), 'warning');
}
else
{
switch(name)
{
case 'acl':
egw_link_handler(egw_webserverUrl+'/index.php?menuaction=preferences.preferences_acl.index&acl_app='+current_app, current_app);
break;
}
}
}

View File

@ -674,9 +674,9 @@ egw.set_user('.$GLOBALS['egw']->accounts->json($GLOBALS['egw_info']['user']['acc
*/
function _add_topmenu_item(array $app_data,$alt_label=null)
{
$_item['url'] = $app_data['url'];
$_item['url'] = htmlspecialchars($app_data['url']);
$_item['urlextra'] = $app_data['target'];
$_item['label'] = ($alt_label?$alt_label:$app_data['title']);
$_item['label'] = $alt_label ? $alt_label : $app_data['title'];
$this->tplsav2->menuitems[] = $_item;
$this->tplsav2->icon_or_star = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images'.'/orange-ball.png';
}

View File

@ -472,4 +472,57 @@ class preferences_hooks
'extradata' => 'menuaction=preferences.preferences_settings.index'
);
}
/**
* hooks to build sidebox-menu plus the admin and preferences sections
*
* @param string|array $args hook args
*/
static function admin($args)
{
$appname = 'preferences';
$file = Array(
'Site configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname),
);
display_section($appname, $file);
}
/**
* Hook returning options for deny_acl groups
*
* @param array $config
*/
public static function deny_prefs($config)
{
$accountsel = new uiaccountsel();
return '<input type="hidden" value="" name="newsettings[deny_prefs]" />'.
$accountsel->selection('newsettings[deny_prefs]', 'deny_prefs', $config['deny_prefs'], 'groups', 4);
}
/**
* Hook returning options for deny_acl groups
*
* @param array $config
*/
public static function deny_acl($config)
{
$accountsel = new uiaccountsel();
return '<input type="hidden" value="" name="newsettings[deny_acl]" />'.
$accountsel->selection('newsettings[deny_acl]', 'deny_acl', $config['deny_acl'], 'groups', 4);
}
/**
* Hook returning options for deny_cats groups
*
* @param array $config
*/
public static function deny_cats($config)
{
$accountsel = new uiaccountsel();
return '<input type="hidden" value="" name="newsettings[deny_cats]" />'.
$accountsel->selection('newsettings[deny_cats]', 'deny_cats', $config['deny_cats'], 'groups', 4);
}
}

View File

@ -26,6 +26,10 @@ $setup_info['preferences']['hooks']['edit_user'] = 'preferences_hooks::edit_
$setup_info['preferences']['hooks']['view_user'] = 'preferences_hooks::edit_user';
$setup_info['preferences']['hooks']['edit_group'] = 'preferences_hooks::edit_user';
$setup_info['preferences']['hooks']['group_manager'] = 'preferences_hooks::edit_user';
$setup_info['preferences']['hooks']['admin'] = 'preferences_hooks::admin';
$setup_info['preferences']['hooks']['deny_prefs'] = 'preferences_hooks::deny_prefs';
$setup_info['preferences']['hooks']['deny_acl'] = 'preferences_hooks::deny_acl';
$setup_info['preferences']['hooks']['deny_cats'] = 'preferences_hooks::deny_cats';
/* Dependencies for this app to work */
$setup_info['preferences']['depends'][] = array(

View File

@ -0,0 +1,40 @@
<!-- $Id: config.tpl 43784 2013-09-11 13:08:59Z ralfbecker $ -->
<!-- BEGIN header -->
<p style="text-align: center; color: red; font-weight: bold;">{error}</p>
<form method="POST" action="{action_url}">
<table align="center" width="85%" callspacing="0" style="{ border: 1px solid #000000; }">
<tr class="th">
<td colspan="2">&nbsp;<b>{title}</b></td>
</tr>
<!-- END header -->
<!-- BEGIN body -->
<tr class="row_off">
<td>{lang_Deny_following_groups_access_to_preferences}:</td>
<td>{call_preferences_hooks::deny_prefs}</td>
</tr>
<tr class="row_on">
<td>{lang_Deny_following_groups_access_to_ACL_(grant_access)}:</td>
<td>{call_preferences_hooks::deny_acl}</td>
</tr>
<tr class="row_off">
<td>{lang_Deny_following_groups_access_to_edit_categories}:</td>
<td>{call_preferences_hooks::deny_cats}</td>
</tr>
<!-- END body -->
<!-- BEGIN footer -->
<tr class="th">
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submit" value="{lang_submit}">
<input type="submit" name="cancel" value="{lang_cancel}">
<br>
</td>
</tr>
</table>
</form>
<!-- END footer -->