do_not_sync_from_ldap for groups (fixes #158)

This commit is contained in:
Florian Schlichting 2019-01-30 21:42:01 +01:00
parent de1e994cab
commit afcaacaf2a
2 changed files with 17 additions and 7 deletions

View File

@ -624,8 +624,9 @@ $c->admin_email ='calendar-admin@example.com';
//
// );
//
// /* If there is some user you do not want to sync from LDAP, put their username in this list */
// /* If there is some user/group you do not want to sync from LDAP, put their username in these lists */
// $c->do_not_sync_from_ldap = array( 'admin' => true );
// $c->do_not_sync_group_from_ldap = array( 'teamclient1' => true );
//
//include('drivers_ldap.php');
@ -652,8 +653,9 @@ $c->admin_email ='calendar-admin@example.com';
// 'format_updated' => array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2))
// );
//
// /* If there is some user you do not want to sync from LDAP, put their username in this list */
// /* If there is some user/group you do not want to sync from LDAP, put their username in these lists */
// $c->do_not_sync_from_ldap = array( 'admin' => true );
// $c->do_not_sync_group_from_ldap = array( 'teamclient1' => true );
//
//include('drivers_ldap.php');

View File

@ -566,12 +566,20 @@ function sync_LDAP_groups(){
}
if ( sizeof ( $groups_to_deactivate ) ){
$c->messages[] = sprintf(i18n('- deactivate groups : %s'),join(', ',$groups_to_deactivate));
foreach ( $groups_to_deactivate as $group ){
$qry = new AwlQuery( 'UPDATE dav_principal SET user_active=FALSE WHERE username=:group AND type_id = 3',array(':group'=>$group) );
$qry->Exec('sync_LDAP',__LINE__,__FILE__);
Principal::cacheFlush('username=:group AND type_id = 3', array(':group'=>$group) );
foreach ( $groups_to_deactivate as $k => $group ){
if ( isset($c->do_not_sync_group_from_ldap) && isset($c->do_not_sync_group_from_ldap[$group]) ){
unset($groups_to_deactivate[$k]);
$groups_nothing_done[] = $group;
} else {
$qry = new AwlQuery( 'UPDATE dav_principal SET user_active=FALSE WHERE username=:group AND type_id = 3',array(':group'=>$group) );
$qry->Exec('sync_LDAP',__LINE__,__FILE__);
Principal::cacheFlush('username=:group AND type_id = 3', array(':group'=>$group) );
}
}
if ( sizeof($groups_to_deactivate) )
$c->messages[] = sprintf(i18n('- deactivated groups : %s'), join(', ',$groups_to_deactivate));
if ( sizeof($groups_nothing_done) )
$c->messages[] = sprintf(i18n('- nothing done on : %s'), join(', ', $groups_nothing_done));
}
}