/**
  * Add form settings page with schedule export options.
  *
  * TODO: Add default email address - admin email if empty?
  *
  * @since    1.0.0
  *
  */
 public function form_settings_fields($form)
 {
     if (!GFCommon::current_user_can_any('gravityforms_edit_forms')) {
         wp_die('You do not have permission to access this page');
     }
     //collect the form id from the schedule export settings page url for the current form
     $form_id = $_REQUEST['id'];
     $form = apply_filters("gform_form_export_page_{$form_id}", apply_filters('gform_form_export_page', $form));
     //collect filter settings TODO: these are currently not used.
     $filter_settings = GFCommon::get_field_filter_settings($form);
     $filter_settings_json = json_encode($filter_settings);
     //collect and add the default export fields
     $form = GFExport::add_default_export_fields($form);
     $form_fields = $form['fields'];
     $choices[] = array('label' => 'Select All', 'name' => '', 'default_value' => 1);
     //loop through the fields and format all the inputs in to an array to be rendered as checkboxes
     foreach ($form_fields as $field) {
         $inputs = $field->get_entry_inputs();
         if (is_array($inputs)) {
             foreach ($inputs as $input) {
                 $choices[] = array('label' => GFCommon::get_label($field, $input['id']), 'name' => $input['id'], 'default_value' => 1);
             }
         } else {
             if (!$field->displayOnly) {
                 $choices[] = array('label' => GFCommon::get_label($field), 'name' => $field->id, 'default_value' => 1);
             }
         }
     }
     $inputs = array(array('title' => "Scheduled Entries Export", 'description' => "The settings below will automatically export new entries and send them to the emails below based on the set time frame.", 'fields' => array(array('label' => "Activate the Schedule", 'type' => "checkbox", 'name' => "enabled", 'tooltip' => "Enabling the schedule based on the sets below. This runs off WP Cron.", 'choices' => array(array('label' => "", 'name' => "enabled"))), array('label' => "Time Frame", 'type' => "select", 'name' => "time_frame", 'tooltip' => "Set how frequently it the entries are exported and emailed", 'choices' => array(array('label' => "Hourly", 'value' => "hourly"), array('label' => "Twice Daily", 'value' => "twicedaily"), array('label' => "Daily", 'value' => "daily"), array('label' => "Weekly", 'value' => "weekly"), array('label' => "Monthly - Every 30 Days", 'value' => "monthly"))), array('type' => "text", 'name' => "email", 'label' => "Email Address", 'class' => "medium", 'tooltip' => "Enter a comma separated list of emails you would like to receive the exported entries file."), array('label' => "Form Fields", 'type' => "checkbox", 'name' => "fields", 'tooltip' => "Select the fields you would like to include in the export. Caution: Make sure you are not sending any sensitive information.", 'choices' => $choices))));
     return $inputs;
 }
示例#2
0
 public static function select_export_form()
 {
     check_ajax_referer('rg_select_export_form', 'rg_select_export_form');
     $form_id = intval($_POST['form_id']);
     $form = RGFormsModel::get_form_meta($form_id);
     /**
      * Filters through the Form Export Page
      *
      * @param int $form_id The ID of the form to export
      * @param int $form The Form Object of the form to export
      */
     $form = gf_apply_filters('gform_form_export_page', $form_id, $form);
     $filter_settings = GFCommon::get_field_filter_settings($form);
     $filter_settings_json = json_encode($filter_settings);
     $fields = array();
     $form = GFExport::add_default_export_fields($form);
     if (is_array($form['fields'])) {
         /* @var GF_Field $field */
         foreach ($form['fields'] as $field) {
             $inputs = $field->get_entry_inputs();
             if (is_array($inputs)) {
                 foreach ($inputs as $input) {
                     $fields[] = array($input['id'], GFCommon::get_label($field, $input['id']));
                 }
             } else {
                 if (!$field->displayOnly) {
                     $fields[] = array($field->id, GFCommon::get_label($field));
                 }
             }
         }
     }
     $field_json = GFCommon::json_encode($fields);
     die("EndSelectExportForm({$field_json}, {$filter_settings_json});");
 }
示例#3
0
 public static function select_export_form()
 {
     check_ajax_referer("rg_select_export_form", "rg_select_export_form");
     $form_id = intval($_POST["form_id"]);
     $form = RGFormsModel::get_form_meta($form_id);
     $fields = array();
     $form = GFExport::add_default_export_fields($form);
     if (is_array($form["fields"])) {
         foreach ($form["fields"] as $field) {
             if (is_array(rgar($field, "inputs"))) {
                 foreach ($field["inputs"] as $input) {
                     $fields[] = array($input["id"], GFCommon::get_label($field, $input["id"]));
                 }
             } else {
                 if (!rgar($field, "displayOnly")) {
                     $fields[] = array($field["id"], GFCommon::get_label($field));
                 }
             }
         }
     }
     $field_json = GFCommon::json_encode($fields);
     die("EndSelectExportForm({$field_json});");
 }