Skip to content

Commit

Permalink
Merge pull request #466 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Deploy 14-08-2024
  • Loading branch information
lazysoundsystem authored Aug 13, 2024
2 parents a1c04fd + df5a2be commit f0f2754
Show file tree
Hide file tree
Showing 118 changed files with 1,283 additions and 1,438 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/composer-update-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run Composer Update with Config

on:
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Update The Thing with config
id: update-action-with-config
uses: UN-OCHA/actions/composer-update@OPS-10254-config-too
with:
aws_access_key_id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
github_access_token: ${{ secrets.PAT }}
patch_branch: ${{ github.head_ref || github.ref_name }}
patch_maintainers: ${{ secrets.DRUPAL_MAINTAINERS }}
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
slack_channel_name: ${{ vars.SLACK_CHANNEL }}
26 changes: 13 additions & 13 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml up -d
docker compose -f tests/docker-compose.yml up -d
sleep 10
docker ps -a
docker-compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install
docker compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install
env:
fail-fast: true

Expand All @@ -115,7 +115,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom
docker compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom
env:
fail-fast: true

Expand All @@ -124,7 +124,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config minimal install_configure_form.enable_update_status_emails=NULL
docker compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config minimal install_configure_form.enable_update_status_emails=NULL
env:
fail-fast: true

Expand All @@ -133,13 +133,13 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private
docker-compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs
docker-compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/sites/default/files/browser_output
docker-compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files/browser_output
docker-compose -f tests/docker-compose.yml exec -T -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPUT_DIRECTORY=/srv/www/html/sites/default/files/browser_output -e DTT_BASE_URL=http://127.0.0.1 drupal ./vendor/bin/phpunit --coverage-clover /srv/www/html/build/logs/clover.xml --debug
docker compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private
docker compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs
docker compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/sites/default/files/browser_output
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files/browser_output
docker compose -f tests/docker-compose.yml exec -T -w /srv/www -e XDEBUG_MODE=coverage -e BROWSERTEST_OUTPUT_DIRECTORY=/srv/www/html/sites/default/files/browser_output -e DTT_BASE_URL=http://127.0.0.1 drupal ./vendor/bin/phpunit --coverage-clover /srv/www/html/build/logs/clover.xml --debug
env:
fail-fast: true

Expand All @@ -148,7 +148,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker cp "$(docker-compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml .
docker cp "$(docker compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml .
- name: Monitor coverage
id: coveralls
Expand All @@ -168,7 +168,7 @@ jobs:
uses: cafuego/command-output@main
with:
run: |
docker-compose -f tests/docker-compose.yml exec -T drupal drush watchdog:show --count=50 --extended
docker compose -f tests/docker-compose.yml exec -T drupal drush watchdog:show --count=50 --extended
- name: Find Comment
uses: peter-evans/find-comment@v3
Expand Down
48 changes: 20 additions & 28 deletions PATCHES/user_expire/customize-notification-email.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ index 62f9e8c7d5a064d87448b0faf5811a08709370c7..ea9fb144d2add8031bcafc516fb46cca
+ subject: "[site:name]: Account expiration warning"
+ body: "Hello [user:display-name]\r\n\r\nBecause you have not logged in recently, your account at [site:name] will be blocked in the near future. If you still use this site, please log in [site:login-url] to prevent your account being blocked.\r\n\r\n-- [site:name] team"
diff --git a/config/schema/user_expire.schema.yml b/config/schema/user_expire.schema.yml
index a46bc68eeea8b41fa1e7bde72008daf77d54032d..f8e9e2e101f58d8f5a5cbfb87483bc9821a6a7a6 100644
index a46bc68eeea8b41fa1e7bde72008daf77d54032d..be0c3fca4e7604994e5c0070942ef79920eab454 100644
--- a/config/schema/user_expire.schema.yml
+++ b/config/schema/user_expire.schema.yml
@@ -7,9 +7,21 @@ user_expire.settings:
Expand All @@ -31,24 +31,24 @@ index a46bc68eeea8b41fa1e7bde72008daf77d54032d..f8e9e2e101f58d8f5a5cbfb87483bc98
type: integer
label: 'Warning offset time in seconds'
+ send_mail:
+ type: integer
+ type: boolean
+ label: 'Flag that enables or disables expiry emails'
user_expire_roles:
type: sequence
label: 'Roles and expire value'
diff --git a/src/Form/UserExpireSettingsForm.php b/src/Form/UserExpireSettingsForm.php
index 8d7e2d0d0f01265abce72f018b8b32facf76087a..d8d9cb6671b29364c0ba198e893e823261079412 100644
index f7824c09ad10612818c2cc3e2cc2a85e590377a7..cd2c4e515d0887df9a70fe0c7c72bc599de84033 100644
--- a/src/Form/UserExpireSettingsForm.php
+++ b/src/Form/UserExpireSettingsForm.php
@@ -111,6 +111,50 @@ class UserExpireSettingsForm extends ConfigFormBase {
@@ -109,6 +109,50 @@ class UserExpireSettingsForm extends ConfigFormBase {
];
}

