You are here

function course_install in Course 7.2

Same name and namespace in other branches
  1. 8.3 course.install \course_install()
  2. 8.2 course.install \course_install()
  3. 6 course.install \course_install()
  4. 7 course.install \course_install()
  5. 3.x course.install \course_install()

Implements hook_install().

Install a default content type, set some defaults.

File

./course.install, line 13
course.install Install and update functions for Courses.

Code

function course_install() {
  module_load_include('module', 'node', 'node');
  $type = array(
    'type' => 'course',
    'name' => 'Course',
    'module' => 'node',
    'has_title' => 1,
    'title_label' => 'Title',
    'has_body' => 1,
    'body_label' => 'Description',
    'description' => 'A <em>course</em> containing Drupal learning objects.',
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
    'help' => '',
    'min_word_count' => '',
    'base' => 'node_content',
  );
  $type = (object) node_type_set_defaults($type);
  node_type_save($type);
  node_types_rebuild();
  menu_rebuild();
  variable_set('course_use_course', 1);
  $enrollment_type = entity_create('course_enrollment_type', array(
    'type' => 'course_enrollment',
    'label' => t('Course'),
  ));
  $enrollment_type
    ->save();
  variable_set('course_default_enrollment_type', 'course_enrollment');
  user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array(
    'access course',
  ));
}