You are here

course.install in Course 3.x

course.install Install and update functions for Courses.

File

course.install
View source
<?php

use Drupal\Core\Database\Database;
use Drupal\Core\Session\AccountInterface;

/**
 * @file course.install
 * Install and update functions for Courses.
 */

/**
 * Implements hook_install().
 *
 * Add default permissions to authenticated users.
 */
function course_install() {
  user_role_grant_permissions(AccountInterface::AUTHENTICATED_ROLE, array(
    'view any course',
    'take course',
    'enroll course',
  ));
  user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, array(
    'view any course',
  ));
}

/**
 * Add unique indexes.
 */
function course_update_8001() {
  $schema = Database::getConnection()
    ->schema();
  $schema
    ->addUniqueKey('course_enrollment', 'cid_uid', [
    'cid',
    'uid',
  ]);
  $schema
    ->addUniqueKey('course_object_fulfillment', 'coid_uid', [
    'coid',
    'uid',
  ]);
  return t('Added unique indexes.');
}

Functions

Namesort descending Description
course_install Implements hook_install().
course_update_8001 Add unique indexes.