Exemple #1
0
 public static function maybe_export()
 {
     if (isset($_POST["export_lead"])) {
         check_admin_referer("rg_start_export", "rg_start_export_nonce");
         $form_id = $_POST["export_form"];
         $form = RGFormsModel::get_form_meta($form_id);
         $filename = sanitize_title_with_dashes($form["title"]) . "-" . date("Y-m-d") . ".csv";
         $charset = get_option('blog_charset');
         header('Content-Description: File Transfer');
         header("Content-Disposition: attachment; filename={$filename}");
         header('Content-Type: text/plain; charset=' . $charset, true);
         ob_clean();
         GFExport::start_export($form);
         die;
     } else {
         if (isset($_POST["export_forms"])) {
             check_admin_referer("gf_export_forms", "gf_export_forms_nonce");
             $selected_forms = $_POST["gf_form_id"];
             if (empty($selected_forms)) {
                 echo "<div class='error' style='padding:15px;'>" . __("Please select the forms to be exported", "gravityforms") . "</div>";
                 return;
             }
             $forms = RGFormsModel::get_forms_by_id($selected_forms);
             //removing the inputs for checkboxes (choices will be used during the import)
             foreach ($forms as &$form) {
                 foreach ($form["fields"] as &$field) {
                     $inputType = RGFormsModel::get_input_type($field);
                     unset($field["pageNumber"]);
                     if ($inputType == "checkbox") {
                         unset($field["inputs"]);
                     } else {
                         if ($inputType != "address") {
                             unset($field["addressType"]);
                         } else {
                             if ($inputType != "date") {
                                 unset($field["calendarIconType"]);
                             } else {
                                 if ($field["type"] == $field["inputType"]) {
                                     unset($field["inputType"]);
                                 }
                             }
                         }
                     }
                     if (in_array($inputType, array("checkbox", "radio", "select")) && !$field["enableChoiceValue"]) {
                         foreach ($field["choices"] as &$choice) {
                             unset($choice["value"]);
                         }
                     }
                 }
             }
             require_once "xml.php";
             $options = array("version" => GFCommon::$version, "forms/form/id" => array("is_hidden" => true), "forms/form/nextFieldId" => array("is_hidden" => true), "forms/form/notification/routing" => array("array_tag" => "routing_item"), "forms/form/useCurrentUserAsAuthor" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/postCategory" => array("is_attribute" => true), "forms/form/postStatus" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/labelPlacement" => array("is_attribute" => true), "forms/form/confirmation/type" => array("is_attribute" => true), "forms/form/lastPageButton/type" => array("is_attribute" => true), "forms/form/pagination/type" => array("is_attribute" => true), "forms/form/pagination/style" => array("is_attribute" => true), "forms/form/button/type" => array("is_attribute" => true), "forms/form/button/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/id" => array("is_attribute" => true), "forms/form/fields/field/type" => array("is_attribute" => true), "forms/form/fields/field/inputType" => array("is_attribute" => true), "forms/form/fields/field/displayOnly" => array("is_attribute" => true), "forms/form/fields/field/size" => array("is_attribute" => true), "forms/form/fields/field/isRequired" => array("is_attribute" => true), "forms/form/fields/field/noDuplicates" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/id" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/name" => array("is_attribute" => true), "forms/form/fields/field/formId" => array("is_hidden" => true), "forms/form/fields/field/allowsPrepopulate" => array("is_attribute" => true), "forms/form/fields/field/adminOnly" => array("is_attribute" => true), "forms/form/fields/field/enableChoiceValue" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/previousButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/isSelected" => array("is_attribute" => true), "forms/form/fields/field/choices/choice/text" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/value" => array("allow_empty" => true), "forms/form/fields/field/rangeMin" => array("is_attribute" => true), "forms/form/fields/field/rangeMax" => array("is_attribute" => true), "forms/form/fields/field/calendarIconType" => array("is_attribute" => true), "forms/form/fields/field/dateFormat" => array("is_attribute" => true), "forms/form/fields/field/dateType" => array("is_attribute" => true), "forms/form/fields/field/nameFormat" => array("is_attribute" => true), "forms/form/fields/field/phoneFormat" => array("is_attribute" => true), "forms/form/fields/field/addressType" => array("is_attribute" => true), "forms/form/fields/field/hideCountry" => array("is_attribute" => true), "forms/form/fields/field/hideAddress2" => array("is_attribute" => true), "forms/form/fields/field/displayTitle" => array("is_attribute" => true), "forms/form/fields/field/displayCaption" => array("is_attribute" => true), "forms/form/fields/field/displayDescription" => array("is_attribute" => true), "forms/form/fields/field/displayAllCategories" => array("is_attribute" => true), "forms/form/fields/field/postCustomFieldName" => array("is_attribute" => true));
             $serializer = new RGXML($options);
             $xml .= $serializer->serialize("forms", $forms);
             if (!seems_utf8($xml)) {
                 $value = utf8_encode($xml);
             }
             $filename = "gravityforms-export-" . date("Y-m-d") . ".xml";
             header('Content-Description: File Transfer');
             header("Content-Disposition: attachment; filename={$filename}");
             header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
             echo $xml;
             die;
         }
     }
 }
