示例#1
0
function removeSelectedGroups($http, &$groups, $base)
{
    if ($http->hasPostVariable("DeleteGroupButton")) {
        if (eZHTTPPersistence::splitSelected($base, $groups, $http, "id", $keepers, $rejects)) {
            $groups = $keepers;
            foreach ($rejects as $reject) {
                $group_id = $reject->attribute("id");
                // Remove all workflows in current group
                $list_in_group = eZWorkflowGroupLink::fetchWorkflowList(0, $group_id, $asObject = true);
                $workflow_list = eZWorkflow::fetchList();
                $list = array();
                foreach ($workflow_list as $workflow) {
                    foreach ($list_in_group as $group) {
                        $id = $workflow->attribute("id");
                        $workflow_id = $group->attribute("workflow_id");
                        if ($id === $workflow_id) {
                            $list[] = $workflow;
                        }
                    }
                }
                foreach ($list as $workFlow) {
                    eZTrigger::removeTriggerForWorkflow($workFlow->attribute('id'));
                    $workFlow->remove();
                }
                $reject->remove();
                eZWorkflowGroupLink::removeGroupMembers($group_id);
            }
        }
    }
}
 public function tearDown()
 {
     // Remove trigger
     eZTrigger::removeTriggerForWorkflow($this->workflow->attribute('id'));
     // Log in as whoever was logged in
     eZUser::setCurrentlyLoggedInUser($this->currentUser, $this->currentUser->attribute('id'));
     // Important that the parent method is run AFTER changes are done to the database.
     parent::tearDown();
 }
示例#3
0
    $Module->run('edit', $params);
    return;
}
if ($http->hasPostVariable('DeleteButton') and $http->hasPostVariable('Workflow_id_checked')) {
    if ($http->hasPostVariable('CurrentGroupID')) {
        // 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'));
    }
 /**
  * Helper function used to remove a workflow.
  * Will remove the workflow, its events, its triggers and its group link.
  *
  * @param eZWorkflow $workflow
  * @return void
  */
 protected function removeWorkflow(eZWorkflow $workflow)
 {
     // Remove trigger
     eZTrigger::removeTriggerForWorkflow($workflow->attribute('id'));
     // remove the workflow, its events and the group link
     eZWorkflow::removeEvents(false, $workflow->attribute('id'), $workflow->attribute('version'));
     eZWorkflow::removeWorkflow($this->workflow->attribute('id'), $workflow->attribute('version'));
     eZWorkflowGroupLink::removeWorkflowMembers($workflow->attribute('id'), $workflow->attribute('version'));
 }