You are here

function CourseObjectNode::save in Course 6

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

On object write, set privacy on this node.

Overrides CourseObject::save

File

includes/course_object.core.inc, line 1279

Class

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

Code

function save() {
  parent::save();
  if ($this
    ->hasNodePrivacySupport() && $this
    ->getOption('private')) {

    // Ensure that per-node access is enabled.
    $global_settings = content_access_get_settings();
    $global_settings['per_node'][$this->node->type] = 1;
    content_access_set_settings($global_settings);

    // Remove "view" permissions to everyone on this node.
    $settings = content_access_get_per_node_settings($this->node);
    $settings['view'] = array();
    content_access_save_per_node_settings($this->node, $settings);

    // Resave node to update access.
    node_save($this->node);
  }
}