public static function update_action() { $flow_id = Lib_Request::post_var('flow_id'); $flow_id = intval($flow_id); if (empty($flow_id)) { Lib_Request::flash('error', '流程ID为空!'); Module_HttpRequest_Router::redirect_to('/flow_manager/flow/list'); } $flow = new Module_FlowManager_Flow(); $url = '/flow_manager/flow/edit?flow_id=' . $flow_id; $data = self::_get_flow_data($url, $flow_id); $model_flow = new Model_FlowInfo(); $old_flow = $model_flow->get_flow_info_by_id($flow_id); if ($old_flow['errno'] !== Const_Err_Base::ERR_OK) { $old_flow['data'] = []; } $old_flow = $old_flow['data']; $ignore_fields = ['flow_id', 'create_time', 'update_time']; $diff = Module_OperationRecord_Main::get_diff($old_flow, $data, $ignore_fields); if (Const_Err_Base::ERR_OK !== $diff['errno']) { $msg = isset($diff['data']['msg']) ? $diff['data']['msg'] : '未知错误!'; Lib_Request::flash('warn', $msg); Module_HttpRequest_Router::redirect_to($url); } $diff = $diff['data']; $result = $flow->update($flow_id, $data); if ($result['errno'] !== Const_Err_Base::ERR_OK) { throw new Exception('流程修改失败', Const_Err_Db::ERR_SAVE_DATA_FAIL); Lib_Request::flash('error', '流程修改失败!'); Module_HttpRequest_Router::redirect_to($url); } Module_OperationRecord_Main::add_record(Module_OperationRecord_Main::OPCODE_FLOW_EDIT, $diff, $flow_id); Lib_Request::flash('success', '流程修改成功!'); Module_HttpRequest_Router::redirect_to('/flow_manager/flow/list'); }
/** * @param int $id * @param array $custom_flow * @param array $custom_options * @return $this|null */ function set_current_flow($id, $custom_flow = null, $custom_options = null) { if (isset($this->_flow_list[$id])) { $this->_current_id = $id; $this->_current_flow = $this->_flow_list[$id]; } else { $flow = new Module_FlowManager_Flow(); $flow->id = $id; $get_flow = $flow->get(); if ($get_flow === false) { $this->_current_id = null; $this->_current_flow = null; return null; } $this->_current_id = $id; $this->_current_flow = $flow; } $this->custom_flow($custom_flow); $this->custom_options($custom_options); return $this; }
/** * @param int $flow_id * @return array */ private static function _get_fields_by_flow_id($flow_id) { $flow = new Module_FlowManager_Flow(); $flow->id = $flow_id; $flow_info = $flow->get(); if (!$flow_info) { return Lib_Helper::get_err_struct(Const_Err_DataAccess::ERR_FLOW_NOT_EXISTS, 'no this flow, flow_id: ' . $flow_id); } $fields = Module_ModuleManager_InterfaceGen::get_instance()->gen_fields($flow); return Lib_Helper::get_return_struct($fields); }