Ejemplo n.º 1
0
<?php

require_once '../../config/dmsDefaults.php';
require_once KT_LIB_DIR . '/documentmanagement/Document.inc';
require_once KT_LIB_DIR . '/workflow/workflow.inc.php';
require_once KT_LIB_DIR . '/workflow/workflowutil.inc.php';
$oDocument =& Document::get(4);
$oWorkflow =& KTWorkflow::get(1);
$res = KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument);
if (PEAR::isError($res)) {
    var_dump($res);
}
Ejemplo n.º 2
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt('workflow'));
     $oTemplate =& $this->oValidator->validateTemplate('ktcore/workflow/documentWorkflow');
     $oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
     $oWorkflow = KTWorkflowUtil::getWorkflowForDocument($oDocument);
     $oWorkflowState = KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
     $oUser =& User::get($_SESSION['userID']);
     // If the document is checked out - set transitions and workflows to empty and set checkedout to true
     $bIsCheckedOut = $this->oDocument->getIsCheckedOut();
     if ($bIsCheckedOut) {
         $aTransitions = array();
         $aWorkflows = array();
         $transition_fields = array();
         $bHasPerm = FALSE;
     } else {
         $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($oDocument, $oUser);
         $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1 ');
         $bHasPerm = false;
         if (KTPermissionUtil::userHasPermissionOnItem($oUser, 'ktcore.permissions.workflow', $oDocument)) {
             $bHasPerm = true;
         }
         $fieldErrors = null;
         $transition_fields = array();
         if ($aTransitions) {
             $aVocab = array();
             foreach ($aTransitions as $oTransition) {
                 if (is_null($oTransition) || PEAR::isError($oTransition)) {
                     continue;
                 }
                 $aVocab[$oTransition->getId()] = $oTransition->showDescription();
             }
             $fieldOptions = array('vocab' => $aVocab);
             $transition_fields[] = new KTLookupWidget(_kt('Transition to perform'), _kt('The transition listed will cause the document to change from its current state to the listed destination state.'), 'fTransitionId', null, $this->oPage, true, null, $fieldErrors, $fieldOptions);
             $transition_fields[] = new KTTextWidget(_kt('Reason for transition'), _kt('Describe why this document qualifies to be changed from its current state to the destination state of the transition chosen.'), 'fComments', '', $this->oPage, true, null, null, array('cols' => 80, 'rows' => 4));
         }
     }
     // Add an electronic signature
     global $default;
     if ($default->enableESignatures) {
         $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
         $heading = _kt('You are attempting to modify the document workflow');
         $submit['type'] = 'button';
         $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.modify_workflow', 'document', 'start_workflow_form', 'submit', {$this->oDocument->iId});";
         $heading2 = _kt('You are attempting to transition the document workflow');
         $submit2['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading2}', 'ktcore.transactions.transition_workflow', 'document', 'transition_wf_form', 'submit', {$this->oDocument->iId});";
     } else {
         $submit['type'] = 'submit';
         $submit['onclick'] = '';
         $submit2['onclick'] = '';
     }
     $aTemplateData = array('oDocument' => $oDocument, 'oWorkflow' => $oWorkflow, 'oState' => $oWorkflowState, 'aTransitions' => $aTransitions, 'aWorkflows' => $aWorkflows, 'transition_fields' => $transition_fields, 'bHasPerm' => $bHasPerm, 'bIsCheckedOut' => $bIsCheckedOut, 'submit' => $submit, 'submit2' => $submit2);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 3
