public static function maybe_deploy() { global $gfpdfe_data; /* * Check if we have a 'direct' method, that the software isn't fully installed and we aren't trying to manually initialise */ if ($gfpdfe_data->automated === true && $gfpdfe_data->is_initialised === false && !rgpost('upgrade') && get_option('gfpdfe_automated_install') != 'installing') { /* * Initialise all multisites if a super admin is logged in */ if (is_multisite() && is_super_admin()) { $results = GFPDF_InstallUpdater::run_multisite_deployment(array('GFPDF_InstallUpdater', 'do_deploy')); if ($results === true) { add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_network_deploy_success')); } elseif ($results === false) { add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_network_failure')); } return $results; } else { if (self::do_deploy()) { /* * Output successfull automated installation message */ add_action($gfpdfe_data->notice_type, array('GFPDF_Notices', 'gf_pdf_auto_deploy_success')); } } } }
/** * [gf_notification_attachment_save description] * @param array $notification * @param array $form * @return array */ function gf_notification_attachment_save($notification, $form) { if (function_exists('rgpost')) { $notification["attachment_id"] = rgpost("gform_notification_attachment_id"); } return $notification; }
public function get_value_submission($field_values, $get_from_post_global_var = true) { $parameter_values = GFFormsModel::get_parameter_value($this->inputName, $field_values, $this); if (!empty($parameter_values) && !is_array($parameter_values)) { $parameter_values = explode(',', $parameter_values); } if (!is_array($this->inputs)) { return ''; } $choice_index = 0; $value = array(); foreach ($this->inputs as $input) { if (!empty($_POST['is_submit_' . $this->formId]) && $get_from_post_global_var) { $input_value = rgpost('input_' . str_replace('.', '_', strval($input['id']))); if (is_array($input_value)) { $input_value = ''; } $value[strval($input['id'])] = $input_value; } else { if (is_array($parameter_values)) { foreach ($parameter_values as $item) { $item = trim($item); if (GFFormsModel::choice_value_match($this, $this->choices[$choice_index], $item)) { $value[$input['id'] . ''] = $item; break; } } } } $choice_index++; } return $value; }
function reject_urls_in_textarea($validation_result) { // Get the form object from the validation result $form = $validation_result["form"]; //Loop through the form fields foreach ($form['fields'] as &$field) { if ($field["type"] == 'textarea') { // Get the submitted value from the $_POST $field_value = rgpost("input_{$field['id']}"); $pattern = '#[-a-zA-Z0-9@:%_\\+.~\\#?&//=]{2,256}\\.[a-z]{2,4}\\b(\\/[-a-zA-Z0-9@:%_\\+.~\\#?&//=]*)?#si'; if (preg_match_all($pattern, $field_value)) { //Fail the validation for the entire form $validation_result['is_valid'] = false; //Mark the specific field that failed and add a custom validation message $field['failed_validation'] = true; $field['validation_message'] = 'Urls [Links] or [Emails] are not allowed in this field.'; //Assign our modified $form object back to the validation result $validation_result['form'] = $form; } else { //Huston we are a go! continue; } } else { //!textarea continue; } } //Return validated result return $validation_result; }
public function get_field_input($form, $value = '', $entry = null) { $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); if (is_array($value)) { $value = array_values($value); } $form_id = $form['id']; $id = intval($this->id); $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}"; $form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id; $size = $this->size; $disabled_text = $is_form_editor ? "disabled='disabled'" : ''; $class_suffix = $is_entry_detail ? '_admin' : ''; $class = $this->emailConfirmEnabled ? '' : $size . $class_suffix; //Size only applies when confirmation is disabled $form_sub_label_placement = rgar($form, 'subLabelPlacement'); $field_sub_label_placement = $this->subLabelPlacement; $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above'; $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label'" : ''; $html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text'; $enter_email_field_input = GFFormsModel::get_input($this, $this->id . ''); $confirm_field_input = GFFormsModel::get_input($this, $this->id . '.2'); $enter_email_label = rgar($enter_email_field_input, 'customLabel') != '' ? $enter_email_field_input['customLabel'] : __('Enter Email', 'gravityforms'); $enter_email_label = apply_filters("gform_email_{$form_id}", apply_filters('gform_email', $enter_email_label, $form_id), $form_id); $confirm_email_label = rgar($confirm_field_input, 'customLabel') != '' ? $confirm_field_input['customLabel'] : __('Confirm Email', 'gravityforms'); $confirm_email_label = apply_filters("gform_email_confirm_{$form_id}", apply_filters('gform_email_confirm', $confirm_email_label, $form_id), $form_id); $single_placeholder_attribute = $this->get_field_placeholder_attribute(); $enter_email_placeholder_attribute = $this->get_input_placeholder_attribute($enter_email_field_input); $confirm_email_placeholder_attribute = $this->get_input_placeholder_attribute($confirm_field_input); if ($is_form_editor) { $single_style = $this->emailConfirmEnabled ? "style='display:none;'" : ''; $confirm_style = $this->emailConfirmEnabled ? '' : "style='display:none;'"; if ($is_sub_label_above) { return "<div class='ginput_container ginput_single_email' {$single_style}>\n <input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute} />\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>"; } else { return "<div class='ginput_container ginput_single_email' {$single_style}>\n <input class='{$class}' name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute}/>\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute}/>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>"; } } else { $logic_event = $this->get_conditional_logic_event('keyup'); if ($this->emailConfirmEnabled && !$is_entry_detail) { $first_tabindex = $this->get_tabindex(); $last_tabindex = $this->get_tabindex(); $email_value = is_array($value) ? esc_attr($value[0]) : $value; $confirmation_value = is_array($value) ? esc_attr($value[1]) : rgpost('input_' . $this->id . '_2'); $confirmation_disabled = $is_entry_detail ? "disabled='disabled'" : $disabled_text; if ($is_sub_label_above) { return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <label for='{$field_id}'>" . $enter_email_label . "</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>"; } else { return "<div class='ginput_complex ginput_container' id='{$field_id}_container'>\n <span id='{$field_id}_container' class='ginput_left'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='" . $email_value . "' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute}/>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='" . $confirmation_value . "' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>"; } } else { $tabindex = $this->get_tabindex(); $value = esc_attr($value); $class = esc_attr($class); return "<div class='ginput_container'>\n <input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$disabled_text} {$single_placeholder_attribute}/>\n </div>"; } } }
public function validate_recaptcha() { // when user clicks on the "I'm not a robot" box, the response token is populated into a hidden field by Google, get token from POST $response_token = rgpost('g-recaptcha-response'); $is_valid = $this->verify_recaptcha_response($response_token); if (!$is_valid) { $this->failed_validation = true; $this->validation_message = empty($this->errorMessage) ? __('The reCAPTCHA was invalid. Go back and try it again.', 'gravityforms') : $this->errorMessage; } }
function jbl_save_gform_notification_settings($notification, $form) { if (isset($_POST['jbl_gfuaa_enable'])) { $notification['jbl_gfuaa_enable'] = rgpost('jbl_gfuaa_enable'); } if (isset($_POST['jbl_gfuaa_delete_files_after'])) { $notification['jbl_gfuaa_delete_files_after'] = rgpost('jbl_gfuaa_delete_files_after'); } return $notification; }
function validate($value, $form) { if ($this->isRequired && $this->nameFormat != 'simple') { $first = rgpost('input_' . $this->id . '_3'); $last = rgpost('input_' . $this->id . '_6'); if (empty($first) && !$this->get_input_property('3', 'isHidden') || empty($last) && !$this->get_input_property('6', 'isHidden')) { $this->failed_validation = true; $this->validation_message = empty($this->errorMessage) ? esc_html__('This field is required. Please enter the first and last name.', 'gravityforms') : $this->errorMessage; } } }
public function validate_recaptcha() { // when user clicks on the "I'm not a robot" box, the response token is populated into a hidden field by Google, get token from POST $response_token = rgpost('g-recaptcha-response'); $is_valid = $this->verify_recaptcha_response($response_token); if (!$is_valid) { $this->failed_validation = true; $this->validation_message = empty($this->errorMessage) ? __('The reCAPTCHA was invalid. Go back and try it again.', 'gravityforms') : $this->errorMessage; $error_message = is_wp_error($response) ? $response->get_error_message() : ''; GFCommon::log_debug(__METHOD__ . ' - Validating the reCAPTCHA response has failed due to the following: ' . $error_message); } }
public function is_value_submission_empty($form_id) { $value = rgpost('input_' . $this->id); if (is_array($value)) { // Date field and date drop-downs foreach ($value as $input) { if (strlen(trim($input)) <= 0) { return true; } } return false; } else { // Date picker return strlen(trim($value)) <= 0; } }
/** * Returns the fields inner markup. * * @param array $form The form object currently being processed. * @param string $value The field value from the $_POST or the resumed incomplete submission. Not currently used. * @param null $entry * * @return string */ public function get_field_input($form, $value = '', $entry = null) { $form_id = $form['id']; $is_entry_detail = $this->is_entry_detail(); $id = (int) $this->id; if ($is_entry_detail) { $input = "<input type='hidden' id='input_{$id}' name='input_{$id}' value='{$value}' />"; return $input . '<br/>' . esc_html__('Coupon fields are not editable', 'gravityformscoupons'); } $disabled_text = $this->is_form_editor() ? 'disabled="disabled"' : ''; $logic_event = $this->get_conditional_logic_event('change'); $placeholder_attribute = $this->get_field_placeholder_attribute(); $coupons_detail = rgpost("gf_coupons_{$form_id}"); $coupon_codes = empty($coupons_detail) ? '' : rgpost("input_{$id}"); $input = "<div class='ginput_container' id='gf_coupons_container_{$form_id}'>" . "<input id='gf_coupon_code_{$form_id}' class='gf_coupon_code' onkeyup='DisableApplyButton({$form_id});' onchange='DisableApplyButton({$form_id});' onpaste='setTimeout(function(){DisableApplyButton({$form_id});}, 50);' type='text' {$disabled_text} {$placeholder_attribute} " . $this->get_tabindex() . '/>' . "<input type='button' disabled='disabled' onclick='ApplyCouponCode({$form_id});' value='" . esc_attr__('Apply', 'gravityformscoupons') . "' id='gf_coupon_button' class='button' {$disabled_text} " . $this->get_tabindex() . '/> ' . "<img style='display:none;' id='gf_coupon_spinner' src='" . gf_coupons()->get_base_url() . "/images/spinner.gif' alt='" . esc_attr__('please wait', 'gravityformscoupons') . "'/>" . "<div id='gf_coupon_info'></div>" . "<input type='hidden' id='gf_coupon_codes_{$form_id}' name='input_{$id}' value='" . esc_attr($coupon_codes) . "' {$logic_event} />" . "<input type='hidden' id='gf_total_no_discount_{$form_id}'/>" . "<input type='hidden' id='gf_coupons_{$form_id}' name='gf_coupons_{$form_id}' value='" . esc_attr($coupons_detail) . "' />" . "</div>"; return $input; }
protected function run_setting_routing() { global $gfpdfe_data; /* * Check if we need to redeploy default PDF templates/styles to the theme folder */ if (rgpost("gfpdf_deploy") && (wp_verify_nonce(PDF_Common::post('gfpdf_deploy_nonce'), 'gfpdf_deploy_nonce_action') || wp_verify_nonce(PDF_Common::get('_wpnonce'), 'pdf-extended-filesystem'))) { /* * Check if the user wants to upgrade the system or only initialise the fonts */ if (PDF_Common::post('font-initialise')) { /* * We only want to reinitialise the font files and configuration */ if (GFPDF_InstallUpdater::initialise_fonts() === false) { return true; } } else { if (rgpost('upgrade')) { /* * Deploy new template styles * If we get false returned Wordpress is trying to get * access details to update files so don't display anything. */ if (self::deploy() === 'false') { return true; } } } } /* * Check if we need to sync the theme folders because a user changes theme * Sniff the _wpnonce values to determine this. */ if (isset($_GET['_wpnonce'])) { /* * Check if we want to copy the theme files */ if ((is_dir($gfpdfe_data->old_template_location) || is_dir($gfpdfe_data->old_3_6_template_site_location)) && wp_verify_nonce(PDF_Common::get('_wpnonce'), 'gfpdfe_migrate')) { if (GFPDF_InstallUpdater::run_template_migration() === 'false') { return true; } } } }
public function get_field_input($form, $value = '', $entry = null) { if (is_array($value)) { $value = array_values($value); } $form_id = $form['id']; $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); $is_admin = $is_entry_detail || $is_form_editor; $id = (int) $this->id; $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}"; $class_suffix = $is_entry_detail ? '_admin' : ''; $form_sub_label_placement = rgar($form, 'subLabelPlacement'); $field_sub_label_placement = $this->subLabelPlacement; $is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above'; $sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : ''; $disabled_text = $is_form_editor ? 'disabled="disabled"' : ''; $first_tabindex = $this->get_tabindex(); $last_tabindex = $this->get_tabindex(); $strength_style = !$this->passwordStrengthEnabled ? "style='display:none;'" : ''; $strength_indicator_label = esc_html__('Strength indicator', 'gravityforms'); $strength = $this->passwordStrengthEnabled || $is_admin ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$strength_indicator_label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : ''; $action = !$is_admin ? "gformShowPasswordStrength(\"{$field_id}\");" : ''; $onchange = $this->passwordStrengthEnabled ? "onchange='{$action}'" : ''; $onkeyup = $this->passwordStrengthEnabled ? "onkeyup='{$action}'" : ''; $confirmation_value = rgpost('input_' . $id . '_2'); $password_value = is_array($value) ? $value[0] : $value; $password_value = esc_attr($password_value); $confirmation_value = esc_attr($confirmation_value); $enter_password_field_input = GFFormsModel::get_input($this, $this->id . ''); $confirm_password_field_input = GFFormsModel::get_input($this, $this->id . '.2'); $enter_password_label = rgar($enter_password_field_input, 'customLabel') != '' ? $enter_password_field_input['customLabel'] : esc_html__('Enter Password', 'gravityforms'); $enter_password_label = gf_apply_filters(array('gform_password', $form_id), $enter_password_label, $form_id); $confirm_password_label = rgar($confirm_password_field_input, 'customLabel') != '' ? $confirm_password_field_input['customLabel'] : esc_html__('Confirm Password', 'gravityforms'); $confirm_password_label = gf_apply_filters(array('gform_password_confirm', $form_id), $confirm_password_label, $form_id); $required_attribute = $this->isRequired ? 'aria-required="true"' : ''; $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"'; $enter_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($enter_password_field_input); $confirm_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($confirm_password_field_input); if ($is_sub_label_above) { return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_password' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_1_container' class='ginput_left'>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}"; } else { return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_password' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_1_container' class='ginput_left'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}"; } }
public static function maybe_export() { if (isset($_POST['export_lead'])) { check_admin_referer('rg_start_export', 'rg_start_export_nonce'); //see if any fields chosen if (empty($_POST['export_field'])) { GFCommon::add_error_message(__('Please select the fields to be exported', 'gravityforms')); return; } $form_id = $_POST['export_form']; $form = RGFormsModel::get_form_meta($form_id); $filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv'; $charset = get_option('blog_charset'); header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename={$filename}"); header('Content-Type: text/csv; charset=' . $charset, true); $buffer_length = ob_get_length(); //length or false if no buffer if ($buffer_length > 1) { ob_clean(); } GFExport::start_export($form); die; } else { if (isset($_POST['export_forms'])) { check_admin_referer('gf_export_forms', 'gf_export_forms_nonce'); $selected_forms = rgpost('gf_form_id'); if (empty($selected_forms)) { GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms')); return; } $forms = RGFormsModel::get_form_meta_by_id($selected_forms); $forms = self::prepare_forms_for_export($forms); $forms['version'] = GFForms::$version; $forms_json = json_encode($forms); $filename = 'gravityforms-export-' . date('Y-m-d') . '.json'; header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename={$filename}"); header('Content-Type: application/json; charset=' . get_option('blog_charset'), true); echo $forms_json; die; } } }
/** * Validate the given BSN number */ function ecs_gform_add_bsn_validation($validation_result) { foreach ($validation_result['form']['fields'] as &$field) { $field_value = rgpost("input_{$field['id']}"); if ('bsn' == $field['inputMaskValue']) { if (0 == strlen($field_value)) { // If empty dont check, when the field is required GF will automaticly catch that before us. continue; } else { if (!ecs_validate_bsn($field_value)) { $validation_result['is_valid'] = false; $field['failed_validation'] = true; $field['validation_message'] = __('Please enter a valid value.', 'gravityforms'); } } } } return $validation_result; }
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; }
public static function is_fully_installed() { global $frmpro_is_installed; if (!$frmpro_is_installed) { if (!is_callable('FrmAppHelper::pro_is_installed') || !FrmAppHelper::pro_is_installed()) { return false; } } if (get_option('fp_pdf_extended_installed') != 'installed' || !is_dir(FP_PDF_TEMPLATE_LOCATION)) { return false; } if (get_option('fp_pdf_extended_version') != FP_PDF_EXTENDED_VERSION) { return false; } if (get_option('fp_pdf_extended_deploy') == 'no' && !rgpost('upgrade') && FP_PDF_DEPLOY === true) { return false; } if (file_exists(FP_PDF_PLUGIN_DIR . 'mPDF.zip')) { return false; } return true; }
private static function run_setting_routing() { /* * Check if we need to redeploy default PDF templates/styles to the theme folder */ if (FP_PDF_DEPLOY === true && rgpost('fp_pdf_deploy') && (wp_verify_nonce($_POST['fp_pdf_deploy_nonce'], 'fp_pdf_deploy_nonce_action') || wp_verify_nonce($_GET['_wpnonce'], 'pdf-extended-filesystem'))) { if (rgpost('upgrade')) { /* * Deploy new template styles * If we get false returned Wordpress is trying to get * access details to update files so don't display anything. */ if (self::deploy() === false) { return true; } } elseif (rgpost('font-initialise')) { } /*elseif(rgpost('cancel')) { update_option('gf_pdf_extended_deploy', 'yes'); }*/ } /* * If the user hasn't requested deployment and there is a _wpnonce check which one it is * and call appropriate function */ if (isset($_GET['_wpnonce'])) { /* * Check if we want to copy the theme files */ if (wp_verify_nonce($_GET['_wpnonce'], 'fppdfe_sync_now')) { $themes = get_option('fppdfe_switch_theme'); if (isset($themes['old']) && isset($themes['new']) && FPPDF_InstallUpdater::do_theme_switch($themes['old'], $themes['new']) === false) { return true; } } } }
public function limit_by_field_values_validation($validation_result) { extract($this->_args); $form = $validation_result['form']; $exceeded_limit = false; foreach ($form['fields'] as &$field) { if ($field['id'] != intval($input_id)) { continue; } $requested_value = rgpost("input_" . str_replace('.', '_', $input_id)); $field_sum = self::get_field_values_sum($form['id'], $input_id); if ($field_sum + $requested_value <= $limit || empty($requested_value)) { continue; } $exceeded_limit = true; $number_left = $limit - $field_sum >= 0 ? $limit - $field_sum : 0; $field['failed_validation'] = true; $field['validation_message'] = sprintf($validation_message, $requested_value, $number_left); } $validation_result['form'] = $form; $validation_result['is_valid'] = !$validation_result['is_valid'] ? false : !$exceeded_limit; return $validation_result; }
/** * Handles the post submission and submitting any data to the appropriate service/method */ public function gravityforms_push($validation_result) { // Get the form action $form = $validation_result['form']; // Build an array of fields for the lead $fields = array(); foreach ($form['fields'] as $field) { if (isset($field['infusionsoft_field'])) { $fields[$field['infusionsoft_field']] = rgpost('input_' . $field['id']); } } // If no fields are being passed (or no email field) or the GF integration isn't loaded, exit now if (empty($fields) or !class_exists('Infusionsoft_GravityForms')) { return $validation_result; } // Access the $infusionsoft global and call the relevant method with the data provided global $infusionsoft; if (isset($form['form_infusionsoft_method'])) { $data = array($form['form_infusionsoft_method'], $fields); call_user_func_array(array($infusionsoft, $form['form_infusionsoft_service']), $data); } return $validation_result; }
function gform_limit_by_field_values_validation($validation_result) { global $sum_field_id, $sum_limit, $sum_validation_message; $form = $validation_result['form']; $exceeded_limit = false; foreach ($form['fields'] as &$field) { if ($field['id'] != intval($sum_field_id)) { continue; } $requested_value = rgpost("input_" . str_replace('.', '_', $sum_field_id)); $field_sum = gform_get_field_values_sum($form['id'], $sum_field_id); if ($field_sum + $requested_value <= $sum_limit) { continue; } $exceeded_limit = true; $number_left = $sum_limit - $field_sum >= 0 ? $sum_limit - $field_sum : 0; $field['failed_validation'] = true; $field['validation_message'] = sprintf($sum_validation_message, $requested_value, $number_left); } $validation_result['form'] = $form; $validation_result['is_valid'] = !$validation_result['is_valid'] ? false : !$exceeded_limit; return $validation_result; }
function require_list_columns($validation_result) { $form = $validation_result['form']; $new_validation_error = false; foreach ($form['fields'] as &$field) { if (!$this->is_applicable_field($field, $form)) { continue; } $values = rgpost("input_{$field['id']}"); // If we got specific fields, loop through those only if (count($this->required_cols)) { foreach ($this->required_cols as $required_col) { if (empty($values[$required_col])) { $new_validation_error = true; $field['failed_validation'] = true; $field['validation_message'] = $field['errorMessage'] ? $field['errorMessage'] : 'All inputs must be filled out.'; } } } else { // skip fields that have req cols specified by another GWRequireListColumns instance $fields_with_req_cols = rgar(self::$fields_with_req_cols, $form['id']); if (is_array($fields_with_req_cols) && in_array($field['id'], $fields_with_req_cols)) { continue; } foreach ($values as $value) { if (empty($value)) { $new_validation_error = true; $field['failed_validation'] = true; $field['validation_message'] = $field['errorMessage'] ? $field['errorMessage'] : 'All inputs must be filled out.'; } } } } $validation_result['form'] = $form; $validation_result['is_valid'] = $new_validation_error ? false : $validation_result['is_valid']; return $validation_result; }
/** * Output the select to change the entry creator * @param int $form_id GF Form ID * @param array $lead GF lead array * @return void */ function add_select($form_id, $lead) { if (rgpost('screen_mode') !== 'edit') { return; } /** * There are issues with too many users where it breaks the select. We try to keep it at a reasonable number. * @link texthttp://codex.wordpress.org/Function_Reference/get_users * @var array Settings array */ $get_users_settings = apply_filters('gravityview_change_entry_creator_user_parameters', array('number' => 300)); $users = get_users($get_users_settings); $output = '<label for="change_created_by">'; $output .= esc_html__('Change Entry Creator:', 'gravity-forms-addons'); $output .= '</label> <select name="created_by" id="change_created_by" class="widefat">'; $output .= '<option value=""> — ' . esc_attr__('No User', 'gravity-view') . ' — </option>'; foreach ($users as $user) { $output .= '<option value="' . $user->ID . '"' . selected($lead['created_by'], $user->ID, false) . '>' . esc_attr($user->display_name . ' (' . $user->user_nicename . ')') . '</option>'; } $output .= '</select>'; $output .= '<input name="originally_created_by" value="' . $lead['created_by'] . '" type="hidden" />'; echo $output; }
public function get_field_input($form, $value = '', $entry = null) { $lead_id = absint(rgar($entry, 'id')); $form_id = absint($form['id']); $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); $id = absint($this->id); $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}"; $size = $this->size; $class_suffix = $is_entry_detail ? '_admin' : ''; $class = $size . $class_suffix; $disabled_text = $is_form_editor ? 'disabled="disabled"' : ''; $tabindex = $this->get_tabindex(); $multiple_files = $this->multipleFiles; $file_list_id = 'gform_preview_' . $form_id . '_' . $id; $is_entry_detail = $this->is_entry_detail(); $is_form_editor = $this->is_form_editor(); $is_admin = $is_entry_detail || $is_form_editor; $max_upload_size = !$is_admin && $this->maxFileSize > 0 ? $this->maxFileSize * 1048576 : wp_max_upload_size(); $allowed_extensions = !empty($this->allowedExtensions) ? join(',', GFCommon::clean_extensions(explode(',', strtolower($this->allowedExtensions)))) : array(); if (!empty($allowed_extensions)) { $extensions_message = esc_attr(sprintf(__('Accepted file types: %s.', 'gravityforms'), str_replace(',', ', ', $allowed_extensions))); } else { $extensions_message = ''; } if ($multiple_files) { $upload_action_url = trailingslashit(site_url()) . '?gf_page=' . GFCommon::get_upload_page_slug(); $max_files = $this->maxFiles > 0 ? $this->maxFiles : 0; $browse_button_id = 'gform_browse_button_' . $form_id . '_' . $id; $container_id = 'gform_multifile_upload_' . $form_id . '_' . $id; $drag_drop_id = 'gform_drag_drop_area_' . $form_id . '_' . $id; $messages_id = "gform_multifile_messages_{$form_id}_{$id}"; if (empty($allowed_extensions)) { $allowed_extensions = '*'; } $disallowed_extensions = GFCommon::get_disallowed_file_extensions(); if (defined('DOING_AJAX') && DOING_AJAX && 'rg_change_input_type' === rgpost('action')) { $plupload_init = array(); } else { $plupload_init = array('runtimes' => 'html5,flash,html4', 'browse_button' => $browse_button_id, 'container' => $container_id, 'drop_element' => $drag_drop_id, 'filelist' => $file_list_id, 'unique_names' => true, 'file_data_name' => 'file', 'url' => $upload_action_url, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array('mime_types' => array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions)), 'max_file_size' => $max_upload_size . 'b'), 'multipart' => true, 'urlstream_upload' => false, 'multipart_params' => array('form_id' => $form_id, 'field_id' => $id), 'gf_vars' => array('max_files' => $max_files, 'message_id' => $messages_id, 'disallowed_extensions' => $disallowed_extensions)); if (rgar($form, 'requireLogin')) { $plupload_init['multipart_params']['_gform_file_upload_nonce_' . $form_id] = wp_create_nonce('gform_file_upload_' . $form_id, '_gform_file_upload_nonce_' . $form_id); } // plupload 2 was introduced in WordPress 3.9. Plupload 1 accepts a slightly different init array. if (version_compare(get_bloginfo('version'), '3.9-RC1', '<')) { $plupload_init['max_file_size'] = $max_upload_size . 'b'; $plupload_init['filters'] = array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions)); } } $plupload_init = gf_apply_filters('gform_plupload_settings', $form_id, $plupload_init, $form_id, $this); $drop_files_here_text = esc_html__('Drop files here or', 'gravityforms'); $select_files_text = esc_attr__('Select files', 'gravityforms'); $plupload_init_json = htmlspecialchars(json_encode($plupload_init), ENT_QUOTES, 'UTF-8'); $upload = "<div id='{$container_id}' data-settings='{$plupload_init_json}' class='gform_fileupload_multifile'>\n\t\t\t\t\t\t\t\t\t\t<div id='{$drag_drop_id}' class='gform_drop_area'>\n\t\t\t\t\t\t\t\t\t\t\t<span class='gform_drop_instructions'>{$drop_files_here_text} </span>\n\t\t\t\t\t\t\t\t\t\t\t<input id='{$browse_button_id}' type='button' value='{$select_files_text}' class='button gform_button_select_files' aria-describedby='extensions_message' {$tabindex} />\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>"; if (!$is_admin) { $upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>"; $upload .= "<div class='validation_message'>\n\t\t\t\t\t\t\t\t<ul id='{$messages_id}'>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</div>"; } if ($is_entry_detail) { $upload .= sprintf('<input type="hidden" name="input_%d" value=\'%s\' />', $id, esc_attr($value)); } } else { $upload = ''; if ($max_upload_size <= 2047 * 1048576) { // MAX_FILE_SIZE > 2048MB fails. The file size is checked anyway once uploaded, so it's not necessary. $upload = sprintf("<input type='hidden' name='MAX_FILE_SIZE' value='%d' />", $max_upload_size); } $upload .= sprintf("<input name='input_%d' id='%s' type='file' class='%s' aria-describedby='extensions_message' {$tabindex} %s/>", $id, $field_id, esc_attr($class), $disabled_text); if (!$is_admin) { $upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>"; } } if ($is_entry_detail && !empty($value)) { // edit entry $file_urls = $multiple_files ? json_decode($value) : array($value); $upload_display = $multiple_files ? '' : "style='display:none'"; $preview = "<div id='upload_{$id}' {$upload_display}>{$upload}</div>"; $preview .= sprintf("<div id='%s'></div>", $file_list_id); $preview .= sprintf("<div id='preview_existing_files_%d'>", $id); foreach ($file_urls as $file_index => $file_url) { if (GFCommon::is_ssl() && strpos($file_url, 'http:') !== false) { $file_url = str_replace('http:', 'https:', $file_url); } $download_file_text = esc_attr__('Download file', 'gravityforms'); $delete_file_text = esc_attr__('Delete file', 'gravityforms'); $file_index = intval($file_index); $file_url = esc_attr($file_url); $display_file_url = GFCommon::truncate_url($file_url); $download_button_url = GFCommon::get_base_url() . '/images/download.png'; $delete_button_url = GFCommon::get_base_url() . '/images/delete.png'; $preview .= "<div id='preview_file_{$file_index}' class='ginput_preview'>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$file_url}' title='{$file_url}'>{$display_file_url}</a>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$download_file_text}' title='{$download_file_text}'>\n\t\t\t\t\t\t\t\t<img src='{$download_button_url}' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='{$delete_file_text}' title='{$delete_file_text}' onclick='DeleteFile({$lead_id},{$id},this);' ><img src='{$delete_button_url}' style='margin-left:10px;'/></a>\n\t\t\t\t\t\t\t</div>"; } $preview .= '</div>'; return $preview; } else { $input_name = "input_{$id}"; $uploaded_files = isset(GFFormsModel::$uploaded_files[$form_id][$input_name]) ? GFFormsModel::$uploaded_files[$form_id][$input_name] : array(); $file_infos = $multiple_files ? $uploaded_files : RGFormsModel::get_temp_filename($form_id, $input_name); if (!empty($file_infos)) { $preview = sprintf("<div id='%s'>", $file_list_id); $file_infos = $multiple_files ? $uploaded_files : array($file_infos); foreach ($file_infos as $file_info) { $file_upload_markup = apply_filters('gform_file_upload_markup', "<img alt='" . esc_attr__('Delete file', 'gravityforms') . "' title='" . esc_attr__('Delete file', 'gravityforms') . "' class='gform_delete' src='" . GFCommon::get_base_url() . "/images/delete.png' onclick='gformDeleteUploadedFile({$form_id}, {$id}, this);' /> <strong>" . esc_html($file_info['uploaded_filename']) . '</strong>', $file_info, $form_id, $id); $preview .= "<div class='ginput_preview'>{$file_upload_markup}</div>"; } $preview .= '</div>'; if (!$multiple_files) { $upload = str_replace(" class='", " class='gform_hidden ", $upload); } return "<div class='ginput_container ginput_container_fileupload'>" . $upload . " {$preview}</div>"; } else { $preview = $multiple_files ? sprintf("<div id='%s'></div>", $file_list_id) : ''; return "<div class='ginput_container ginput_container_fileupload'>{$upload}</div>" . $preview; } } }
public static function ajax_get_more_results() { $form_id = rgpost('form_id'); $field_id = rgpost('field_id'); $offset = rgpost('offset'); $search_criteria = rgpost('search_criteria'); if (empty($search_criteria)) { $search_criteria = array(); } $page_size = 10; $form = RGFormsModel::get_form_meta($form_id); $form_id = $form['id']; $field = RGFormsModel::get_field($form, $field_id); $more_remaining = false; $html = self::get_default_field_results($form_id, $field, $search_criteria, $offset, $page_size, $more_remaining); $response = array(); $response['more_remaining'] = $more_remaining; $response['html'] = $html; $response['offset'] = $offset; echo json_encode($response); die; }
public static function update_lead_status() { check_ajax_referer('gf_delete_entry'); $status = rgpost('status'); $lead_id = rgpost('entry'); switch ($status) { case 'unspam': RGFormsModel::update_lead_property($lead_id, 'status', 'active'); break; case 'delete': if (GFCommon::current_user_can_any('gravityforms_delete_entries')) { RGFormsModel::delete_lead($lead_id); } break; default: RGFormsModel::update_lead_property($lead_id, 'status', $status); break; } header('Content-Type: text/xml'); echo "<?xml version='1.0' standalone='yes'?><wp_ajax></wp_ajax>"; exit; }
public static function lead_detail_page() { global $current_user; if (!GFCommon::ensure_wp_version()) { return; } echo GFCommon::get_remote_message(); $form = RGFormsModel::get_form_meta(absint($_GET['id'])); $form_id = absint($form['id']); $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form)); $lead_id = absint(rgget('lid')); $filter = rgget('filter'); $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active'; $position = rgget('pos') ? rgget('pos') : 0; $sort_direction = rgget('dir') ? rgget('dir') : 'DESC'; $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort']; $sort_field_meta = RGFormsModel::get_field($form, $sort_field); $is_numeric = $sort_field_meta['type'] == 'number'; $star = $filter == 'star' ? 1 : null; $read = $filter == 'unread' ? 0 : null; $search_criteria['status'] = $status; if ($star) { $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star); } if (!is_null($read)) { $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read); } $search_field_id = rgget('field_id'); if (isset($_GET['field_id']) && $_GET['field_id'] !== '') { $key = $search_field_id; $val = rgget('s'); $strpos_row_key = strpos($search_field_id, '|'); if ($strpos_row_key !== false) { //multi-row likert $key_array = explode('|', $search_field_id); $key = $key_array[0]; $val = $key_array[1] . ':' . $val; } $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_GET) ? 'is' : rgget('operator'), 'value' => $val); $type = rgget('type'); if (empty($type)) { if (rgget('field_id') == '0') { $search_criteria['type'] = 'global'; } } } $paging = array('offset' => $position, 'page_size' => 1); if (!empty($sort_field)) { $sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric); } else { $sorting = array(); } $total_count = 0; $leads = GFAPI::get_entries($form['id'], $search_criteria, $sorting, $paging, $total_count); $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false; $next_pos = !rgblank($position) && $position < $total_count - 1 ? $position + 1 : false; // unread filter requires special handling for pagination since entries are filter out of the query as they are read if ($filter == 'unread') { $next_pos = $position; if ($next_pos + 1 == $total_count) { $next_pos = false; } } if (!$lead_id) { $lead = !empty($leads) ? $leads[0] : false; } else { $lead = GFAPI::get_entry($lead_id); } if (!$lead) { esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms'); return; } RGFormsModel::update_lead_property($lead['id'], 'is_read', 1); switch (RGForms::post('action')) { case 'update': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); //Loading files that have been uploaded to temp folder $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files'))); if (!is_array($files)) { $files = array(); } GFFormsModel::$uploaded_files[$form_id] = $files; GFFormsModel::save_lead($form, $lead); do_action('gform_after_update_entry', $form, $lead['id']); do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']); $lead = RGFormsModel::get_lead($lead['id']); $lead = GFFormsModel::set_entry_meta($lead, $form); break; case 'add_note': check_admin_referer('gforms_update_note', 'gforms_update_note'); $user_data = get_userdata($current_user->ID); RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note'])); //emailing notes if configured if (rgpost('gentry_email_notes_to')) { GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.'); $email_to = $_POST['gentry_email_notes_to']; $email_from = $current_user->user_email; $email_subject = stripslashes($_POST['gentry_email_subject']); $body = stripslashes($_POST['new_note']); $headers = "From: \"{$email_from}\" <{$email_from}> \r\n"; GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}"); $is_success = wp_mail($email_to, $email_subject, $body, $headers); $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success; GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}"); if (!is_wp_error($is_success) && $is_success) { GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.'); } else { GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.'); } if (has_filter('phpmailer_init')) { GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.'); } do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead); } break; case 'add_quick_note': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); $user_data = get_userdata($current_user->ID); RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note'])); break; case 'bulk': check_admin_referer('gforms_update_note', 'gforms_update_note'); if ($_POST['bulk_action'] == 'delete') { if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) { die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms')); } RGFormsModel::delete_notes($_POST['note']); } break; case 'trash': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); RGFormsModel::update_lead_property($lead['id'], 'status', 'trash'); $lead = RGFormsModel::get_lead($lead['id']); break; case 'restore': case 'unspam': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); RGFormsModel::update_lead_property($lead['id'], 'status', 'active'); $lead = RGFormsModel::get_lead($lead['id']); break; case 'spam': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); RGFormsModel::update_lead_property($lead['id'], 'status', 'spam'); $lead = RGFormsModel::get_lead($lead['id']); break; case 'delete': check_admin_referer('gforms_save_entry', 'gforms_save_entry'); if (!GFCommon::current_user_can_any('gravityforms_delete_entries')) { die(esc_html__("You don't have adequate permission to delete entries.", 'gravityforms')); } RGFormsModel::delete_lead($lead['id']); ?> <script type="text/javascript"> document.location.href = '<?php echo 'admin.php?page=gf_entries&view=entries&id=' . absint($form['id']); ?> '; </script> <?php break; } $mode = empty($_POST['screen_mode']) ? 'view' : $_POST['screen_mode']; $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min'; ?> <link rel="stylesheet" href="<?php echo GFCommon::get_base_url(); ?> /css/admin<?php echo $min; ?> .css" /> <script type="text/javascript"> jQuery(document).ready(function () { toggleNotificationOverride(true); jQuery('#gform_update_button').prop('disabled', false); }); function DeleteFile(leadId, fieldId, deleteButton) { if (confirm(<?php echo json_encode(__("Would you like to delete this file? 'Cancel' to stop. 'OK' to delete", 'gravityforms')); ?> )) { var fileIndex = jQuery(deleteButton).parent().index(); var mysack = new sack("<?php echo admin_url('admin-ajax.php'); ?> "); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar("action", "rg_delete_file"); mysack.setVar("rg_delete_file", "<?php echo wp_create_nonce('rg_delete_file'); ?> "); mysack.setVar("lead_id", leadId); mysack.setVar("field_id", fieldId); mysack.setVar("file_index", fileIndex); mysack.onError = function () { alert(<?php echo json_encode(__('Ajax error while deleting field.', 'gravityforms')); ?> ) }; mysack.runAJAX(); return true; } } function EndDeleteFile(fieldId, fileIndex) { var previewFileSelector = "#preview_existing_files_" + fieldId + " .ginput_preview"; var $previewFiles = jQuery(previewFileSelector); var rr = $previewFiles.eq(fileIndex); $previewFiles.eq(fileIndex).remove(); var $visiblePreviewFields = jQuery(previewFileSelector); if ($visiblePreviewFields.length == 0) { jQuery('#preview_' + fieldId).hide(); jQuery('#upload_' + fieldId).show('slow'); } } function ToggleShowEmptyFields() { if (jQuery("#gentry_display_empty_fields").is(":checked")) { createCookie("gf_display_empty_fields", true, 10000); document.location = document.location.href; } else { eraseCookie("gf_display_empty_fields"); document.location = document.location.href; } } function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; } function eraseCookie(name) { createCookie(name, "", -1); } function ResendNotifications() { var selectedNotifications = new Array(); jQuery(".gform_notifications:checked").each(function () { selectedNotifications.push(jQuery(this).val()); }); var sendTo = jQuery('#notification_override_email').val(); if (selectedNotifications.length <= 0) { displayMessage(<?php echo json_encode(__('You must select at least one type of notification to resend.', 'gravityforms')); ?> , 'error', '#notifications_container'); return; } jQuery('#please_wait_container').fadeIn(); jQuery.post(ajaxurl, { action : "gf_resend_notifications", gf_resend_notifications: '<?php echo wp_create_nonce('gf_resend_notifications'); ?> ', notifications : jQuery.toJSON(selectedNotifications), sendTo : sendTo, leadIds : '<?php echo absint($lead['id']); ?> ', formId : '<?php echo absint($form['id']); ?> ' }, function (response) { if (response) { displayMessage(response, "error", "#notifications_container"); } else { displayMessage(<?php echo json_encode(esc_html__('Notifications were resent successfully.', 'gravityforms')); ?> , "updated", "#notifications_container" ); // reset UI jQuery(".gform_notifications").attr( 'checked', false ); jQuery('#notification_override_email').val(''); toggleNotificationOverride(); } jQuery('#please_wait_container').hide(); setTimeout(function () { jQuery('#notifications_container').find('.message').slideUp(); }, 5000); } ); } function displayMessage( message, messageClass, container ) { jQuery( container ).find( '.message' ).hide().html( message ).attr( 'class', 'message ' + messageClass ).slideDown(); } function toggleNotificationOverride(isInit) { if (isInit) jQuery('#notification_override_email').val(''); if (jQuery(".gform_notifications:checked").length > 0) { jQuery('#notifications_override_settings').slideDown(); } else { jQuery('#notifications_override_settings').slideUp(function () { jQuery('#notification_override_email').val(''); }); } } </script> <form method="post" id="entry_form" enctype='multipart/form-data'> <?php wp_nonce_field('gforms_save_entry', 'gforms_save_entry'); ?> <input type="hidden" name="action" id="action" value="" /> <input type="hidden" name="screen_mode" id="screen_mode" value="<?php echo esc_attr(rgpost('screen_mode')); ?> " /> <div class="wrap gf_entry_wrap"> <h2 class="gf_admin_page_title"> <span><?php echo esc_html__('Entry #', 'gravityforms') . absint($lead['id']); ?> </span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php echo absint($form['id']); ?> </span><span class='gf_admin_page_formname'><?php esc_html_e('Form Name', 'gravityforms'); ?> : <?php echo esc_html($form['title']); $gf_entry_locking = new GFEntryLocking(); $gf_entry_locking->lock_info($lead_id); ?> </span></span></h2> <?php if (isset($_GET['pos'])) { ?> <div class="gf_entry_detail_pagination"> <ul> <li class="gf_entry_count"> <span>entry <strong><?php echo $position + 1; ?> </strong> of <strong><?php echo $total_count; ?> </strong></span> </li> <li class="gf_entry_prev gf_entry_pagination"><?php echo GFEntryDetail::entry_detail_pagination_link($prev_pos, 'Previous Entry', 'gf_entry_prev_link', 'fa fa-arrow-circle-o-left'); ?> </li> <li class="gf_entry_next gf_entry_pagination"><?php echo GFEntryDetail::entry_detail_pagination_link($next_pos, 'Next Entry', 'gf_entry_next_link', 'fa fa-arrow-circle-o-right'); ?> </li> </ul> </div> <?php } ?> <?php RGForms::top_toolbar(); ?> <div id="poststuff" class="metabox-holder has-right-sidebar"> <div id="side-info-column" class="inner-sidebar"> <?php do_action('gform_entry_detail_sidebar_before', $form, $lead); ?> <!-- INFO BOX --> <div id="submitdiv" class="stuffbox"> <h3 class="hndle" style="cursor:default;"> <span><?php esc_html_e('Entry', 'gravityforms'); ?> </span> </h3> <div class="inside"> <div id="submitcomment" class="submitbox"> <div id="minor-publishing" style="padding:10px;"> <?php esc_html_e('Entry Id', 'gravityforms'); ?> : <?php echo absint($lead['id']); ?> <br /><br /> <?php esc_html_e('Submitted on', 'gravityforms'); ?> : <?php echo esc_html(GFCommon::format_date($lead['date_created'], false, 'Y/m/d')); ?> <br /><br /> <?php esc_html_e('User IP', 'gravityforms'); ?> : <?php echo esc_html($lead['ip']); ?> <br /><br /> <?php if (!empty($lead['created_by']) && ($usermeta = get_userdata($lead['created_by']))) { ?> <?php esc_html_e('User', 'gravityforms'); ?> : <a href="user-edit.php?user_id=<?php echo absint($lead['created_by']); ?> " alt="<?php esc_attr_e('View user profile', 'gravityforms'); ?> " title="<?php esc_attr_e('View user profile', 'gravityforms'); ?> "><?php echo esc_html($usermeta->user_login); ?> </a> <br /><br /> <?php } ?> <?php esc_html_e('Embed Url', 'gravityforms'); ?> : <a href="<?php echo esc_url($lead['source_url']); ?> " target="_blank" alt="<?php echo esc_attr($lead['source_url']); ?> " title="<?php echo esc_attr($lead['source_url']); ?> ">.../<?php echo esc_html(GFCommon::truncate_url($lead['source_url'])); ?> </a> <br /><br /> <?php if (!empty($lead['post_id'])) { $post = get_post($lead['post_id']); ?> <?php esc_html_e('Edit Post', 'gravityforms'); ?> : <a href="post.php?action=edit&post=<?php echo absint($post->ID); ?> " alt="<?php esc_attr_e('Click to edit post', 'gravityforms'); ?> " title="<?php esc_attr_e('Click to edit post', 'gravityforms'); ?> "><?php echo esc_html($post->post_title); ?> </a> <br /><br /> <?php } if (do_action('gform_enable_entry_info_payment_details', true, $lead)) { if (!empty($lead['payment_status'])) { echo $lead['transaction_type'] != 2 ? esc_html__('Payment Status', 'gravityforms') : esc_html__('Subscription Status', 'gravityforms'); ?> : <span id="gform_payment_status"><?php echo apply_filters('gform_payment_status', $lead['payment_status'], $form, $lead); ?> </span> <br /><br /> <?php if (!empty($lead['payment_date'])) { echo $lead['transaction_type'] != 2 ? esc_html__('Payment Date', 'gravityforms') : esc_html__('Start Date', 'gravityforms'); ?> : <?php echo GFCommon::format_date($lead['payment_date'], false, 'Y/m/d', $lead['transaction_type'] != 2); ?> <br /><br /> <?php } if (!empty($lead['transaction_id'])) { echo $lead['transaction_type'] != 2 ? esc_html__('Transaction Id', 'gravityforms') : esc_html__('Subscriber Id', 'gravityforms'); ?> : <?php echo esc_html($lead['transaction_id']); ?> <br /><br /> <?php } if (!rgblank($lead['payment_amount'])) { echo $lead['transaction_type'] != 2 ? esc_html__('Payment Amount', 'gravityforms') : esc_html__('Subscription Amount', 'gravityforms'); ?> : <?php echo GFCommon::to_money($lead['payment_amount'], $lead['currency']); ?> <br /><br /> <?php } } } do_action('gform_entry_info', $form['id'], $lead); ?> </div> <div id="major-publishing-actions"> <div id="delete-action"> <?php switch ($lead['status']) { case 'spam': if (GFCommon::spam_enabled($form['id'])) { ?> <a onclick="jQuery('#action').val('unspam'); jQuery('#entry_form').submit()" href="#"><?php esc_html_e('Not Spam', 'gravityforms'); ?> </a> <?php echo GFCommon::current_user_can_any('gravityforms_delete_entries') ? '|' : ''; } if (GFCommon::current_user_can_any('gravityforms_delete_entries')) { ?> <a class="submitdelete deletion" onclick="if ( confirm('<?php echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms')); ?> ') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php esc_html_e('Delete Permanently', 'gravityforms'); ?> </a> <?php } break; case 'trash': ?> <a onclick="jQuery('#action').val('restore'); jQuery('#entry_form').submit()" href="#"><?php esc_html_e('Restore', 'gravityforms'); ?> </a> <?php if (GFCommon::current_user_can_any('gravityforms_delete_entries')) { ?> | <a class="submitdelete deletion" onclick="if ( confirm('<?php echo esc_js(__("You are about to delete this entry. 'Cancel' to stop, 'OK' to delete.", 'gravityforms')); ?> ') ) {jQuery('#action').val('delete'); jQuery('#entry_form').submit(); return true;} return false;" href="#"><?php esc_html_e('Delete Permanently', 'gravityforms'); ?> </a> <?php } break; default: if (GFCommon::current_user_can_any('gravityforms_delete_entries')) { ?> <a class="submitdelete deletion" onclick="jQuery('#action').val('trash'); jQuery('#entry_form').submit()" href="#"><?php esc_html_e('Move to Trash', 'gravityforms'); ?> </a> <?php echo GFCommon::spam_enabled($form['id']) ? '|' : ''; } if (GFCommon::spam_enabled($form['id'])) { ?> <a class="submitdelete deletion" onclick="jQuery('#action').val('spam'); jQuery('#entry_form').submit()" href="#"><?php esc_html_e('Mark as Spam', 'gravityforms'); ?> </a> <?php } } ?> </div> <div id="publishing-action"> <?php if (GFCommon::current_user_can_any('gravityforms_edit_entries') && $lead['status'] != 'trash') { $button_text = $mode == 'view' ? __('Edit', 'gravityforms') : __('Update', 'gravityforms'); $disabled = $mode == 'view' ? '' : ' disabled="disabled" '; $update_button_id = $mode == 'view' ? 'gform_edit_button' : 'gform_update_button'; $button_click = $mode == 'view' ? "jQuery('#screen_mode').val('edit');" : "jQuery('#action').val('update'); jQuery('#screen_mode').val('view');"; $update_button = '<input id="' . $update_button_id . '" ' . $disabled . ' class="button button-large button-primary" type="submit" tabindex="4" value="' . esc_attr($button_text) . '" name="save" onclick="' . $button_click . '"/>'; echo apply_filters('gform_entrydetail_update_button', $update_button); if ($mode == 'edit') { echo ' <input class="button button-large" type="submit" tabindex="5" value="' . esc_attr__('Cancel', 'gravityforms') . '" name="cancel" onclick="jQuery(\'#screen_mode\').val(\'view\');"/>'; } } ?> </div> <div class="clear"></div> </div> </div> </div> </div> <?php if (!empty($lead['payment_status']) && !apply_filters('gform_enable_entry_info_payment_details', true, $lead)) { self::payment_details_box($lead, $form); } ?> <?php do_action('gform_entry_detail_sidebar_middle', $form, $lead); ?> <?php if (GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) { ?> <!-- start notifications --> <div class="postbox" id="notifications_container"> <h3 class="hndle" style="cursor:default;"> <span><?php esc_html_e('Notifications', 'gravityforms'); ?> </span> </h3> <div class="inside"> <div class="message" style="display:none;padding:10px;"></div> <div> <?php $notifications = GFCommon::get_notifications('resend_notifications', $form); if (!is_array($notifications) || count($form['notifications']) <= 0) { ?> <p class="description"><?php esc_html_e('You cannot resend notifications for this entry because this form does not currently have any notifications configured.', 'gravityforms'); ?> </p> <a href="<?php echo admin_url("admin.php?page=gf_edit_forms&view=settings&subview=notification&id={$form_id}"); ?> " class="button"><?php esc_html_e('Configure Notifications', 'gravityforms'); ?> </a> <?php } else { foreach ($notifications as $notification) { ?> <input type="checkbox" class="gform_notifications" value="<?php echo esc_attr($notification['id']); ?> " id="notification_<?php echo esc_attr($notification['id']); ?> " onclick="toggleNotificationOverride();" /> <label for="notification_<?php echo esc_attr($notification['id']); ?> "><?php echo esc_html($notification['name']); ?> </label> <br /><br /> <?php } ?> <div id="notifications_override_settings" style="display:none;"> <p class="description" style="padding-top:0; margin-top:0; width:99%;">You may override the default notification settings by entering a comma delimited list of emails to which the selected notifications should be sent.</p> <label for="notification_override_email"><?php esc_html_e('Send To', 'gravityforms'); ?> <?php gform_tooltip('notification_override_email'); ?> </label><br /> <input type="text" name="notification_override_email" id="notification_override_email" style="width:99%;" /> <br /><br /> </div> <input type="button" name="notification_resend" value="<?php esc_attr_e('Resend Notifications', 'gravityforms'); ?> " class="button" style="" onclick="ResendNotifications();" /> <span id="please_wait_container" style="display:none; margin-left: 5px;"> <i class='gficon-gravityforms-spinner-icon gficon-spin'></i> <?php esc_html_e('Resending...', 'gravityforms'); ?> </span> <?php } ?> </div> </div> </div> <!-- / end notifications --> <?php } ?> <!-- begin print button --> <div class="detail-view-print"> <a href="javascript:;" onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='<?php echo trailingslashit(site_url()); ?> ?gf_page=print-entry&fid=<?php echo absint($form['id']); ?> &lid=<?php echo absint($lead['id']); ?> ' + notes_qs; window.open (url,'printwindow');" class="button"><?php esc_html_e('Print', 'gravityforms'); ?> </a> <?php if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) { ?> <input type="checkbox" name="print_notes" value="print_notes" checked="checked" id="gform_print_notes" /> <label for="print_notes"><?php esc_html_e('include notes', 'gravityforms'); ?> </label> <?php } ?> </div> <!-- end print button --> <?php do_action('gform_entry_detail_sidebar_after', $form, $lead); ?> </div> <div id="post-body" class="has-sidebar"> <div id="post-body-content" class="has-sidebar-content"> <?php do_action('gform_entry_detail_content_before', $form, $lead); if ($mode == 'view') { self::lead_detail_grid($form, $lead, true); } else { self::lead_detail_edit($form, $lead); } do_action('gform_entry_detail', $form, $lead); if (GFCommon::current_user_can_any('gravityforms_view_entry_notes')) { ?> <div class="postbox"> <h3> <label for="name"><?php esc_html_e('Notes', 'gravityforms'); ?> </label> </h3> <form method="post"> <?php wp_nonce_field('gforms_update_note', 'gforms_update_note'); ?> <div class="inside"> <?php $notes = RGFormsModel::get_lead_notes($lead['id']); //getting email values $email_fields = GFCommon::get_email_fields($form); $emails = array(); foreach ($email_fields as $email_field) { if (!empty($lead[$email_field->id])) { $emails[] = $lead[$email_field->id]; } } //displaying notes grid $subject = ''; self::notes_grid($notes, true, $emails, $subject); ?> </div> </form> </div> <?php } do_action('gform_entry_detail_content_after', $form, $lead); ?> </div> </div> </div> </div> </form> <?php if (rgpost('action') == 'update') { ?> <div class="updated fade" style="padding:6px;"> <?php esc_html_e('Entry Updated.', 'gravityforms'); ?> </div> <?php } }
public static function save_form_setting($form) { $form['enable_sisyphus'] = rgpost('enable_sisyphus'); return $form; }
function is_last_page_reached() { return rgpost('gw_last_page_reached'); }
/** * get input values for recurring payments field * @param integer $field_id * @return array */ public static function getPost($field_id) { $recurring = rgpost('gfeway_' . $field_id); if (is_array($recurring)) { $intervalSize = 1; switch ($recurring[6]) { case 'weekly': $intervalType = GFEwayRecurringPayment::WEEKS; break; case 'fortnightly': $intervalType = GFEwayRecurringPayment::WEEKS; $intervalSize = 2; break; case 'monthly': $intervalType = GFEwayRecurringPayment::MONTHS; break; case 'quarterly': $intervalType = GFEwayRecurringPayment::MONTHS; $intervalSize = 3; break; case 'yearly': $intervalType = GFEwayRecurringPayment::YEARS; break; default: // invalid or not selected $intervalType = -1; break; } $recurring = array('amountInit' => GFCommon::to_number($recurring[1]), 'dateInit' => self::parseDate($recurring[2]), 'amountRecur' => GFCommon::to_number($recurring[3]), 'dateStart' => self::parseDate($recurring[4]), 'dateEnd' => self::parseDate($recurring[5]), 'intervalSize' => $intervalSize, 'intervalType' => $intervalType, 'intervalTypeDesc' => $recurring[6]); } else { $recurring = false; } return $recurring; }