/** * Processes a status update for a specified assignee of the current step of the specified entry. * * @param $entry_id * @param string $assignee_key */ function post_entries_assignees($entry_id, $assignee_key = null) { global $HTTP_RAW_POST_DATA; $capability = apply_filters('gravityflow_web_api_capability_post_entries_assignees', 'gravityflow_create_steps'); $this->authorize($capability); if (empty($assignee_key)) { $this->end(400, 'Bad request'); } $entry = GFAPI::get_entry($entry_id); if (empty($entry)) { $this->end(404, 'Entry not found'); } $form_id = absint($entry['form_id']); $api = new Gravity_Flow_API($form_id); $step = $api->get_current_step($entry); $assignee = new Gravity_Flow_Assignee($assignee_key, $step); if (!isset($HTTP_RAW_POST_DATA)) { $HTTP_RAW_POST_DATA = file_get_contents('php://input'); } $data = json_decode($HTTP_RAW_POST_DATA, true); $new_status = $data['status']; $form = GFAPI::get_form($form_id); $step->process_assignee_status($assignee, $new_status, $form); $api->process_workflow($entry_id); $response = 'Status updated successfully'; $this->end(200, $response); }
/** * Get the value of the Workflow Step based on the `workflow_step` entry meta int value * * @uses Gravity_Flow_API::get_current_step * * @param string $output HTML value output * @param array $entry The GF entry array * @param array $field_settings Settings for the particular GV field * @param array $field Current field being displayed * * @since 1.17 * * @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. */ function modify_entry_value_workflow_step($output, $entry, $field_settings, $field) { // If not set, the entry hasn't started a workflow $has_workflow_step = isset($entry['workflow_step']); if ($has_workflow_step) { $GFlow = new Gravity_Flow_API($entry['form_id']); if ($current_step = $GFlow->get_current_step($entry)) { $output = esc_html($current_step->get_name()); } else { $output = esc_html__('Workflow Complete', 'gravityview'); } unset($GFlow); } return $output; }
function _add_user_input_step($override_settings = array()) { $default_settings = array('step_name' => 'User Input', 'description' => '', 'step_type' => 'user_input', 'feed_condition_logic_conditional_logic' => '0', 'feed_condition_conditional_logic_object' => array(), 'assignee_policy' => 'any', 'type' => 'select', 'assignees' => array('user_id|1'), 'routing' => array(), 'assignee_notification_enabled' => '0', 'assignee_notification_message' => 'A new entry is pending your input', 'destination_complete' => 'next'); $settings = wp_parse_args($override_settings, $default_settings); return $this->api->add_step($settings); }
public function action_gform_post_add_entry($entry, $form) { $this->log_debug(__METHOD__ . '(): starting'); $api = new Gravity_Flow_API($form['id']); $steps = $api->get_steps(); if ($steps) { $this->log_debug(__METHOD__ . '(): triggering workflow for entry ID: ' . $entry['id']); gravity_flow()->maybe_process_feed($entry, $form); $api->process_workflow($entry['id']); } }