public function CourseObject::optionsSubmit in Course 6
Same name and namespace in other branches
- 7.2 includes/CourseObject.inc \CourseObject::optionsSubmit()
- 7 includes/CourseObject.inc \CourseObject::optionsSubmit()
Save object configs to cache.
Overrides CourseHandler::optionsSubmit
1 call to CourseObject::optionsSubmit()
- CourseObjectNode::optionsSubmit in includes/
course_object.core.inc - Save object configs to cache.
1 method overrides CourseObject::optionsSubmit()
- CourseObjectNode::optionsSubmit in includes/
course_object.core.inc - Save object configs to cache.
File
- includes/
course_object.core.inc, line 367
Class
- CourseObject
- Parent abstract base class of all course objects.
Code
public function optionsSubmit(&$form, &$form_state) {
ctools_include('plugins');
$uniqid = $this
->getId();
$nid = $this
->getCourseNid();
// Flip 'visible' so it behaves like 'hidden'.
$form_state['values']['hidden'] = $form_state['values']['hidden'] != 1;
// Object-specific settings
foreach (array_keys($this
->getOptions()) as $key) {
if (!is_null($form_state['values'][$key])) {
$_SESSION['course'][$nid]['editing'][$uniqid][$key] = $form_state['values'][$key];
}
}
// Save plugin info.
foreach (ctools_get_plugins('course', 'access') as $key => $plugin) {
$_SESSION['course'][$nid]['editing'][$uniqid]['plugins']['access'][$key] = $form_state['values']['plugins']['access'][$key];
}
// Update the options.
$this
->setOptions($_SESSION['course'][$nid]['editing'][$uniqid]);
// Perform ajax operations on the overview form, before overview submission.
if ($form_state['ajax']) {
$commands = array();
// Set title.
$title = '<div id="title-' . $uniqid . '">' . $form_state['values']['title'] . '</div>';
$commands[] = ctools_ajax_command_replace("#title-{$uniqid}", $title);
// Set summary.
$html = '<div id="summary-' . $uniqid . '">' . $this
->renderOptionsSummary() . '</div>';
$commands[] = ctools_ajax_command_replace("#summary-{$uniqid}", $html);
// Deletion handling.
if ($form_state['values']['delete']) {
// Add `deleted` class to the row. An admin stylesheet is loaded from
// theme_course_outline_overview_form().
$commands[] = ctools_ajax_command_attr("#row-{$uniqid}", 'class', 'deleted');
}
$commands[] = ctools_modal_command_dismiss();
ctools_ajax_render($commands);
}
}