This repository has been archived by the owner on Jan 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1222 from UN-OCHA/develop
Deploy 15-02-23
- Loading branch information
Showing
55 changed files
with
1,267 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
diff --git a/user_expire.module b/user_expire.module | ||
index 4d01061f69b447cdefcd7d6b3e5bdaec09eed438..332ab12a88793eff57e233e298330721627aeb9c 100644 | ||
--- a/user_expire.module | ||
+++ b/user_expire.module | ||
@@ -164,7 +164,7 @@ function user_expire_user_update(&$edit, $account, $category) { | ||
function _user_expire_save($account) { | ||
if (isset($account->user_expiration) && $account->user_expiration) { | ||
if (is_array($account->user_expiration_date) && isset($account->user_expiration_date['month'])) { | ||
- $time_for_datetime = $account->user_expiration_date['year'] . '-' . $account->user_expiration_date['month'] . '-' . $account->user_expiration_date['day']; | ||
+ $time_for_datetime = $account->user_expiration_date['year'] . '-' . $account->user_expiration_date['month'] . '-' . $account->user_expiration_date['day']; | ||
} | ||
else { | ||
$time_for_datetime = $account->user_expiration_date; | ||
@@ -254,7 +254,6 @@ function user_expire_set_expiration($account, $expiration = NULL) { | ||
if (!isset($account->is_new) || !$account->is_new) { | ||
// New accounts can't have a record to delete. | ||
// Existing records (!is_new) might. | ||
- | ||
// Remove user expiration times for this user. | ||
$deleted = db_delete('user_expire') | ||
->condition('uid', $account->uid) | ||
@@ -483,7 +482,7 @@ function user_expire_mail($key, &$message, $params) { | ||
$message['body'][] = ''; | ||
$message['body'][] = t('Thanks, @site_name', array('@site_name' => variable_get('site_name', 'Drupal.org'))); | ||
} | ||
- else if ($key == 'account_expired') { | ||
+ elseif ($key == 'account_expired') { | ||
// The subject. | ||
$message['subject'] = t('@site_name: Account expired', array('@site_name' => variable_get('site_name', 'Drupal.org'))); | ||
// The body. | ||
@@ -499,3 +498,15 @@ function user_expire_mail($key, &$message, $params) { | ||
$message['body'][] = t('Thanks, @site_name', array('@site_name' => variable_get('site_name', 'Drupal.org'))); | ||
} | ||
} | ||
+ | ||
+/** | ||
+ * Implements hook_user_presave(). | ||
+ * | ||
+ * If the account was blocked but is now active, update the expiry so it is | ||
+ * not re-blocked by the next cron run. | ||
+ */ | ||
+function user_expire_user_presave(&$edit, $account, $category) { | ||
+ if (!empty($account->original) && $account->original->status == 0 && $edit['status'] == 1) { | ||
+ $edit['access'] = REQUEST_TIME; | ||
+ } | ||
+} | ||
diff --git a/user_expire.test b/user_expire.test | ||
index cb9e3bdafc3ef27711b8d1b1c58ad4437257c97b..3d955a99e0c329b64fd837c7f28de875eb926eea 100644 | ||
--- a/user_expire.test | ||
+++ b/user_expire.test | ||
@@ -4,6 +4,9 @@ | ||
* Tests for User expire module. | ||
*/ | ||
|
||
+/** | ||
+ * {@inheritdoc} | ||
+ */ | ||
class UserExpireTestCase extends DrupalWebTestCase { | ||
/** | ||
* Implements getInfo(). | ||
@@ -17,6 +20,9 @@ class UserExpireTestCase extends DrupalWebTestCase { | ||
); | ||
} | ||
|
||
+ /** | ||
+ * {@inheritdoc} | ||
+ */ | ||
public function setUp() { | ||
// Enable User Expire module. | ||
parent::setUp('user_expire'); | ||
@@ -30,11 +36,14 @@ class UserExpireTestCase extends DrupalWebTestCase { | ||
'administer users', | ||
'set user expiration', | ||
'view expiring users report', | ||
- 'administer user expire settings' | ||
+ 'administer user expire settings', | ||
)); | ||
} | ||
|
||
- function testUserExpire() { | ||
+ /** | ||
+ * Run all user_expire tests. | ||
+ */ | ||
+ public function testUserExpire() { | ||
$this->assertTrue($this->basic_account->status, t('User account is currently enabled.')); | ||
user_expire_set_expiration($this->basic_account, REQUEST_TIME - 1); | ||
user_expire_expire_users(array($this->basic_account)); | ||
@@ -142,7 +151,7 @@ class UserExpireTestCase extends DrupalWebTestCase { | ||
user_expire_expire_by_role(); | ||
|
||
// Ensure they are still enabled. | ||
- $this->drupalGet("user/$new_basic_account->uid/edit"); | ||
+ $this->drupalGet("user/{$new_basic_account->uid}/edit"); | ||
$this->assertRaw('type="radio" id="edit-status-1" name="status" value="1" checked="checked" class="form-radio"', t('New user account stays active.')); | ||
|
||
// Age the new user's created by 90+ days. | ||
@@ -151,9 +160,21 @@ class UserExpireTestCase extends DrupalWebTestCase { | ||
// Process it. | ||
user_expire_expire_by_role(); | ||
|
||
- // Ensure they are disabled | ||
- $this->drupalGet("user/$new_basic_account->uid/edit"); | ||
+ // Ensure they are disabled. | ||
+ $this->drupalGet("user/{$new_basic_account->uid}/edit"); | ||
$this->assertRaw('type="radio" id="edit-status-0" name="status" value="0" checked="checked" class="form-radio"', t('User account is currently disabled.')); | ||
|
||
+ // Manually unblock the user. | ||
+ $edit = array(); | ||
+ $edit['status'] = 1; | ||
+ $this->drupalPost("user/{$new_basic_account->uid}/edit", $edit, t('Save')); | ||
+ | ||
+ // Process it. | ||
+ user_expire_expire_by_role(); | ||
+ | ||
+ // Ensure they are still active. | ||
+ $this->drupalGet("user/{$new_basic_account->uid}/edit"); | ||
+ $this->assertRaw('type="radio" id="edit-status-1" name="status" value="1" checked="checked" class="form-radio"', $this->t('User account is currently active.')); | ||
} | ||
+ | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#-*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- | ||
### fastcgi configuration for serving private files. | ||
## 1. Parameters. | ||
fastcgi_param QUERY_STRING q=$uri&$args; | ||
fastcgi_param REQUEST_METHOD $request_method; | ||
fastcgi_param CONTENT_TYPE $content_type; | ||
fastcgi_param CONTENT_LENGTH $content_length; | ||
|
||
fastcgi_param SCRIPT_NAME /index.php; | ||
fastcgi_param REQUEST_URI $request_uri; | ||
fastcgi_param DOCUMENT_URI $document_uri; | ||
fastcgi_param DOCUMENT_ROOT $document_root; | ||
fastcgi_param SERVER_PROTOCOL $server_protocol; | ||
|
||
fastcgi_param GATEWAY_INTERFACE CGI/1.1; | ||
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; | ||
|
||
fastcgi_param REMOTE_ADDR $remote_addr; | ||
fastcgi_param REMOTE_PORT $remote_port; | ||
fastcgi_param SERVER_ADDR $server_addr; | ||
fastcgi_param SERVER_PORT $server_port; | ||
fastcgi_param SERVER_NAME $server_name; | ||
## PHP only, required if PHP was built with --enable-force-cgi-redirect | ||
fastcgi_param REDIRECT_STATUS 200; | ||
fastcgi_param SCRIPT_FILENAME $document_root/index.php; | ||
## HTTPS 'on' parameter. This requires Nginx version 1.1.11 or | ||
## later. The if_not_empty flag was introduced in 1.1.11. See: | ||
## http://nginx.org/en/CHANGES. If using a version that doesn't | ||
## support this comment out the line below. | ||
fastcgi_param HTTPS $fastcgi_https if_not_empty; | ||
## For Nginx versions below 1.1.11 uncomment the line below after commenting out the above. | ||
#fastcgi_param HTTPS $fastcgi_https; | ||
|
||
## 2. Nginx FCGI specific directives. | ||
fastcgi_buffers 256 4k; | ||
fastcgi_intercept_errors on; | ||
## Allow 4 hrs - pass timeout responsibility to upstream. | ||
fastcgi_read_timeout 14400; | ||
fastcgi_index index.php; | ||
## Hide the X-Drupal-Cache header provided by Pressflow. | ||
fastcgi_hide_header 'X-Drupal-Cache'; | ||
## Hide the Drupal 7 header X-Generator. | ||
fastcgi_hide_header 'X-Generator'; |
Oops, something went wrong.