示例#1
0
 function test_assignee_field()
 {
     $form = GFAPI::get_form($this->form_id);
     $assignee_field_properties_json = '{"type":"workflow_assignee_select","id":6,"label":"Assignee","adminLabel":"","isRequired":false,"size":"medium","errorMessage":"","inputs":null,"formId":93,"pageNumber":1,"choices":"","conditionalLogic":"","displayOnly":"","labelPlacement":"","descriptionPlacement":"","subLabelPlacement":"","placeholder":"","multipleFiles":false,"maxFiles":"","calculationFormula":"","calculationRounding":"","enableCalculation":"","disableQuantity":false,"displayAllCategories":false,"inputMask":false,"inputMaskValue":"","allowsPrepopulate":false,"gravityflowAssigneeFieldShowUsers":true,"gravityflowAssigneeFieldShowRoles":true,"gravityflowAssigneeFieldShowFields":true,"cssClass":""}';
     $assignee_field_properties = json_decode($assignee_field_properties_json, true);
     $assignee_field_properties['id'] = 999;
     $assignee_field = new Gravity_Flow_Field_Assignee_Select($assignee_field_properties);
     $form['fields'][] = $assignee_field;
     GFAPI::update_form($form);
     $step_settings = array('assignees' => array('assignee_field|999'));
     $step1_id = $this->_add_user_input_step($step_settings);
     $this->_create_entries();
     $entries = GFAPI::get_entries($this->form_id);
     $entry = $entries[0];
     $entry_id = $entry['id'];
     $entry[999] = 'user_id|1';
     GFAPI::update_entry($entry);
     // simulate submission
     gravity_flow()->maybe_process_feed($entry, $form);
     $this->api->process_workflow($entry_id);
     $entry = GFAPI::get_entry($entry_id);
     // Check status
     $status = $this->api->get_status($entry);
     $this->assertEquals('pending', $status);
     // Complete
     $step1 = $this->api->get_step($step1_id, $entry);
     $step1->update_user_status(1, 'complete');
     $this->api->process_workflow($entry_id);
     // Refresh entry
     $entry = GFAPI::get_entry($entry_id);
     // Check status
     $status = $this->api->get_status($entry);
     $this->assertEquals('complete', $status);
 }
 /**
  * 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);
 }
 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']);
     }
 }