예제 #1
0
 public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
 {
     if ($source_field && $source_field["type"] == "post_category") {
         $field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
     }
     if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
         //convert the comma-delimited string into an array
         $field_value = explode(",", $field_value);
     }
     if (is_array($field_value)) {
         $field_value = array_values($field_value);
         //returning array values, ignoring keys if array is associative
         $match_count = 0;
         foreach ($field_value as $val) {
             if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
                 $match_count++;
             }
         }
         //If operation is Is Not, none of the values in the array can match the target value.
         return $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
     } else {
         if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
             return true;
         }
     }
     return false;
 }
 public static function is_value_match($field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null)
 {
     $is_match = false;
     if ($source_field && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'post_category') {
         $field_value = GFCommon::prepare_post_category_value($field_value, $source_field, 'conditional_logic');
     }
     if (!empty($field_value) && !is_array($field_value) && is_subclass_of($source_field, 'GF_Field') && $source_field->type == 'multiselect') {
         $field_value = explode(',', $field_value);
     }
     // convert the comma-delimited string into an array
     $form_id = $source_field instanceof GF_Field ? $source_field->formId : 0;
     $target_value = GFFormsModel::maybe_trim_input($target_value, $form_id, $source_field);
     if (is_array($field_value)) {
         $field_value = array_values($field_value);
         //returning array values, ignoring keys if array is associative
         $match_count = 0;
         foreach ($field_value as $val) {
             $val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, 'formId'), $source_field);
             if (self::matches_operation($val, $target_value, $operation)) {
                 $match_count++;
             }
         }
         // if operation is Is Not, none of the values in the array can match the target value.
         $is_match = $operation == 'isnot' ? $match_count == count($field_value) : $match_count > 0;
     } else {
         if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), $form_id, $source_field), $target_value, $operation)) {
             $is_match = true;
         }
     }
     return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
 }
예제 #3
0
 public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null, $rule = null)
 {
     $is_match = false;
     if ($source_field && $source_field["type"] == "post_category") {
         $field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
     }
     if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
         $field_value = explode(",", $field_value);
     }
     // convert the comma-delimited string into an array
     $target_value = GFFormsModel::maybe_trim_input($target_value, rgar($source_field, "formId"), $source_field);
     if (is_array($field_value)) {
         $field_value = array_values($field_value);
         //returning array values, ignoring keys if array is associative
         $match_count = 0;
         foreach ($field_value as $val) {
             $val = GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($val), rgar($source_field, "formId"), $source_field);
             if (self::matches_operation($val, $target_value, $operation)) {
                 $match_count++;
             }
         }
         // if operation is Is Not, none of the values in the array can match the target value.
         $is_match = $operation == "isnot" ? $match_count == count($field_value) : $match_count > 0;
     } else {
         if (self::matches_operation(GFFormsModel::maybe_trim_input(GFCommon::get_selection_value($field_value), rgar($source_field, "formId"), $source_field), $target_value, $operation)) {
             $is_match = true;
         }
     }
     return apply_filters('gform_is_value_match', $is_match, $field_value, $target_value, $operation, $source_field, $rule);
 }
예제 #4
0
 /**
  * Maybe update user role of the specified lead and feed
  *
  * @param array $lead
  * @param Feed $feed
  */
 private function maybe_update_user_role($lead, $feed)
 {
     $user = false;
     // Gravity Forms User Registration Add-On
     if (class_exists('GFUserData')) {
         $user = GFUserData::get_user_by_entry_id($lead['id']);
     }
     if (false === $user) {
         $created_by = $lead[Pronamic_WP_Pay_Extensions_GravityForms_LeadProperties::CREATED_BY];
         $user = new WP_User($created_by);
     }
     if ($user && !empty($feed->user_role_field_id) && isset($lead[$feed->user_role_field_id])) {
         $value = $lead[$feed->user_role_field_id];
         $value = GFCommon::get_selection_value($value);
         $user->set_role($value);
     }
 }
예제 #5
0
 public static function is_value_match($field_value, $target_value)
 {
     if (is_array($field_value)) {
         foreach ($field_value as $val) {
             if (GFCommon::get_selection_value($val) == $target_value) {
                 return true;
             }
         }
     } else {
         if (GFCommon::get_selection_value($field_value) == $target_value) {
             return true;
         }
     }
     return false;
 }
 public static function is_value_match($field_value, $target_value, $operation = "is", $source_field = null)
 {
     if ($source_field && $source_field["type"] == "post_category") {
         $field_value = GFCommon::prepare_post_category_value($field_value, $source_field, "conditional_logic");
     }
     if (!empty($field_value) && !is_array($field_value) && $source_field["type"] == "multiselect") {
         //convert the comma-delimited string into an array
         $field_value = explode(",", $field_value);
     }
     if (is_array($field_value)) {
         foreach ($field_value as $val) {
             if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
                 return true;
             }
         }
     } else {
         if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
             return true;
         }
     }
     return false;
 }
예제 #7
0
 public static function is_value_match($field_value, $target_value, $operation = "is")
 {
     if (is_array($field_value)) {
         foreach ($field_value as $val) {
             if (self::matches_operation(GFCommon::get_selection_value($val), $target_value, $operation)) {
                 return true;
             }
         }
     } else {
         if (self::matches_operation(GFCommon::get_selection_value($field_value), $target_value, $operation)) {
             return true;
         }
     }
     return false;
 }