function CourseObjectNode::save in Course 7
Same name and namespace in other branches
- 6 includes/course_object.core.inc \CourseObjectNode::save()
- 7.2 includes/CourseObjectNode.inc \CourseObjectNode::save()
On object write, set privacy on this node.
Overrides CourseObject::save
1 call to CourseObjectNode::save()
- CourseObjectBook::save in modules/
course_book/ course_book.classes.inc - Override of CourseObjectNode::save()
1 method overrides CourseObjectNode::save()
- CourseObjectBook::save in modules/
course_book/ course_book.classes.inc - Override of CourseObjectNode::save()
File
- includes/
CourseObjectNode.inc, line 328
Class
- CourseObjectNode
- A course object that uses a node as a base.
Code
function save() {
if ($this
->getOption('clone_and_reference')) {
module_load_include('inc', 'clone', 'clone.pages');
$new_nid = clone_node_save($this
->getOption('instance'));
$this
->setInstanceId($new_nid);
$this
->setOption('clone_and_reference', 0);
}
parent::save();
$privacy_enabled = $this
->hasNodePrivacySupport() && $this
->getOption('private');
$external_node = $this
->getInstanceId() > 0 && $this
->getInstanceId() != $this
->getCourseNid();
if ($privacy_enabled && $external_node) {
// Ensure that per-node access is enabled.
$type_settings = content_access_get_settings('all', $this->node->type);
$type_settings['per_node'] = 1;
content_access_set_settings($type_settings, $this->node->type);
// Remove "view" permissions to everyone on this node.
$settings = content_access_get_per_node_settings($this->node);
$grant_roles = array_filter(variable_get('course_object_private_roles', array()));
$settings['view'] = $grant_roles;
content_access_save_per_node_settings($this->node, $settings);
// Resave node to update access.
node_access_acquire_grants($this->node);
}
}