diff options
author | Daniel Lange <DLange@git.local> | 2016-04-08 13:58:32 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-08 13:58:32 +0200 |
commit | 99dffc20ec579fc7b24989fe2f793fb3f875f6df (patch) | |
tree | d73c8d929ac659d1f7c024f44e6021a689b8332f | |
parent | e82ab61ed1de64292bd6b1a6684c61288eec0aaa (diff) | |
download | drupal_htpasswdsync-99dffc20ec579fc7b24989fe2f793fb3f875f6df.tar.gz drupal_htpasswdsync-99dffc20ec579fc7b24989fe2f793fb3f875f6df.tar.bz2 drupal_htpasswdsync-99dffc20ec579fc7b24989fe2f793fb3f875f6df.zip |
-rw-r--r-- | CHANGELOG.txt | 2 | ||||
-rw-r--r-- | HTPasswdSync.module | 26 |
2 files changed, 23 insertions, 5 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 849c772..b7167a8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,5 @@ +v1.3 Update status report functionality (drupal/admin/reports/status) + v1.2 Enable or disable curly braces password prefix like {SHA512-crypt} Dovecot introduced the prefix, htpasswd from nginx doesn't understand it diff --git a/HTPasswdSync.module b/HTPasswdSync.module index f6689bb..3ac1a77 100644 --- a/HTPasswdSync.module +++ b/HTPasswdSync.module @@ -19,6 +19,21 @@ function _htpasswdsync_grpfilename() { /** + * Returns the age of the htpasswd/group file or "unknown" + * @param string $file + * @return string + */ +function _htpasswdsync_fileage($file) { + if(is_file($file)) { + return t('last update !time ago', array( + '!time' => format_interval(time()-filemtime($file)))); + } else { + return t('unknown'); + } +} + + +/** * Returns an array containing the role ids of the roles to write into * the htgroup file. (selected in the admin page) * @return array @@ -699,7 +714,8 @@ function htpasswdsync_requirements($phase) { $htpasswd_status_msg = _htpasswdsync_check_file(_htpasswdsync_passfilename()); $htpasswd_status_val = REQUIREMENT_ERROR; if (!$htpasswd_status_msg) { - $htpasswd_status_msg = t('!file file is writable', array('!file' => 'htpasswd')); + $htpasswd_status_msg = t('!file file is writable', array('!file' => 'htpasswd')) . + " (" . _htpasswdsync_fileage(_htpasswdsync_passfilename()) . ")"; $htpasswd_status_val = REQUIREMENT_OK; } } else { @@ -711,7 +727,8 @@ function htpasswdsync_requirements($phase) { $htgroup_status_msg = _htpasswdsync_check_file(_htpasswdsync_grpfilename()); $htgroup_status_val = REQUIREMENT_ERROR; if (!$htgroup_status_msg) { - $htgroup_status_msg = t('!file file is writable', array('!file' => 'htgroup')); + $htgroup_status_msg = t('!file file is writable', array('!file' => 'htgroup')) . + " (" . _htpasswdsync_fileage(_htpasswdsync_grpfilename()) . ")"; $htgroup_status_val = REQUIREMENT_OK; } } else { @@ -723,9 +740,8 @@ function htpasswdsync_requirements($phase) { $requirements['htpasswdsync_status'] = array( 'title' => t('HTPasswd Sync Status'), - 'value' => $htpasswd_status_msg . "<br>" . $htgroup_status_msg . "<br>" . - t('last update !time ago.', array( - '!time' => format_interval(time()-variable_get('htpasswdsync_cron_time', 0)))), + 'value' => "htpasswd: " . $htpasswd_status_msg . "<br>" . + "htgroup: " . $htgroup_status_msg . "<br>", 'severity' => $status, ); |