Permalink
Browse files

MDL-29538 core_condition: cached result in usercondition array now st…

…ores all attributes
  • Loading branch information...
markn86 committed May 10, 2012
1 parent a6b538a commit 129e4a73ecc0524693703678a766237d47d13119
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/conditionlib.php
View
@@ -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;
}
/**
@@ -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;
}

0 comments on commit 129e4a7

Please sign in to comment.