* @modified	2008-12-05	Andreas Lindner, make select box values for time unit selection language independent
 * {@internal 
 *   created 
 *   
 *   $Id$: 
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
plugin_include('workflow', 'classes/class.workflow.php');
plugin_include('workflow', 'includes/functions.workflow.php');
cInclude("includes", "functions.encoding.php");
$iIdMarked = (int) $_GET['idworkflowitem'];
$availableWorkflowActions = WorkflowActions::getAvailableWorkflowActions();
$sCurrentEncoding = getEncodingByLanguage($db, $lang, $cfg);
if (htmlentities($adduser, ENT_COMPAT, $sCurrentEncoding) == htmlentities(i18n("Add User", "workflow"), ENT_COMPAT, $sCurrentEncoding)) {
    $action = "workflow_create_user";
}
/* Function: Move step up */
if ($action == "workflow_step_up") {
    $workflowitems = new WorkflowItems();
    $workflowitems->swap($idworkflow, $position, $position - 1);
}
/* Function: Move step down */
if ($action == "workflow_step_down") {
    $workflowitems = new WorkflowItems();
    $workflowitems->swap($idworkflow, $position, $position + 1);
}
/* Function: Move user up */
function getActionSelect($idartlang, $idusersequence)
{
    global $cfg;
    $workflowActions = new WorkflowActions();
    $allActions = $workflowActions->getAvailableWorkflowActions();
    $wfSelect = new Template();
    $wfSelect->set('s', 'NAME', 'wfselect' . $idartlang);
    $wfSelect->set('s', 'CLASS', 'text_medium');
    $userSequence = new WorkflowUserSequence();
    $userSequence->loadByPrimaryKey($idusersequence);
    $workflowItem = $userSequence->getWorkflowItem();
    if ($workflowItem === false) {
        return;
    }
    $wfRights = $workflowItem->getStepRights();
    $artAllocation = new WorkflowArtAllocations();
    $artAllocation->select("idartlang = '{$idartlang}'");
    if ($obj = $artAllocation->next()) {
        $laststep = $obj->get("lastusersequence");
    }
    $bExistOption = false;
    if ($laststep != $idusersequence) {
        $wfSelect->set('d', 'VALUE', 'next');
        $wfSelect->set('d', 'CAPTION', i18n("Confirm", "workflow"));
        $wfSelect->set('d', 'SELECTED', 'SELECTED');
        $wfSelect->next();
        $bExistOption = true;
    }
    if ($wfRights["last"] == true) {
        $wfSelect->set('d', 'VALUE', 'last');
        $wfSelect->set('d', 'CAPTION', i18n("Back to last editor", "workflow"));
        $wfSelect->set('d', 'SELECTED', '');
        $wfSelect->next();
        $bExistOption = true;
    }
    if ($wfRights["reject"] == true) {
        $wfSelect->set('d', 'VALUE', 'reject');
        $wfSelect->set('d', 'CAPTION', i18n("Reject article", "workflow"));
        $wfSelect->set('d', 'SELECTED', '');
        $wfSelect->next();
        $bExistOption = true;
    }
    if ($wfRights["revise"] == true) {
        $wfSelect->set('d', 'VALUE', 'revise');
        $wfSelect->set('d', 'CAPTION', i18n("Revise article", "workflow"));
        $wfSelect->set('d', 'SELECTED', '');
        $wfSelect->next();
        $bExistOption = true;
    }
    if ($bExistOption) {
        return $wfSelect->generate($cfg['path']['templates'] . $cfg['templates']['generic_select'], true);
    } else {
        return false;
    }
}
 function getStepRights()
 {
     $idwfi = $this->values["idworkflowitem"];
     $workflowActions = new WorkflowActions();
     $actions = WorkflowActions::getAvailableWorkflowActions();
     foreach ($actions as $key => $value) {
         $rights[$key] = $workflowActions->get($idwfi, $key);
     }
     return $rights;
 }