diff --git a/config/example-config.php b/config/example-config.php index 85831f78..cc4bdefa 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -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'); diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 4bae21fe..252a2c49 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -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)); } }