mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-31 19:19:43 +01:00
moved check_acl to admin-cli and fixed bug #143: check_acl.php deletes all ACL if accounts are in ldap
This commit is contained in:
parent
5c43c59a5d
commit
06b826b611
@ -52,6 +52,9 @@ switch($action)
|
|||||||
case '--change-account-id':
|
case '--change-account-id':
|
||||||
return do_change_account_id($arg0s);
|
return do_change_account_id($arg0s);
|
||||||
|
|
||||||
|
case '--check-acl';
|
||||||
|
return do_check_acl();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage($action);
|
usage($action);
|
||||||
break;
|
break;
|
||||||
@ -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 " 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 "--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 " 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;
|
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
|
* Delete a given user from eGW
|
||||||
*
|
*
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**************************************************************************\
|
|
||||||
* eGroupWare - Admin - delete ACL records of deleted accounts *
|
|
||||||
* http://www.egroupware.org *
|
|
||||||
* Written and (c) 2004 by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
||||||
* -------------------------------------------- *
|
|
||||||
* 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 '<p align="center">'.lang('Permission denied')."</p>\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 '<p align="center">'.lang('%1 ACL records of not (longer) existing accounts deleted.',$deleted)."</p>\n";
|
|
||||||
}
|
|
||||||
$GLOBALS['egw']->common->egw_footer();
|
|
||||||
$GLOBALS['egw']->common->egw_exit();
|
|
Loading…
Reference in New Issue
Block a user