You are here

function quiz_update_defaults in Quiz 7.6

Same name and namespace in other branches
  1. 8.6 quiz.module \quiz_update_defaults()
  2. 8.5 quiz.module \quiz_update_defaults()
  3. 7.5 quiz.module \quiz_update_defaults()
3 calls to quiz_update_defaults()
quiz_admin_node_form_submit in ./quiz.admin.inc
Submit function for quiz_admin_node_form
quiz_insert in ./quiz.module
Implements hook_insert().
quiz_update in ./quiz.module
Implements hook_update().

File

./quiz.module, line 637
quiz.module Main file for the Quiz module.

Code

function quiz_update_defaults($node) {
  global $user;
  $entity = clone $node;
  $entity->aid = !empty($entity->aid) ? $entity->aid : 0;
  $entity->summary_pass = is_array($node->summary_pass) ? $node->summary_pass['value'] : $node->summary_pass;
  $entity->summary_pass_format = is_array($node->summary_pass) ? $node->summary_pass['format'] : $node->summary_pass_format;
  $entity->summary_default = is_array($node->summary_default) ? $node->summary_default['value'] : $node->summary_default;
  $entity->summary_default_format = is_array($node->summary_default) ? $node->summary_default['format'] : $node->summary_default_format;
  $entity->tid = isset($entity->tid) ? $entity->tid : 0;

  // Save the node values.
  $quiz_props = clone $entity;
  $quiz_props->uid = 0;
  quiz_save_properties($quiz_props);
  if (!empty($node->remember_settings)) {

    // Save user defaults.
    $user_defaults = clone $quiz_props;
    $user_defaults->nid = 0;
    $user_defaults->vid = 0;
    $user_defaults->uid = $user->uid;
    quiz_save_properties($user_defaults);
  }
  if (!empty($node->remember_global)) {

    // Save global defaults.
    $global_defaults = clone $quiz_props;
    $global_defaults->uid = 0;
    $global_defaults->nid = 0;
    $global_defaults->vid = 0;
    quiz_save_properties($global_defaults);
  }
}