0
 /**
  * This returns detailed information on the document.
  *
  * @author KnowledgeTree Team
  * @access public
  * @return array The document information
  */
 function get_detail()
 {
     global $default;
     // make sure we ge tthe latest
     $this->clearCache();
     $config = KTConfig::getSingleton();
     $wsversion = $config->get('webservice/version', LATEST_WEBSERVICE_VERSION);
     $detail = array();
     $document = $this->document;
     // get the document id
     $detail['document_id'] = (int) $document->getId();
     $oem_document_no = null;
     if ($wsversion >= 2) {
         $oem_document_no = $document->getOemNo();
     }
     if (empty($oem_document_no)) {
         $oem_document_no = 'n/a';
     }
     $detail['custom_document_no'] = 'n/a';
     $detail['oem_document_no'] = $oem_document_no;
     // get the title
     $detail['title'] = $document->getName();
     // get the document type
     $documenttypeid = $document->getDocumentTypeID();
     $documenttype = '* unknown *';
     if (is_numeric($documenttypeid)) {
         $dt = DocumentType::get($documenttypeid);
         if (!is_null($dt) && !PEAR::isError($dt)) {
             $documenttype = $dt->getName();
         }
     }
     $detail['document_type'] = $documenttype;
     // get the filename
     $detail['filename'] = $document->getFilename();
     // get the filesize
     $detail['filesize'] = (int) $document->getFileSize();
     // get the folder id
     $detail['folder_id'] = (int) $document->getFolderID();
     // get the creator
     $userid = $document->getCreatorID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['created_by'] = $username;
     // get the creation date
     $detail['created_date'] = $document->getCreatedDateTime();
     // get the checked out user
     $userid = $document->getCheckedOutUserID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['checked_out_by'] = $username;
     // get the checked out date
     list($major, $minor, $fix) = explode('.', $default->systemVersion);
     if ($major == 3 && $minor >= 5) {
         $detail['checked_out_date'] = $document->getCheckedOutDate();
     } else {
         $detail['checked_out_date'] = $detail['modified_date'];
     }
     if (is_null($detail['checked_out_date'])) {
         $detail['checked_out_date'] = 'n/a';
     }
     // get the modified user
     $userid = $document->getModifiedUserId();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['modified_by'] = $detail['updated_by'] = $username;
     // get the modified date
     $detail['updated_date'] = $detail['modified_date'] = $document->getLastModifiedDate();
     // get the owner
     $userid = $document->getOwnerID();
     $username = '******';
     if (is_numeric($userid)) {
         $username = '******';
         $user = User::get($userid);
         if (!is_null($user) && !PEAR::isError($user)) {
             $username = $user->getName();
         }
     }
     $detail['owned_by'] = $username;
     // get the version
     $detail['version'] = $document->getVersion();
     if ($wsversion >= 2) {
         $detail['version'] = (double) $detail['version'];
     }
     //might be unset at the bottom in case of old webservice version
     //make sure we're using the real document for this one
     $this->document->switchToRealCore();
     $detail['linked_document_id'] = $document->getLinkedDocumentId();
     $this->document->switchToLinkedCore();
     // check immutability
     $detail['is_immutable'] = (bool) $document->getImmutable();
     // check permissions
     $detail['permissions'] = KTAPI_Document::get_permission_string($document);
     // get workflow name
     $workflowid = $document->getWorkflowId();
     $workflowname = 'n/a';
     if (is_numeric($workflowid)) {
         $workflow = KTWorkflow::get($workflowid);
         if (!is_null($workflow) && !PEAR::isError($workflow)) {
             $workflowname = $workflow->getName();
         }
     }
     $detail['workflow'] = $workflowname;
     // get the workflow state
     $stateid = $document->getWorkflowStateId();
     $workflowstate = 'n/a';
     if (is_numeric($stateid)) {
         $state = KTWorkflowState::get($stateid);
         if (!is_null($state) && !PEAR::isError($state)) {
             $workflowstate = $state->getName();
         }
     }
     $detail['workflow_state'] = $workflowstate;
     // get the full path
     $detail['full_path'] = '/' . $this->document->getFullPath();
     // get mime info
     $mimetypeid = $document->getMimeTypeID();
     $detail['mime_type'] = KTMime::getMimeTypeName($mimetypeid);
     $detail['mime_icon_path'] = KTMime::getIconPath($mimetypeid);
     $detail['mime_display'] = KTMime::getFriendlyNameForString($detail['mime_type']);
     // get the storage path
     $detail['storage_path'] = $document->getStoragePath();
     if ($wsversion >= 2) {
         unset($detail['updated_by']);
         unset($detail['updated_date']);
     }
     if ($wsversion < 3) {
         unset($detail['linked_document_id']);
     }
     return $detail;
 }