Exemple #2
0
 public static function maybe_export()
 {
     if (isset($_POST["export_lead"])) {
         check_admin_referer("rg_start_export", "rg_start_export_nonce");
         //see if any fields chosen
         if (empty($_POST["export_field"])) {
             GFCommon::add_error_message(__('Please select the fields to be exported', 'gravityforms'));
             return;
         }
         $form_id = $_POST["export_form"];
         $form = RGFormsModel::get_form_meta($form_id);
         $filename = sanitize_title_with_dashes($form["title"]) . "-" . gmdate("Y-m-d", GFCommon::get_local_timestamp(time())) . ".csv";
         $charset = get_option('blog_charset');
         header('Content-Description: File Transfer');
         header("Content-Disposition: attachment; filename={$filename}");
         header('Content-Type: text/plain; charset=' . $charset, true);
         $buffer_length = ob_get_length();
         //length or false if no buffer
         if ($buffer_length > 1) {
             ob_clean();
         }
         GFExport::start_export($form);
         die;
     } else {
         if (isset($_POST["export_forms"])) {
             check_admin_referer("gf_export_forms", "gf_export_forms_nonce");
             $selected_forms = rgpost("gf_form_id");
             if (empty($selected_forms)) {
                 GFCommon::add_error_message(__('Please select the forms to be exported', 'gravityforms'));
                 return;
             }
             $forms = RGFormsModel::get_form_meta_by_id($selected_forms);
             //removing the inputs for checkboxes (choices will be used during the import)
             foreach ($forms as &$form) {
                 foreach ($form["fields"] as &$field) {
                     $inputType = RGFormsModel::get_input_type($field);
                     if (isset($field["pageNumber"])) {
                         unset($field["pageNumber"]);
                     }
                     if ($inputType == "checkbox") {
                         unset($field["inputs"]);
                     }
                     if ($inputType != "address") {
                         unset($field["addressType"]);
                     }
                     if ($inputType != "date") {
                         unset($field["calendarIconType"]);
                         unset($field["dateType"]);
                     }
                     if ($inputType != "creditcard") {
                         unset($field["creditCards"]);
                     }
                     if ($field["type"] == rgar($field, "inputType")) {
                         unset($field["inputType"]);
                     }
                     if (in_array($inputType, array("checkbox", "radio", "select")) && !rgar($field, "enableChoiceValue")) {
                         foreach ($field["choices"] as &$choice) {
                             unset($choice["value"]);
                         }
                     }
                     // convert associative array to indexed
                     if (isset($form['confirmations'])) {
                         $form['confirmations'] = array_values($form['confirmations']);
                     }
                     if (isset($form['notifications'])) {
                         $form['notifications'] = array_values($form['notifications']);
                     }
                 }
             }
             require_once "xml.php";
             $options = array("version" => GFCommon::$version, "forms/form/id" => array("is_hidden" => true), "forms/form/nextFieldId" => array("is_hidden" => true), "forms/form/notification/routing" => array("array_tag" => "routing_item"), "forms/form/useCurrentUserAsAuthor" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/postCategory" => array("is_attribute" => true), "forms/form/postStatus" => array("is_attribute" => true), "forms/form/postAuthor" => array("is_attribute" => true), "forms/form/postFormat" => array("is_attribute" => true), "forms/form/labelPlacement" => array("is_attribute" => true), "forms/form/confirmation/type" => array("is_attribute" => true), "forms/form/lastPageButton/type" => array("is_attribute" => true), "forms/form/pagination/type" => array("is_attribute" => true), "forms/form/pagination/style" => array("is_attribute" => true), "forms/form/button/type" => array("is_attribute" => true), "forms/form/button/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/button/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/id" => array("is_attribute" => true), "forms/form/fields/field/type" => array("is_attribute" => true), "forms/form/fields/field/inputType" => array("is_attribute" => true), "forms/form/fields/field/displayOnly" => array("is_attribute" => true), "forms/form/fields/field/size" => array("is_attribute" => true), "forms/form/fields/field/isRequired" => array("is_attribute" => true), "forms/form/fields/field/noDuplicates" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/id" => array("is_attribute" => true), "forms/form/fields/field/inputs/input/name" => array("is_attribute" => true), "forms/form/fields/field/formId" => array("is_hidden" => true), "forms/form/fields/field/descriptionPlacement" => array("is_hidden" => true), "forms/form/fields/field/allowsPrepopulate" => array("is_attribute" => true), "forms/form/fields/field/adminOnly" => array("is_attribute" => true), "forms/form/fields/field/enableChoiceValue" => array("is_attribute" => true), "forms/form/fields/field/enableEnhancedUI" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/previousButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/type" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/actionType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/logicType" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/fieldId" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/operator" => array("is_attribute" => true), "forms/form/fields/field/nextButton/conditionalLogic/rules/rule/value" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/isSelected" => array("is_attribute" => true), "forms/form/fields/field/choices/choice/text" => array("allow_empty" => true), "forms/form/fields/field/choices/choice/value" => array("allow_empty" => true), "forms/form/fields/field/rangeMin" => array("is_attribute" => true), "forms/form/fields/field/rangeMax" => array("is_attribute" => true), "forms/form/fields/field/numberFormat" => array("is_attribute" => true), "forms/form/fields/field/calendarIconType" => array("is_attribute" => true), "forms/form/fields/field/dateFormat" => array("is_attribute" => true), "forms/form/fields/field/dateType" => array("is_attribute" => true), "forms/form/fields/field/nameFormat" => array("is_attribute" => true), "forms/form/fields/field/phoneFormat" => array("is_attribute" => true), "forms/form/fields/field/addressType" => array("is_attribute" => true), "forms/form/fields/field/hideCountry" => array("is_attribute" => true), "forms/form/fields/field/hideAddress2" => array("is_attribute" => true), "forms/form/fields/field/disableQuantity" => array("is_attribute" => true), "forms/form/fields/field/productField" => array("is_attribute" => true), "forms/form/fields/field/enablePrice" => array("is_attribute" => true), "forms/form/fields/field/displayTitle" => array("is_attribute" => true), "forms/form/fields/field/displayCaption" => array("is_attribute" => true), "forms/form/fields/field/displayDescription" => array("is_attribute" => true), "forms/form/fields/field/displayAllCategories" => array("is_attribute" => true), "forms/form/fields/field/postCustomFieldName" => array("is_attribute" => true), "forms/form/confirmations/confirmation/id" => array("is_attribute" => true), "forms/form/confirmations/confirmation/type" => array("is_attribute" => true), "forms/form/confirmations/confirmation/isDefault" => array("is_attribute" => true), "forms/form/confirmations/confirmation/disableAutoformatting" => array("is_attribute" => true), "forms/form/notifications/notification/id" => array("is_attribute" => true));
             $serializer = new RGXML($options);
             $xml = $serializer->serialize("forms", $forms);
             if (!seems_utf8($xml)) {
                 $value = utf8_encode($xml);
             }
             $filename = "gravityforms-export-" . date("Y-m-d") . ".xml";
             header('Content-Description: File Transfer');
             header("Content-Disposition: attachment; filename={$filename}");
             header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
             echo $xml;
             die;
         }
     }
 }