aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstfwi <cerberos@atwillys.de>2011-09-26 17:34:17 +0200
committerstfwi <cerberos@atwillys.de>2011-09-26 17:34:17 +0200
commit6868511ac9bcc6aaca5dfeb1f8b342082e9c0ad7 (patch)
treee7e39d71075b4e74b6f1e7458c6d948d2227dccd
parent3e08bdba4f3f2061d25946ab30f83077bfa14db9 (diff)
downloaddrupal_htpasswdsync-6868511ac9bcc6aaca5dfeb1f8b342082e9c0ad7.tar.gz
drupal_htpasswdsync-6868511ac9bcc6aaca5dfeb1f8b342082e9c0ad7.tar.bz2
drupal_htpasswdsync-6868511ac9bcc6aaca5dfeb1f8b342082e9c0ad7.zip
Added keys to __htpasswdsync_hashes(); Added additional plausibility checks in admin form; Added/modified description texts in admin form.
-rw-r--r--HTPasswdSync.module34
1 files changed, 24 insertions, 10 deletions
diff --git a/HTPasswdSync.module b/HTPasswdSync.module
index 43bd347..e61334b 100644
--- a/HTPasswdSync.module
+++ b/HTPasswdSync.module
@@ -33,7 +33,7 @@ function _htpasswdsync_roles() {
* @return array
*/
function _htpasswdsync_hashes() {
- return array ('crypt', 'SHA-1');
+ return array ('crypt' => 'crypt', 'SHA-1' => 'SHA-1');
}
@@ -129,14 +129,22 @@ function _htpasswdsync_check_file($path) {
if(is_file($path) && is_writable($path) && is_readable($path)) {
return false;
} else if(!is_file($path)) {
- return t("File '!file' does not exists, you should create it.",
- array('!file' => $path));
+ if(is_dir($path)) {
+ return t("File '!file' that you specified is an existing directory. Please check your path setting.", array('!file' => $path));
+ } else if(!is_dir(dirname($path))) {
+ return t("File '!file' does not exists and the parent directory does not exist neither. Please check the path you entered or create the file manually.", array('!file' => $path));
+ } else if(!is_writable(dirname($path))) {
+ return t("File '!file' does not exists and the parent directory is not writable. Please create the file manually.", array('!file' => $path));
+ } else if(file_put_contents($path, '') === false || !is_file($path) || !is_writable($path) || !is_readable($path)) {
+ return t("File '!file' does not exists, and it could no be created properly. Please create the file manually.", array('!file' => $path));
+ }
+ return false;
} else if(!is_readable($path)) {
- return t("File '!file' exists but is not readable for the server. Use chmod command to change this.",
- array('!file' => $path));
+ return t("File '!file' exists but is not readable for the server. Use chmod command to change this.", array('!file' => $path));
+ } else if(!is_writable($path)) {
+ return t("File '!file' exists but is not writable for the server. Use chmod command to change this.", array('!file' => $path));
} else {
- return t("File '!file' exists but is not writable for the server. Use chmod command to change this.",
- array('!file' => $path));
+ return t("File '!file' (dead branch check): Please inform the maintainer that there is a bug in function _htpasswdsync_check_file().", array('!file' => $path));
}
}
@@ -500,19 +508,20 @@ function htpasswdsync_admin_form() {
$form['htpasswdsync_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Roles to be exported into the htgroup file'),
+ '#description' => t("Only users of these roles will be syncronized into the htpasswd/htgroup file. If none is specified, no user will be in the file (not 'default all')."),
'#default_value' => _htpasswdsync_roles(),
'#options' => user_roles(true),
);
$form['htpasswdsync_overwrite'] = array(
'#type' => 'checkbox',
'#title' => t('htpasswd file is only managed by this module'),
- '#description' => t("If yes, manually added users in the user file will be removed. If no, only the users stored in the database will be changed/added/deleted."),
+ '#description' => t("If yes, manually added users in the user file will be removed (simply overwrites the files). If no, only the users stored in the database will be changed/added/deleted (Files will be analyzed and users not existing in the database will be left unchanged)."),
'#default_value' => _htpasswdsync_overwrite(),
);
$form['htpasswdsync_names_lowercase'] = array(
'#type' => 'checkbox',
'#title' => t('Export user names and group names lowercase'),
- '#description' => t("If yes, htpasswdsync will export the lowercase user names as well (e.g. 'User' will be exported as 'User' and 'user'). Groups will always be exported lowercase (as the user does not need to enter a group, so this makes it easier to design the .htaccess files). Caution: this option may increase the file size of the htuser file."),
+ '#description' => t("If yes, htpasswdsync will export the lowercase user names (e.g. 'User' will be exported as 'user'). Groups will always be exported lowercase (as the user does not need to enter a group, so this makes it easier to design the .htaccess files). Caution: this option may increase the file size of the htuser file."),
'#default_value' => _htpasswdsync_names_lowercase(),
);
$form['htpasswdsync_names_without_whitespace'] = array(
@@ -572,10 +581,15 @@ function htpasswdsync_admin_form_validate($form, &$form_state) {
if(empty($form_state['values']['htpasswdsync_htpasswd']) && empty($form_state['values']['htpasswdsync_htgroup'])) {
form_set_error('htpasswdsync_htpasswd', 'You should at least specify the htpasswd file.');
+ $error = true;
} else if(!empty($form_state['values']['htpasswdsync_htgroup']) && empty($form_state['values']['htpasswdsync_htpasswd'])) {
form_set_error('htpasswdsync_htpasswd', 'The htgroup file makes no sense without the htpasswd file.');
+ $error = true;
+ } else if($form_state['values']['htpasswdsync_htgroup'] == $form_state['values']['htpasswdsync_htpasswd']) {
+ form_set_error('htpasswdsync_htpasswd', 'The htgroup file and the htpasswd file have to be different files.');
+ $error = true;
}
-
+
$file = $form_state['values']['htpasswdsync_htpasswd'];
if(!empty($file)) {
if($msg = _htpasswdsync_check_file($file)) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy