Exemplo n.º 1
0
 function do_performquicktransition()
 {
     $oForm = $this->form_quicktransition();
     $res = $oForm->validate();
     if (!empty($res['errors'])) {
         return $oForm->handleError();
     }
     $this->startTransaction();
     $data = $res['results'];
     $oTransition = KTWorkflowTransition::get($_REQUEST['fTransitionId']);
     $res = KTWorkflowUtil::performTransitionOnDocument($oTransition, $this->oDocument, $this->oUser, $data['reason']);
     if (!Permission::userHasDocumentReadPermission($this->oDocument)) {
         $this->commitTransaction();
         $_SESSION['KTInfoMessage'][] = _kt('Transition performed') . '. ' . _kt('You no longer have permission to view this document');
         controllerRedirect('browse', sprintf('fFolderId=%d', $this->oDocument->getFolderId()));
     } else {
         $this->commitTransaction();
         $_SESSION['KTInfoMessage'][] = _kt('Transition performed');
         controllerRedirect('viewDocument', sprintf('fDocumentId=%d', $this->oDocument->getId()));
     }
 }
Exemplo n.º 2
0
 /**
  * This performs a transition to a new state of the workflow on the document
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $transition The transition to perform
  * @param string $reason The reason for transitioning the document to a new state
  * @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure
  */
 function perform_workflow_transition($transition, $reason)
 {
     $user = $this->can_user_access_object_requiring_permission($this->document, KTAPI_PERMISSION_WORKFLOW);
     if (PEAR::isError($user)) {
         return $user;
     }
     $workflowid = $this->document->getWorkflowId();
     if (empty($workflowid)) {
         return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS);
     }
     $transition =& KTWorkflowTransition::getByName($transition);
     if (is_null($transition) || PEAR::isError($transition)) {
         return new KTAPI_Error(KTAPI_ERROR_WORKFLOW_INVALID, $transition);
     }
     DBUtil::startTransaction();
     $result = KTWorkflowUtil::performTransitionOnDocument($transition, $this->document, $user, $reason);
     if (is_null($result) || PEAR::isError($result)) {
         DBUtil::rollback();
         return new KTAPI_Error(KTAPI_ERROR_WORKFLOW_INVALID, $transition);
     }
     DBUtil::commit();
 }