Ejemplo n.º 4
0
 function finalise()
 {
     $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
     if (!empty($fWizardKey)) {
         $this->errorRedirectToMain(_kt("Could not create workflow."));
         exit;
     }
     $wiz_data = $_SESSION['_wiz_data'][$fWizardKey];
     // gather all our data.  we're sure this is all good and healthy.
     $states = $wiz_data['states'];
     $transitions = $wiz_data['transitions'];
     $from = $wiz_data['from'];
     $to = $wiz_data['to'];
     $initial_state = $wiz_data['initial_state'];
     $workflow_name = $wiz_data['workflow_name'];
     $this->startTransaction();
     // create the initial workflow
     $oWorkflow = KTWorkflow::createFromArray(array('name' => $workflow_name, 'humanname' => $workflow_name, 'enabled' => true));
     if (PEAR::isError($oWorkflow)) {
         $this->errorRedirectToMain(sprintf(_kt("Failed to create workflow: %s"), $oWorkflow->getMessage()));
     }
     $iWorkflowId = $oWorkflow->getId();
     // create the states.
     $aStates = array();
     foreach ($states as $state_name) {
         $oState = KTWorkflowState::createFromArray(array('workflowid' => $iWorkflowId, 'name' => $state_name, 'humanname' => $state_name));
         if (PEAR::isError($oState)) {
             $this->errorRedirectToMain(sprintf(_kt("Failed to create state: %s"), $oState->getMessage()));
         }
         $aStates[$state_name] = $oState;
     }
     // update the initial state on workflow
     $oInitialState = $aStates[$initial_state];
     $oWorkflow->setStartStateId($oInitialState->getId());
     $res = $oWorkflow->update();
     if (PEAR::isError($res)) {
         $this->errorRedirectToMain(sprintf(_kt("Failed to update workflow: %s"), $res->getMessage()));
     }
     // next, we create and hook up the transitions.
     $aTransitions = array();
     foreach ($transitions as $transition) {
         $dest_name = $to[$transition];
         $oDestState = $aStates[$dest_name];
         $oTransition = KTWorkflowTransition::createFromArray(array("WorkflowId" => $iWorkflowId, "Name" => $transition, "HumanName" => $transition, "TargetStateId" => $oDestState->getId(), "GuardPermissionId" => null, "GuardGroupId" => null, "GuardRoleId" => null, "GuardConditionId" => null));
         if (PEAR::isError($oTransition)) {
             $this->errorRedirectToMain(sprintf(_kt("Failed to create transition: %s"), $oTransition->getMessage()));
         }
         // hook up source states.
         $state_ids = array();
         $sources = (array) $from[$transition];
         foreach ($sources as $state_name) {
             // must exist.
             $oState = $aStates[$state_name];
             $state_ids[] = $oState->getId();
         }
         $res = KTWorkflowAdminUtil::saveTransitionSources($oTransition, $state_ids);
         if (PEAR::isError($res)) {
             $this->errorRedirectToMain(sprintf(_kt("Failed to set transition origins: %s"), $res->getMessage()));
         }
     }
     $this->commitTransaction();
     // finally, we want to redirect the user to the parent dispatcher somehow.
     // FIXME nbm:  how do you recommend we do this?
     $base = $_SERVER['PHP_SELF'];
     $qs = sprintf("action=view&fWorkflowId=%d", $oWorkflow->getId());
     $url = KTUtil::addQueryString($base, $qs);
     $this->addInfoMessage(_kt("Your new workflow has been created.  You may want to configure security and notifications from the menu on the left."));
     redirect($url);
 }
