/** * Takes the default query parameters, and traverses them, adding the model relation chain * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND) * @param array $where_conditions * @param string $model_relation_chain * @return array * @throws \EE_Error */ public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) { $where_conditions_with_model_relation_chain_prefixes = array(); if (!is_array($where_conditions)) { $where_conditions = array(); } foreach ($where_conditions as $key => $value) { if (in_array($key, array('OR', 'AND', 'NOT')) || strpos($key, 'OR*') !== false || strpos($key, 'AND*') !== false || strpos($key, 'NOT*') !== false) { $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying($value, $model_relation_chain); } else { if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') { $model_relation_chain = $model_relation_chain . "."; } //check for the current user id place holder, and if present change it if ($value === self::current_user_placeholder) { $value = get_current_user_id(); } //check for user field placeholder if ($key == self::user_field_name_placeholder) { if (!$this->_model->wp_user_field_name()) { throw new EE_Error(sprintf(__('There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso'), $this->_model->get_this_model_name())); } $key = $this->_model->wp_user_field_name(); } $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain . $key] = $value; } } return $where_conditions_with_model_relation_chain_prefixes; }