2007-11-27 04:20:28 +01:00
< ? php
/**
2018-04-03 20:14:03 +02:00
* EGroupWare admin - admin command : check ACL for entries of deleted accounts
2007-11-27 04:20:28 +01:00
*
* @ link http :// www . egroupware . org
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ package admin
2016-04-27 21:12:20 +02:00
* @ copyright ( c ) 2007 - 16 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
2007-11-27 04:20:28 +01:00
* @ license http :// opensource . org / licenses / gpl - license . php GPL - GNU General Public License
2016-04-27 21:12:20 +02:00
* @ version $Id $
2007-11-27 04:20:28 +01:00
*/
/**
* admin command : check ACL for entries of deleted accounts
*/
2016-04-27 21:12:20 +02:00
class admin_cmd_check_acl extends admin_cmd
2007-11-27 04:20:28 +01:00
{
/**
* Constructor
*
2016-04-27 21:12:20 +02:00
* @ param array $data = array () default parm from parent class , no real parameters
2007-11-27 04:20:28 +01:00
*/
function __construct ( $data = array ())
{
admin_cmd :: __construct ( $data );
}
/**
* give or remove run rights from a given account and application
2016-04-27 21:12:20 +02:00
*
* @ param boolean $check_only = false only run the checks ( and throw the exceptions ), but not the command itself
2007-11-27 04:20:28 +01:00
* @ return string success message
* @ throws Exception ( lang ( " Permission denied !!! " ), 2 )
* @ throws Exception ( lang ( " Unknown account: %1 !!! " , $this -> account ), 15 );
* @ throws Exception ( lang ( " Application '%1' not found (maybe not installed or misspelled)! " , $name ), 8 );
*/
protected function exec ( $check_only = false )
{
if ( $check_only ) return true ;
admin_cmd :: _instanciate_accounts ();
$deleted = 0 ;
if (( $all_accounts = admin_cmd :: $accounts -> search ( array ( 'type' => 'both' ))))
{
$ids = array ();
foreach ( $all_accounts as $account )
{
$ids [] = $account [ 'account_id' ];
}
$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 ();
}
2018-04-03 20:14:03 +02:00
return lang ( " %1 ACL records of not (longer) existing accounts deleted. " , $deleted );
2007-11-27 04:20:28 +01:00
}
/**
* Return a title / string representation for a given command , eg . to display it
*
* @ return string
*/
function __tostring ()
{
return lang ( 'Check ACL for entries of not (longer) existing accounts' );
}
}