Ejemplo n.º 5
0
 function do_confirmCopy()
 {
     $oSelWorkflow = KTWorkflow::get(KTUtil::arrayGet($_REQUEST, 'workflowId', array()));
     $sWorkflowName = KTUtil::arrayGet($_REQUEST, 'workflowName', array());
     // Check that the workflow does not exist already
     $sWorkflowName = str_replace(array('   ', '  '), array(' ', ' '), $sWorkflowName);
     $oWorkflow = KTWorkflow::getByName($sWorkflowName);
     if (!PEAR::isError($oWorkflow)) {
         return $this->errorRedirectToMain(_kt("A workflow with that name already exists.  Please choose a different name for this workflow."));
     }
     // create the initial workflow
     $oNewWorkflow = KTWorkflow::createFromArray(array('name' => $sWorkflowName, 'humanname' => $sWorkflowName, 'enabled' => true));
     // get selected workflow states from database
     $oSelWorkflowStates = KTWorkflowState::getByWorkflow($oSelWorkflow);
     // array to store map of old and new states
     $aStatesMap = array();
     // create new states and build old-to-new map
     foreach ($oSelWorkflowStates as $oOldState) {
         $oNewState = KTWorkflowState::createFromArray(array('workflowid' => $oNewWorkflow->getId(), 'name' => $oOldState->getName(), 'humanname' => $oOldState->getName()));
         $aStatesMap[oldId][] = $oOldState->getId();
         $aStatesMap[newId][] = $oNewState->getId();
         if (PEAR::isError($oNewState)) {
             $oForm->errorRedirectToMain(sprintf(_kt("Unexpected failure cloning state: %s"), $oNewState->getMessage()));
         }
         // Get all state permission assignments for old workflow transitions
         // and copy for copied workflow state permission assignments
         $aPermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oOldState);
         if (count($aPermissionAssignments) > 0) {
             foreach ($aPermissionAssignments as $oPermAssign) {
                 for ($i = 0; $i < count($aStatesMap[oldId]); $i++) {
                     if ($aStatesMap[oldId][$i] == $oPermAssign->getStateId()) {
                         $iStateId = $aStatesMap[newId][$i];
                         $res = KTWorkflowStatePermissionAssignment::createFromArray(array('iStateId' => $iStateId, 'iPermissionId' => $oPermAssign->getPermissionId(), 'iDescriptorId' => $oPermAssign->getDescriptorId()));
                         if (PEAR::isError($res)) {
                             return $this->errorRedirectToMain(sprintf(_kt("Unable to copy state permission assignment: %s"), $res->getMessage()));
                         }
                     }
                 }
             }
         }
         // Copy all disabled actions for states
         $aDisabled = KTWorkflowUtil::getDisabledActionsForState($oOldState);
         $res = KTWorkflowUtil::setDisabledActionsForState($oNewState, $aDisabled);
         // Copy all enabled actions for states
         $aDisabled = KTWorkflowUtil::getEnabledActionsForState($oOldState);
         $res = KTWorkflowUtil::setEnabledActionsForState($oNewState, $aDisabled);
         if (PEAR::isError($res)) {
             return $this->errorRedirectToMain(sprintf(_kt("Unable to copy disabled state actions: %s"), $res->getMessage()));
         }
         $this->copyStateNotifications($oOldState, $oNewState);
     }
     // update workflow and set initial state
     for ($i = 0; $i < count($aStatesMap[oldId]); $i++) {
         if ($oSelWorkflow->getStartStateId() == $aStatesMap[oldId][$i]) {
             $oNewWorkflow->setStartStateId($aStatesMap[newId][$i]);
             $res = $oNewWorkflow->update();
             if (PEAR::isError($res)) {
                 $this->errorRedirectToMain(sprintf(_kt("Failed to update workflow: %s"), $res->getMessage()));
             }
         }
     }
     // set controlled workflow actions
     $aWFActions = KTWorkflowUtil::getControlledActionsForWorkflow($oSelWorkflow);
     $res = KTWorkflowUtil::setControlledActionsForWorkflow($oNewWorkflow, $aWFActions);
     if (PEAR::isError($res)) {
         $this->errorRedirectToMain(sprintf(_kt("Failed to copy workflow controlled actions: %s"), $res->getMessage()));
     }
     // get selected workflow transitions from database
     $oSelWorkflowTransitions = KTWorkflowTransition::getByWorkflow($oSelWorkflow);
     // array to store map of old and new transitions
     $aTransitionsMap = array();
     // copy transitions for workflow
     foreach ($oSelWorkflowTransitions as $oOldTransition) {
         for ($i = 0; $i < count($aStatesMap[oldId]); $i++) {
             if ($oOldTransition->getTargetStateId() == $aStatesMap[oldId][$i]) {
                 $iDestState = $aStatesMap[newId][$i];
             }
         }
         $oNewTransition = KTWorkflowTransition::createFromArray(array('workflowid' => $oNewWorkflow->getId(), 'Name' => $oOldTransition->getName(), 'HumanName' => $oOldTransition->getName(), 'TargetStateId' => $iDestState, 'GuardPermissionId' => null, 'GuardGroupId' => null, 'GuardRoleId' => null, 'GuardConditionId' => null));
         $aTransitionsMap[oldId][] = $oOldTransition->getId();
         $aTransitionsMap[newId][] = $oNewTransition->getId();
         if (PEAR::isError($oNewTransition)) {
             $this->errorRedirectToMain(sprintf(_kt("Failed to copy transition: %s"), $oTransition->getMessage()));
         }
         // map source transitions onto states
         $aOldTransitionSources = KTWorkflowAdminUtil::getSourceStates($oOldTransition);
         $aSourceStates = array();
         for ($j = 0; $j < count($aOldTransitionSources); $j++) {
             for ($i = 0; $i < count($aStatesMap[oldId]); $i++) {
                 if ($aStatesMap[oldId][$i] == $aOldTransitionSources[$j]->getId()) {
                     $aSourceStates[] = $aStatesMap[newId][$i];
                     continue;
                 }
             }
         }
         $res = KTWorkflowAdminUtil::saveTransitionSources($oNewTransition, $aSourceStates);
         if (PEAR::isError($res)) {
             $this->errorRedirectToMain(sprintf(_kt("Failed to set transition origins: %s"), $res->getMessage()));
         }
         // Get all triggers for old workflow transitions and
         // copy for copied workflow transitions
         $aTriggers = KTWorkflowTriggerInstance::getByTransition($oOldTransition);
         if (count($aTriggers) > 0) {
             foreach ($aTriggers as $oTrigger) {
                 for ($i = 0; $i < count($aTransitionsMap[oldId]); $i++) {
                     if ($aTransitionsMap[oldId][$i] == $oTrigger->getTransitionId()) {
                         $iTransitionId = $aTransitionsMap[newId][$i];
                         $res = KTWorkflowTriggerInstance::createFromArray(array('transitionid' => $iTransitionId, 'namespace' => $oTrigger->getNamespace(), 'config' => $oTrigger->getConfigArrayText()));
                         if (PEAR::isError($res)) {
                             return $this->errorRedirectToMain(sprintf(_kt("Unable to add trigger: %s"), $res->getMessage()));
                         }
                     }
                 }
             }
         }
     }
     return $this->successRedirectToMain(sprintf(_kt("%s successfully copied as %s"), $oSelWorkflow->getName(), $oNewWorkflow->getName()));
 }
