From d9117ecff0ae4d08bdcd75f0e61cebf88ec4c944 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 20 Apr 2010 06:57:57 +0000 Subject: [PATCH] fixed handling of group acl: addressbook eg. is NOT using it at all --- infolog/inc/class.infolog_hooks.inc.php | 24 +++++++++++++++++++++++- infolog/setup/setup.inc.php | 3 ++- phpgwapi/inc/class.acl.inc.php | 17 ++++++++++++----- preferences/inc/class.uiaclprefs.inc.php | 14 ++++++++++++-- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/infolog/inc/class.infolog_hooks.inc.php b/infolog/inc/class.infolog_hooks.inc.php index ca1f4defb8..f0ea77b8a7 100644 --- a/infolog/inc/class.infolog_hooks.inc.php +++ b/infolog/inc/class.infolog_hooks.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker * @package infolog - * @copyright (c) 2003-9 by Ralf Becker + * @copyright (c) 2003-10 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -15,6 +15,19 @@ */ class infolog_hooks { + /** + * For which groups should no group acl be used: infolog group owners + * + * @param string|array $data + * @return boolean|array true, false or array with group-account_id's + */ + static function not_enum_group_acls($data) + { + $config = config::read('infolog'); + + return $config['group_owners']; + } + /** * Hook called by link-class to include infolog in the appregistry of the linkage * @@ -23,6 +36,15 @@ class infolog_hooks */ static function search_link($location) { + // register our not_enum_group_acls hook, if not already registered + // can be removed after next infolog version update after 1.6 + if ($GLOBALS['egw']->hooks->single('not_enum_group_acls',$acl_app) === false) + { + include(EGW_INCLUDE_ROOT.'/infolog/setup/setup.inc.php'); + $GLOBALS['egw']->hooks->register_hooks('infolog',$setup_info['infolog']['hooks']); + unset($setup_info); + } + return array( 'query' => 'infolog.infolog_bo.link_query', 'title' => 'infolog.infolog_bo.link_title', diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index 4976b97de7..7fdfb97684 100755 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -6,7 +6,7 @@ * @author Ralf Becker * @package infolog * @subpackage setup - * @copyright (c) 2003-8 by Ralf Becker + * @copyright (c) 2003-10 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -48,6 +48,7 @@ $setup_info['infolog']['hooks']['preferences'] = 'infolog_hooks::all_hooks'; $setup_info['infolog']['hooks']['settings'] = 'infolog_hooks::settings'; $setup_info['infolog']['hooks']['verify_settings'] = 'infolog_hooks::verify_settings'; $setup_info['infolog']['hooks']['admin'] = 'infolog_hooks::all_hooks'; +$setup_info['infolog']['hooks']['not_enum_group_acls'] = 'infolog_hooks::not_enum_group_acls'; $setup_info['infolog']['hooks']['deleteaccount'] = 'infolog.infolog_so.change_delete_owner'; $setup_info['infolog']['hooks'][] = 'home'; $setup_info['infolog']['hooks']['addressbook_view'] = 'infolog.infolog_ui.hook_view'; diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index d34f2531b6..477825e33a 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -122,10 +122,10 @@ class acl /** * Read acl records for $acl->account_id from reposity * - * @internal + * @param boolean|array $no_groups=false if true, do not use memberships, if array do not use given groups * @return array along with storing it in $acl->data.
*/ - function read_repository() + function read_repository($no_groups=false) { // For some reason, calling this via XML-RPC doesn't call the constructor. // Here is yet another work around(tm) (jengo) @@ -133,9 +133,16 @@ class acl { $this->acl(); } - $acl_acc_list = $GLOBALS['egw']->accounts->memberships($this->account_id,true); - @array_unshift($acl_acc_list,$this->account_id); - + if ($no_groups === true) + { + $acl_acc_list = $this->account_id; + } + else + { + $acl_acc_list = $GLOBALS['egw']->accounts->memberships($this->account_id,true); + if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); + array_unshift($acl_acc_list,$this->account_id); + } $this->data = Array(); foreach($this->db->select(acl::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) diff --git a/preferences/inc/class.uiaclprefs.inc.php b/preferences/inc/class.uiaclprefs.inc.php index 59a3a00fdb..b384c3357f 100644 --- a/preferences/inc/class.uiaclprefs.inc.php +++ b/preferences/inc/class.uiaclprefs.inc.php @@ -99,7 +99,9 @@ class uiaclprefs $no_privat_grants = $owner != $GLOBALS['egw_info']['user']['account_id']; } $this->acl = new acl((int)$owner); - $this->acl->read_repository(); + // should we enumerate group acl (does app use it), eg. addressbook does NOT use group ACL's but group addressbooks + $not_enum_group_acls = $acl_app == 'addressbook' ? true : $GLOBALS['egw']->hooks->single('not_enum_group_acls',$acl_app); + $this->acl->read_repository($not_enum_group_acls); if ($_POST['save'] || $_POST['apply']) { @@ -223,7 +225,15 @@ class uiaclprefs $totalentries = $GLOBALS['egw']->accounts->total; $shownentries = count($accounts); - $memberships = $GLOBALS['egw']->accounts->memberships($owner,true); + if ($not_enum_group_acls === true) + { + $memberships = array(); + } + else + { + $memberships = $GLOBALS['egw']->accounts->memberships($owner,true); + if (is_array($not_enum_group_acls)) $memberships = array_diff($memberships,$not_enum_group_acls); + } $header_type = ''; $processed = Array(); foreach((array)$accounts as $uid => $data)