From 99dffc20ec579fc7b24989fe2f793fb3f875f6df Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Fri, 8 Apr 2016 13:58:32 +0200 Subject: Fix and improve drupal status report from module --- CHANGELOG.txt | 2 ++ 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 @@ -18,6 +18,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) @@ -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 . "
" . $htgroup_status_msg . "
" . - t('last update !time ago.', array( - '!time' => format_interval(time()-variable_get('htpasswdsync_cron_time', 0)))), + 'value' => "htpasswd: " . $htpasswd_status_msg . "
" . + "htgroup: " . $htgroup_status_msg . "
", 'severity' => $status, ); -- cgit v1.2.3