From 3e08bdba4f3f2061d25946ab30f83077bfa14db9 Mon Sep 17 00:00:00 2001 From: stfwi Date: Tue, 5 Jul 2011 22:38:30 +0100 Subject: Group file is now updated when the group file name is set to an empty string in the config form --- HTPasswdSync.module | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/HTPasswdSync.module b/HTPasswdSync.module index 4c65b21..43bd347 100644 --- a/HTPasswdSync.module +++ b/HTPasswdSync.module @@ -598,12 +598,20 @@ function htpasswdsync_admin_form_validate($form, &$form_state) { // Directly apply changes if no validation errors if($error == false) { - // A workaround to update the files directly after saving the config form - variable_set('htpasswdsync_flag_needs_rebuild', true); - foreach(_htpasswdsync_roles() as $role) { - if($role > 0 && !in_array($role, $form_state['values']['htpasswdsync_roles'])) { + if($form_state['values']['htpasswdsync_htgroup'] == '' && _htpasswdsync_grpfilename() != '') { + // Group file was unset, so the groups shpuld be all deleted + foreach(_htpasswdsync_roles() as $role) { _htpasswdsync_remove_role($role); } + } else { + // Check which roles have to be removed + // A workaround to update the files directly after saving the config form + variable_set('htpasswdsync_flag_needs_rebuild', true); + foreach(_htpasswdsync_roles() as $role) { + if($role > 0 && !in_array($role, $form_state['values']['htpasswdsync_roles'])) { + _htpasswdsync_remove_role($role); + } + } } } } -- cgit v1.2.3