public static function action_conditions_met($action, $entry) { $notification = $action->post_content; $stop = false; $met = array(); if (!isset($notification['conditions']) || empty($notification['conditions'])) { return $stop; } foreach ($notification['conditions'] as $k => $condition) { if (!is_numeric($k)) { continue; } if ($stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop']) { continue; } if (is_array($condition['hide_opt'])) { $condition['hide_opt'] = reset($condition['hide_opt']); } $observed_value = isset($entry->metas[$condition['hide_field']]) ? $entry->metas[$condition['hide_field']] : ''; if ($condition['hide_opt'] == 'current_user') { $condition['hide_opt'] = get_current_user_id(); } $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); if ($notification['conditions']['send_stop'] == 'send') { $stop = $stop ? false : true; } $met[$stop] = $stop; } if ($notification['conditions']['any_all'] == 'all' && !empty($met) && isset($met[0]) && isset($met[1])) { $stop = $notification['conditions']['send_stop'] == 'send'; } else { if ($notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0])) { $stop = false; } } return $stop; }
public static function action_conditions_met($action, $entry) { $notification = $action->post_content; $stop = false; $met = array(); if (!isset($notification['conditions']) || empty($notification['conditions'])) { return $stop; } foreach ($notification['conditions'] as $k => $condition) { if (!is_numeric($k)) { continue; } if ($stop && 'any' == $notification['conditions']['any_all'] && 'stop' == $notification['conditions']['send_stop']) { continue; } self::prepare_logic_value($condition['hide_opt']); $observed_value = self::get_value_from_entry($entry, $condition['hide_field']); $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); if ($notification['conditions']['send_stop'] == 'send') { $stop = $stop ? false : true; } $met[$stop] = $stop; } if ($notification['conditions']['any_all'] == 'all' && !empty($met) && isset($met[0]) && isset($met[1])) { $stop = $notification['conditions']['send_stop'] == 'send'; } else { if ($notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0])) { $stop = false; } } return $stop; }
public static function is_field_hidden($field, $values) { if ($field->type == 'user_id' || $field->type == 'hidden' || !isset($field->field_options['hide_field']) || empty($field->field_options['hide_field'])) { return false; } $field->field_options['hide_field'] = (array) $field->field_options['hide_field']; if (!isset($field->field_options['hide_field_cond'])) { $field->field_options['hide_field_cond'] = array('=='); } $field->field_options['hide_field_cond'] = (array) $field->field_options['hide_field_cond']; $field->field_options['hide_opt'] = (array) $field->field_options['hide_opt']; if (!isset($field->field_options['show_hide'])) { $field->field_options['show_hide'] = 'show'; } if (!isset($field->field_options['any_all'])) { $field->field_options['any_all'] = 'any'; } $hidden = false; $hide = array(); foreach ($field->field_options['hide_field'] as $hide_key => $hide_field) { if ($hidden && $field->field_options['any_all'] == 'any' && $field->field_options['show_hide'] == 'hide') { continue; } $observed_value = ''; if (isset($values['item_meta'][$hide_field])) { $observed_value = $values['item_meta'][$hide_field]; } else { if (isset($field->temp_id) && $field->id != $field->temp_id) { // this field depends on a field in a repeating section $id_parts = explode('-', $field->temp_id); if (isset($_POST['item_meta'][$id_parts[1]]) && isset($_POST['item_meta'][$id_parts[1]][$id_parts[2]]) && isset($_POST['item_meta'][$id_parts[1]][$id_parts[2]][$hide_field])) { $observed_value = stripslashes_deep($_POST['item_meta'][$id_parts[1]][$id_parts[2]][$hide_field]); } } } if ($field->type == 'data') { // Don't require a Dynamic Field with no available options self::is_dynamic_field_empty($field, $hide_key, $hide_field, $observed_value); } $hidden = FrmFieldsHelper::value_meets_condition($observed_value, $field->field_options['hide_field_cond'][$hide_key], $field->field_options['hide_opt'][$hide_key]); if ($field->field_options['show_hide'] == 'show') { $hidden = $hidden ? false : true; } $hide[$hidden] = $hidden; } if ($field->field_options['any_all'] == 'all' && !empty($hide) && isset($hide[0]) && isset($hide[1])) { $hidden = $field->field_options['show_hide'] == 'show' ? true : false; } else { if ($field->field_options['any_all'] == 'any' && $field->field_options['show_hide'] == 'show' && isset($hide[0])) { $hidden = false; } } return $hidden; }