Ejemplo n.º 6
0
 /**
  * Performs a workflow transition on a document, changing it from
  * one workflow state to another, with potential side effects (user
  * scripts, and so forth).
  *
  * This function currently assumes that the user in question is
  * allowed to perform the transition and that all the guard
  * functionality on the transition has passed.
  */
 function performTransitionOnDocument($oTransition, $oDocument, $oUser, $sComments)
 {
     $oWorkflow =& KTWorkflow::getByDocument($oDocument);
     if (empty($oWorkflow)) {
         return PEAR::raiseError(_kt("Document has no workflow"));
     }
     if (PEAR::isError($oWorkflow)) {
         return $oWorkflow;
     }
     $oSourceState =& KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
     // walk the action triggers.
     $aActionTriggers = KTWorkflowUtil::getActionTriggersForTransition($oTransition);
     if (PEAR::isError($aActionTriggers)) {
         return $aActionTriggers;
         // error out?
     }
     foreach ($aActionTriggers as $oTrigger) {
         $res = $oTrigger->precheckTransition($oDocument, $oUser);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     $iPreviousMetadataVersion = $oDocument->getMetadataVersionId();
     $oDocument->startNewMetadataVersion($oUser);
     KTDocumentUtil::copyMetadata($oDocument, $iPreviousMetadataVersion);
     $iStateId = $oTransition->getTargetStateId();
     $oDocument->setWorkflowStateId($iStateId);
     $res = $oDocument->update();
     if (PEAR::isError($res)) {
         return $res;
     }
     $oTargetState =& KTWorkflowState::get($iStateId);
     $sSourceState = $oSourceState->getName();
     $sTargetState = $oTargetState->getName();
     // create the document transaction record
     $sTransactionComments = sprintf(_kt("Workflow state changed from %s to %s"), $sSourceState, $sTargetState);
     if ($sComments) {
         $sTransactionComments .= _kt("; Reason given was: ") . $sComments;
     }
     $oDocumentTransaction = new DocumentTransaction($oDocument, $sTransactionComments, 'ktcore.transactions.workflow_state_transition');
     $oDocumentTransaction->create();
     // walk the action triggers.
     foreach ($aActionTriggers as $oTrigger) {
         $res = $oTrigger->performTransition($oDocument, $oUser);
         if (PEAR::isError($res)) {
             return $res;
         }
     }
     KTPermissionUtil::updatePermissionLookup($oDocument);
     KTWorkflowUtil::informUsersForState($oTargetState, KTWorkflowUtil::getInformedForState($oTargetState), $oDocument, $oUser, $sComments);
     return true;
 }
Ejemplo n.º 7
0
 /**
  * Create a table of the document metadata.
  * Hard coded for the moment
  *
  * @return unknown
  */
 function getMetadata()
 {
     /* Get document info */
     // Filename
     $sFilenameLb = _kt('Document Filename: ');
     $sFilename = $this->_oDocument->getFileName();
     // Mime type
     $sMimeTypeLb = _kt('File is a: ');
     $iMimeId = $this->_oDocument->getMimeTypeID();
     $sMimeType = KTMime::getMimeTypeName($iMimeId);
     $sMimeType = KTMime::getFriendlyNameForString($sMimeType);
     // Version
     $sVersionLb = _kt('Document Version: ');
     $iVersion = $this->_oDocument->getVersion();
     // Created by
     $sCreatedByLb = _kt('Created by: ');
     $iCreatorId = $this->_oDocument->getCreatorID();
     $sCreated = $this->_oDocument->getCreatedDateTime();
     $oCreator = User::get($iCreatorId);
     $sCreatedBy = $oCreator->getName() . ' (' . $sCreated . ')';
     // Owned by
     $sOwnedByLb = _kt('Owned by: ');
     $iOwnedId = $this->_oDocument->getOwnerID();
     $oOwner = User::get($iOwnedId);
     $sOwnedBy = $oOwner->getName();
     // Last update by
     $iModifiedId = $this->_oDocument->getModifiedUserId();
     $sLastUpdatedByLb = '';
     $sLastUpdatedBy = '';
     if (!empty($iModifiedId)) {
         $sLastUpdatedByLb = _kt('Last updated by: ');
         $sModified = $this->_oDocument->getLastModifiedDate();
         $oModifier = User::get($iModifiedId);
         $sLastUpdatedBy = $oModifier->getName() . ' (' . $sModified . ')';
     }
     // Document type
     $sDocTypeLb = _kt('Document Type: ');
     $iDocTypeId = $this->_oDocument->getDocumentTypeID();
     $oDocType = DocumentType::get($iDocTypeId);
     $sDocType = $oDocType->getName();
     // Workflow
     $iWFId = $this->_oDocument->getWorkflowId();
     $sWF = '';
     $sWFLb = '';
     if (!empty($iWFId)) {
         $sWFLb = _kt('Workflow: ');
         $iWFStateId = $this->_oDocument->getWorkflowStateId();
         $oWF = KTWorkflow::get($iWFId);
         $sWF = $oWF->getHumanName();
         $oWFState = KTWorkflowState::get($iWFStateId);
         $sWF .= ' (' . $oWFState->getHumanName() . ')';
     }
     // Checked out by
     $sCheckedLb = '';
     $sCheckedOutBy = '';
     if ($this->_oDocument->getIsCheckedOut()) {
         $sCheckedLb = _kt('Checked out by: ');
         $iCheckedID = $this->_oDocument->getCheckedOutUserID();
         $oCheckedUser = User::get($iCheckedID);
         $sCheckedOutBy = $oCheckedUser->getName();
     }
     // Id
     $sIdLb = _kt('Document ID: ');
     $sId = $this->_IDocId;
     /* Create table */
     $sInfo = "<div style='float:left; width:405px;'>\n            <table cellspacing='3px' cellpadding='3px' width='405px'>\n            <tr><td>{$sFilenameLb}</td><td><b>{$sFilename}</b></td></tr>\n            <tr><td>{$sMimeTypeLb}</td><td><b>{$sMimeType}</b></td></tr>\n            <tr><td>{$sVersionLb}</td><td><b>{$iVersion}</b></td></tr>\n            <tr><td>{$sCreatedByLb}</td><td><b>{$sCreatedBy}</b></td></tr>\n            <tr><td>{$sOwnedByLb}</td><td><b>{$sOwnedBy}</b></td></tr>";
     if (!empty($sLastUpdatedBy)) {
         $sInfo .= "<tr><td>{$sLastUpdatedByLb}</td><td><b>{$sLastUpdatedBy}</b></td></tr>";
     }
     $sInfo .= "<tr><td>{$sDocTypeLb}</td><td><b>{$sDocType}</b></td></tr>";
     if (!empty($sWF)) {
         $sInfo .= "<tr><td>{$sWFLb}</td><td><b>{$sWF}</b></td></tr>";
     }
     if (!empty($sCheckedOutBy)) {
         $sInfo .= "<tr><td>{$sCheckedLb}</td><td><b>{$sCheckedOutBy}</b></td></tr>";
     }
     $sInfo .= "<tr><td>{$sIdLb}</td><td><b>{$sId}</b></td></tr>";
     $sInfo .= " </table></div>";
     return $sInfo;
 }
Ejemplo n.º 8
0
 function do_main()
 {
     $this->oPage->setBreadcrumbDetails(_kt("Configure Workflows for Folder"));
     $this->oPage->setTitle(_kt("Configure Workflows for Folder"));
     $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/folderconfigure');
     $fields = array();
     $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1');
     $aVocab = array();
     $aVocab[] = _kt('No automatic workflow.');
     foreach ($aWorkflows as $oWorkflow) {
         $aVocab[$oWorkflow->getId()] = $oWorkflow->getName();
     }
     $fieldOptions = array("vocab" => $aVocab);
     // grab the value.
     $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map');
     $sQuery .= ' WHERE `folder_id` = ?';
     $aParams = array($this->oFolder->getId());
     $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id');
     if (PEAR::isError($res)) {
         $res = null;
     }
     $fields[] = new KTLookupWidget(_kt('Automatic Workflow'), _kt('If you specify an automatic workflow, new documents will automatically enter that workflow\'s starting state.  Setting this to "No Automatic Workflow" will mean that users can choose the appropriate workflow.'), 'fWorkflowId', $res, $this->oPage, true, null, $fieldErrors, $fieldOptions);
     $oTemplate->setData(array('context' => &$this, 'folder_id' => $this->oFolder->getId(), 'fields' => $fields));
     return $oTemplate->render();
 }
Ejemplo n.º 9
0
 function &getByDocument($oDocument)
 {
     $oDocument = KTUtil::getObject('Document', $oDocument);
     $iWorkflowId = $oDocument->getWorkflowId();
     if (PEAR::isError($iWorkflowId)) {
         return $iWorkflowId;
     }
     if (is_null($iWorkflowId)) {
         return $iWorkflowId;
     }
     return KTWorkflow::get($iWorkflowId);
 }
Ejemplo n.º 10
0
<?php

require_once '../../config/dmsDefaults.php';
require_once KT_LIB_DIR . '/documentmanagement/Document.inc';
require_once KT_LIB_DIR . '/workflow/workflow.inc.php';
require_once KT_LIB_DIR . '/workflow/workflowutil.inc.php';
$oDocument =& Document::get(4);
$res = KTWorkflow::getByDocument($oDocument);
if (PEAR::isError($res)) {
    print "FAILED\n";
    var_dump($res);
}
$iWorkflowId = $res->getId();
if ($iWorkflowId != 1) {
    print "FAILED\n";
    print $iWorkflowId;
}
Ejemplo n.º 11
0
 function do_update()
 {
     $types_mapping = (array) KTUtil::arrayGet($_REQUEST, 'fDocumentTypeAssignment');
     $aWorkflows = KTWorkflow::getList();
     $aTypes = DocumentType::getList();
     $sQuery = 'DELETE FROM ' . KTUtil::getTableName('type_workflow_map');
     $aParams = array();
     DBUtil::runQuery(array($sQuery, $aParams));
     $aOptions = array('noid' => true);
     $sTable = KTUtil::getTableName('type_workflow_map');
     foreach ($aTypes as $oType) {
         $t = $types_mapping[$oType->getId()];
         if ($t == null) {
             $t = null;
         }
         $res = DBUtil::autoInsert($sTable, array('document_type_id' => $oType->getId(), 'workflow_id' => $t), $aOptions);
     }
     $this->successRedirectToMain(_kt('Type mapping updated.'));
 }