diff --git a/classes/booking_campaigns/campaigns/campaign_blockbooking.php b/classes/booking_campaigns/campaigns/campaign_blockbooking.php index 4f9a204ca..c0ee8bcad 100644 --- a/classes/booking_campaigns/campaigns/campaign_blockbooking.php +++ b/classes/booking_campaigns/campaigns/campaign_blockbooking.php @@ -350,22 +350,23 @@ public function is_blocking(booking_option_settings $settings, int $userid): arr // If there is a value, it has to match in order to block. $blocking = false; $operator = $this->cpoperator; - $operator = $this->cpvalue; // TODO Handle other types of fields like arrays. - if (is_string($user->profile->$fieldname)) { + if (is_string($user->profile[$fieldname])) { switch ($operator) { case "=": // Equals. - $blocking = $user->profile->$fieldname === $this->cpvalue; + $blocking = $user->profile[$fieldname] === $this->cpvalue; + break; case "~": // Contains. - $blocking = strpos($user->profile->$fieldname, $this->cpvalue) !== false; + $blocking = strpos($user->profile[$fieldname], $this->cpvalue) !== false; + break; } } } if ($blocking) { return [ 'status' => true, - 'label' => $this->blockinglabel, + 'label' => format_string($this->blockinglabel), ]; } return [ diff --git a/classes/booking_campaigns/campaigns_info.php b/classes/booking_campaigns/campaigns_info.php index 32bff52f1..09db1e9b0 100644 --- a/classes/booking_campaigns/campaigns_info.php +++ b/classes/booking_campaigns/campaigns_info.php @@ -61,8 +61,7 @@ public static function add_campaigns_to_mform(MoodleQuickForm &$mform, $campaigns = self::get_campaigns(); $campaignsforselect = []; - // phpcs:ignore Squiz.PHP.CommentedOutCode.Found - /* $campaignsforselect['0'] = get_string('choose...', 'mod_booking'); */ + $campaignsforselect['0'] = get_string('choose...', 'mod_booking'); foreach ($campaigns as $campaign) { $fullclassname = get_class($campaign); // With namespace. $classnameparts = explode('\\', $fullclassname); diff --git a/classes/singleton_service.php b/classes/singleton_service.php index 2b4290dcc..31aba8a01 100644 --- a/classes/singleton_service.php +++ b/classes/singleton_service.php @@ -380,22 +380,25 @@ public static function get_instance_of_booking_option_settings($optionid, ?stdCl * Service to create and return singleton instance of Moodle user. * * @param int $userid + * @param bool $includeprofilefields * * @return stdClass */ public static function get_instance_of_user(int $userid, bool $includeprofilefields = false) { + global $CFG; $instance = self::get_instance(); if (isset($instance->users[$userid])) { if ($includeprofilefields && !isset($instance->users[$userid]->profile)) { - $customfields = profile_user_record($userid); - $instance->users[$userid]->profile = $customfields; + require_once("{$CFG->dirroot}/user/profile/lib.php"); + profile_load_custom_fields($instance->users[$userid]); } return $instance->users[$userid]; } else { $user = core_user::get_user($userid); if ($includeprofilefields) { - $user->profile = profile_user_record($userid); + require_once("{$CFG->dirroot}/user/profile/lib.php"); + profile_load_custom_fields($user); } $instance->users[$userid] = $user; return $user;