Skip to content

Commit

Permalink
Merge pull request #917 from UN-OCHA/develop
Browse files Browse the repository at this point in the history
Develop -> Main - v2.18.0
  • Loading branch information
orakili authored Oct 8, 2024
2 parents f057301 + 2ac2298 commit 7e6b55f
Show file tree
Hide file tree
Showing 37 changed files with 1,380 additions and 216 deletions.
342 changes: 171 additions & 171 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/seckit.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ seckit_xss:
style-src: "'self' 'unsafe-inline' https://googletagmanager.com https://tagmanager.google.com fonts.googleapis.com https://cdn.popupsmart.com"
img-src: "'self' data: https://*"
media-src: "'none'"
frame-src: "'self' https://www.googletagmanager.com https://bid.g.doubleclick.net https://td.doubleclick.net https://*.mapbox.com https://www.youtube.com https://youtu.be"
frame-src: "'self' https://www.googletagmanager.com https://bid.g.doubleclick.net https://td.doubleclick.net https://*.mapbox.com https://www.youtube.com https://youtu.be https://app.powerbi.com"
frame-ancestors: "'self'"
child-src: "'self' blob: https:"
font-src: "'self' data: fonts.gstatic.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ protected function parseApiData(array $data, $limit) {
*
* @todo Return creation date dimension and use to boost more recent reports.
*/
protected function buildPayload(FilterExpression $filter = NULL, int $limit) {
protected function buildPayload(?FilterExpression $filter = NULL, int $limit = 1000) {
$expressions = [
new FilterExpression([
'filter' => new Filter([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function reliefweb_disaster_map_get_disaster_type_tokens() {
* @return \Drupal\Component\Render\MarkupInterface|string
* The rendered disaster map HTML content to use as token replacement.
*/
function reliefweb_disaster_map_get_disaster_map_token_replacement($token, BubbleableMetadata $bubbleable_metadata = NULL, $render = TRUE) {
function reliefweb_disaster_map_get_disaster_map_token_replacement($token, ?BubbleableMetadata $bubbleable_metadata = NULL, $render = TRUE) {
$tokens = reliefweb_disaster_map_get_disaster_type_tokens();
$values = !empty($token) ? explode('-', strtoupper($token)) : [];
$options = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* Entity management for ReliefWeb.
*/

use Drupal\block\Entity\Block;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Entity\EntityFormInterface;
Expand All @@ -17,6 +16,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface;
use Drupal\block\Entity\Block;
use Drupal\media\MediaInterface;
use Drupal\reliefweb_entities\BundleEntityInterface;
use Drupal\reliefweb_entities\BundleEntityStorageInterface;
Expand Down
66 changes: 54 additions & 12 deletions html/modules/custom/reliefweb_entities/src/Entity/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class Report extends Node implements BundleEntityInterface, EntityModeratedInter
use EntityRevisionedTrait;
use StringTranslationTrait;

/**
* Store the emails for the publication notifications.
*
* @var ?array<string>
*/
protected ?array $publicationNotificationEmails = NULL;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -288,7 +295,7 @@ protected function preparePublicationNotification() {
}

// Store the emails to notify after the node is saved.
$this->_publication_notification_emails = $emails;
$this->setPublicationNotificationEmails($emails);

// Update the log message with the list of emails to notify.
$log_field = $this->getEntityType()
Expand All @@ -310,11 +317,11 @@ protected function preparePublicationNotification() {
* Notify of the publication.
*/
protected function sendPublicationNotification() {
if (empty($this->_publication_notification_emails)) {
if (!$this->hasPublicationNotificationEmails()) {
return;
}
$emails = $this->_publication_notification_emails;
unset($this->_publication_notification_emails);
$emails = $this->getPublicationNotificationEmails();
$this->resetPublicationNotificationEmails();

// Recipients and sender.
$to = implode(', ', $emails);
Expand All @@ -323,17 +330,15 @@ protected function sendPublicationNotification() {
return;
}

$message = ReliefWebStateHelper::getReportPublicationEmailMessage();
if (empty($message)) {
return;
}

// Subject and content.
$parameters = [];
$parameters['subject'] = 'ReliefWeb: Your submission has been published';
$parameters['content'] = strtr(implode("\n\n", [
"Thank you for your submission to ReliefWeb.",
"Your submission \"@title\" has been published with the following URL:",
"@url",
"Please respond to this email in case you have questions or corrections to your submission.",
"Best regards,",
"ReliefWeb team",
]), [
$parameters['content'] = strtr($message, [
'@title' => $this->label(),
'@url' => $this->toUrl('canonical', [
'absolute' => TRUE,
Expand All @@ -348,4 +353,41 @@ protected function sendPublicationNotification() {
->mail('reliefweb_entities', 'report_publication_notification', $to, $langcode, $parameters, $from, TRUE);
}

/**
* Temporarily store the email address to notify after publication.
*
* @param array $emails
* Emails to notify.
*/
protected function setPublicationNotificationEmails(array $emails): void {
$this->publicationNotificationEmails = $emails;
}

/**
* Get the email address to notify after publication.
*
* @return array
* Emails to notify.
*/
protected function getPublicationNotificationEmails(): array {
return $this->publicationNotificationEmails ?? [];
}

/**
* Check if there are email address to notify after publication.
*
* @return bool
* TRUE if there are emails to noify.
*/
protected function hasPublicationNotificationEmails(): bool {
return !empty($this->publicationNotificationEmails);
}

/**
* Remove set publication notification emails.
*/
protected function resetPublicationNotificationEmails(): void {
$this->publicationNotificationEmails = NULL;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(
ModuleHandlerInterface $module_handler,
AccountInterface $current_user,
EntityFieldManagerInterface $entity_field_manager,
EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL,
EntityTypeBundleInfoInterface $entity_type_bundle_info,
EntityRepositoryInterface $entity_repository,
Connection $database,
LanguageManagerInterface $language_manager,
Expand Down
Loading

0 comments on commit 7e6b55f

Please sign in to comment.