예제 #1
0
파일: webapi.php 프로젝트: tlandn/akvo-web
 public function post_feeds($feeds, $form_id = null)
 {
     $this->authorize("gravityforms_edit_forms");
     $feed_ids = array();
     $result = array();
     foreach ($feeds as $feed) {
         $addon_slug = isset($feed["addon_slug"]) ? $feed["addon_slug"] : rgget("addon");
         $f_id = empty($form_id) ? $feed["form_id"] : $form_id;
         if (empty($f_id)) {
             $result = new WP_Error("missing_form_id", __("Missing form id", "gravityforms"));
             break;
         }
         $result = GFAPI::add_feed($f_id, $feed["meta"], $addon_slug);
         if (is_wp_error($result)) {
             break;
         }
         $feed_ids[] = $result;
     }
     if (is_wp_error($result)) {
         $response = $this->get_error_response($result);
         $status = $this->get_error_status($result);
     } else {
         $status = 201;
         $response = $feed_ids;
     }
     $this->end($status, $response);
 }
예제 #2
0
 /**
  * Adds a Workflow step to the form with the given settings. The following settings are required:
  * - step_name (string)
  * - step_type (string)
  * - description (string)
  *
  * @param $step_settings
  *
  * @return mixed
  */
 public function add_step($step_settings)
 {
     return GFAPI::add_feed($this->form_id, $step_settings, 'gravityflow');
 }
예제 #3
0
 public function post_feeds($feeds, $form_id = null)
 {
     $this->log_debug(__METHOD__ . '(): Running.');
     $capability = apply_filters('gform_web_api_capability_post_feeds', 'gravityforms_edit_forms');
     $this->authorize($capability);
     $feed_ids = array();
     $result = array();
     foreach ($feeds as $feed) {
         $addon_slug = isset($feed['addon_slug']) ? $feed['addon_slug'] : rgget('addon');
         $f_id = empty($form_id) ? $feed['form_id'] : $form_id;
         if (empty($f_id)) {
             $result = new WP_Error('missing_form_id', __('Missing form id', 'gravityforms'));
             break;
         }
         $result = GFAPI::add_feed($f_id, $feed['meta'], $addon_slug);
         if (is_wp_error($result)) {
             break;
         }
         $feed_ids[] = $result;
     }
     if (is_wp_error($result)) {
         $response = $this->get_error_response($result);
         $status = $this->get_error_status($result);
     } else {
         $status = 201;
         $response = $feed_ids;
     }
     $this->end($status, $response);
 }
 public function import_gravityflow_feeds($original_feeds, $new_form_id)
 {
     $feed_id_mappings = array();
     foreach ($original_feeds as $feed) {
         $new_feed_id = GFAPI::add_feed($new_form_id, $feed['meta'], 'gravityflow');
         if (!$feed['is_active']) {
             $this->update_feed_active($new_feed_id, false);
         }
         $feed_id_mappings[$feed['id']] = $new_feed_id;
     }
     $new_steps = $this->get_steps($new_form_id);
     foreach ($new_steps as $new_step) {
         $statuses_configs = $new_step->get_status_config();
         $new_step_meta = $new_step->get_feed_meta();
         $step_ids_updated = false;
         foreach ($statuses_configs as $status_config) {
             $destination_key = 'destination_' . $status_config['status'];
             $old_destination_step_id = $new_step_meta[$destination_key];
             if (!in_array($old_destination_step_id, array('next', 'complete')) && isset($feed_id_mappings[$old_destination_step_id])) {
                 $new_step_meta[$destination_key] = $feed_id_mappings[$old_destination_step_id];
                 $step_ids_updated = true;
             }
         }
         if ($new_step->get_type() == 'approval') {
             if (!empty($new_step->revert_buttonValue)) {
                 $new_step_meta['revert_buttonValue'] = $feed_id_mappings[$new_step->revert_buttonValue];
             }
         }
         if ($step_ids_updated) {
             $this->update_feed_meta($new_step->get_id(), $new_step_meta);
         }
     }
 }