本文整理汇总了PHP中RGFormsModel::is_field_hidden方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::is_field_hidden方法的具体用法?PHP RGFormsModel::is_field_hidden怎么用?PHP RGFormsModel::is_field_hidden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::is_field_hidden方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_value_merge_tag
public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br)
{
$use_value = $modifier == 'value';
$use_price = in_array($modifier, array('price', 'currency'));
$format_currency = $modifier == 'currency';
if (is_array($raw_value) && (string) intval($input_id) != $input_id) {
$items = array($input_id => $value);
//float input Ids. (i.e. 4.1 ). Used when targeting specific checkbox items
} elseif (is_array($raw_value)) {
$items = $raw_value;
} else {
$items = array($input_id => $raw_value);
}
$ary = array();
foreach ($items as $input_id => $item) {
if ($use_value) {
list($val, $price) = rgexplode('|', $item, 2);
} elseif ($use_price) {
list($name, $val) = rgexplode('|', $item, 2);
if ($format_currency) {
$val = GFCommon::to_money($val, rgar($entry, 'currency'));
}
} elseif ($this->type == 'post_category') {
$use_id = strtolower($modifier) == 'id';
$item_value = GFCommon::format_post_category($item, $use_id);
$val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : $item_value;
} else {
$val = RGFormsModel::is_field_hidden($form, $this, array(), $entry) ? '' : RGFormsModel::get_choice_text($this, $raw_value, $input_id);
}
$ary[] = GFCommon::format_variable_value($val, $url_encode, $esc_html, $format);
}
return GFCommon::implode_non_blank(', ', $ary);
}
示例2: is_condition_true
/**
* Check if the iDEAL condition is true
*
* @param mixed $form
* @param mixed $feed
*/
public static function is_condition_true($form, $feed)
{
if (!$feed->condition_enabled) {
return true;
}
$field = RGFormsModel::get_field($form, $feed->condition_field_id);
// Unknown field
if (empty($field)) {
return true;
}
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
// Ignore condition if the field is hidden
if ($is_hidden) {
return false;
}
$value = RGFormsModel::get_field_value($field, array());
$is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
switch ($feed->condition_operator) {
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
$result = $is_match;
break;
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
$result = !$is_match;
break;
default:
$result = true;
}
return $result;
}
示例3: is_applicable_field
function is_applicable_field($field, $form)
{
if ($field['pageNumber'] != GFFormDisplay::get_source_page($form['id'])) {
return false;
}
if ($field['type'] != 'list' || RGFormsModel::is_field_hidden($form, $field, array())) {
return false;
}
// if the field has already failed validation, we don't need to fail it again
if (!$field['isRequired'] || $field['failed_validation']) {
return false;
}
if (empty($this->field_ids)) {
return true;
}
return in_array($field['id'], $this->field_ids);
}
示例4: validate_captcha
function validate_captcha($validation_result)
{
// 2 - Get the form object from the validation result
$form = $validation_result["form"];
// 3 - Get the current page being validated
$current_page = rgpost('gform_source_page_number_' . $form['id']) ? rgpost('gform_source_page_number_' . $form['id']) : 1;
//print_r($validation_result); exit;
// 4 - Loop through the form fields
foreach ($form['fields'] as &$field) {
// 5 - If the field does not have our designated CSS class, skip it
if (strpos($field['cssClass'], 'validate-anti-spam') === false) {
continue;
}
// 6 - Get the field's page number
$field_page = $field['pageNumber'];
// 7 - Check if the field is hidden by GF conditional logic
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
// 8 - If the field is not on the current page OR if the field is hidden, skip it
if ($field_page != $current_page || $is_hidden) {
continue;
}
// 9 - Get the submitted value from the $_POST
$field_value = rgpost("input_{$field['id']}");
// 10 - Make a call to your validation function to validate the value
$is_valid = is_valid_captcha($field_value);
// 11 - If the field is valid we don't need to do anything, skip it
if ($is_valid) {
continue;
}
// 12 - The field failed validation, so first we'll need to fail the validation for the entire form
$validation_result['is_valid'] = false;
// 13 - Next we'll mark the specific field that failed and add a custom validation message
$field['failed_validation'] = true;
$field['validation_message'] = 'Vul het antwoord op de vraag in, het antwoord is het getal nul (0).';
}
// 14 - Assign our modified $form object back to the validation result
$validation_result['form'] = $form;
// 15 - Return the validation result
return $validation_result;
}
示例5: is_condition_true
/**
* Check if the iDEAL condition is true
*
* @param mixed $form
* @param mixed $feed
*/
public static function is_condition_true($form, $feed)
{
$result = true;
if ($feed->condition_enabled) {
$field = RGFormsModel::get_field($form, $feed->condition_field_id);
if (empty($field)) {
// unknown field
$result = true;
} else {
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
if ($is_hidden) {
// if conditional is enabled, but the field is hidden, ignore conditional
$result = false;
} else {
$value = RGFormsModel::get_field_value($field, array());
$is_match = RGFormsModel::is_value_match($value, $feed->condition_value);
switch ($feed->condition_operator) {
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS:
$result = $is_match;
break;
case Pronamic_WP_Pay_Extensions_GravityForms_GravityForms::OPERATOR_IS_NOT:
$result = !$is_match;
break;
default:
// unknown operator
$result = true;
break;
}
}
}
} else {
// condition is disabled, result is true
$result = true;
}
return $result;
}
示例6: prepare_value
/**
* Prepare the value before saving it to the lead.
*
* @param mixed $form
* @param mixed $field
* @param mixed $value
* @param mixed $input_name
* @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations)
* @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function
*/
public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array())
{
$form_id = $form["id"];
$input_type = self::get_input_type($field);
switch ($input_type) {
case "total":
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = GFCommon::get_order_total($form, $lead);
break;
case "calculation":
// ignore submitted value and recalculate price in backend
list(, , $input_id) = rgexplode("_", $input_name, 3);
if ($input_id == 2) {
require_once GFCommon::get_base_path() . '/currency.php';
$currency = new RGCurrency(GFCommon::get_currency());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
$value = $currency->to_money(GFCommon::calculate($field, $form, $lead));
}
break;
case "phone":
if ($field["phoneFormat"] == "standard" && preg_match('/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/', $value, $matches)) {
$value = sprintf("(%s)%s-%s", $matches[1], $matches[2], $matches[3]);
}
break;
case "time":
if (!is_array($value) && !empty($value)) {
preg_match('/^(\\d*):(\\d*) ?(.*)$/', $value, $matches);
$value = array();
$value[0] = $matches[1];
$value[1] = $matches[2];
$value[2] = rgar($matches, 3);
}
$hour = empty($value[0]) ? "0" : strip_tags($value[0]);
$minute = empty($value[1]) ? "0" : strip_tags($value[1]);
$ampm = strip_tags(rgar($value, 2));
if (!empty($ampm)) {
$ampm = " {$ampm}";
}
if (!(empty($hour) && empty($minute))) {
$value = sprintf("%02d:%02d%s", $hour, $minute, $ampm);
} else {
$value = "";
}
break;
case "date":
$value = self::prepare_date(rgar($field, 'dateFormat'), $value);
break;
case "post_image":
$url = self::get_fileupload_value($form_id, $input_name);
$image_title = isset($_POST["{$input_name}_1"]) ? strip_tags($_POST["{$input_name}_1"]) : "";
$image_caption = isset($_POST["{$input_name}_4"]) ? strip_tags($_POST["{$input_name}_4"]) : "";
$image_description = isset($_POST["{$input_name}_7"]) ? strip_tags($_POST["{$input_name}_7"]) : "";
$value = !empty($url) ? $url . "|:|" . $image_title . "|:|" . $image_caption . "|:|" . $image_description : "";
break;
case "fileupload":
if (rgar($field, "multipleFiles")) {
global $_gf_uploaded_files;
if (isset($_gf_uploaded_files[$input_name])) {
$value = $_gf_uploaded_files[$input_name];
} else {
if (isset(GFFormsModel::$uploaded_files[$form_id][$input_name])) {
$uploaded_temp_files = GFFormsModel::$uploaded_files[$form_id][$input_name];
$uploaded_files = array();
foreach ($uploaded_temp_files as $i => $file_info) {
$temp_filepath = self::get_upload_path($form_id) . '/tmp/' . $file_info['temp_filename'];
if ($file_info && file_exists($temp_filepath)) {
$uploaded_files[$i] = self::move_temp_file($form_id, $file_info);
}
}
if (!empty($value)) {
// merge with existing files (admin edit entry)
$value = json_decode($value, true);
$value = array_merge($value, $uploaded_files);
$value = json_encode($value);
} else {
$value = json_encode($uploaded_files);
}
} else {
$value = '';
}
$_gf_uploaded_files[$input_name] = $value;
}
} else {
$value = self::get_fileupload_value($form_id, $input_name);
}
break;
case "number":
$value = GFCommon::maybe_add_leading_zero($value);
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
$lead = empty($lead) ? RGFormsModel::get_lead($lead_id) : $lead;
//.........这里部分代码省略.........
示例7: is_optin
public static function is_optin($form, $settings, $entry)
{
$config = $settings["meta"];
$field = RGFormsModel::get_field($form, $config["optin_field_id"]);
if (empty($field) || !$config["optin_enabled"]) {
return true;
}
$operator = $config["optin_operator"];
$field_value = RGFormsModel::get_lead_field_value($entry, $field);
$is_value_match = RGFormsModel::is_value_match($field_value, $config["optin_value"]);
$is_visible = !RGFormsModel::is_field_hidden($form, $field, array(), $entry);
$is_match = $is_value_match && $is_visible;
$is_optin = $operator == "is" && $is_match || $operator == "isnot" && !$is_match;
return $is_optin;
}
示例8: save_lead
/**
* Adapted from forms_model.php, RGFormsModel::save_lead($Form, $lead)
* @param array $form Form object.
* @param array $lead Lead object
* @return void
*/
public static function save_lead($form, &$lead)
{
global $wpdb;
if (IS_ADMIN && !GFCommon::current_user_can_any("gravityforms_edit_entries")) {
die(__("You don't have adequate permission to edit entries.", "gravityforms"));
}
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
//Inserting lead if null
if ($lead == null) {
global $current_user;
$user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
$lead_table = RGFormsModel::get_lead_table_name();
$user_agent = RGFormsModel::truncate($_SERVER["HTTP_USER_AGENT"], 250);
$currency = GFCommon::get_currency();
$source_url = RGFormsModel::truncate(RGFormsModel::get_current_page_url(), 200);
$wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form["id"], RGFormsModel::get_ip(), $source_url, $user_agent, $currency));
//reading newly created lead id
$lead_id = $wpdb->insert_id;
$lead = array("id" => $lead_id);
}
$current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead["id"]));
$original_post_id = rgget("post_id", $lead);
$total_fields = array();
$calculation_fields = array();
$recalculate_total = false;
foreach ($form["fields"] as $field) {
//Ignore fields that are marked as display only
if (rgget("displayOnly", $field) && $field["type"] != "password") {
continue;
}
//ignore pricing fields in the entry detail
if (RG_CURRENT_VIEW == "entry" && GFCommon::is_pricing_field($field["type"])) {
continue;
}
//process total field after all fields have been saved
if ($field["type"] == "total") {
$total_fields[] = $field;
continue;
}
//only save fields that are not hidden (except on entry screen)
if (RG_CURRENT_VIEW == "entry" || !RGFormsModel::is_field_hidden($form, $field, array(), $lead)) {
// process calculation fields after all fields have been saved (moved after the is hidden check)
if (GFCommon::has_field_calculation($field)) {
$calculation_fields[] = $field;
continue;
}
if ($field['type'] == 'post_category') {
$field = GFCommon::add_categories_as_choices($field, '');
}
if (isset($field["inputs"]) && is_array($field["inputs"])) {
foreach ($field["inputs"] as $input) {
RGFormsModel::save_input($form, $field, $lead, $current_fields, $input["id"]);
}
} else {
RGFormsModel::save_input($form, $field, $lead, $current_fields, $field["id"]);
}
}
//Refresh lead to support conditionals (not optimal but...)
$lead = RGFormsModel::get_lead($lead['id']);
}
if (!empty($calculation_fields)) {
foreach ($calculation_fields as $calculation_field) {
if (isset($calculation_field["inputs"]) && is_array($calculation_field["inputs"])) {
foreach ($calculation_field["inputs"] as $input) {
RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $input["id"]);
RGFormsModel::refresh_lead_field_value($lead["id"], $input["id"]);
}
} else {
RGFormsModel::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field["id"]);
RGFormsModel::refresh_lead_field_value($lead["id"], $calculation_field["id"]);
}
}
RGFormsModel::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
}
//saving total field as the last field of the form.
if (!empty($total_fields)) {
foreach ($total_fields as $total_field) {
GFCommon::log_debug("Saving total field.");
RGFormsModel::save_input($form, $total_field, $lead, $current_fields, $total_field["id"]);
}
}
}
示例9: create_lead
public static function create_lead($form)
{
global $current_user;
$total_fields = array();
$calculation_fields = array();
$lead = array();
$lead['id'] = null;
$lead['post_id'] = null;
$lead['date_created'] = null;
$lead['form_id'] = $form['id'];
$lead['ip'] = self::get_ip();
$source_url = self::truncate(self::get_current_page_url(), 200);
$lead['source_url'] = esc_url_raw($source_url);
$user_agent = strlen($_SERVER['HTTP_USER_AGENT']) > 250 ? substr($_SERVER['HTTP_USER_AGENT'], 0, 250) : $_SERVER['HTTP_USER_AGENT'];
$lead['user_agent'] = sanitize_text_field($user_agent);
$lead['created_by'] = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
/**
* Allow the currency code to be overridden.
*
* @param string $currency The three character ISO currency code to be stored in the entry. Default is value returned by GFCommon::get_currency()
* @param array $form The form currently being processed.
*
*/
$lead['currency'] = gf_apply_filters('gform_currency_pre_save_entry', $form['id'], GFCommon::get_currency(), $form);
foreach ($form['fields'] as $field) {
/* @var $field GF_Field */
// ignore fields that are marked as display only
if ($field->displayOnly && $field->type != 'password') {
continue;
}
// process total field after all fields have been saved
if ($field->type == 'total') {
$total_fields[] = $field;
continue;
}
// process calculation fields after all fields have been saved
if ($field->has_calculation()) {
$calculation_fields[] = $field;
continue;
}
// only save fields that are not hidden
if (!RGFormsModel::is_field_hidden($form, $field, array())) {
if ($field->type == 'post_category') {
$field = GFCommon::add_categories_as_choices($field, '');
}
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$lead[(string) $input['id']] = self::get_prepared_input_value($form, $field, $lead, $input['id']);
}
} else {
$lead[$field->id] = self::get_prepared_input_value($form, $field, $lead, $field->id);
}
}
}
if (!empty($calculation_fields)) {
foreach ($calculation_fields as $field) {
/* @var $field GF_Field */
// only save fields that are not hidden
if (RGFormsModel::is_field_hidden($form, $field, array())) {
continue;
}
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$lead[(string) $input['id']] = self::get_prepared_input_value($form, $field, $lead, $input['id']);
}
} else {
$lead[$field->id] = self::get_prepared_input_value($form, $field, $lead, $field->id);
}
}
self::refresh_product_cache($form, $lead);
}
// saving total field as the last field of the form.
if (!empty($total_fields)) {
foreach ($total_fields as $total_field) {
$lead[$total_field->id] = self::get_prepared_input_value($form, $total_field, $lead, $total_field->id);
}
}
return $lead;
}
示例10: user_registration_validation
public static function user_registration_validation($validation_result)
{
$form = $validation_result['form'];
$entry = self::convert_post_to_entry();
$config = self::get_active_config($form, $entry);
$is_update_feed = rgars($config, 'meta/feed_type') == 'update';
$pagenum = rgpost("gform_source_page_number_{$form['id']}");
// if there is no registration feed or the registration condition is not met or feed is inactive, abandon ship
if (!$config || !self::registration_condition_met($form, $config, $entry) || !$config['is_active']) {
return $validation_result;
}
$username_field = RGFormsModel::get_field($form, $config['meta']['username']);
$email_field = RGFormsModel::get_field($form, $config['meta']['email']);
$password_field = RGFormsModel::get_field($form, $config['meta']['password']);
$is_username_hidden = RGFormsModel::is_field_hidden($form, $username_field, array());
$is_email_hidden = RGFormsModel::is_field_hidden($form, $email_field, array());
$is_password_hidden = RGFormsModel::is_field_hidden($form, $password_field, array());
$user_name = apply_filters("gform_username_{$form['id']}", apply_filters('gform_username', self::get_meta_value('username', $config, $form, $entry), $config, $form, $entry), $config, $form, $entry);
$user_email = self::get_prepared_value($email_field, $config['meta']['email'], $entry);
$user_pass = rgpost('input_' . $config['meta']['password']);
//$user_pass = stripslashes( $user_pass );
if (!function_exists('username_exists')) {
require_once ABSPATH . WPINC . "/registration.php";
}
// if password field is not hidden and is on the current page we are validating, validate it
if (!$is_password_hidden && $password_field['pageNumber'] == $pagenum) {
if (strpos($user_pass, "\\") !== false) {
$form = self::add_validation_failure($config['meta']['password'], $form, __('Passwords may not contain the character "\\"', 'gravityformsuserregistration'));
}
}
if (is_multisite()) {
// if multisite is defined and true, lowercase name for validation
$user_name = strtolower($user_name);
$_POST['input_' . str_replace('.', '_', $config['meta']['username'])] = $user_name;
$result = wpmu_validate_user_signup($user_name, $user_email);
$errors = $result['errors']->errors;
// special validation overrides for update feeds
if ($is_update_feed) {
// do not validate username on update feeds
if (isset($errors['user_name'])) {
unset($errors['user_name']);
}
// do not validate if email belongs to user
if (isset($errors['user_email'])) {
for ($i = count($errors['user_email']) - 1; $i >= 0; $i--) {
$error_message = $errors['user_email'][$i];
// if user is re-submitting their own email address, don't give already used error
if ($error_message == __('Sorry, that email address is already used!') && self::is_users_email($user_email)) {
unset($errors['user_email'][$i]);
} elseif ($error_message == __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.') && self::is_users_email($user_email)) {
unset($errors['user_email'][$i]);
}
}
// if no other user email errors remain, unset
if (count($errors['user_email']) <= 0) {
unset($errors['user_email']);
}
}
}
if (!empty($errors)) {
foreach ($errors as $type => $error_msgs) {
foreach ($error_msgs as $error_msg) {
switch ($type) {
case 'user_name':
if (!$is_username_hidden && $username_field['pageNumber'] == $pagenum) {
$form = self::add_validation_failure($config['meta']['username'], $form, $error_msg);
}
break;
case 'user_email':
if (!$is_email_hidden && $email_field['pageNumber'] == $pagenum) {
$form = self::add_validation_failure($config['meta']['email'], $form, $error_msg);
}
break;
}
}
}
}
} else {
if (!$is_email_hidden && $email_field['pageNumber'] == $pagenum) {
$email_valid = true;
$email_exists = email_exists($user_email);
if (!$user_email) {
$email_valid = false;
$form = self::add_validation_failure($config['meta']['email'], $form, __('The email address can not be empty', 'gravityformsuserregistration'));
}
if ($email_valid && self::pending_activation_exists('user_email', $user_email)) {
$email_valid = false;
$form = self::add_validation_failure($config['meta']['email'], $form, __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
}
if ($email_valid && !$is_update_feed && $email_exists) {
$form = self::add_validation_failure($config['meta']['email'], $form, __('This email address is already registered', 'gravityformsuserregistration'));
} elseif ($email_valid && $is_update_feed && $email_exists && !self::is_users_email($user_email)) {
$form = self::add_validation_failure($config['meta']['email'], $form, __('This email address is already registered', 'gravityformsuserregistration'));
}
}
// do not validate the user name if this is an update feed, if the user name field is hidden or if we are not on the correct page
if (!$is_update_feed && !$is_username_hidden && $username_field['pageNumber'] == $pagenum) {
$username_valid = true;
if (empty($user_name)) {
$username_valid = false;
//.........这里部分代码省略.........
示例11: get_issuer_id
public function get_issuer_id()
{
$issuer_id = null;
$issuer_field = null;
$issuer_fields = GFCommon::get_fields_by_type($this->form, array(Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE));
foreach ($issuer_fields as $field) {
if (!RGFormsModel::is_field_hidden($this->form, $field, array())) {
$issuer_field = $field;
break;
}
}
if (null !== $issuer_field) {
$issuer_id = RGFormsModel::get_field_value($issuer_field);
}
return $issuer_id;
}
示例12: authorize
public function authorize($feed, $submission_data, $form, $entry)
{
// public function process_feed($feed, $entry, $form){
$data = array();
foreach ($form["fields"] as $field) {
if ($field['type'] == 'creditcard' && !RGFormsModel::is_field_hidden($form, $field, array())) {
$ccnumber = rgpost('input_' . $field['id'] . '_1');
$ccdate_array = rgpost('input_' . $field['id'] . '_2');
$ccdate_month = $ccdate_array[0];
if (strlen($ccdate_month) < 2) {
$ccdate_month = '0' . $ccdate_month;
}
$ccdate_year = $ccdate_array[1];
if (strlen($ccdate_year) > 2) {
$ccdate_year = substr($ccdate_year, -2);
}
// Only want last 2 digits
$ccv = rgpost('input_' . $field['id'] . '_3');
$ccname = rgpost('input_' . $field['id'] . '_5');
$is_creditcard = true;
$data["customer"]["payment_source"]["card_name"] = $ccname;
$data["customer"]["payment_source"]["card_number"] = $ccnumber;
$data["customer"]["payment_source"]["expire_month"] = $ccdate_month;
$data["customer"]["payment_source"]["expire_year"] = $ccdate_year;
$data["customer"]["payment_source"]["card_ccv"] = $ccv;
}
}
$payment_type = $entry[$feed["meta"]["pd_payment_mapped_details_pd_payment_type"]];
if ($payment_type == "bsb") {
$data["customer"]["payment_source"]["type"] = "bsb";
$data["customer"]["payment_source"]["account_name"] = $entry[$feed["meta"]["pd_payment_mapped_details_pd_account_name"]];
$data["customer"]["payment_source"]["account_bsb"] = $entry[$feed["meta"]["pd_payment_mapped_details_pd_account_bsb"]];
$data["customer"]["payment_source"]["account_number"] = $entry[$feed["meta"]["pd_payment_mapped_details_pd_account_number"]];
}
$data["customer"]["payment_source"]["gateway_id"] = $feed["meta"]["pd_select_gateway"];
$data["customer"]["first_name"] = $entry[$feed["meta"]["pd_personal_mapped_details_pd_first_name"]];
$data["customer"]["last_name"] = $entry[$feed["meta"]["pd_personal_mapped_details_pd_last_name"]];
$data["customer"]["email"] = $entry[$feed["meta"]["pd_personal_mapped_details_pd_email"]];
$data["reference"] = $entry[$feed["meta"]["pd_payment_mapped_details_pd_transaction_reference"]];
$data["amount"] = $entry[$feed["meta"]["pd_payment_mapped_details_pd_total_payable"]];
$data["currency"] = !empty($currency) ? $currency : GFCommon::get_currency();
$pd_options = get_option('gravityformsaddon_gravityformspaydock_settings');
$api_key = $pd_options['paydock_api_key'];
$api_url = $pd_options['paydock_api_uri'] . 'charges/';
$data_string = json_encode($data);
$envoyrecharge_key = $api_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-user-token:' . $envoyrecharge_key, 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result);
if ($response->status > "250") {
// set the form validation to false
$auth = array('is_authorized' => false, 'transaction_id' => $response->resource->data->_id, 'error_message' => "There was an error with your transaction please try again.");
foreach ($form['fields'] as &$field) {
if ($field->id == '9') {
$field->failed_validation = true;
$field->validation_message = 'There was a problem processing your payment, please try again or contact us.';
break;
}
}
} else {
$auth = array('is_authorized' => true, 'transaction_id' => $response->resource->data->_id);
}
return $auth;
// $feedName = $feed["meta"]["feedName"];
// $mytextbox = $feed["meta"]["mytextbox"];
// $checkbox = $feed["meta"]["mycheckbox"];
// $mapped_email = $feed["meta"]["mappedFields_email"];
// $mapped_name = $feed["meta"]["mappedFields_name"];
// $email = $entry[$mapped_email];
// $name = $entry[$mapped_name];
}
示例13: get_product_fields
public static function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false)
{
$products = array();
$product_info = null;
// retrieve static copy of product info (only for "real" entries)
if (!rgempty("id", $lead)) {
$product_info = gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
}
// if no static copy, generate from form/lead info
if (!$product_info) {
foreach ($form["fields"] as $field) {
$id = $field["id"];
$lead_value = RGFormsModel::get_lead_field_value($lead, $field);
$quantity_field = self::get_product_fields_by_type($form, array("quantity"), $id);
$quantity = sizeof($quantity_field) > 0 && !RGFormsModel::is_field_hidden($form, $quantity_field[0], array(), $lead) ? RGFormsModel::get_lead_field_value($lead, $quantity_field[0]) : 1;
switch ($field["type"]) {
case "product":
//ignore products that have been hidden by conditional logic
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array(), $lead);
if ($is_hidden) {
continue;
}
//if single product, get values from the multiple inputs
if (is_array($lead_value)) {
$product_quantity = sizeof($quantity_field) == 0 && !rgar($field, "disableQuantity") ? rgget($id . ".3", $lead_value) : $quantity;
if (empty($product_quantity)) {
continue;
}
if (!rgget($id, $products)) {
$products[$id] = array();
}
$products[$id]["name"] = $use_admin_label && !rgempty("adminLabel", $field) ? $field["adminLabel"] : $lead_value[$id . ".1"];
$products[$id]["price"] = $lead_value[$id . ".2"];
$products[$id]["quantity"] = $product_quantity;
} else {
if (!empty($lead_value)) {
if (empty($quantity)) {
continue;
}
if (!rgar($products, $id)) {
$products[$id] = array();
}
if ($field["inputType"] == "price") {
$name = $field["label"];
$price = $lead_value;
} else {
list($name, $price) = explode("|", $lead_value);
}
$products[$id]["name"] = !$use_choice_text ? $name : RGFormsModel::get_choice_text($field, $name);
$products[$id]["price"] = $price;
$products[$id]["quantity"] = $quantity;
$products[$id]["options"] = array();
}
}
if (isset($products[$id])) {
$options = self::get_product_fields_by_type($form, array("option"), $id);
foreach ($options as $option) {
$option_value = RGFormsModel::get_lead_field_value($lead, $option);
$option_label = empty($option["adminLabel"]) ? $option["label"] : $option["adminLabel"];
if (is_array($option_value)) {
foreach ($option_value as $value) {
$option_info = self::get_option_info($value, $option, $use_choice_text);
if (!empty($option_info)) {
$products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
}
}
} else {
if (!empty($option_value)) {
$option_info = self::get_option_info($option_value, $option, $use_choice_text);
$products[$id]["options"][] = array("field_label" => rgar($option, "label"), "option_name" => rgar($option_info, "name"), "option_label" => $option_label . ": " . rgar($option_info, "name"), "price" => rgar($option_info, "price"));
}
}
}
}
break;
}
}
$shipping_field = self::get_fields_by_type($form, array("shipping"));
$shipping_price = $shipping_name = "";
if (!empty($shipping_field) && !RGFormsModel::is_field_hidden($form, $shipping_field[0], array(), $lead)) {
$shipping_price = RGFormsModel::get_lead_field_value($lead, $shipping_field[0]);
$shipping_name = $shipping_field[0]["label"];
if ($shipping_field[0]["inputType"] != "singleshipping") {
list($shipping_method, $shipping_price) = explode("|", $shipping_price);
$shipping_name = $shipping_field[0]["label"] . " ({$shipping_method})";
}
}
$shipping_price = self::to_number($shipping_price);
$product_info = array("products" => $products, "shipping" => array("name" => $shipping_name, "price" => $shipping_price));
$product_info = apply_filters("gform_product_info_{$form["id"]}", apply_filters("gform_product_info", $product_info, $form, $lead), $form, $lead);
// save static copy of product info (only for "real" entries)
if (!rgempty("id", $lead) && !empty($product_info["products"])) {
gform_update_meta($lead['id'], "gform_product_info_{$use_choice_text}_{$use_admin_label}", $product_info);
}
}
return $product_info;
}
示例14: math_captcha_validation
/**
* Validates the solution to the math captcha question.
*
* @since 1.0.0
*/
public function math_captcha_validation($validation_result)
{
$form = $validation_result['form'];
$current_page = rgpost('gform_source_page_number_' . $form['id']) ? rgpost('gform_source_page_number_' . $form['id']) : 1;
foreach ($form['fields'] as &$field) {
// Check that we're validating a math captcha field.
if ($field['type'] != 'math_captcha') {
continue;
}
// Make sure that the field isn't hidden or on a different page of the form.
$field_page = $field['pageNumber'];
$is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
if ($field_page != $current_page || $is_hidden) {
continue;
}
// Get the accepted answers from the hidden input.
$answers_no_spam = rgpost("math_captcha_answers_{$field['id']}");
// Convert the encoded answers from hexidecimal format.
$answers_unhex = '';
$answers = preg_replace('/[^A-Za-z0-9]/', '', $answers_no_spam);
for ($i = 0; $i < strlen($answers) - 1; $i += 2) {
$answers_unhex .= chr(hexdec($answers[$i] . $answers[$i + 1]));
}
// Create an array of the accepted answers.
$answer_array = explode(',', $answers_unhex);
// Check $_POST to see if one of the accepted answers was submitted.
if (!in_array(strtolower(rgpost("input_{$field['id']}")), $answer_array)) {
$validation_result['is_valid'] = false;
$field['failed_validation'] = true;
$field['validation_message'] = __("Sorry, that wasn't the correct answer. Please try again.", $this->plugin_slug);
break;
}
}
// Assign modified $form object back to the validation result.
$validation_result['form'] = $form;
return $validation_result;
}
开发者ID:projoktibangla,项目名称:gravity-forms-math-captcha,代码行数:42,代码来源:class-gravity-forms-math-captcha.php
示例15: validate
private function validate(&$form, $field_values)
{
$form = apply_filters('gform_pre_validation', $form);
foreach ($form["fields"] as &$field) {
/*
* Skip over the following fields as we aren't processing any of them
*/
$skip_field = false;
switch (RGFormsModel::get_input_type($field)) {
case "captcha":
case "html":
case "password":
case "product":
case "coupon":
case "quantity":
case "shipping":
case "donation":
case "total":
case "singleproduct":
case "hiddenproduct":
case "singleshipping":
case "creditcard":
case "page":
case "post_image":
case "fileupload":
//ignore certain fields
$skip_field = true;
break;
}
if (isset($field['productField']) && (int) $field['productField'] > 0 || $field['type'] == 'shipping') {
$skip_field = true;
}
/* ignore validation if field is hidden or admin only */
if (RGFormsModel::is_field_hidden($form, $field, $field_values) || isset($field['adminOnly']) && $field['adminOnly']) {
$skip_field = true;
}
/* ignore user-defined restricted fields or hidden fields */
if (in_array($field['id'], $this->atts['restricted_fields']) || in_array($field['id'], $this->atts['hidden_fields'])) {
$skip_field = true;
}
if ($skip_field) {
continue;
}
$value = RGFormsModel::get_field_value($field);
//display error message if field is marked as required and the submitted value is empty
if ($field["isRequired"] && GFFormDisplay::is_empty($field, $form["id"])) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required.", "gravityforms") : $field["errorMessage"];
} else {
if ($field["noDuplicates"] && RGFormsModel::is_duplicate($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$input_type = RGFormsModel::get_input_type($field);
switch ($input_type) {
case "date":
$default_message = __("This date has already been taken. Please select a new date.", "gravityforms");
break;
default:
$default_message = is_array($value) ? __("This field requires a unique entry and the values you entered have been already been used.", "gravityforms") : sprintf(__("This field requires a unique entry and '%s' has already been used", "gravityforms"), $value);
break;
}
$field["validation_message"] = apply_filters("gform_duplicate_message_{$form["id"]}", apply_filters("gform_duplicate_message", $default_message, $form, $field, $value), $form, $field, $value);
} else {
if (GFFormDisplay::failed_state_validation($form["id"], $field, $value)) {
$field["failed_validation"] = true;
$field["validation_message"] = in_array($field["inputType"], array("singleproduct", "singleshipping", "hiddenproduct")) ? __("Please enter a valid value.", "gravityforms") : __("Invalid selection. Please select one of the available choices.", "gravityforms");
} else {
switch (RGFormsModel::get_input_type($field)) {
case "name":
if ($field["isRequired"] && $field["nameFormat"] != "simple") {
$first = $_POST["input_" . $field["id"] . "_3"];
$last = $_POST["input_" . $field["id"] . "_6"];
if (empty($first) || empty($last)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter the first and last name.", "gravityforms") : $field["errorMessage"];
}
}
break;
case "address":
if ($field["isRequired"]) {
$street = $_POST["input_" . $field["id"] . "_1"];
$city = $_POST["input_" . $field["id"] . "_3"];
$state = $_POST["input_" . $field["id"] . "_4"];
$zip = $_POST["input_" . $field["id"] . "_5"];
$country = $_POST["input_" . $field["id"] . "_6"];
if (empty($street) || empty($city) || empty($zip) || empty($state) && !$field["hideState"] || empty($country) && !$field["hideCountry"]) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("This field is required. Please enter a complete address.", "gravityforms") : $field["errorMessage"];
}
}
break;
case "email":
if (!rgblank($value) && !GFCommon::is_valid_email($value)) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? __("Please enter a valid email address.", "gravityforms") : $field["errorMessage"];
} else {
if (rgget("emailConfirmEnabled", $field) && !empty($value)) {
$confirm = rgpost("input_" . $field["id"] . "_2");
if ($confirm != $value) {
$field["failed_validation"] = true;
$field["validation_message"] = __("Your emails do not match.", "gravityforms");
//.........这里部分代码省略.........