Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1222 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Deploy 15-02-23
  • Loading branch information
lazysoundsystem authored Feb 14, 2023
2 parents 61c66da + 2f246e9 commit b5330f1
Show file tree
Hide file tree
Showing 55 changed files with 1,267 additions and 297 deletions.
120 changes: 120 additions & 0 deletions PATCHES/user-expire-reset-activation-period.patch
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.'));
}
+
}
82 changes: 42 additions & 40 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"Disable entity loading 2": "PATCHES/shs_lazyload_2.patch"
},
"drupal/user_expire": {
"If a user is activated, deactivated by the module, and reactivated by an admin, reset their expiration period": "https://git.drupalcode.org/project/user_expire/-/merge_requests/8.diff",
"If a user is activated, deactivated by the module, and reactivated by an admin, reset their expiration period": "PATCHES/user-expire-reset-activation-period.patch",
"OPS-8147: Customise the expiry email text": "PATCHES/user-expire-2836514-mails-hack.patch"
}
}
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /srv/www
RUN composer self-update && \
composer install --quiet --no-dev --prefer-dist

FROM public.ecr.aws/unocha/php-k8s:${TAG:-7.4-NR-stable}
FROM public.ecr.aws/unocha/php-k8s:7.4-stable

ARG VCS_REF
ARG VCS_URL
Expand All @@ -33,6 +33,7 @@ COPY --from=builder /srv/www/vendor /srv/www/vendor
COPY --from=builder /srv/www/composer.json /srv/www/composer.json
COPY --from=builder /srv/www/composer.lock /srv/www/composer.lock
COPY --from=builder /srv/www/composer.patches.json /srv/www/composer.patches.json
COPY --from=builder /srv/www/docker/fastcgi_drupal.conf /etc/nginx/apps/drupal/fastcgi_drupal.conf
COPY --from=builder /srv/www/docker/custom /etc/nginx/custom

RUN cd /srv/www/html/sites && \
Expand Down
43 changes: 43 additions & 0 deletions docker/fastcgi_drupal.conf
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';
Loading

0 comments on commit b5330f1

Please sign in to comment.