+ // Enable or disable email notifications.
+ $form['send_mail'] = [
+ '#type' => 'checkbox',
+ '#title' => $this->t('Send notifiation emails'),
+ '#default_value' => $config->get('send_mail') ?: true,
+ '#title' => $this->t('Send notification emails'),
+ '#default_value' => $config->get('send_mail') ?: TRUE,
+ '#description' => $this->t('Send a notification email to the user, starting at the defined offset time before account expiry.'),
+ ];
+
Expand Down Expand Up @@ -80,7 +80,7 @@ index 8d7e2d0d0f01265abce72f018b8b32facf76087a..d8d9cb6671b29364c0ba198e893e8232
+ '#type' => 'textarea',
+ '#title' => $this->t('Body'),
+ '#default_value' => $config->get('mail.body') ?: '',
+ '#description' => $this->t('Body for the notifiction email.'),
+ '#description' => $this->t('Body for the notification email.'),
+ '#rows' => 15,
+ ];
+
Expand All @@ -91,7 +91,7 @@ index 8d7e2d0d0f01265abce72f018b8b32facf76087a..d8d9cb6671b29364c0ba198e893e8232
return parent::buildForm($form, $form_state);
}

@@ -162,6 +206,13 @@ class UserExpireSettingsForm extends ConfigFormBase {
@@ -160,6 +204,13 @@ class UserExpireSettingsForm extends ConfigFormBase {
}

$config->set('user_expire_roles', $rules);
Expand All @@ -106,25 +106,18 @@ index 8d7e2d0d0f01265abce72f018b8b32facf76087a..d8d9cb6671b29364c0ba198e893e8232
}

diff --git a/user_expire.module b/user_expire.module
index 26beacd1c168d92962fae31090470698f753ff47..34f61dc939b476aa6a93323f6aff2801fab64891 100644
index d4dcd8ba28b51ee8f54a7626d8b10443244520d9..9365c5db3b87e88dd03611a03656370e2b4f99cb 100644
--- a/user_expire.module
+++ b/user_expire.module
@@ -12,6 +12,7 @@ use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\user\RoleInterface;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Component\Render\PlainTextOutput;
@@ -5,6 +5,7 @@
* Main module file for User expire module.
*/

