You are here

public function CourseObjectNode::optionsForm in Course 6

Same name and namespace in other branches
  1. 7.2 includes/CourseObjectNode.inc \CourseObjectNode::optionsForm()
  2. 7 includes/CourseObjectNode.inc \CourseObjectNode::optionsForm()

Default options form for all course objects.

Overrides CourseObject::optionsForm

5 calls to CourseObjectNode::optionsForm()
CourseObjectBook::optionsForm in modules/course_book/course_book.classes.inc
Default options form for all course objects.
CourseObjectContent::optionsForm in modules/course_content/course_content.classes.inc
Set the default content type to be created.
CourseObjectQuiz::optionsForm in modules/course_quiz/course_quiz.classes.inc
Add an option only pertinent to quiz?
CourseObjectSignup::optionsForm in modules/course_signup/course_signup.classes.inc
Default options form for all course objects.
CourseObjectUbercart::optionsForm in modules/course_uc/course_uc.classes.inc
Default options form for all course objects.
5 methods override CourseObjectNode::optionsForm()
CourseObjectBook::optionsForm in modules/course_book/course_book.classes.inc
Default options form for all course objects.
CourseObjectContent::optionsForm in modules/course_content/course_content.classes.inc
Set the default content type to be created.
CourseObjectQuiz::optionsForm in modules/course_quiz/course_quiz.classes.inc
Add an option only pertinent to quiz?
CourseObjectSignup::optionsForm in modules/course_signup/course_signup.classes.inc
Default options form for all course objects.
CourseObjectUbercart::optionsForm in modules/course_uc/course_uc.classes.inc
Default options form for all course objects.

File

includes/course_object.core.inc, line 1148

Class

CourseObjectNode
A course object that uses a node as a base.

Code

public function optionsForm(&$form, &$form_state) {
  parent::optionsForm($form, $form_state);
  $config = $this
    ->getOptions();
  if (!$this
    ->getInstanceId()) {
    $types = drupal_map_assoc($this
      ->getNodeTypes());
    $options = array_intersect_key(node_get_types('names'), $types);
    if (count($options) > 1) {
      array_unshift($options, '- select -');
    }
    $form['node_type'] = array(
      '#title' => 'Create node',
      '#type' => 'select',
      '#options' => $options,
      '#description' => 'Selecting a node type will automatically create this node and link it to this course object.',
      '#default_value' => $config['node_type'],
    );
    if (count($options) > 1) {
      $form['node_type']['#required'] = TRUE;
    }
  }
  $form['node'] = array(
    '#type' => 'fieldset',
    '#title' => 'Node',
    '#description' => 'Settings for node-based objects.',
  );
  $form['node']['instance'] = array(
    '#title' => 'Existing node',
    '#autocomplete_path' => 'course/autocomplete/node/' . implode(',', $this
      ->getNodeTypes()),
    '#type' => 'textfield',
    '#description' => t('Use an existing node instead of creating a new one.'),
  );
  $form['node']['private'] = array(
    '#title' => t('Private'),
    '#description' => $this
      ->hasNodePrivacySupport() ? t('This content will not be available to users who are not enrolled in this course.') : t('You must enable content_access and acl in order to restrict course content to users who are enrolled in this course.'),
    '#type' => 'checkbox',
    '#default_value' => $config['private'],
    '#disabled' => !$this
      ->hasNodePrivacySupport(),
  );
  $nid = $this
    ->getInstanceId();
  if ($nid) {
    $node = node_load($nid);
    $link = l(t("'%title' [node id %nid]", array(
      '%title' => $node->title,
      '%nid' => $node->nid,
    )), "node/{$node->nid}", array(
      'attributes' => array(
        'target' => '_blank',
        'title' => t('Open in new window'),
      ),
      'html' => TRUE,
    ));
    $form['node']['instance']['#description'] = t('Currently set to !link', array(
      '!link' => $link,
    ));
  }
}