From 64f4989004a1b4d9ff78eb6b5d95acd8a88b6fea Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 12 Mar 2014 12:49:28 +0000 Subject: [PATCH] fixed not working setting of ACL, if user has no access to admin app --- admin/inc/class.admin_acl.inc.php | 25 +++++++++++-------- admin/js/app.js | 10 +++++--- preferences/inc/class.preferences_acl.inc.php | 7 ++++++ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/admin/inc/class.admin_acl.inc.php b/admin/inc/class.admin_acl.inc.php index c720d0719d..be68a27ae9 100644 --- a/admin/inc/class.admin_acl.inc.php +++ b/admin/inc/class.admin_acl.inc.php @@ -10,15 +10,18 @@ * @version $Id$ */ -require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate.inc.php'; - /** - * UI for admin + * UI for admin ACL * - * @todo acl needs to use etemplate_old, as auto-repeat does not work for acl & label + * Will also be extended by preferences_acl for user ACL */ class admin_acl { + /** + * Appname we are running as + */ + const APPNAME = 'preferences'; + /** * Methods callable via menuaction * @var array @@ -148,7 +151,7 @@ class admin_acl } //error_log(__METHOD__."() _GET[id]=".array2string($_GET['id'])." --> content=".array2string($content)); - $tpl->exec('admin.admin_acl.acl', $content, $sel_options, $readonlys, $content); + $tpl->exec('admin.admin_acl.acl', $content, $sel_options, $readonlys, $content, 2); } /** @@ -181,15 +184,15 @@ class admin_acl } elseif (!$old_apps) { - egw_framework::refresh_opener(lang('ACL added.'), 'admin', null, 'add'); + egw_framework::refresh_opener(lang('ACL added.'), static::APPNAME, null, 'add'); } elseif (!$added_apps) { - egw_framework::refresh_opener(lang('ACL deleted.'), 'admin', $deleted_ids, 'delete'); + egw_framework::refresh_opener(lang('ACL deleted.'), static::APPNAME, $deleted_ids, 'delete'); } else { - egw_framework::refresh_opener(lang('ACL updated.'), 'admin', null, 'edit'); + egw_framework::refresh_opener(lang('ACL updated.'), static::APPNAME, null, 'edit'); } } @@ -217,18 +220,18 @@ class admin_acl elseif (!$rights) // all rights removed --> delete it { $this->acl->delete_repository($content['acl_appname'], $content['acl_location'], $content['acl_account']); - egw_framework::refresh_opener(lang('ACL deleted.'), 'admin', $id, 'delete'); + egw_framework::refresh_opener(lang('ACL deleted.'), static::APPNAME, $id, 'delete'); } else { $this->acl->add_repository($content['acl_appname'], $content['acl_location'], $content['acl_account'], $rights); if ($content['id']) { - egw_framework::refresh_opener(lang('ACL updated.'), 'admin', $id, 'edit'); + egw_framework::refresh_opener(lang('ACL updated.'), static::APPNAME, $id, 'edit'); } else { - egw_framework::refresh_opener(lang('ACL added.'), 'admin', $id, 'add'); + egw_framework::refresh_opener(lang('ACL added.'), static::APPNAME, $id, 'add'); } } } diff --git a/admin/js/app.js b/admin/js/app.js index c3134566ef..64f1bc05bc 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -255,20 +255,22 @@ app.classes.admin = AppJS.extend( var ids = []; for(var i=0; i < _senders.length; ++i) { - ids.push(_senders[i].id.substr(7)); // remove "admin::" prefix + ids.push(_senders[i].id.split('::').pop()); // remove "admin::" prefix } + var app = egw.app_name(); // can be either admin or preferences! + var className = app+'_acl'; switch(_action.id) { case 'delete': - var request = egw.json('admin_acl::ajax_change_acl', [ids], this._acl_callback,this,false,this) + var request = egw.json(className+'::ajax_change_acl', [ids], this._acl_callback,this,false,this) .sendRequest(); break; case 'edit': // need to specify window to get correct opener, as admin has multiple windows open! egw('admin', window).open_link(egw.link('/index.php', { - menuaction: 'admin.admin_acl.acl', + menuaction: app+'.'+className+'.acl', id: ids[0] }), 'acl', '300x300'); break; @@ -276,7 +278,7 @@ app.classes.admin = AppJS.extend( case 'add': var current = ids[0].split(':'); egw('admin', window).open_link(egw.link('/index.php', { - menuaction: 'admin.admin_acl.acl', + menuaction: app+'.'+className+'.acl', app: current[0], account: current[1] }), 'acl', '250x250'); diff --git a/preferences/inc/class.preferences_acl.inc.php b/preferences/inc/class.preferences_acl.inc.php index 831d21672f..6fd6693795 100644 --- a/preferences/inc/class.preferences_acl.inc.php +++ b/preferences/inc/class.preferences_acl.inc.php @@ -17,9 +17,16 @@ */ class preferences_acl extends admin_acl { + /** + * Appname we are running as + */ + const APPNAME = 'preferences'; + function __construct() { translation::add_app('admin'); egw_framework::includeCSS('admin', 'app'); + + parent::__construct(); } } \ No newline at end of file