/**
* Implements hook_help().
@@ -332,18 +333,21 @@ function user_expire_expire_by_role_warning() {
if ($uids_to_warn) {
foreach ($uids_to_warn as $uid) {
$account = \Drupal::entityTypeManager()->getStorage('user')->load($uid->uid);
- if ($account) {
+ if (!$account) {
$logger->debug('Skipping warning @uid as it failed to load a valid user', [
'@uid' => $uid->uid,
+use Drupal\Component\Render\PlainTextOutput;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\StatementInterface;
use Drupal\Core\Datetime\DrupalDateTime;
@@ -332,12 +333,15 @@ function user_expire_expire_by_role_warning(): void {
]);
}
else {
Expand All @@ -146,9 +139,9 @@ index 26beacd1c168d92962fae31090470698f753ff47..34f61dc939b476aa6a93323f6aff2801
}
}
}
@@ -445,20 +449,23 @@ function user_expire_get_role_rules() {
@@ -439,20 +443,22 @@ function user_expire_get_role_rules(): mixed {
*/
function user_expire_mail($key, &$message, $params) {
function user_expire_mail($key, &$message, $params): void {
if ($key == 'expiration_warning') {
- $site_name = \Drupal::config('system.site')->get('name');
- // The subject.
Expand All @@ -160,12 +153,11 @@ index 26beacd1c168d92962fae31090470698f753ff47..34f61dc939b476aa6a93323f6aff2801
- $message['body'][] = t('Because you have not logged in recently, your account at @site_name will be blocked in the near future. If you still use this site, please log in @login_url to avoid having your account blocked.',
- [
- '@site_name' => $site_name,
- '@login_url' => Url::fromRoute('entity.user.canonical', ['user' => \Drupal::currentUser()->id()], ['absolute' => TRUE]),
- '@login_url' => Url::fromRoute('entity.user.canonical', ['user' => \Drupal::currentUser()->id()], ['absolute' => TRUE])->toString(),
- ]
- );
- $message['body'][] = '';
- $message['body'][] = t('Thanks, @site_name', ['@site_name' => $site_name]);
+
+ $token_service = \Drupal::token();
+ $language_manager = \Drupal::languageManager();
+ $langcode = $message['langcode'];
Expand Down
22 changes: 11 additions & 11 deletions PATCHES/user_expire/reset-expiration-on-reactivation.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/tests/src/Functional/UserExpireTest.php b/tests/src/Functional/UserExpireTest.php
index fb5180d8bc697603e46a4cf8debba8f07ef7552c..6bc1bb618ebfad3726fb0e0d5163f21aabbae3d1 100644
index c746350f47259d17d458e4cfdee81e541ea55062..b427dfee1793e26094154573375f66927b56e7be 100644
--- a/tests/src/Functional/UserExpireTest.php
+++ b/tests/src/Functional/UserExpireTest.php
@@ -161,6 +161,18 @@ class UserExpireTest extends BrowserTestBase {
@@ -167,6 +167,18 @@ class UserExpireTest extends BrowserTestBase {
// Ensure they are disabled.
$this->drupalGet("user/" . $new_basic_account->id() . "/edit");
$this->assertSession()->responseContains('type="radio" id="edit-status-0" name="status" value="0" checked="checked" class="form-radio"', $this->t('User account is currently disabled.'));
+
+ // Manually unblock the user.
+ $edit = [];
+ $edit['status'] = 1;
+ $this->drupalPostForm("user/" . $new_basic_account->id() . "/edit", $edit, $this->t('Save'));
+ $this->submitForm($edit, $this->t('Save'));
+
+ // Process it.
+ user_expire_expire_by_role();
Expand All @@ -22,18 +22,18 @@ index fb5180d8bc697603e46a4cf8debba8f07ef7552c..6bc1bb618ebfad3726fb0e0d5163f21a

}
diff --git a/user_expire.module b/user_expire.module
index cb2958708e8063270d4765ec999009ea51f81ee9..9d7e157fbd908763521551237a7e2cc8d9a4abad 100644
index d4dcd8ba28b51ee8f54a7626d8b10443244520d9..fae1de17d4bb1b0a1a3819446c65817daaccf424 100644
--- a/user_expire.module
+++ b/user_expire.module
@@ -9,6 +9,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Datetime\DrupalDateTime;
@@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
+use Drupal\user\Entity\User;
use Drupal\user\RoleInterface;
use Drupal\Core\Url;
use Drupal\Core\Routing\RouteMatchInterface;
@@ -462,3 +463,15 @@ function user_expire_mail($key, &$message, $params) {

/**
@@ -456,3 +457,15 @@ function user_expire_mail($key, &$message, $params): void {
$message['body'][] = t('Thanks, @site_name', ['@site_name' => $site_name]);
}
}
Expand Down
24 changes: 5 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,7 @@
}
}
},
{
"type": "package",
"package": {
"name": "unocha/common_design",
"version": "9.2.2",
"type": "drupal-theme",
"dist": {
"url": "https://github.com/UN-OCHA/common_design/archive/refs/tags/v9.2.2.zip",
"type": "zip"
}
}
},
{
{
"type": "package",
"package": {
"name": "drupaloverride/condition_query",
Expand Down Expand Up @@ -121,8 +109,6 @@
"drupal/aws": "dev-2.0.x",
"drupal/back_to_top": "^3.0",
"drupal/block_class": "^2.0",
"drupal/bootstrap": "^3.23",
"drupal/bootstrap_barrio": "^5.5",
"drupal/ckeditor_config": "^3.1",
"drupal/ckeditor_font": "^1.2",
"drupal/ckeditor_iframe": "^2.1",
Expand All @@ -141,7 +127,6 @@
"drupal/csp": "^1.16",
"drupal/ctools": "^4.0",
"drupal/ds": "^3.13",
"drupal/dxpr_theme": "^1.2",
"drupal/entity_browser": "^2.6",
"drupal/environment_indicator": "^4.0",
"drupal/features": "^3.12",
Expand Down Expand Up @@ -175,12 +160,13 @@
"drupal/rdf": "^2.0",
"drupal/redirect": "^1.6",
"drupal/search_api": "^1.28",
"drupal/seckit": "^2.0",
"drupal/semanticviews": "^3.0",
"drupal/social_auth": "^3.0",
"drupal/social_auth_hid": "^3.2",
"drupal/social_auth_roles": "^1.4",
"drupal/social_auth_roles": "^2",
"drupal/stable": "^2.0",
"drupal/stage_file_proxy": "^2.1",
"drupal/stage_file_proxy": "^3",
"drupal/superfish": "^1.6",
"drupal/tb_megamenu": "^3.0@alpha",
"drupal/token": "^1.9",
Expand All @@ -197,7 +183,7 @@
"drush/drush": "^12",
"oomphinc/composer-installers-extender": "^2.0",
"symfony/flex": "^1.17",
"unocha/common_design": "^9.2",
"unocha/common_design": "9.2.6",
"unocha/gtm_barebones": "^1.0",
"unocha/ocha_monitoring": "^1.0",
"unocha/ocha_snap": "^8.3.0",
Expand Down
Loading

0 comments on commit f0f2754

Please sign in to comment.