From 06b826b6110381d097e62aea92ec2c1e7e3fd651 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 8 May 2007 13:36:17 +0000 Subject: [PATCH] moved check_acl to admin-cli and fixed bug #143: check_acl.php deletes all ACL if accounts are in ldap --- admin/admin-cli.php | 22 +++++++++++++++++++++ admin/check_acl.php | 47 --------------------------------------------- 2 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 admin/check_acl.php diff --git a/admin/admin-cli.php b/admin/admin-cli.php index c79ca85153..f37996a296 100755 --- a/admin/admin-cli.php +++ b/admin/admin-cli.php @@ -51,6 +51,9 @@ switch($action) case '--change-account-id': return do_change_account_id($arg0s); + + case '--check-acl'; + return do_check_acl(); default: usage($action); @@ -100,9 +103,28 @@ function usage($action=null,$ret=0) echo " Deletes a user from eGroupWare. It's data can be moved to an other user or it get deleted too.\n"; echo "--change-account-id admin-account[@domain],admin-password,from1,to1[...,fromN,toN]\n"; echo " Changes one or more account_id's in the database (make a backup before!).\n"; + echo "--check-acl admin-account[@domain],admin-password\n"; + echo " Deletes ACL entries of not longer existing accounts (make a database backup before!).\n"; exit; } +function do_check_acl() +{ + $deleted = 0; + if (($all_accounts = $GLOBALS['egw']->accounts->search(array('type'=>'both')))) + { + $ids = array(); + foreach($all_accounts as $account) + { + $ids[] = $account['account_id']; + } + // does not work for LDAP! $ids = array_keys($all_accounts); + $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$ids)."')",__LINE__,__FILE__); + $deleted = $GLOBALS['egw']->db->affected_rows(); + } + echo "\n$deleted ACL records of not (longer) existing accounts deleted.\n\n"; +} + /** * Delete a given user from eGW * diff --git a/admin/check_acl.php b/admin/check_acl.php deleted file mode 100644 index c487180e1c..0000000000 --- a/admin/check_acl.php +++ /dev/null @@ -1,47 +0,0 @@ - * -* -------------------------------------------- * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 2 of the License, or (at your * -* option) any later version. * -\**************************************************************************/ - -/* $Id$ */ - -/** - * delete ACL records of deleted accounts (can be called only via the URL) - * - * ACL records of deleted accounts have very irritating effects on the ACL (specialy calendar) - * - * @package admin - * @author RalfBecker@outdoor-training.de - * @license GPL - */ - -$GLOBALS['egw_info'] = array( - 'flags' => array( - 'currentapp' => 'admin', -)); -include('../header.inc.php'); - -if (!$GLOBALS['egw_info']['user']['apps']['admin']) -{ - echo '

'.lang('Permission denied')."

\n"; -} -else -{ - $deleted = 0; - if (($all_accounts = $GLOBALS['egw']->accounts->search(array('type'=>'both')))) - { - $all_accounts = array_keys($all_accounts); - $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$all_accounts).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$all_accounts)."')",__LINE__,__FILE__); - $deleted = $GLOBALS['egw']->db->affected_rows(); - } - echo '

'.lang('%1 ACL records of not (longer) existing accounts deleted.',$deleted)."

\n"; -} -$GLOBALS['egw']->common->egw_footer(); -$GLOBALS['egw']->common->egw_exit();