Skip to content

Commit

Permalink
MDL-29538 core_condition: cached result in usercondition array now st…
Browse files Browse the repository at this point in the history
…ores all attributes
  • Loading branch information
mdjnelson committed Jun 26, 2012
1 parent a6b538a commit 129e4a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/conditionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,20 @@ public function add_user_field_condition($field, $operator, $value) {
$objavailfield = new stdClass;
$objavailfield->coursemoduleid = $this->cm->id;
if (is_numeric($field)) { // If the condition field is numeric then it is a custom profile field
// Need to get the field name so we can add it to the cache
$ufield = $DB->get_field('user_info_field', 'name', array('id' => $field));
$objavailfield->fieldname = $ufield;
$objavailfield->customfieldid = $field;
} else {
$objavailfield->fieldname = $field;
$objavailfield->userfield = $field;
}
$objavailfield->operator = $operator;
$objavailfield->value = $value;
$DB->insert_record('course_modules_avail_fields', $objavailfield, false);

// Store in memory too
$this->cm->conditionsfield[$field] = (object)array(
'field'=>$field,'operator'=>$operator,'value'=>$value);
$this->cm->conditionsfield[$field] = $objavailfield;
}

/**
Expand Down Expand Up @@ -1234,7 +1237,7 @@ private function get_cached_user_profile_field($userid, $fieldid, $grabthelot) {
if ($userid == 0 || $userid == $USER->id) {
if ($iscustomprofilefield) {
// For current user, go via cache in session
if (empty($SESSION->userfieldcache) || $SESSION->userfieldcacheuserid!=$USER->id) {
if (empty($SESSION->userfieldcache) || $SESSION->userfieldcacheuserid != $USER->id) {
$SESSION->userfieldcache = array();
$SESSION->userfieldcacheuserid = $USER->id;
}
Expand Down

0 comments on commit 129e4a7

Please sign in to comment.