Exemplo n.º 1
0
 /**
  * Checks if a particular action is enabled to occur on a document
  * by virtue of its workflow and workflow state.
  *
  * A controlled action is one that can be enabled or disabled by a
  * workflow state attached to this workflow.  This allows for
  * actions such as "Delete" to not be allowed to occur during the
  * workflow, or for special actions such as "Publish" to only occur
  * when a particular workflow state is reached.
  *
  * Only the enabled actions are tracked.  Any actions controlled by
  * the workflow but not explicitly enabled are disabled.
  */
 function actionEnabledForDocument($oDocument, $sName)
 {
     $oWorkflow =& KTWorkflow::getByDocument($oDocument);
     if (is_null($oWorkflow)) {
         return true;
     }
     // FIXME: The workflow_actions table that the method below uses is always empty!
     //        It seems the new method was never followed though to completion.
     //if (!in_array($sName, KTWorkflowUtil::getControlledActionsForWorkflow($oWorkflow))) {
     //    return true;
     //}
     $oState =& KTWorkflowState::getByDocument($oDocument);
     if (in_array($sName, KTWorkflowUtil::getDisabledActionsForState($oState))) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 function do_editactions()
 {
     $oTemplate = $this->oValidator->validateTemplate('ktcore/workflow/admin/actions_edit');
     $this->oPage->setBreadcrumbDetails(_kt("Edit Actions"));
     $actions = KTUtil::keyArray(KTDocumentActionUtil::getAllDocumentActions(), 'getName');
     $blacklist = array('ktcore.actions.document.displaydetails');
     $this->breadcrumbs_security();
     foreach ($blacklist as $name) {
         unset($actions[$name]);
     }
     $states = KTWorkflowState::getByWorkflow($this->oWorkflow);
     $action_grid = array();
     foreach ($states as $oState) {
         $state_actions = array();
         $disabled = KTWorkflowUtil::getDisabledActionsForState($oState);
         foreach ($disabled as $name) {
             $state_actions[$name] = $name;
         }
         $action_grid[$oState->getId()] = $state_actions;
     }
     $oTemplate->setData(array('context' => $this, 'states' => $states, 'actions' => $actions, 'grid' => $action_grid, 'args' => $this->meldPersistQuery("", "saveactions", true)));
     return $oTemplate->render();
 }