/** * Check if the form has a text field with a Custom CSS Class that contains 'helpscout-docs' * * @param array $form * * @return bool True: yes, it does. False: nope. */ private function has_docs_field($form) { $text_fields = GFCommon::get_fields_by_type($form, 'text'); foreach ($text_fields as $text_field) { if (strpos(rgar($text_field, 'cssClass'), self::field_css_class) !== false) { return true; } } return false; }
function GFUEA_custom_notification_attachments($notification, $form, $entry) { $log = 'rw_notification_attachments() - '; GFCommon::log_debug($log . 'starting.'); # mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true)); if (substr($notification["name"], -5) == "GFUEA") { //mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true)); $fileupload_fields = GFCommon::get_fields_by_type($form, array('fileupload')); if (!is_array($fileupload_fields)) { return $notification; } $attachments = array(); $upload_root = RGFormsModel::get_upload_root(); foreach ($fileupload_fields as $field) { $url = $entry[$field['id']]; if (empty($url)) { continue; } elseif ($field['multipleFiles']) { $uploaded_files = json_decode(stripslashes($url), true); $zip = new ZipArchive(); //$filetext = date("Y-m-d his"); $filename = $upload_root . "/uploaded_files" . $entry['id'] . ".zip"; if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) { foreach ($uploaded_files as $uploaded_file) { $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file); GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true)); $attachments[] = $attachment; } } else { foreach ($uploaded_files as $uploaded_file) { $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file); GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true)); $new_filename = substr($attachment, strrpos($attachment, '/') + 1); $zip->addFile($attachment, $new_filename); //$attachments[] = $attachment; } $zip->close(); $attachments[] = $filename; add_filter('gform_confirmation', 'gfuea_clean_zips', 10, 4); } } else { $attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $url); GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true)); $attachments[] = $attachment; } } $notification['attachments'] = $attachments; } //mail("*****@*****.**","Notification Fire" . date("Y-m-d h:i:s"), "Attach IDs:\n" . print_r($attachIds, true) . "\nNotification:\n" . print_r($notification, true) . "\nForm:\n" .print_r($form,true) . "\nEntry:\n" .print_r($entry,true)); GFCommon::log_debug($log . 'stopping.'); return $notification; }
/** * @inheritDoc * * @since 1.8 */ public function pre_render_frontend() { if (!class_exists('GFPolls')) { $return = false; do_action('gravityview_log_error', 'Poll Widget not displayed; the Poll Addon is not loaded'); } else { $return = parent::pre_render_frontend(); $poll_fields = GFCommon::get_fields_by_type(GravityView_View::getInstance()->getForm(), array('poll')); if (empty($poll_fields)) { do_action('gravityview_log_error', 'Poll Widget not displayed; there are no poll fields for the form'); $return = false; } } return $return; }
public static function has_multifile_fileupload_field($form) { $fileupload_fields = GFCommon::get_fields_by_type($form, array('fileupload', 'post_custom_field')); if (is_array($fileupload_fields)) { foreach ($fileupload_fields as $field) { if ($field->multipleFiles) { return true; } } } return false; }
public static function delete_passwords($entry, $form) { $password_fields = GFCommon::get_fields_by_type($form, array('password')); foreach ($password_fields as $password_field) { GFAPI::update_entry_field($entry['id'], $password_field['id'], ''); } }
private function _field_condition_matches($field_types, $form) { if (!is_array($field_types)) { $field_types = array($field_types); } $fields = GFCommon::get_fields_by_type($form, $field_types); if (count($fields) > 0) { return true; } return false; }
/** * Retrieves the coupon field object or false. * * @param array $form The form object currently being processed. * * @return object|false */ public function get_coupon_field($form) { $coupons = GFCommon::get_fields_by_type($form, array('coupon')); return count($coupons) > 0 ? $coupons[0] : false; }
private static function get_akismet_field($field_type, $form, $lead) { $fields = GFCommon::get_fields_by_type($form, array($field_type)); if (empty($fields)) { return ""; } $value = RGFormsModel::get_lead_field_value($lead, $fields[0]); switch ($field_type) { case "name": $value = GFCommon::get_lead_field_display($fields[0], $value); break; } return $value; }
public static function delete_password($entry, $form) { $password_fields = GFCommon::get_fields_by_type($form, array('password')); if (empty($password_fields)) { return; } $field_ids = array(); foreach ($password_fields as $password_field) { $field_ids[] = $password_field['id']; } $field_id_list = implode(',', $field_ids); global $wpdb; $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}rg_lead_detail\n\t\t\t\t\t\t\t\t\t WHERE lead_id = %d AND form_id = %d\n\t\t\t\t\t\t\t\t\t AND CAST(field_number as DECIMAL(4,2)) IN ({$field_id_list})", $entry['id'], $form['id'])); }
public function display_confirmation($confirmation, $form, $lead, $ajax) { $poll_fields = GFCommon::get_fields_by_type($form, array('poll')); $display_confirmation = false; $display_results = false; if (empty($poll_fields)) { return $confirmation; } $form_id = $form['id']; $override = false; $field_values = array(); if (isset($_POST['gform_field_values'])) { $field_values = wp_parse_args($_POST['gform_field_values']); } // shortcode attributes override form settings if (rgar($field_values, 'gpoll_enabled') == '1') { $field_values = wp_parse_args($_POST['gform_field_values']); $show_results_link = rgar($field_values, 'gpoll_show_results_link'); $show_results_link = $show_results_link == '1' ? true : false; $style = rgar($field_values, 'gpoll_style'); $percentages = rgar($field_values, 'gpoll_percentages'); $percentages = $percentages == '1' ? true : false; $counts = rgar($field_values, 'gpoll_counts'); $counts = $counts == '1' ? true : false; $cookie = rgar($field_values, 'gpoll_cookie'); $display_results = rgar($field_values, 'gpoll_display_results'); $display_results = $display_results == '1' ? true : false; $display_confirmation = rgar($field_values, 'gpoll_confirmation'); $display_confirmation = $display_confirmation == '1' ? true : false; $checksum = rgar($field_values, 'gpoll_checksum'); if ($checksum == $this->generate_checksum($display_results, $show_results_link, $cookie, $display_confirmation, $percentages, $counts, $style)) { $override = true; } } if (false === $override) { $style = $this->get_form_setting($form, 'style'); $percentages = $this->get_form_setting($form, 'showPercentages'); $counts = $this->get_form_setting($form, 'showCounts'); $display_results = $this->get_form_setting($form, 'displayResults'); $display_confirmation = true; } $submitted_fields = array(); foreach ($poll_fields as $field) { $field_id = $field['id']; $entry_value = RGFormsModel::get_lead_field_value($lead, $field); if (is_array($entry_value)) { $entry_value = implode('', $entry_value); } if (false === empty($entry_value)) { $submitted_fields[] = $field_id; } } if ($display_confirmation && $display_results) { //confirmation message plus results //override in the case of headers already sent or ajax = true if (is_array($confirmation) && array_key_exists('redirect', $confirmation)) { $confirmation = ''; } //override confirmation if it's a redirect $str_pos = strpos($confirmation, 'gformRedirect'); if (false !== $str_pos) { $confirmation = ''; } $has_confirmation_wrapper = false !== strpos($confirmation, 'gform_confirmation_wrapper') ? true : false; if ($has_confirmation_wrapper) { $confirmation = substr($confirmation, 0, strlen($confirmation) - 6); } //remove the closing div of the wrapper $has_confirmation_message = false !== strpos($confirmation, 'gforms_confirmation_message') ? true : false; if ($has_confirmation_message) { $confirmation = substr($confirmation, 0, strlen($confirmation) - 6); } else { $confirmation .= "<div id='gforms_confirmation_message' class='gform_confirmation_message_{$form_id}'>"; } $results = $this->gpoll_get_results($form['id'], $submitted_fields, $style, $percentages, $counts, $lead); $confirmation .= $results['summary'] . '</div>'; if ($has_confirmation_wrapper) { $confirmation .= '</div>'; } } elseif (!$display_confirmation && $display_results) { //only the results without the confirmation message $results = $this->gpoll_get_results($form['id'], $submitted_fields, $style, $percentages, $counts, $lead); $results_summary = $results['summary']; $confirmation = sprintf("<div id='gforms_confirmation_message' class='gform_confirmation_message_{$form_id}'>%s</div>", $results_summary); } elseif (!$display_confirmation && !$display_results) { $confirmation = "<div id='gforms_confirmation_message' class='gform_confirmation_message_{$form_id}'></div>"; } return $confirmation; }
private static function has_price_field($form){ $price_fields = GFCommon::get_fields_by_type($form, array("product", "donation")); return !empty($price_fields); }
public function add_merge_tags($form) { $survey_fields = GFCommon::get_fields_by_type($form, array('survey')); if (empty($survey_fields)) { return $form; } $scoring_enabled = false; $merge_tags = array(); foreach ($form['fields'] as $field) { $type = GFFormsModel::get_input_type($field); if ('likert' == $type && rgar($field, 'gsurveyLikertEnableScoring')) { $scoring_enabled = true; $field_id = $field['id']; $field_label = $field['label']; $group = rgar($field, 'isRequired') ? 'required' : 'optional'; $merge_tags[] = array('group' => $group, 'label' => 'Survey Field Score: ' . $field_label, 'tag' => "{score:id={$field_id}}"); } } if ($scoring_enabled) { $merge_tags[] = array('group' => 'other', 'label' => 'Survey Total Score', 'tag' => '{survey_total_score}'); } ?> <script type="text/javascript"> if (window.gform) gform.addFilter("gform_merge_tags", "gsurvey_add_merge_tags"); function gsurvey_add_merge_tags(mergeTags, elementId, hideAllFields, excludeFieldTypes, isPrepop, option) { if (isPrepop) return mergeTags; var customMergeTags = <?php echo json_encode($merge_tags); ?> ; jQuery.each(customMergeTags, function (i, customMergeTag) { mergeTags[customMergeTag.group].tags.push({ tag: customMergeTag.tag, label: customMergeTag.label }); }); return mergeTags; } </script> <?php //return the form object from the php hook return $form; }
/** * Get file upload fields for feed settings field. * * @access public * @return array $choices */ public function fileupload_fields_for_feed_setting() { /* Setup choices array. */ $choices = array(); /* Get the form file fields. */ $form = GFAPI::get_form(rgget('id')); $file_fields = GFCommon::get_fields_by_type($form, array('fileupload')); if (!empty($file_fields)) { foreach ($file_fields as $field) { $choices[] = array('name' => 'attachments[' . $field->id . ']', 'label' => $field->label, 'default_value' => 0); } } return $choices; }
public function get_credit_card() { $credit_card = null; $credit_card_fields = GFCommon::get_fields_by_type($this->form, array('creditcard')); $credit_card_field = array_shift($credit_card_fields); if ($credit_card_field) { $credit_card = new Pronamic_Pay_CreditCard(); // Number $variable_name = sprintf('input_%s_1', $credit_card_field['id']); $number = filter_input(INPUT_POST, $variable_name, FILTER_SANITIZE_STRING); $credit_card->set_number($number); // Expiration date $variable_name = sprintf('input_%s_2', $credit_card_field['id']); $expiration_date = filter_input(INPUT_POST, $variable_name, FILTER_VALIDATE_INT, FILTER_FORCE_ARRAY); $month = array_shift($expiration_date); $year = array_shift($expiration_date); $credit_card->set_expiration_month($month); $credit_card->set_expiration_year($year); // Security code $variable_name = sprintf('input_%s_3', $credit_card_field['id']); $security_code = filter_input(INPUT_POST, $variable_name, FILTER_SANITIZE_STRING); $credit_card->set_security_code($security_code); // Name $variable_name = sprintf('input_%s_5', $credit_card_field['id']); $name = filter_input(INPUT_POST, $variable_name, FILTER_SANITIZE_STRING); $credit_card->set_name($name); } return $credit_card; }
public static function has_pricing_field($form) { $fields = GFCommon::get_fields_by_type($form, array("product")); return count($fields) > 0; }
public static function notification_page($form_id) { add_action('media_buttons', array('GFNotification', 'media_buttons'), 40); $form = RGFormsModel::get_form_meta($form_id); $invalid_tab = ""; if (rgpost("save")) { check_admin_referer('gforms_save_notification', 'gforms_save_notification'); $form["notification"]["to"] = rgpost("form_notification_to"); $form["notification"]["bcc"] = rgpost("form_notification_bcc"); $form["notification"]["subject"] = rgpost("form_notification_subject"); $form["notification"]["message"] = rgpost("form_notification_message"); $form["notification"]["from"] = rgempty("form_notification_from_field") ? rgpost("form_notification_from") : ""; $form["notification"]["fromField"] = rgpost("form_notification_from_field"); $form["notification"]["fromName"] = rgempty("form_notification_from_name_field") ? rgpost("form_notification_from_name") : ""; $form["notification"]["fromNameField"] = rgpost("form_notification_from_name_field"); $form["notification"]["replyTo"] = rgempty("form_notification_reply_to_field") ? rgpost("form_notification_reply_to") : ""; $form["notification"]["replyToField"] = rgpost("form_notification_reply_to_field"); $form["notification"]["routing"] = !rgempty("gform_routing_meta") ? GFCommon::json_decode(rgpost("gform_routing_meta"), true) : null; $form["notification"]["disableAutoformat"] = rgpost("form_notification_disable_autoformat"); $form["autoResponder"]["toField"] = rgpost("form_autoresponder_to"); $form["autoResponder"]["bcc"] = rgpost("form_autoresponder_bcc"); $form["autoResponder"]["fromName"] = rgpost("form_autoresponder_from_name"); $form["autoResponder"]["from"] = rgpost("form_autoresponder_from"); $form["autoResponder"]["replyTo"] = rgpost("form_autoresponder_reply_to"); $form["autoResponder"]["subject"] = rgpost("form_autoresponder_subject"); $form["autoResponder"]["message"] = rgpost("form_autoresponder_message"); $form["autoResponder"]["disableAutoformat"] = rgpost("form_autoresponder_disable_autoformat"); //validating input... $invalid_tab = self::validate_notification(); if ($invalid_tab == 0) { //input valid, updating... //emptying notification email if it is supposed to be disabled if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "routing") { $form["notification"]["to"] = ""; } //emptying notification routing if it is supposed to be disabled if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "email") { $form["notification"]["routing"] = null; } //emptying autoResponder settings if it is supposed to be disabled if (empty($_POST["form_notification_enable_user"])) { $form["autoResponder"]["toField"] = ""; } RGFormsModel::update_form_meta($form_id, $form); } } $wp_email = "{admin_email}"; $email_fields = GFCommon::get_email_fields($form); $name_fields = GFCommon::get_fields_by_type($form, array("name")); $has_admin_notification_fields = GFCommon::has_admin_notification($form); $has_user_notification_fields = GFCommon::has_user_notification($form); $is_admin_notification_enabled = $has_admin_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_admin"]); $is_user_notification_enabled = $has_user_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_user"]); $is_routing_enabled = !empty($form["notification"]["routing"]) && rgpost("notification_to") != "email"; ?> <link rel="stylesheet" href="<?php echo GFCommon::get_base_url(); ?> /css/admin.css?ver=<?php echo GFCommon::$version; ?> " /> <script type="text/javascript" src="<?php echo GFCommon::get_base_url(); ?> /js/forms.js?ver=<?php echo GFCommon::$version; ?> "></script> <script src="<?php echo GFCommon::get_base_url(); ?> /js/jquery.json-1.3.js?ver=<?php echo GFCommon::$version; ?> "></script> <script type="text/javascript"> var gform_has_unsaved_changes = false; jQuery(document).ready(function(){ jQuery("#entry_form input, #entry_form textarea, #entry_form select").change(function(){ gform_has_unsaved_changes = true; }); window.onbeforeunload = function(){ if (gform_has_unsaved_changes){ return "You have unsaved changes."; } } if(jQuery(document).on){ jQuery(document).on('change', '.gfield_routing_value_dropdown', function(){ SetRoutingValueDropDown(jQuery(this)); }); } else{ jQuery('.gfield_routing_value_dropdown').live('change', function(){ SetRoutingValueDropDown(jQuery(this)); }); } }); <?php if (empty($form["notification"])) { $form["notification"] = array(); } ?> var form = <?php echo GFCommon::json_encode($form); ?> ; function SetRoutingValueDropDown(element){ //parsing ID to get routing Index var index = element.attr("id").replace("routing_value_", ""); SetRouting(index); } function InsertVariable(element_id, callback, variable){ if(!variable) variable = jQuery('#' + element_id + '_variable_select').val(); var messageElement = jQuery("#" + element_id); if(document.selection) { // Go the IE way messageElement[0].focus(); document.selection.createRange().text=variable; } else if(messageElement[0].selectionStart) { // Go the Gecko way obj = messageElement[0] obj.value = obj.value.substr(0, obj.selectionStart) + variable + obj.value.substr(obj.selectionEnd, obj.value.length); } else { messageElement.val(variable + messageElement.val()); } jQuery('#' + element_id + '_variable_select')[0].selectedIndex = 0; if(callback && window[callback]){ window[callback].call(null, element_id, variable); } } function InsertEditorVariable(elementId){ var select = jQuery("#" + elementId + "_variable_select"); var variable = select.val(); select[0].selectedIndex = 0; wpActiveEditor = elementId; window.send_to_editor(variable); } function CreateRouting(routings){ var str = ""; for(var i=0; i< routings.length; i++){ var isSelected = routings[i].operator == "is" ? "selected='selected'" :""; var isNotSelected = routings[i].operator == "isnot" ? "selected='selected'" :""; var greaterThanSelected = routings[i].operator == ">" ? "selected='selected'" :""; var lessThanSelected = routings[i].operator == "<" ? "selected='selected'" :""; var containsSelected = routings[i].operator == "contains" ? "selected='selected'" :""; var startsWithSelected = routings[i].operator == "starts_with" ? "selected='selected'" :""; var endsWithSelected = routings[i].operator == "ends_with" ? "selected='selected'" :""; var email = routings[i]["email"] ? routings[i]["email"] : ''; str += "<div style='width:99%'><?php _e("Send to", "gravityforms"); ?> <input type='text' id='routing_email_" + i +"' value='" + email + "' onkeyup='SetRouting(" + i + ");'/>"; str += " <?php _e("if", "gravityforms"); ?> " + GetRoutingFields(i, routings[i].fieldId); str += "<select id='routing_operator_" + i + "' onchange='SetRouting(" + i + ");'>"; str += "<option value='is' " + isSelected + "><?php _e("is", "gravityforms"); ?> </option>"; str += "<option value='isnot' " + isNotSelected + "><?php _e("is not", "gravityforms"); ?> </option>"; str += "<option value='>' " + greaterThanSelected + "><?php _e("greater than", "gravityforms"); ?> </option>"; str += "<option value='<' " + lessThanSelected + "><?php _e("less than", "gravityforms"); ?> </option>"; str += "<option value='contains' " + containsSelected + "><?php _e("contains", "gravityforms"); ?> </option>"; str += "<option value='starts_with' " + startsWithSelected + "><?php _e("starts with", "gravityforms"); ?> </option>"; str += "<option value='ends_with' " + endsWithSelected + "><?php _e("ends with", "gravityforms"); ?> </option>"; str += "</select>"; str += GetRoutingValues(i, routings[i].fieldId, routings[i].value); str += "<img src='<?php echo GFCommon::get_base_url(); ?> /images/add.png' class='add_field_choice' title='add another rule' alt='add another rule' style='cursor:pointer; margin:0 3px;' onclick=\"InsertRouting(" + (i+1) + ");\" />"; if(routings.length > 1 ) str += "<img src='<?php echo GFCommon::get_base_url(); ?> /images/remove.png' title='remove this rule' alt='remove this rule' class='delete_field_choice' style='cursor:pointer;' onclick=\"DeleteRouting(" + i + ");\" /></li>"; str += "</div>"; } jQuery("#notification_to_routing_container").html(str); } function GetRoutingValues(index, fieldId, selectedValue){ str = GetFieldValues(index, fieldId, selectedValue, 16); return str; } function GetRoutingFields(index, selectedItem){ var str = "<select id='routing_field_id_" + index + "' class='gfield_routing_select' onchange='jQuery(\"#routing_value_" + index + "\").replaceWith(GetRoutingValues(" + index + ", jQuery(this).val())); SetRouting(" + index + "); '>"; str += GetSelectableFields(selectedItem, 16); str += "</select>"; return str; } //---------------------- generic --------------- function GetSelectableFields(selectedFieldId, labelMaxCharacters){ var str = ""; var inputType; for(var i=0; i<form.fields.length; i++){ inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; //see if this field type can be used for conditionals if (IsNotificationConditionalLogicField(form.fields[i])) { var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + form.fields[i].label + "</option>"; } } return str; } function IsNotificationConditionalLogicField(field){ //this function is a duplicate of IsConditionalLogicField from form_editor.js inputType = field.inputType ? field.inputType : field.type; var supported_fields = ["checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title", "post_tags", "post_custom_field", "post_content", "post_excerpt"]; var index = jQuery.inArray(inputType, supported_fields); return index >= 0; } function GetFirstSelectableField(){ var inputType; for(var i=0; i<form.fields.length; i++){ inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if (IsNotificationConditionalLogicField(form.fields[i])){ return form.fields[i].id; } } return 0; } function TruncateMiddle(text, maxCharacters){ if(!text) return ""; if(text.length <= maxCharacters) return text; var middle = parseInt(maxCharacters / 2); return text.substr(0, middle) + "..." + text.substr(text.length - middle, middle); } function GetFieldValues(index, fieldId, selectedValue, labelMaxCharacters){ if(!fieldId) fieldId = GetFirstSelectableField(); if(!fieldId) return ""; var str = ""; var field = GetFieldById(fieldId); var isAnySelected = false; if(!field) return ""; if(field["type"] == "post_category" && field["displayAllCategories"]){ var dropdown_id = "routing_value_" + index; var dropdown = jQuery('#' + dropdown_id + ".gfield_category_dropdown"); //don't load category drop down if it already exists (to avoid unecessary ajax requests) if(dropdown.length > 0){ var options = dropdown.html(); options = options.replace("value=\"" + selectedValue + "\"", "value=\"" + selectedValue + "\" selected=\"selected\""); str = "<select id='" + dropdown_id + "' class='gfield_routing_select gfield_category_dropdown gfield_routing_value_dropdown'>" + options + "</select>"; } else{ //loading categories via AJAX jQuery.post(ajaxurl,{ action:"gf_get_notification_post_categories", ruleIndex: index, selectedValue: selectedValue}, function(dropdown_string){ if(dropdown_string){ jQuery('#gfield_ajax_placeholder_' + index).replaceWith(dropdown_string.trim()); } } ); //will be replaced by real drop down during the ajax callback str = "<select id='gfield_ajax_placeholder_" + index + "' class='gfield_routing_select'><option><?php _e("Loading...", "gravityforms"); ?> </option></select>"; } } else if(field.choices){ //create a drop down for fields that have choices (i.e. drop down, radio, checkboxes, etc...) str = "<select class='gfield_routing_select gfield_routing_value_dropdown' id='routing_value_" + index + "'>"; for(var i=0; i<field.choices.length; i++){ var choiceValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text; var isSelected = choiceValue == selectedValue; var selected = isSelected ? "selected='selected'" : ""; if(isSelected) isAnySelected = true; str += "<option value='" + choiceValue.replace(/'/g, "'") + "' " + selected + ">" + field.choices[i].text + "</option>"; } if(!isAnySelected && selectedValue){ str += "<option value='" + selectedValue.replace(/'/g, "'") + "' selected='selected'>" + selectedValue + "</option>"; } str += "</select>"; } else { selectedValue = selectedValue ? selectedValue.replace(/'/g, "'") : ""; //create a text field for fields that don't have choices (i.e text, textarea, number, email, etc...) str = "<input type='text' placeholder='<?php _e("Enter value", "gravityforms"); ?> ' class='gfield_routing_select' id='routing_value_" + index + "' value='" + selectedValue.replace(/'/g, "'") + "' onchange='SetRouting(" + index + ");' onkeyup='SetRouting(" + index + ");'>"; } return str; } function GetFieldById(fieldId){ for(var i=0; i<form.fields.length; i++){ if(form.fields[i].id == fieldId) return form.fields[i]; } return null; } //--------------------------------------------------------------------------------- function InsertRouting(index){ var routings = form.notification.routing; routings.splice(index, 0, new ConditionalRule()); CreateRouting(routings); SetRouting(index); } function SetRouting(ruleIndex){ if(!form.notification.routing && ruleIndex == 0) form.notification.routing = [new ConditionalRule()]; form.notification.routing[ruleIndex]["email"] = jQuery("#routing_email_" + ruleIndex).val(); form.notification.routing[ruleIndex]["fieldId"] = jQuery("#routing_field_id_" + ruleIndex).val(); form.notification.routing[ruleIndex]["operator"] = jQuery("#routing_operator_" + ruleIndex).val(); form.notification.routing[ruleIndex]["value"] =jQuery("#routing_value_" + ruleIndex).val(); var json = jQuery.toJSON(form.notification.routing); jQuery('#gform_routing_meta').val(json); } function DeleteRouting(ruleIndex){ form.notification.routing.splice(ruleIndex, 1); CreateRouting(form.notification.routing); } </script> <?php echo GFCommon::get_remote_message(); ?> <form method="post" id="entry_form" onsubmit="gform_has_unsaved_changes = false; jQuery('#gform_routing_meta').val(jQuery.toJSON(form.notification.routing));"> <?php wp_nonce_field('gforms_save_notification', 'gforms_save_notification'); ?> <input type="hidden" id="gform_routing_meta" name="gform_routing_meta" /> <div class="wrap"> <div class="icon32" id="gravity-notification-icon"><br></div> <h2><?php _e("Notifications", "gravityforms"); ?> : <?php echo esc_html($form["title"]); ?> </h2> <?php RGForms::top_toolbar(); ?> <div id="poststuff" class="metabox-holder"> <div id="submitdiv" class="stuffbox"> <h3><span class="hndle"><?php _e("Notification to Administrator", "gravityforms"); ?> </span></h3> <div class="inside"> <div id="submitcomment" class="submitbox"> <div id="minor-publishingx" style="padding:10px;"> <input type="checkbox" name="form_notification_enable_admin" id="form_notification_enable_admin" value="1" <?php echo $is_admin_notification_enabled ? "checked='checked'" : ""; ?> onclick="if(this.checked) {jQuery('#form_notification_admin_container').show('slow');} else {jQuery('#form_notification_to').val(''); jQuery('#form_notification_admin_container').hide('slow');}"/> <label for="form_notification_enable_admin"><?php _e("Enable email notification to administrators", "gravityforms"); ?> </label> <div id="form_notification_admin_container" style="display:<?php echo $is_admin_notification_enabled ? "block" : "none"; ?> ;"> <br/> <?php _e("Enter a message below to receive a notification email when users submit this form.", "gravityforms"); ?> <br/><br/><br/> <ul id="form_notification_container"> <?php $is_invalid_email_to = $invalid_tab == 1 && !self::is_valid_admin_to(); $class = $is_invalid_email_to ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <label for="notification_to_email"> <?php _e("Send To Email", "gravityforms"); ?> <span class="gfield_required">*</span> <?php gform_tooltip("notification_send_to_email"); ?> </label> <input type="radio" id="notification_to_email" name="notification_to" <?php echo !$is_routing_enabled ? "checked='checked'" : ""; ?> value="email" onclick="jQuery('#notification_to_routing_container').hide(); jQuery('#notification_to_email_container').show('slow');"/> <label for="notification_to_email" class="inline"> <?php _e("Email", "gravityforms"); ?> </label> <input type="radio" id="notification_to_routing" name="notification_to" <?php echo $is_routing_enabled ? "checked='checked'" : ""; ?> value="routing" onclick="jQuery('#notification_to_email_container').hide(); jQuery('#notification_to_routing_container').show('slow');"/> <label for="form_button_image" class="inline"> <?php _e("Routing", "gravityforms"); ?> <?php gform_tooltip("notification_send_to_routing"); ?> </label> <div id="notification_to_email_container" style="margin-top:5px; display:<?php echo $is_routing_enabled ? "none" : "block"; ?> ;"> <input type="text" name="form_notification_to" id="form_notification_to" value="<?php echo esc_attr($form["notification"]["to"]); ?> " class="fieldwidth-1" /> <?php if (rgpost("notification_to") == "email" && $is_invalid_email_to) { ?> <span class="validation_message"><?php _e("Please enter a valid email address"); ?> </span> <?php } ?> </div> <div id="notification_to_routing_container" style="margin-top:5px; display:<?php echo $is_routing_enabled ? "block" : "none"; ?> ;"> <div> <?php $routing_fields = self::get_routing_fields($form, "0"); if (empty($routing_fields)) { //if(empty(){ ?> <div class="gold_notice"> <p><?php _e("To use notification routing, your form must have a field supported by conditional logic.", "gravityforms"); ?> </p> </div> <?php } else { if (empty($form["notification"]["routing"])) { $form["notification"]["routing"] = array(array()); } $count = sizeof($form["notification"]["routing"]); $routing_list = ","; for ($i = 0; $i < $count; $i++) { $routing_list .= $i . ","; $routing = $form["notification"]["routing"][$i]; $is_invalid_rule = $invalid_tab == 1 && $_POST["notification_to"] == "routing" && !self::is_valid_notification_email($routing["email"]); $class = $is_invalid_rule ? "class='grouting_rule_error'" : ""; ?> <div style='width:99%' <?php echo $class; ?> > <?php _e("Send to", "gravityforms"); ?> <input type="text" id="routing_email_<?php echo $i; ?> " value="<?php echo rgar($routing, "email"); ?> " onkeyup="SetRouting(<?php echo $i; ?> );"/> <?php _e("if", "gravityforms"); ?> <select id="routing_field_id_<?php echo $i; ?> " class='gfield_routing_select' onchange='jQuery("#routing_value_<?php echo $i; ?> ").replaceWith(GetRoutingValues(<?php echo $i; ?> , jQuery(this).val())); SetRouting(<?php echo $i; ?> ); '><?php echo self::get_routing_fields($form, rgar($routing, "fieldId")); ?> </select> <select id="routing_operator_<?php echo $i; ?> " onchange="SetRouting(<?php echo $i; ?> )" > <option value="is" <?php echo rgar($routing, "operator") == "is" ? "selected='selected'" : ""; ?> ><?php _e("is", "gravityforms"); ?> </option> <option value="isnot" <?php echo rgar($routing, "operator") == "isnot" ? "selected='selected'" : ""; ?> ><?php _e("is not", "gravityforms"); ?> </option> <option value=">" <?php echo rgar($routing, "operator") == ">" ? "selected='selected'" : ""; ?> ><?php _e("greater than", "gravityforms"); ?> </option> <option value="<" <?php echo rgar($routing, "operator") == "<" ? "selected='selected'" : ""; ?> ><?php _e("less than", "gravityforms"); ?> </option> <option value="contains" <?php echo rgar($routing, "operator") == "contains" ? "selected='selected'" : ""; ?> ><?php _e("contains", "gravityforms"); ?> </option> <option value="starts_with" <?php echo rgar($routing, "operator") == "starts_with" ? "selected='selected'" : ""; ?> ><?php _e("starts with", "gravityforms"); ?> </option> <option value="ends_with" <?php echo rgar($routing, "operator") == "ends_with" ? "selected='selected'" : ""; ?> ><?php _e("ends with", "gravityforms"); ?> </option> </select> <?php echo self::get_field_values($i, $form, rgar($routing, "fieldId"), rgar($routing, "value")); ?> <img src='<?php echo GFCommon::get_base_url(); ?> /images/add.png' class='add_field_choice' title='add another email routing' alt='add another email routing' style='cursor:pointer; margin:0 3px;' onclick='SetRouting(<?php echo $i; ?> ); InsertRouting(<?php echo $i + 1; ?> );' /> <?php if ($count > 1) { ?> <img src='<?php echo GFCommon::get_base_url(); ?> /images/remove.png' id='routing_delete_<?php echo $i; ?> ' title='remove this email routing' alt='remove this email routing' class='delete_field_choice' style='cursor:pointer;' onclick='DeleteRouting(<?php echo $i; ?> );' /> <?php } ?> </div> <?php } if ($is_invalid_rule) { ?> <span class="validation_message"><?php _e("Please enter a valid email address for all highlighted routing rules above."); ?> </span> <?php } ?> <input type="hidden" name="routing_count" id="routing_count" value="<?php echo $routing_list; ?> "/> <?php } ?> </div> </div> </li> <li> <label for="form_notification_from"> <?php _e("From Name", "gravityforms"); ?> <?php gform_tooltip("notification_from_name"); ?> </label> <input type="text" class="fieldwidth-2" name="form_notification_from_name" id="form_notification_from_name" onkeydown="jQuery('#form_notification_from_name_field').val('');" onchange="jQuery('#form_notification_from_name_field').val('');" value="<?php echo esc_attr(rgget("fromName", $form["notification"])); ?> "/> <?php if (!empty($name_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_from_name_field" id="form_notification_from_name_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_from_name').val('');"> <option value=""><?php _e("Select a name field", "gravityforms"); ?> </option> <?php foreach ($name_fields as $field) { $selected = rgget("fromNameField", $form["notification"]) == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_from"> <?php _e("From Email", "gravityforms"); ?> <?php gform_tooltip("notification_from_email"); ?> </label> <input type="text" class="fieldwidth-2" name="form_notification_from" id="form_notification_from" onkeydown="jQuery('#form_notification_from_field').val('');" onchange="jQuery('#form_notification_from_field').val('');" value="<?php echo rgempty("from", $form["notification"]) && rgempty("fromField", $form["notification"]) ? esc_attr($wp_email) : esc_attr(rgget("from", $form["notification"])); ?> "/> <?php if (!empty($email_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_from_field" id="form_notification_from_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_from').val('');"> <option value=""><?php _e("Select an email field", "gravityforms"); ?> </option> <?php foreach ($email_fields as $field) { $selected = rgget("fromField", $form["notification"]) == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_reply_to"> <?php _e("Reply To", "gravityforms"); ?> <?php gform_tooltip("notification_reply_to"); ?> </label> <input type="text" name="form_notification_reply_to" id="form_notification_reply_to" onkeydown="jQuery('#form_notification_reply_to_field').val('');" onchange="jQuery('#form_notification_reply_to_field').val('');" value="<?php echo esc_attr(rgget("replyTo", $form["notification"])); ?> " class="fieldwidth-2" /> <?php if (!empty($email_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_reply_to_field" id="form_notification_reply_to_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_reply_to').val('');"> <option value=""><?php _e("Select an email field", "gravityforms"); ?> </option> <?php foreach ($email_fields as $field) { $selected = rgar($form["notification"], "replyToField") == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_bcc"> <?php _e("BCC", "gravityforms"); ?> <?php gform_tooltip("notification_bcc"); ?> </label> <input type="text" name="form_notification_bcc" id="form_notification_bcc" value="<?php echo esc_attr(rgget("bcc", $form["notification"])); ?> " class="fieldwidth-1" /> </li> <?php $is_invalid_subject = $invalid_tab == 1 && empty($_POST["form_notification_subject"]); $class = $is_invalid_subject ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_notification_subject"> <?php _e("Subject", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_notification_subject", true); ?> </div> <input type="text" name="form_notification_subject" id="form_notification_subject" value="<?php echo esc_attr($form["notification"]["subject"]); ?> " class="fieldwidth-1" /> <?php if ($is_invalid_subject) { ?> <span class="validation_message"><?php _e("Please enter a subject for the notification email"); ?> </span> <?php } ?> </div> </li> <?php $is_invalid_message = $invalid_tab == 1 && empty($_POST["form_notification_message"]); $class = $is_invalid_message ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_notification_message"> <?php _e("Message", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <?php if (GFCommon::is_wp_version("3.3")) { wp_editor($form["notification"]["message"], "form_notification_message", array("autop" => false)); } else { ?> <textarea name="form_notification_message" id="form_notification_message" class="fieldwidth-1 fieldheight-1" ><?php echo esc_html($form["notification"]["message"]); ?> </textarea> <?php } if ($is_invalid_message) { ?> <span class="validation_message"><?php _e("Please enter a message for the notification email"); ?> </span> <?php } ?> </div> </li> <li> <div> <input type="checkbox" name="form_notification_disable_autoformat" id="form_notification_disable_autoformat" value="1" <?php echo empty($form["notification"]["disableAutoformat"]) ? "" : "checked='checked'"; ?> /> <label for="form_notification_disable_autoformat" class="inline"> <?php _e("Disable Auto-formatting", "gravityforms"); ?> <?php gform_tooltip("notification_autoformat"); ?> </label> </div> </li> </ul> </div> </div> </div> </div> </div> <div id="submitdiv" class="stuffbox"> <h3><span class="hndle"><?php _e("Notification to User", "gravityforms"); ?> </span></h3> <div class="inside"> <div id="submitcomment" class="submitbox"> <div id="minor-publishingx" style="padding:10px;"> <?php if (!isset($form["autoResponder"])) { $form["autoResponder"] = array(); } if (empty($email_fields)) { ?> <div class="gold_notice"> <p><?php echo sprintf(__("Your form does not have any %semail%s field.", "gravityforms"), "<strong>", "</strong>"); ?> </p> <p> <?php echo sprintf(__("Sending notifications to users require that the form has at least one email field. %sEdit your form%s", "gravityforms"), '<a href="?page=gf_edit_forms&id=' . absint($form_id) . '">', '</a>'); ?> </p> </div> <?php } else { ?> <input type="checkbox" name="form_notification_enable_user" id="form_notification_enable_user" value="1" <?php echo $is_user_notification_enabled ? "checked='checked'" : ""; ?> onclick="if(this.checked) {jQuery('#form_notification_user_container').show('slow');} else {jQuery('#form_notification_user_container').hide('slow');}"/> <label for="form_notification_enable_user"><?php _e("Enable email notification to users", "gravityforms"); ?> </label> <div id="form_notification_user_container" style="display:<?php echo $is_user_notification_enabled ? "block" : "none"; ?> ;"> <br/> <?php _e("Enter a message below to send users an automatic response when they submit this form.", "gravityforms"); ?> <br/><br/><br/> <ul id="form_autoresponder_container"> <li> <label for="form_autoresponder_to"> <?php _e("Send To Field", "gravityforms"); ?> <span class="gfield_required">*</span> <?php gform_tooltip("autoresponder_send_to_email"); ?> </label> <select name="form_autoresponder_to" id="form_autoresponder_to"> <?php foreach ($email_fields as $field) { $selected = rgget("toField", $form["autoResponder"]) == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo esc_html(GFCommon::get_label($field)); ?> </option> <?php } ?> </select> </li> <li> <label for="form_autoresponder_from_name"> <?php _e("From Name", "gravityforms"); ?> <?php gform_tooltip("autoresponder_from_name"); ?> </label> <input type="text" name="form_autoresponder_from_name" id="form_autoresponder_from_name" value="<?php echo esc_attr(rgget("fromName", $form["autoResponder"])); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_from"> <?php _e("From Email", "gravityforms"); ?> <?php gform_tooltip("autoresponder_from"); ?> </label> <input type="text" name="form_autoresponder_from" id="form_autoresponder_from" value="<?php echo rgempty("from", $form["autoResponder"]) ? esc_attr($wp_email) : esc_attr(rgget("from", $form["autoResponder"])); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_reply_to" style="display:block;"> <?php _e("Reply To (optional)", "gravityforms"); ?> <?php gform_tooltip("autoresponder_reply_to"); ?> </label> <input type="text" name="form_autoresponder_reply_to" id="form_autoresponder_reply_to" value="<?php echo esc_attr(rgget("replyTo", $form["autoResponder"])); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_bcc"> <?php _e("BCC", "gravityforms"); ?> <?php gform_tooltip("autoresponder_bcc"); ?> </label> <input type="text" name="form_autoresponder_bcc" id="form_autoresponder_bcc" value="<?php echo esc_attr(rgget("bcc", $form["autoResponder"])); ?> " class="fieldwidth-1" /> </li> <?php $is_invalid_subject = $invalid_tab == 2 && rgempty("form_autoresponder_subject"); $class = $is_invalid_subject ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <label for="form_autoresponder_subject"> <?php _e("Subject", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_autoresponder_subject", true); ?> </div> <input type="text" name="form_autoresponder_subject" id="form_autoresponder_subject" value="<?php echo esc_attr(rgget("subject", $form["autoResponder"])); ?> " class="fieldwidth-1" /> <?php if ($is_invalid_subject) { ?> <span class="validation_message"><?php _e("Please enter a subject for the user notification email"); ?> </span> <?php } ?> </li> <?php $is_invalid_message = $invalid_tab == 2 && rgempty("form_autoresponder_message"); $class = $is_invalid_message ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_autoresponder_message"> <?php _e("Message", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <?php if (GFCommon::is_wp_version("3.3")) { wp_editor(rgget("message", $form["autoResponder"]), "form_autoresponder_message", array("autop" => false)); } else { ?> <textarea name="form_autoresponder_message" id="form_autoresponder_message" class="fieldwidth-1 fieldheight-1"><?php echo esc_html(rgget("message", $form["autoResponder"])); ?> </textarea> <?php } if ($is_invalid_message) { ?> <span class="validation_message"><?php _e("Please enter a message for the user notification email"); ?> </span> <?php } ?> </div> </li> <li> <div> <input type="checkbox" name="form_autoresponder_disable_autoformat" id="form_autoresponder_disable_autoformat" value="1" <?php echo rgempty("disableAutoformat", $form["autoResponder"]) ? "" : "checked='checked'"; ?> /> <label for="form_notification_disable_autoformat" class="inline"> <?php _e("Disable Auto-formatting", "gravityforms"); ?> <?php gform_tooltip("notification_autoformat"); ?> </label> </div> </li> </ul> </div> <?php } ?> </div> </div> </div> </div> <br class="clear" /> <div> <?php $notification_button = '<input class="button-primary" type="submit" value="' . __("Save Settings", "gravityforms") . '" name="save"/>'; echo apply_filters("gform_save_notification_button", $notification_button); ?> </div> </div> </div> </form> <?php if (rgpost("save")) { if ($invalid_tab == 0) { ?> <div class="updated fade" style="padding:6px;"> <?php _e("Notification Updated.", "gravityforms"); ?> </div> <?php } else { ?> <div class="error" style="padding:6px;"> <?php _e("Notification could not be updated. Please enter all required information below.", "gravityforms"); ?> </div> <?php } } }
protected function get_payment_choices($form) { $fields = GFCommon::get_fields_by_type($form, array('product')); $choices = array(array('label' => __('Select a product field', 'gravityforms'), 'value' => '')); foreach ($fields as $field) { $field_id = $field['id']; $field_label = RGFormsModel::get_label($field); $choices[] = array('value' => $field_id, 'label' => $field_label); } return $choices; }
public static function notification_page($form_id) { $form = RGFormsModel::get_form_meta($form_id); if ($_POST["save"]) { check_admin_referer('gforms_save_notification', 'gforms_save_notification'); $form["notification"]["to"] = stripslashes($_POST["form_notification_to"]); $form["notification"]["bcc"] = stripslashes($_POST["form_notification_bcc"]); $form["notification"]["subject"] = stripslashes($_POST["form_notification_subject"]); $form["notification"]["message"] = stripslashes($_POST["form_notification_message"]); $form["notification"]["from"] = empty($_POST["form_notification_from_field"]) ? stripslashes($_POST["form_notification_from"]) : ""; $form["notification"]["fromField"] = stripslashes($_POST["form_notification_from_field"]); $form["notification"]["fromName"] = empty($_POST["form_notification_from_name_field"]) ? stripslashes($_POST["form_notification_from_name"]) : ""; $form["notification"]["fromNameField"] = stripslashes($_POST["form_notification_from_name_field"]); $form["notification"]["replyTo"] = empty($_POST["form_notification_reply_to_field"]) ? stripslashes($_POST["form_notification_reply_to"]) : ""; $form["notification"]["replyToField"] = stripslashes($_POST["form_notification_reply_to_field"]); $form["notification"]["routing"] = !empty($_POST["gform_routing_meta"]) ? GFCommon::json_decode(stripslashes($_POST["gform_routing_meta"]), true) : null; $form["notification"]["disableAutoformat"] = $_POST["form_notification_disable_autoformat"]; $form["autoResponder"]["toField"] = stripslashes($_POST["form_autoresponder_to"]); $form["autoResponder"]["bcc"] = stripslashes($_POST["form_autoresponder_bcc"]); $form["autoResponder"]["fromName"] = stripslashes($_POST["form_autoresponder_from_name"]); $form["autoResponder"]["from"] = stripslashes($_POST["form_autoresponder_from"]); $form["autoResponder"]["replyTo"] = stripslashes($_POST["form_autoresponder_reply_to"]); $form["autoResponder"]["subject"] = stripslashes($_POST["form_autoresponder_subject"]); $form["autoResponder"]["message"] = stripslashes($_POST["form_autoresponder_message"]); $form["autoResponder"]["disableAutoformat"] = $_POST["form_autoresponder_disable_autoformat"]; //validating input... $invalid_tab = self::validate_notification(); if ($invalid_tab == 0) { //input valid, updating... //emptying notification email if it is supposed to be disabled if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "routing") { $form["notification"]["to"] = ""; } //emptying notification routing if it is supposed to be disabled if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "email") { $form["notification"]["routing"] = null; } //emptying autoResponder settings if it is supposed to be disabled if (empty($_POST["form_notification_enable_user"])) { $form["autoResponder"]["toField"] = ""; } RGFormsModel::update_form_meta($form_id, $form); } } $wp_email = get_bloginfo("admin_email"); $email_fields = GFCommon::get_email_fields($form); $name_fields = GFCommon::get_fields_by_type($form, array("name")); $has_admin_notification_fields = (!empty($form["notification"]["to"]) || !empty($form["notification"]["routing"])) && (!empty($form["notification"]["subject"]) || !empty($form["notification"]["message"])); $has_user_notification_fields = !empty($form["autoResponder"]["toField"]) && (!empty($form["autoResponder"]["subject"]) || !empty($form["autoResponder"]["message"])); $is_admin_notification_enabled = $has_admin_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_admin"]); $is_user_notification_enabled = $has_user_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_user"]); $is_routing_enabled = !empty($form["notification"]["routing"]) && $_POST["notification_to"] != "email"; ?> <link rel="stylesheet" href="<?php echo GFCommon::get_base_url(); ?> /css/admin.css?ver=<?php echo GFCommon::$version; ?> " /> <script type="text/javascript" src="<?php echo GFCommon::get_base_url(); ?> /js/forms.js?ver=<?php echo GFCommon::$version; ?> "></script> <script src="<?php echo GFCommon::get_base_url(); ?> /js/jquery.json-1.3.js?ver=<?php echo GFCommon::$version; ?> "></script> <script type="text/javascript"> var gform_has_unsaved_changes = false; jQuery(document).ready(function(){ jQuery("#entry_form input, #entry_form textarea, #entry_form select").change(function(){ gform_has_unsaved_changes = true; }); window.onbeforeunload = function(){ if (gform_has_unsaved_changes){ return "You have unsaved changes."; } } }); <?php if (empty($form["notification"])) { $form["notification"] = array(); } ?> var form = <?php echo GFCommon::json_encode($form); ?> ; function InsertVariable(element_id){ var variable = jQuery('#' + element_id + '_variable_select').val(); var messageElement = jQuery("#" + element_id); if(document.selection) { // Go the IE way messageElement[0].focus(); document.selection.createRange().text=variable; } else if(messageElement[0].selectionStart) { // Go the Gecko way obj = messageElement[0] obj.value = obj.value.substr(0, obj.selectionStart) + variable + obj.value.substr(obj.selectionEnd, obj.value.length); } else { messageElement.val(variable + messageElement.val()); } jQuery('#' + element_id + '_variable_select')[0].selectedIndex = 0; } function CreateRouting(routings){ var str = ""; for(var i=0; i< routings.length; i++){ var isSelected = routings[i].operator == "is" ? "selected='selected'" :""; var isNotSelected = routings[i].operator == "isnot" ? "selected='selected'" :""; var email = routings[i]["email"] ? routings[i]["email"] : ''; str += "<div style='width:99%'><?php _e("Send to", "gravityforms"); ?> <input type='text' id='routing_email_" + i +"' value='" + email + "' onkeyup='SetRouting(" + i + ");'/>"; str += " <?php _e("if", "gravityforms"); ?> " + GetRoutingFields(i, routings[i].fieldId); str += "<select id='routing_operator_" + i + "' onchange='SetRouting(" + i + ");'><option value='is' " + isSelected + "><?php _e("is", "gravityforms"); ?> </option><option value='isnot' " + isNotSelected + "><?php _e("is not", "gravityforms"); ?> </option></select>"; str += GetRoutingValues(i, routings[i].fieldId, routings[i].value); str += "<img src='<?php echo GFCommon::get_base_url(); ?> /images/add.png' class='add_field_choice' title='add another rule' alt='add another rule' style='cursor:pointer; margin:0 3px;' onclick=\"InsertRouting(" + (i+1) + ");\" />"; if(routings.length > 1 ) str += "<img src='<?php echo GFCommon::get_base_url(); ?> /images/remove.png' title='remove this rule' alt='remove this rule' class='delete_field_choice' style='cursor:pointer;' onclick=\"DeleteRouting(" + i + ");\" /></li>"; str += "</div>"; } jQuery("#notification_to_routing_container").html(str); } function GetRoutingValues(index, fieldId, selectedValue){ var str = "<select class='gfield_routing_select' id='routing_value_" + index + "' onchange='SetRouting(" + index + ");'>"; str += GetFieldValues(fieldId, selectedValue, 16); str += "</select>"; return str; } function GetRoutingFields(index, selectedItem){ var str = "<select id='routing_field_id_" + index + "' class='gfield_routing_select' onchange='jQuery(\"#routing_value_" + index + "\").replaceWith(GetRoutingValues(" + index + ", jQuery(this).val())); SetRouting(" + index + "); '>"; str += GetSelectableFields(selectedItem, 16); str += "</select>"; return str; } //---------------------- generic --------------- function GetSelectableFields(selectedFieldId, labelMaxCharacters){ var str = ""; var inputType; for(var i=0; i<form.fields.length; i++){ inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if(inputType == "checkbox" || inputType == "radio" || inputType == "select"){ var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle(form.fields[i].label, labelMaxCharacters) + "</option>"; } } return str; } function GetFirstSelectableField(){ var inputType; for(var i=0; i<form.fields.length; i++){ inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if(inputType == "checkbox" || inputType == "radio" || inputType == "select") return form.fields[i].id; } return 0; } function TruncateMiddle(text, maxCharacters){ if(text.length <= maxCharacters) return text; var middle = parseInt(maxCharacters / 2); return text.substr(0, middle) + "..." + text.substr(text.length - middle, middle); } function GetFieldValues(fieldId, selectedValue, labelMaxCharacters){ if(!fieldId) fieldId = GetFirstSelectableField(); if(!fieldId) return ""; var str = ""; var field = GetFieldById(fieldId); var isAnySelected = false; for(var i=0; i<field.choices.length; i++){ var choiceValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text; var isSelected = choiceValue == selectedValue; var selected = isSelected ? "selected='selected'" : ""; if(isSelected) isAnySelected = true; str += "<option value='" + choiceValue.replace("'", "'") + "' " + selected + ">" + TruncateMiddle(field.choices[i].text, labelMaxCharacters) + "</option>"; } if(!isAnySelected && selectedValue){ str += "<option value='" + selectedValue.replace("'", "'") + "' selected='selected'>" + TruncateMiddle(selectedValue, labelMaxCharacters) + "</option>"; } return str; } function GetFieldById(fieldId){ for(var i=0; i<form.fields.length; i++){ if(form.fields[i].id == fieldId) return form.fields[i]; } return null; } //--------------------------------------------------------------------------------- function InsertRouting(index){ var routings = form.notification.routing; routings.splice(index, 0, new ConditionalRule()); CreateRouting(routings); SetRouting(index); } function SetRouting(ruleIndex){ if(!form.notification.routing && ruleIndex == 0) form.notification.routing = [new ConditionalRule()]; form.notification.routing[ruleIndex]["email"] = jQuery("#routing_email_" + ruleIndex).val(); form.notification.routing[ruleIndex]["fieldId"] = jQuery("#routing_field_id_" + ruleIndex).val(); form.notification.routing[ruleIndex]["operator"] = jQuery("#routing_operator_" + ruleIndex).val(); form.notification.routing[ruleIndex]["value"] =jQuery("#routing_value_" + ruleIndex).val(); var json = jQuery.toJSON(form.notification.routing); jQuery('#gform_routing_meta').val(json); } function DeleteRouting(ruleIndex){ form.notification.routing.splice(ruleIndex, 1); CreateRouting(form.notification.routing); } </script> <?php echo GFCommon::get_remote_message(); ?> <form method="post" id="entry_form" onsubmit="gform_has_unsaved_changes = false; jQuery('#gform_routing_meta').val(jQuery.toJSON(form.notification.routing));"> <?php wp_nonce_field('gforms_save_notification', 'gforms_save_notification'); ?> <input type="hidden" id="gform_routing_meta" name="gform_routing_meta" /> <div class="wrap"> <img alt="<?php _e("Gravity Forms", "gravityforms"); ?> " src="<?php echo GFCommon::get_base_url(); ?> /images/gravity-notification-icon-32.png" style="float:left; margin:15px 7px 0 0;"/> <h2><?php _e("Notifications", "gravityforms"); ?> : <?php echo esc_html($form["title"]); ?> </h2> <?php RGForms::top_toolbar(); ?> <div id="poststuff" class="metabox-holder"> <div id="submitdiv" class="stuffbox"> <h3><span class="hndle"><?php _e("Notification to Administrator", "gravityforms"); ?> </span></h3> <div class="inside"> <div id="submitcomment" class="submitbox"> <div id="minor-publishingx" style="padding:10px;"> <input type="checkbox" name="form_notification_enable_admin" id="form_notification_enable_admin" value="1" <?php echo $is_admin_notification_enabled ? "checked='checked'" : ""; ?> onclick="if(this.checked) {jQuery('#form_notification_admin_container').show('slow');} else {jQuery('#form_notification_to').val(''); jQuery('#form_notification_admin_container').hide('slow');}"/> <label for="form_notification_enable_admin"><?php _e("Enable email notification to administrators", "gravityforms"); ?> </label> <div id="form_notification_admin_container" style="display:<?php echo $is_admin_notification_enabled ? "block" : "none"; ?> ;"> <br/> <?php _e("Enter a message below to receive a notification email when users submit this form.", "gravityforms"); ?> <br/><br/><br/> <ul id="form_notification_container"> <?php $is_invalid_email_to = $invalid_tab == 1 && !self::is_valid_admin_to(); $class = $is_invalid_email_to ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <label for="notification_to_email"> <?php _e("Send To Email", "gravityforms"); ?> <span class="gfield_required">*</span> <?php gform_tooltip("notification_send_to_email"); ?> </label> <input type="radio" id="notification_to_email" name="notification_to" <?php echo !$is_routing_enabled ? "checked='checked'" : ""; ?> value="email" onclick="jQuery('#notification_to_routing_container').hide(); jQuery('#notification_to_email_container').show('slow');"/> <label for="notification_to_email" class="inline"> <?php _e("Email", "gravityforms"); ?> </label> <input type="radio" id="notification_to_routing" name="notification_to" <?php echo $is_routing_enabled ? "checked='checked'" : ""; ?> value="routing" onclick="jQuery('#notification_to_email_container').hide(); jQuery('#notification_to_routing_container').show('slow');"/> <label for="form_button_image" class="inline"> <?php _e("Routing", "gravityforms"); ?> <?php gform_tooltip("notification_send_to_routing"); ?> </label> <div id="notification_to_email_container" style="margin-top:5px; display:<?php echo $is_routing_enabled ? "none" : "block"; ?> ;"> <input type="text" name="form_notification_to" id="form_notification_to" value="<?php echo esc_attr($form["notification"]["to"]); ?> " class="fieldwidth-1" /> <?php if ($_POST["notification_to"] == "email" && $is_invalid_email_to) { ?> <span class="validation_message"><?php _e("Please enter a valid email address"); ?> </span> <?php } ?> </div> <div id="notification_to_routing_container" style="margin-top:5px; display:<?php echo $is_routing_enabled ? "block" : "none"; ?> ;"> <div> <?php $routing_fields = self::get_routing_fields($form, "0"); if (empty($routing_fields)) { //if(empty(){ ?> <div class="gold_notice"> <p><?php _e("To use notification routing, your form must have a drop down, checkbox or multiple choice field.", "gravityforms"); ?> </p> </div> <?php } else { if (empty($form["notification"]["routing"])) { $form["notification"]["routing"] = array(array()); } $count = sizeof($form["notification"]["routing"]); $routing_list = ","; for ($i = 0; $i < $count; $i++) { $routing_list .= $i . ","; $routing = $form["notification"]["routing"][$i]; $is_invalid_rule = $invalid_tab == 1 && $_POST["notification_to"] == "routing" && !self::is_valid_notification_email($routing["email"]); $class = $is_invalid_rule ? "class='grouting_rule_error'" : ""; ?> <div style='width:99%' <?php echo $class; ?> > <?php _e("Send to", "gravityforms"); ?> <input type="text" id="routing_email_<?php echo $i; ?> " value="<?php echo $routing["email"]; ?> " onkeyup="SetRouting(<?php echo $i; ?> );"/> <?php _e("if", "gravityforms"); ?> <select id="routing_field_id_<?php echo $i; ?> " class='gfield_routing_select' onchange='jQuery("#routing_value_<?php echo $i; ?> ").replaceWith(GetRoutingValues(<?php echo $i; ?> , jQuery(this).val())); SetRouting(<?php echo $i; ?> ); '><?php echo self::get_routing_fields($form, $routing["fieldId"]); ?> </select> <select id="routing_operator_<?php echo $i; ?> " onchange="SetRouting(<?php echo $i; ?> );"/> <option value="is" <?php echo $routing["operator"] == "is" ? "selected='selected'" : ""; ?> ><?php _e("is", "gravityforms"); ?> </option> <option value="isnot" <?php echo $routing["operator"] == "isnot" ? "selected='selected'" : ""; ?> ><?php _e("is not", "gravityforms"); ?> </option> </select> <select id="routing_value_<?php echo $i; ?> " class='gfield_routing_select' onchange="SetRouting(<?php echo $i; ?> );"> <?php echo self::get_field_values($form, $routing["fieldId"], $routing["value"]); ?> </select> <img src='<?php echo GFCommon::get_base_url(); ?> /images/add.png' class='add_field_choice' title='add another email routing' alt='add another email routing' style='cursor:pointer; margin:0 3px;' onclick='SetRouting(<?php echo $i; ?> ); InsertRouting(<?php echo $i + 1; ?> );' /> <?php if ($count > 1) { ?> <img src='<?php echo GFCommon::get_base_url(); ?> /images/remove.png' id='routing_delete_<?php echo $i; ?> ' title='remove this email routing' alt='remove this email routing' class='delete_field_choice' style='cursor:pointer;' onclick='DeleteRouting(<?php echo $i; ?> );' /> <?php } ?> </div> <?php } if ($is_invalid_rule) { ?> <span class="validation_message"><?php _e("Please enter a valid email address for all highlighted routing rules above."); ?> </span> <?php } ?> <input type="hidden" name="routing_count" id="routing_count" value="<?php echo $routing_list; ?> "/> <?php } ?> </div> </div> </li> <li> <label for="form_notification_from"> <?php _e("From Name", "gravityforms"); ?> <?php gform_tooltip("notification_from_name"); ?> </label> <input type="text" class="fieldwidth-2" name="form_notification_from_name" id="form_notification_from_name" onkeydown="jQuery('#form_notification_from_name_field').val('');" onchange="jQuery('#form_notification_from_name_field').val('');" value="<?php echo esc_attr($form["notification"]["fromName"]); ?> "/> <?php if (!empty($name_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_from_name_field" id="form_notification_from_name_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_from_name').val('');"> <option value=""><?php _e("Select a name field", "gravityforms"); ?> </option> <?php foreach ($name_fields as $field) { $selected = $form["notification"]["fromNameField"] == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_from"> <?php _e("From Email", "gravityforms"); ?> <?php gform_tooltip("notification_from_email"); ?> </label> <input type="text" class="fieldwidth-2" name="form_notification_from" id="form_notification_from" onkeydown="jQuery('#form_notification_from_field').val('');" onchange="jQuery('#form_notification_from_field').val('');" value="<?php echo empty($form["notification"]["from"]) && empty($form["notification"]["fromField"]) ? esc_attr($wp_email) : esc_attr($form["notification"]["from"]); ?> "/> <?php if (!empty($email_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_from_field" id="form_notification_from_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_from').val('');"> <option value=""><?php _e("Select an email field", "gravityforms"); ?> </option> <?php foreach ($email_fields as $field) { $selected = $form["notification"]["fromField"] == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_reply_to"> <?php _e("Reply To", "gravityforms"); ?> <?php gform_tooltip("notification_reply_to"); ?> </label> <input type="text" name="form_notification_reply_to" id="form_notification_reply_to" onkeydown="jQuery('#form_notification_reply_to_field').val('');" onchange="jQuery('#form_notification_reply_to_field').val('');" value="<?php echo esc_attr($form["notification"]["replyTo"]); ?> " class="fieldwidth-2" /> <?php if (!empty($email_fields)) { ?> <?php _e("OR", "gravityforms"); ?> <select name="form_notification_reply_to_field" id="form_notification_reply_to_field" onchange="if(jQuery(this).val().length > 0 ) jQuery('#form_notification_reply_to').val('');"> <option value=""><?php _e("Select an email field", "gravityforms"); ?> </option> <?php foreach ($email_fields as $field) { $selected = $form["notification"]["replyToField"] == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } ?> </li> <li> <label for="form_notification_bcc"> <?php _e("BCC", "gravityforms"); ?> <?php gform_tooltip("notification_bcc"); ?> </label> <input type="text" name="form_notification_bcc" id="form_notification_bcc" value="<?php echo esc_attr($form["notification"]["bcc"]); ?> " class="fieldwidth-1" /> </li> <?php $is_invalid_subject = $invalid_tab == 1 && empty($_POST["form_notification_subject"]); $class = $is_invalid_subject ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_notification_subject"> <?php _e("Subject", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_notification_subject", true); ?> </div> <input type="text" name="form_notification_subject" id="form_notification_subject" value="<?php echo esc_attr($form["notification"]["subject"]); ?> " class="fieldwidth-1" /> <?php if ($is_invalid_subject) { ?> <span class="validation_message"><?php _e("Please enter a subject for the notification email"); ?> </span> <?php } ?> </div> </li> <?php $is_invalid_message = $invalid_tab == 1 && empty($_POST["form_notification_message"]); $class = $is_invalid_message ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_notification_message"> <?php _e("Message", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_notification_message"); ?> </div> <textarea name="form_notification_message" id="form_notification_message" class="fieldwidth-1 fieldheight-1" ><?php echo esc_html($form["notification"]["message"]); ?> </textarea> <?php if ($is_invalid_message) { ?> <span class="validation_message"><?php _e("Please enter a message for the notification email"); ?> </span> <?php } ?> </div> </li> <li> <div> <input type="checkbox" name="form_notification_disable_autoformat" id="form_notification_disable_autoformat" value="1" <?php echo empty($form["notification"]["disableAutoformat"]) ? "" : "checked='checked'"; ?> /> <label for="form_notification_disable_autoformat" class="inline"> <?php _e("Disable Auto-formatting", "gravityforms"); ?> <?php gform_tooltip("notification_autoformat"); ?> </label> </div> </li> </ul> </div> </div> </div> </div> </div> <div id="submitdiv" class="stuffbox"> <h3><span class="hndle"><?php _e("Notification to User", "gravityforms"); ?> </span></h3> <div class="inside"> <div id="submitcomment" class="submitbox"> <div id="minor-publishingx" style="padding:10px;"> <?php if (empty($email_fields)) { ?> <div class="gold_notice"> <p><?php echo sprintf(__("Your form does not have any %semail%s field.", "gravityforms"), "<strong>", "</strong>"); ?> </p> <p> <?php echo sprintf(__("Sending notifications to users require that the form has at least one email field. %sEdit your form%s", "gravityforms"), '<a href="?page=gf_edit_forms&id=' . absint($form_id) . '">', '</a>'); ?> </p> </div> <?php } else { ?> <input type="checkbox" name="form_notification_enable_user" id="form_notification_enable_user" value="1" <?php echo $is_user_notification_enabled ? "checked='checked'" : ""; ?> onclick="if(this.checked) {jQuery('#form_notification_user_container').show('slow');} else {jQuery('#form_notification_user_container').hide('slow');}"/> <label for="form_notification_enable_user"><?php _e("Enable email notification to users", "gravityforms"); ?> </label> <div id="form_notification_user_container" style="display:<?php echo $is_user_notification_enabled ? "block" : "none"; ?> ;"> <br/> <?php _e("Enter a message below to send users an automatic response when they submit this form.", "gravityforms"); ?> <br/><br/><br/> <ul id="form_autoresponder_container"> <li> <label for="form_autoresponder_to"> <?php _e("Send To Field", "gravityforms"); ?> <span class="gfield_required">*</span> <?php gform_tooltip("autoresponder_send_to_email"); ?> </label> <select name="form_autoresponder_to" id="form_autoresponder_to"> <?php foreach ($email_fields as $field) { $selected = $form["autoResponder"]["toField"] == $field["id"] ? "selected='selected'" : ""; ?> <option value="<?php echo $field["id"]; ?> " <?php echo $selected; ?> ><?php echo esc_html(GFCommon::get_label($field)); ?> </option> <?php } ?> </select> </li> <li> <label for="form_autoresponder_from_name"> <?php _e("From Name", "gravityforms"); ?> <?php gform_tooltip("autoresponder_from_name"); ?> </label> <input type="text" name="form_autoresponder_from_name" id="form_autoresponder_from_name" value="<?php echo esc_attr($form["autoResponder"]["fromName"]); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_from"> <?php _e("From Email", "gravityforms"); ?> <?php gform_tooltip("autoresponder_from"); ?> </label> <input type="text" name="form_autoresponder_from" id="form_autoresponder_from" value="<?php echo empty($form["autoResponder"]["from"]) ? esc_attr($wp_email) : esc_attr($form["autoResponder"]["from"]); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_reply_to" style="display:block;"> <?php _e("Reply To (optional)", "gravityforms"); ?> <?php gform_tooltip("autoresponder_reply_to"); ?> </label> <input type="text" name="form_autoresponder_reply_to" id="form_autoresponder_reply_to" value="<?php echo esc_attr($form["autoResponder"]["replyTo"]); ?> " class="fieldwidth-2" /> </li> <li> <label for="form_autoresponder_bcc"> <?php _e("BCC", "gravityforms"); ?> <?php gform_tooltip("autoresponder_bcc"); ?> </label> <input type="text" name="form_autoresponder_bcc" id="form_autoresponder_bcc" value="<?php echo esc_attr($form["autoResponder"]["bcc"]); ?> " class="fieldwidth-1" /> </li> <?php $is_invalid_subject = $invalid_tab == 2 && empty($_POST["form_autoresponder_subject"]); $class = $is_invalid_subject ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <label for="form_autoresponder_subject"> <?php _e("Subject", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_autoresponder_subject", true); ?> </div> <input type="text" name="form_autoresponder_subject" id="form_autoresponder_subject" value="<?php echo esc_attr($form["autoResponder"]["subject"]); ?> " class="fieldwidth-1" /> <?php if ($is_invalid_subject) { ?> <span class="validation_message"><?php _e("Please enter a subject for the user notification email"); ?> </span> <?php } ?> </li> <?php $is_invalid_message = $invalid_tab == 2 && empty($_POST["form_autoresponder_message"]); $class = $is_invalid_message ? "class='gfield_error'" : ""; ?> <li <?php echo $class; ?> > <div> <label for="form_autoresponder_message"> <?php _e("Message", "gravityforms"); ?> <span class="gfield_required">*</span> </label> <div> <?php GFCommon::insert_variables($form["fields"], "form_autoresponder_message"); ?> </div> <textarea name="form_autoresponder_message" id="form_autoresponder_message" class="fieldwidth-1 fieldheight-1"><?php echo esc_html($form["autoResponder"]["message"]); ?> </textarea> <?php if ($is_invalid_message) { ?> <span class="validation_message"><?php _e("Please enter a message for the user notification email"); ?> </span> <?php } ?> </div> </li> <li> <div> <input type="checkbox" name="form_autoresponder_disable_autoformat" id="form_autoresponder_disable_autoformat" value="1" <?php echo empty($form["autoResponder"]["disableAutoformat"]) ? "" : "checked='checked'"; ?> /> <label for="form_notification_disable_autoformat" class="inline"> <?php _e("Disable Auto-formatting", "gravityforms"); ?> <?php gform_tooltip("notification_autoformat"); ?> </label> </div> </li> </ul> </div> <?php } ?> </div> </div> </div> </div> <br class="clear" /> <div> <?php $notification_button = '<input class="button-primary" type="submit" value="' . __("Save Settings", "gravityforms") . '" name="save"/>'; echo apply_filters("gform_save_notification_button", $notification_button); ?> </div> </div> </div> </form> <?php if ($_POST["save"]) { if ($invalid_tab == 0) { ?> <div class="updated fade" style="padding:6px;"> <?php _e("Notification Updated.", "gravityforms"); ?> </div> <?php } else { ?> <div class="error" style="padding:6px;"> <?php _e("Notification could not be updated. Please enter all required information below.", "gravityforms"); ?> </div> <?php } } }
protected function get_payment_choices($form) { $fields = GFCommon::get_fields_by_type($form, array("product")); $choices = array(array("label" => __("Select a product field", "gravityforms"), "value" => "")); foreach ($fields as $field) { $field_id = $field["id"]; $field_label = RGFormsModel::get_label($field); $choices[] = array("value" => $field_id, "label" => $field_label); } return $choices; }
private static function get_custom_field($form, $meta_name, $meta_index) { $custom_fields = GFCommon::get_fields_by_type($form, array("post_custom_field")); $index = 0; foreach ($custom_fields as $field) { if ($field["postCustomFieldName"] == $meta_name) { if ($meta_index == $index) { return $field; } $index++; } } return false; }
public function pre_submission_handler($form) { $signature_fields = GFCommon::get_fields_by_type($form, array('signature')); foreach ($signature_fields as $field) { $input_name = "input_{$field['id']}"; $filename = !rgempty($input_name) ? rgpost($input_name) : rgpost("input_{$form['id']}_{$field['id']}_signature_filename"); if (empty($filename)) { //create signature file $filename = $this->save_signature("input_{$form['id']}_{$field['id']}_data"); $_POST["input_{$field['id']}"] = $filename; } else { //rename signature file $new_name = str_replace('temp_', '', $filename); $folder = RGFormsModel::get_upload_root() . '/signatures/'; rename($folder . $filename, $folder . $new_name); $_POST["input_{$field['id']}"] = $new_name; } } }
private static function get_product_options($form, $selected_field) { $str = "<option value=''>" . __("Select a field", "gravityformspaypal") . "</option>"; $fields = GFCommon::get_fields_by_type($form, array("product")); foreach ($fields as $field) { $field_id = $field["id"]; $field_label = RGFormsModel::get_label($field); $selected = $field_id == $selected_field ? "selected='selected'" : ""; $str .= "<option value='" . $field_id . "' " . $selected . ">" . $field_label . "</option>"; } $selected = $selected_field == 'all' ? "selected='selected'" : ""; $str .= "<option value='all' " . $selected . ">" . __("Form Total", "gravityformspaypal") . "</option>"; return $str; }
private static function get_quiz_results($form_array, $form, $lead) { if (self::check_for_fields('quiz', $form) === false) { return $form_array; } /* * If there are any quiz results * add them to the 'quiz' key */ $fields = GFCommon::get_fields_by_type($form, array('quiz')); $count_quiz_fields = count($fields); if ($count_quiz_fields > 0) { $form_array['quiz']['config']['grading'] = isset($form['gravityformsquiz']['grading']) ? $form['gravityformsquiz']['grading'] : ''; $form_array['quiz']['config']['passPercent'] = isset($form['gravityformsquiz']['passPercent']) ? $form['gravityformsquiz']['passPercent'] : ''; $form_array['quiz']['config']['grades'] = isset($form['gravityformsquiz']['grades']) ? $form['gravityformsquiz']['grades'] : ''; $form_array['quiz']['results']['score'] = rgar($lead, 'gquiz_score'); $form_array['quiz']['results']['percent'] = rgar($lead, 'gquiz_percent'); $form_array['quiz']['results']['is_pass'] = rgar($lead, 'gquiz_is_pass'); $form_array['quiz']['results']['grade'] = rgar($lead, 'gquiz_grade'); /* * Get the overall results */ $quiz_global = self::get_quiz_overalls($form); $form_fields = self::$fields; /* * Convert the array keys into their text counterparts * Loop through the global quiz data */ if (empty($quiz_global['field_data'])) { $quiz_global['field_data'] = array(); } foreach ($quiz_global['field_data'] as $id => &$choices) { /* get the $field */ $field = $form_fields[$id]; /* replace ['totals'] key with ['misc'] key */ $choices = self::replace_key($choices, 'totals', 'misc'); /* add the field name to the ['misc'] key */ $choices['misc']['label'] = $field['label']; /* loop through the field choices */ foreach ($field['choices'] as $choice) { $choices = self::replace_key($choices, $choice['value'], $choice['text']); /* check if this is the correct field */ if (isset($choice['gquizIsCorrect']) && $choice['gquizIsCorrect'] == 1) { $choices['misc']['correct_option_name'][] = $choice['text']; } } } $form_array['quiz']['global'] = $quiz_global; //$form_array['quiz']['global'] = self::get_quiz_overalls($form); } return $form_array; }
/** * Get credit card field * * @since * * @uses GFCommon::get_fields_by_type() * * @param $form * * @return bool */ public function get_creditcard_field($form) { $fields = GFCommon::get_fields_by_type($form, array('creditcard')); return empty($fields) ? false : $fields[0]; }
private static function get_field_row_count($form, $exported_field_ids, $entry_count) { $list_fields = GFCommon::get_fields_by_type($form, array('list')); //only getting fields that have been exported $field_ids = ''; foreach ($list_fields as $field) { if (in_array($field->id, $exported_field_ids) && $field->enableColumns) { $field_ids .= $field->id . ','; } } if (empty($field_ids)) { return array(); } $field_ids = substr($field_ids, 0, strlen($field_ids) - 1); $page_size = 200; $offset = 0; $row_counts = array(); global $wpdb; $go_to_next_page = true; while ($go_to_next_page) { $sql = "SELECT d.field_number as field_id, ifnull(l.value, d.value) as value\n FROM {$wpdb->prefix}rg_lead_detail d\n LEFT OUTER JOIN {$wpdb->prefix}rg_lead_detail_long l ON d.id = l.lead_detail_id\n WHERE d.form_id={$form['id']} AND cast(d.field_number as decimal) IN ({$field_ids})\n LIMIT {$offset}, {$page_size}"; $results = $wpdb->get_results($sql, ARRAY_A); foreach ($results as $result) { $list = unserialize($result['value']); $current_row_count = isset($row_counts[$result['field_id']]) ? intval($row_counts[$result['field_id']]) : 0; if (is_array($list) && count($list) > $current_row_count) { $row_counts[$result['field_id']] = count($list); } } $offset += $page_size; $go_to_next_page = count($results) == $page_size; } return $row_counts; }
function form($instance) { $first_form_id = 1; $forms = RGFormsModel::get_forms(); if (!empty($forms)) { $first_form_id = $forms[0]->id; } $override_form_settings = rgar($instance, 'override_form_settings'); $widget_has_legacy_override_settings = "" === $override_form_settings && isset($instance["style"]); $instance = wp_parse_args((array) $instance, array('title' => __("Poll", "gravityforms"), 'tabindex' => '1', 'showtitle' => '0', 'showdescription' => '0', 'displayconfirmation' => '0', 'ajax' => '0', 'disable_scripts' => '0', 'form_id' => $first_form_id, 'mode' => 'results', 'style' => 'green', 'display_results' => '1', 'show_results_link' => '1', 'show_percentages' => '1', 'show_counts' => '1', 'block_repeat_voters' => '0', 'cookie' => '', 'override_form_settings' => '0')); if ($widget_has_legacy_override_settings) { $instance['override_form_settings'] = '1'; } $override_form_ids = apply_filters('gpoll_widget_override', array()); $form_id = $instance['form_id']; if ($widget_has_legacy_override_settings || $override_form_settings) { $show_override_radio = true; $show_override_settings = true; } elseif (in_array($form_id, $override_form_ids) && false === $widget_has_legacy_override_settings) { $show_override_radio = true; $show_override_settings = false; } else { $show_override_radio = false; $show_override_settings = false; } ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e("Title", "gravityforms"); ?> :</label> <input id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " style="width:90%;" /> </p> <p> <label for="<?php echo $this->get_field_id('form_id'); ?> "><?php _e("Select a Form", "gravityforms"); ?> :</label> <select class="gpoll_forms_dropdown" id="<?php echo $this->get_field_id('form_id'); ?> " name="<?php echo $this->get_field_name('form_id'); ?> " style="width:90%;" <?php if (false === $widget_has_legacy_override_settings) { ?> onchange="radioButtonsSelector = '#<?php echo $this->id; ?> _gpoll_override_radio'; radioOffSelector = '#widget-<?php echo $this->id; ?> -override_form_settings_0'; settingsSelector = '#<?php echo $this->id; ?> _gpoll_overrides, #<?php echo $this->id . "_gpoll_override_radio"; ?> '; if (jQuery.inArray(parseInt(this.value), <?php echo json_encode($override_form_ids); ?> ) >= 0 ) {jQuery(radioButtonsSelector).show(); } else { jQuery(settingsSelector).hide();}jQuery(radioOffSelector).trigger('click');"<?php } ?> > <?php $forms = RGFormsModel::get_forms(1, "title"); foreach ($forms as $f) { $form = RGFormsModel::get_form_meta($f->id); $poll_fields = GFCommon::get_fields_by_type($form, array('poll')); if (false === empty($poll_fields)) { $selected = $f->id == $instance['form_id'] ? 'selected="selected"' : ""; echo '<option value="' . $f->id . '" ' . $selected . '>' . $f->title . '</option>'; } } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('mode'); ?> "><?php _e("Display Mode", "gravityformspolls"); ?> :</label> <select id="<?php echo $this->get_field_id('mode'); ?> " name="<?php echo $this->get_field_name('mode'); ?> " style="width:90%;" onchange="if ('poll' === this.value) jQuery('#<?php echo $this->id; ?> _gpoll_override_poll_settings, #<?php echo $this->id; ?> _gpoll_form_settings').show('slow'); else jQuery('#<?php echo $this->id; ?> _gpoll_override_poll_settings, #<?php echo $this->id; ?> _gpoll_form_settings').hide('slow', function(){jQuery(this).css('display', 'none')}); "> <option value="poll" <?php echo $instance['mode'] == "poll" ? 'selected="selected"' : ''; ?> ><?php _e("Poll", "gravityformspolls"); ?> </option> <option value="results" <?php echo $instance['mode'] == "results" ? 'selected="selected"' : ''; ?> ><?php _e("Results only", "gravityformspolls"); ?> </option> </select> </p> <div id="<?php echo $this->id; ?> _gpoll_override_radio" style="<?php echo $show_override_radio ? "" : "display:none"; ?> "> <p> <input type="radio" name="<?php echo $this->get_field_name('override_form_settings'); ?> " value="0" <?php checked($instance['override_form_settings'], "0"); ?> id="<?php echo $this->get_field_id('override_form_settings') . "_0"; ?> " onclick="jQuery('#<?php echo $this->id; ?> _gpoll_overrides').hide('slow');"> <label for="<?php echo $this->get_field_id('override_form_settings') . "_0"; ?> "><?php _e("Use form settings", "gravityformspolls"); ?> </label><br> <input type="radio" name="<?php echo $this->get_field_name('override_form_settings'); ?> " value="1" <?php checked($instance['override_form_settings'], "1"); ?> id="<?php echo $this->get_field_id('override_form_settings') . "_1"; ?> " onclick="jQuery('#<?php echo $this->id; ?> _gpoll_overrides').show('slow');"> <label for="<?php echo $this->get_field_id('override_form_settings') . "_1"; ?> "><?php _e("Override form settings", "gravityformspolls"); ?> </label><br> </p> </div> <div id="<?php echo $this->id; ?> _gpoll_overrides" style="<?php echo $show_override_settings ? "" : "display:none"; ?> "> <p> <strong><?php _e("Results Settings", "gravityformspolls"); ?> </strong><br /> <input type="checkbox" name="<?php echo $this->get_field_name('show_percentages'); ?> " id="<?php echo $this->get_field_id('show_percentages'); ?> " <?php checked($instance['show_percentages']); ?> value="1" /> <label for="<?php echo $this->get_field_id('show_percentages'); ?> "><?php _e("Show percentages", "gravityformspolls"); ?> </label><br/> <input type="checkbox" name="<?php echo $this->get_field_name('show_counts'); ?> " id="<?php echo $this->get_field_id('show_counts'); ?> " <?php checked($instance['show_counts']); ?> value="1" /> <label for="<?php echo $this->get_field_id('show_counts'); ?> "><?php _e("Show counts", "gravityformspolls"); ?> </label><br/> <p> <label for="<?php echo $this->get_field_id('style'); ?> "><?php _e("Style", "gravityformspolls"); ?> :</label> <select id="<?php echo $this->get_field_id('style'); ?> " name="<?php echo $this->get_field_name('style'); ?> " style="width:90%;"> <option value="green" <?php echo $instance['style'] == "green" ? 'selected="selected"' : ''; ?> ><?php _e("Green", "gravityformspolls"); ?> </option> <option value="blue" <?php echo $instance['style'] == "blue" ? 'selected="selected"' : ''; ?> ><?php _e("Blue", "gravityformspolls"); ?> </option> <option value="red" <?php echo $instance['style'] == "red" ? 'selected="selected"' : ''; ?> ><?php _e("Red", "gravityformspolls"); ?> </option> <option value="orange" <?php echo $instance['style'] == "orange" ? 'selected="selected"' : ''; ?> ><?php _e("Orange", "gravityformspolls"); ?> </option> </select> </p> <div id="<?php echo $this->id; ?> _gpoll_override_poll_settings" style="<?php echo $instance['mode'] == "results" ? "display:none" : ""; ?> "> <p> <input type="checkbox" name="<?php echo $this->get_field_name('displayconfirmation'); ?> " id="<?php echo $this->get_field_id('displayconfirmation'); ?> " <?php checked($instance['displayconfirmation']); ?> value="1"/> <label for="<?php echo $this->get_field_id('displayconfirmation'); ?> "><?php _e("Display form confirmation", "gravityforms"); ?> </label><br/> <input type="checkbox" name="<?php echo $this->get_field_name('display_results'); ?> " id="<?php echo $this->get_field_id('display_results'); ?> " <?php checked($instance['display_results']); ?> value="1" /> <label for="<?php echo $this->get_field_id('display_results'); ?> "><?php _e("Display results of submitted poll fields", "gravityformspolls"); ?> </label><br/> <input type="checkbox" name="<?php echo $this->get_field_name('show_results_link'); ?> " id="<?php echo $this->get_field_id('show_results_link'); ?> " <?php checked($instance['show_results_link']); ?> value="1" /> <label for="<?php echo $this->get_field_id('show_results_link'); ?> "><?php _e("Show link to view results", "gravityformspolls"); ?> </label><br/> </p> <p> <?php $cookie_expriation_div_id = $this->id . "_cookie_expriation"; ?> <strong><?php _e("Repeat Voters", "gravityformspolls"); ?> :</strong> <br /> <input type="radio" name="<?php echo $this->get_field_name('block_repeat_voters'); ?> " value="0" <?php checked($instance['block_repeat_voters'], "0"); ?> id="<?php echo $this->get_field_id('block_repeat_voters') . "_0"; ?> " onclick="jQuery('#<?php echo $cookie_expriation_div_id; ?> ').hide('slow');"> <label for="<?php echo $this->get_field_id('block_repeat_voters') . "_0"; ?> "><?php _e("Don't block repeat voting", "gravityformspolls"); ?> </label><br> <input type="radio" name="<?php echo $this->get_field_name('block_repeat_voters'); ?> " value="1" <?php checked($instance['block_repeat_voters'], "1"); ?> id="<?php echo $this->get_field_id('block_repeat_voters') . "_1"; ?> " onclick="jQuery('#<?php echo $cookie_expriation_div_id; ?> ').show('slow');"> <label for="<?php echo $this->get_field_id('block_repeat_voters') . "_1"; ?> "><?php _e("Block repeat voting using cookie", "gravityformspolls"); ?> </label> </p> <div id="<?php echo $cookie_expriation_div_id; ?> " <?php echo $instance['block_repeat_voters'] == '0' ? 'style="display:none;"' : ''; ?> > <label for="<?php echo $this->get_field_id('cookie'); ?> "><?php _e("Expires:", "gravityformspolls"); ?> </label> <select id="<?php echo $this->get_field_id('cookie'); ?> " name="<?php echo $this->get_field_name('cookie'); ?> " style="width:90%;"> <?php $options = array("20 years" => __("Never", "gravityformspolls"), "1 hour" => __("1 hour", "gravityformspolls"), "6 hours" => __("6 hours", "gravityformspolls"), "12 hours" => __("12 hours", "gravityformspolls"), "1 day" => __("1 day", "gravityformspolls"), "1 week" => __("1 week", "gravityformspolls"), "1 month" => __("1 month", "gravityformspolls")); foreach ($options as $key => $value) { $selected = ''; if ($key == rgar($instance, 'cookie')) { $selected = ' selected="selected"'; } echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } ?> </select> <br /><br /> </div> </div> </div> <div id="<?php echo $this->id; ?> _gpoll_form_settings" style="<?php echo $instance['mode'] == "results" ? "display:none" : ""; ?> "> <p> <input type="checkbox" name="<?php echo $this->get_field_name('showtitle'); ?> " id="<?php echo $this->get_field_id('showtitle'); ?> " <?php checked($instance['showtitle']); ?> value="1" /> <label for="<?php echo $this->get_field_id('showtitle'); ?> "><?php _e("Display form title", "gravityforms"); ?> </label><br/> <input type="checkbox" name="<?php echo $this->get_field_name('showdescription'); ?> " id="<?php echo $this->get_field_id('showdescription'); ?> " <?php checked($instance['showdescription']); ?> value="1"/> <label for="<?php echo $this->get_field_id('showdescription'); ?> "><?php _e("Display form description", "gravityforms"); ?> </label><br/> </p> <p> <a href="javascript: var obj = jQuery('.gf_widget_advanced'); if(!obj.is(':visible')) {var a = obj.show('slow');} else {var a = obj.hide('slow');}"><?php _e("advanced options", "gravityforms"); ?> </a> </p> <p class="gf_widget_advanced" style="display:none;"> <input type="checkbox" name="<?php echo $this->get_field_name('ajax'); ?> " id="<?php echo $this->get_field_id('ajax'); ?> " <?php checked($instance['ajax']); ?> value="1"/> <label for="<?php echo $this->get_field_id('ajax'); ?> "><?php _e("Enable AJAX", "gravityforms"); ?> </label><br/> <input type="checkbox" name="<?php echo $this->get_field_name('disable_scripts'); ?> " id="<?php echo $this->get_field_id('disable_scripts'); ?> " <?php checked($instance['disable_scripts']); ?> value="1"/> <label for="<?php echo $this->get_field_id('disable_scripts'); ?> "><?php _e("Disable script output", "gravityforms"); ?> </label><br/> <label for="<?php echo $this->get_field_id('tabindex'); ?> "><?php _e("Tab Index Start", "gravityforms"); ?> : </label> <input id="<?php echo $this->get_field_id('tabindex'); ?> " name="<?php echo $this->get_field_name('tabindex'); ?> " value="<?php echo $instance['tabindex']; ?> " style="width:15%;" /><br/> <small><?php _e("If you have other forms on the page (i.e. Comments Form), specify a higher tabindex start value so that your Gravity Form does not end up with the same tabindices as your other forms. To disable the tabindex, enter 0 (zero).", "gravityforms"); ?> </small> </p> </div> <?php }
public static function delete_password($entry, $form) { $password_fields = GFCommon::get_fields_by_type($form, array('password')); if (is_array($password_fields)) { foreach ($password_fields as $password_field) { $entry[$password_field->id] = ''; } } GFAPI::update_entry($entry); return $entry; }
public function get_product_fields($form, $lead, $use_choice_text = false, $use_admin_label = false) { $products = array(); foreach ($form["fields"] as $field) { $id = $field["id"]; $lead_value = RGFormsModel::get_lead_field_value($lead, $field); $quantity_field = GFCommon::get_product_fields_by_type($form, array("quantity"), $id); $quantity = sizeof($quantity_field) > 0 ? 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"] = rgar($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 = GFCommon::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 = GFCommon::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 = GFCommon::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 = GFCommon::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 = GFCommon::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); return $product_info; }
private static function has_fileupload_field($form) { $fileupload_fields = GFCommon::get_fields_by_type($form, array("fileupload", "post_image")); if (is_array($form["fields"])) { foreach ($form["fields"] as $field) { $input_type = RGFormsModel::get_input_type($field); if (in_array($input_type, array("fileupload", "post_image"))) { return true; } } } return false; }
public static function has_multifile_fileupload_field($form) { $fileupload_fields = GFCommon::get_fields_by_type($form, array("fileupload", "post_custom_field")); if (is_array($fileupload_fields)) { foreach ($fileupload_fields as $field) { if (rgar($field, "multipleFiles")) { return true; } } } return false; }