activity_send_email.install in Open Social 10.1.x
Same filename and directory in other branches
- 8.9 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.2 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.3 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.4 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.5 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.6 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.7 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 8.8 modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 10.3.x modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 10.0.x modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
- 10.2.x modules/custom/activity_send/modules/activity_send_email/activity_send_email.install
Install, update and uninstall functions for the activity_send_email module.
File
modules/custom/activity_send/modules/activity_send_email/activity_send_email.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the activity_send_email module.
*/
use Drupal\Core\Database\Database;
/**
* Implements hook_uninstall().
*
* Removes keys from the State API.
*/
function activity_send_email_uninstall() {
// Get plugins and their intervals.
$emailfrequencymanager = \Drupal::service('plugin.manager.emailfrequency');
$plugins = $emailfrequencymanager
->getDefinitions();
// Remove all cron last run times from the State API.
foreach ($plugins as $frequency) {
\Drupal::state()
->delete('digest.' . $frequency['id'] . '.last_run');
}
}
/**
* Implements hook_schema().
*/
function activity_send_email_schema() {
$schema['user_activity_digest'] = [
'fields' => [
'uid' => [
'description' => 'The {user}.uid of the target user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'activity' => [
'description' => 'The {activity}.id.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'frequency' => [
'description' => 'The frequency for this activity. It should match the EmailFrequency plugin id.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
'timestamp' => [
'description' => 'The timestamp of when this item was inserted.',
'type' => 'int',
'length' => 11,
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
],
],
'indexes' => [
'uad_uid' => [
'uid',
],
'uad_frequency' => [
'frequency',
],
],
];
return $schema;
}
/**
* Add new database tables to store digest activities and digest timings in.
*/
function activity_send_email_update_8001() {
// Get the full spec for the new table.
$spec['user_activity_digest'] = [
'fields' => [
'uid' => [
'description' => 'The {user}.uid of the target user.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'activity' => [
'description' => 'The {activity}.id.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],
'frequency' => [
'description' => 'The frequency for this activity. It should match the EmailFrequency plugin id.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
'timestamp' => [
'description' => 'The timestamp of when this item was inserted.',
'type' => 'int',
'length' => 11,
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
],
],
'indexes' => [
'uad_uid' => [
'uid',
],
'uad_frequency' => [
'frequency',
],
],
];
// Add the two tables.
$schema = Database::getConnection()
->schema();
$schema
->createTable('user_activity_digest', $spec['user_activity_digest']);
}
Functions
Name | Description |
---|---|
activity_send_email_schema | Implements hook_schema(). |
activity_send_email_uninstall | Implements hook_uninstall(). |
activity_send_email_update_8001 | Add new database tables to store digest activities and digest timings in. |