Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOOP-907: Alerts #219

Merged
merged 7 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/sync/config_ignore.settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ignored_config_entities:
- os2loop.settings
- os2loop_analytics.settings
- os2loop_alert.settings
- os2loop_cookies.settings
- os2loop_documents.settings
- os2loop_flag_content.settings
Expand Down
1 change: 1 addition & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module:
node: 0
openid_connect: 0
options: 0
os2loop_alert: 0
os2loop_analytics: 0
os2loop_cookie_information: 0
os2loop_cookies: 0
Expand Down
8 changes: 8 additions & 0 deletions config/sync/os2loop_alert.settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_types:
os2loop_post: os2loop_post
os2loop_documents_collection: 0
os2loop_documents_document: 0
os2loop_external: 0
os2loop_page: 0
os2loop_question: 0
os2loop_section_page: 0
1 change: 1 addition & 0 deletions config/sync/user.role.os2loop_user_administrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ permissions:
- 'oauth authorize any consumers'
- 'oauth register any consumers'
- 'opt-in or out of tracking'
- 'os2loop send alert'
- 'publish any os2loop_documents_collection content'
- 'publish any os2loop_documents_document content'
- 'revert all revisions'
Expand Down
1 change: 1 addition & 0 deletions config/sync/user.role.os2loop_user_document_author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ permissions:
- 'download any image files'
- 'edit own os2loop_documents_document content'
- 'flag os2loop_upvote_correct_answer'
- 'os2loop send alert'
- 'unflag os2loop_upvote_correct_answer'
- 'update any media'
- 'use media wysiwyg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ permissions:
- 'edit own os2loop_documents_document content'
- 'flag os2loop_upvote_correct_answer'
- 'menu view unpublished'
- 'os2loop send alert'
- 'publish any os2loop_documents_collection content'
- 'publish any os2loop_documents_document content'
- 'set revision date for content'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ permissions:
- 'edit any os2loop_question content'
- 'edit terms in os2loop_tag'
- 'flag os2loop_upvote_correct_answer'
- 'os2loop send alert'
- 'revert revisions'
- 'set revision date for content'
- 'unflag os2loop_upvote_correct_answer'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ permissions:
- 'delete own os2loop_external content'
- 'edit any os2loop_external content'
- 'edit own os2loop_external content'
- 'os2loop send alert'
- 'use text format os2loop_external'
- 'view admin path'
- 'view os2loop_external revisions'
Expand Down
1 change: 1 addition & 0 deletions config/sync/user.role.os2loop_user_post_author.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
- 'edit any os2loop_post content'
- 'edit own os2loop_post content'
- 'flag os2loop_upvote_correct_answer'
- 'os2loop send alert'
- 'revert os2loop_post revisions'
- 'unflag os2loop_upvote_correct_answer'
- 'update any media'
Expand Down
11 changes: 11 additions & 0 deletions web/profiles/custom/os2loop/modules/os2loop_alert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OS2Loop Alert

Send out mails alerts on important content to all users or users subscribed to
the subject of the content.

The alert mail is sent to the user sending the notification with [Blind carbon
copy (Bcc)](https://en.wikipedia.org/wiki/Blind_carbon_copy) to the users.

## Configuration

Enable for content types on `/admin/config/os2loop/os2loop_alert/settings`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'os2loop_alert'
type: module
description: 'OS2Loop Alert'
core_version_requirement: ^9
package: 'OS2Loop'

dependencies:
- drupal:os2loop_subscriptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
os2loop_alert.settings:
title: 'OS2Loop alert settings'
route_name: os2loop_alert.settings
description: 'Configure OS2Loop alert settings'
parent: os2loop.group.admin
weight: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* @file
* Contains os2loop_alert.module.
*/

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\os2loop_alert\Helper\Helper;

/**
* Implements hook_help().
*/
function os2loop_alert_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the os2loop_alert module.
case 'help.page.os2loop_alert':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('OS2Loop Alert') . '</p>';
return $output;

default:
}
}

/**
* Implements hook_mail().
*
* @see \Drupal\os2loop_alert\Helper\Helper::mail()
*/
function os2loop_alert_mail($key, &$message, $params) {
return Drupal::service(Helper::class)->mail($key, $message, $params);
}

/**
* Implements hook_mail_alter().
*
* @see \Drupal\os2loop_alert\Helper\Helper::alterMail()
*/
function os2loop_alert_mail_alter(&$message) {
return Drupal::service(Helper::class)->alterMail($message);
}

/**
* Implements hook_os2loop_settings_is_granted().
*
* @see \Drupal\os2loop_alert\Helper\Helper::isGranted()
*/
function os2loop_alert_os2loop_settings_is_granted(string $attribute, $object = NULL) {
return Drupal::service(Helper::class)->isGranted($attribute, $object);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'os2loop send alert':
title: 'Send out alerts'
description: 'Send out alerts on content.'
restrict access: TRUE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
os2loop_alert.settings:
path: '/admin/config/os2loop/os2loop_alert/settings'
defaults:
_form: '\Drupal\os2loop_alert\Form\SettingsForm'
_title: 'OS2Loop alert settings'
requirements:
_permission: 'administer os2loop settings'

os2loop_alert.alert_form:
path: '/os2loop_alert/alert/node/{node}'
defaults:
_title: 'Alert form'
_title_callback: 'Drupal\os2loop_alert\Form\AlertForm::getTitle'
_form: 'Drupal\os2loop_alert\Form\AlertForm'
requirements:
_permission: 'os2loop send alert'
options:
parameters:
node:
type: entity:node
_admin_route: TRUE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
Drupal\os2loop_alert\Helper\Helper:
arguments:
- '@Drupal\os2loop_settings\Settings'
- '@database'
- '@plugin.manager.mail'
- '@language_manager'
- '@token'
- '@os2loop_subscriptions.helper'
- '@current_user'
Loading