// If CurrentGroupID variable exist, delete in that group only: $groupID = $http->postVariable('CurrentGroupID'); $workflowIDs = $http->postVariable('Workflow_id_checked'); foreach ($workflowIDs as $workflowID) { // for all workflows which are tagged for deleting: $workflow = eZWorkflow::fetch($workflowID); if ($workflow) { $workflowInGroups = $workflow->attribute('ingroup_list'); if (count($workflowInGroups) == 1) { //remove entry from eztrigger table also, if it exists there. eZTrigger::removeTriggerForWorkflow($workflowID); // if there is only one group which the workflow belongs to, delete (=disable) it: eZWorkflow::setIsEnabled(false, $workflowID); } else { // if there is more than 1 group, remove only from the group: eZWorkflowFunctions::removeGroup($workflowID, 0, array($groupID)); } } else { // just for sure :-) eZWorkflow::setIsEnabled(false, $workflowID); } } } else { // if there is no CurrentGroupID variable, disable every group in variable Workflow_id_checked: eZWorkflow::setIsEnabled(false, $http->postVariable('Workflow_id_checked')); } } if ($http->hasPostVariable('DeleteButton') and $http->hasPostVariable('Temp_Workflow_id_checked')) { $checkedIDs = $http->postVariable('Temp_Workflow_id_checked'); foreach ($checkedIDs as $checkedID) { eZWorkflow::removeWorkflow($checkedID, 1);
$validation = array( 'processed' => false, 'groups' => array(), 'attributes' => array(), 'events' => array() ); if ( $http->hasPostVariable( "AddGroupButton" ) && $http->hasPostVariable( "Workflow_group") ) { $selectedGroup = $http->postVariable( "Workflow_group" ); eZWorkflowFunctions::addGroup( $WorkflowID, $WorkflowVersion, $selectedGroup ); } if ( $http->hasPostVariable( "DeleteGroupButton" ) && $http->hasPostVariable( "group_id_checked" ) ) { $selectedGroup = $http->postVariable( "group_id_checked" ); if ( !eZWorkflowFunctions::removeGroup( $WorkflowID, $WorkflowVersion, $selectedGroup ) ) { $validation['groups'][] = array( 'text' => ezpI18n::tr( 'kernel/workflow', 'You have to have at least one group that the workflow belongs to!' ) ); $validation['processed'] = true; } } // Fetch events and types $event_list = $workflow->fetchEvents(); $type_list = eZWorkflowType::fetchRegisteredTypes(); // Validate input $canStore = true; $requireFixup = false; foreach( $event_list as $event ) {
$validation = array('processed' => false, 'groups' => array()); $WorkflowID = $Params["WorkflowID"]; $WorkflowID = (int) $WorkflowID; if (!is_int($WorkflowID)) { $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel'); } $workflow = eZWorkflow::fetch($WorkflowID); if (!$workflow) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if ($http->hasPostVariable("AddGroupButton") && $http->hasPostVariable("Workflow_group")) { $selectedGroup = $http->postVariable("Workflow_group"); eZWorkflowFunctions::addGroup($WorkflowID, 0, $selectedGroup); } if ($http->hasPostVariable("DeleteGroupButton") && $http->hasPostVariable("group_id_checked")) { $selectedGroup = $http->postVariable("group_id_checked"); if (!eZWorkflowFunctions::removeGroup($WorkflowID, 0, $selectedGroup)) { $validation['groups'][] = array('text' => ezpI18n::tr('kernel/workflow', 'You have to have at least one group that the workflow belongs to!')); $validation['processed'] = true; } } $event_list = $workflow->fetchEvents(); $tpl = eZTemplate::factory(); $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array("workflow", $workflow->attribute("id")))); $tpl->setVariable("workflow", $workflow); $tpl->setVariable("event_list", $event_list); $tpl->setVariable('validation', $validation); $Result = array(); $Result['content'] = $tpl->fetch("design:workflow/view.tpl"); $Result['path'] = array(array('text' => ezpI18n::tr('kernel/workflow', 'Workflow'), 'url' => false), array('text' => ezpI18n::tr('kernel/workflow', 'View'), 'url' => false));