live_blog-1.0.4/live_blog.install
live_blog.install
<?php
use Drupal\user\RoleInterface;
/**
* Implements hook_schema().
*/
function live_blog_schema() {
$schema['live_blog_log'] = [
'description' => 'Live Blog logs',
'fields' => [
'lid' => [
'description' => 'Log ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'id' => [
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
'description' => 'The Live Blog entity ID of post was affected.',
],
'action' => [
'description' => 'Type of message: create/update/delete/published/unpublished.',
'type' => 'varchar',
'length' => 32,
],
'time' => [
'description' => 'The Unix timestamp of the event.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
],
],
'primary key' => ['lid'],
'indexes' => [
'id' => ['id'],
'time' => ['time'],
],
];
return $schema;
}
/**
* Implements hook_install().
*/
function live_blog_install() {
// Enable default permissions for system roles.
if (\Drupal::moduleHandler()->moduleExists('user')) {
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['view published live blog entities']);
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view published live blog entities']);
}
}
/**
* Implements hook_update_N().
*
* Enable default permissions for system roles.
*/
function live_blog_update_8001() {
if (\Drupal::moduleHandler()->moduleExists('user')) {
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['view published live blog entities']);
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view published live blog entities']);
}
}
