*   created  2003-05-26
 *   modified 2010-05-20, Murat Purc, removed request check during processing ticket [#CON-307]
 *   
 *   $Id$
 * }}
 * 
 */
define('CON_FRAMEWORK', true);
// Contenido startup process
include_once '../../../includes/startup.php';
cInclude("includes", "cfg_language_de.inc.php");
cInclude("includes", "functions.con.php");
plugin_include('workflow', 'classes/class.workflow.php');
plugin_include('workflow', 'includes/functions.workflow.php');
$workflowartallocations = new WorkflowArtAllocations();
$workflowusersequences = new WorkflowUserSequences();
$workflowartallocations->select();
while ($obj = $workflowartallocations->next()) {
    $starttime = $obj->get("starttime");
    $idartlang = $obj->get("idartlang");
    $lastidusersequence = $obj->get("lastusersequence");
    $usersequence = getCurrentUserSequence($idartlang, 0);
    if ($usersequence != $lastidusersequence) {
        $workflowusersequences->select("idusersequence = '{$usersequence}'");
        if ($wfobj = $workflowusersequences->next()) {
            $wfitem = $wfobj->get("idworkflowitem");
            $pos = $wfobj->get("position");
            $timeunit = $wfobj->get("timeunit");
            $timelimit = $wfobj->get("timelimit");
        }
        $starttime = strtotime(substr_replace(substr(substr($starttime, 0, 2) . chunk_split(substr($starttime, 2, 6), 2, "-") . chunk_split(substr($starttime, 8), 2, ":"), 0, 19), " ", 10, 1));
function getWorkflowUsers($idworkflowitem)
{
    global $idworkflow, $cfg;
    $ui = new UI_Menu();
    $workflowusers = new WorkflowUserSequences();
    $workflowusers->select("idworkflowitem = '{$idworkflowitem}'", "", "position ASC");
    while ($workflowitem = $workflowusers->next()) {
        $pos = $workflowitem->get("position");
        $iduser = $workflowitem->get("iduser");
        $timelimit = $workflowitem->get("timelimit");
        $timeunit = $workflowitem->get("timeunit");
        $email = $workflowitem->get("emailnoti");
        $escalation = $workflowitem->get("escalationnoti");
        $timeunit = $workflowitem->get("timeunit");
        $id = $workflowitem->get("idusersequence");
        $moveup = new Link();
        $moveup->setCLink("workflow_steps", 4, "workflow_user_up");
        $moveup->setCustom("idworkflowitem", $idworkflowitem);
        $moveup->setCustom("idworkflow", $idworkflow);
        $moveup->setCustom("position", $pos);
        $moveup->setAlt(i18n("Move user up", "workflow"));
        #$moveup->setContent('<img border="0" style="padding-left: 2px" src="images/pfeil_hoch.gif">');
        $moveup->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/no_verschieben.gif" . '">');
        $movedown = new Link();
        $movedown->setCLink("workflow_steps", 4, "workflow_user_down");
        $movedown->setCustom("idworkflowitem", $idworkflowitem);
        $movedown->setCustom("idworkflow", $idworkflow);
        $movedown->setCustom("position", $pos);
        $movedown->setAlt(i18n("Move user down", "workflow"));
        $movedown->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/nu_verschieben.gif" . '">');
        $deletestep = new Link();
        $deletestep->setCLink("workflow_steps", 4, "workflow_user_delete");
        $deletestep->setCustom("idworkflowitem", $idworkflowitem);
        $deletestep->setCustom("idworkflow", $idworkflow);
        $deletestep->setCustom("position", $pos);
        $deletestep->setCustom("idusersequence", $id);
        $deletestep->setAlt(i18n("Delete user", "workflow"));
        $deletestep->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_step_delete.gif" . '">');
        $title = "{$pos}. " . getUsers($id, $iduser);
        $title .= formGenerateField("text", "wftimelimit" . $id, $timelimit, 3, 6);
        $title .= getTimeUnitSelector($id, $timeunit);
        $altmail = i18n("Notify this user via E-Mail", "workflow");
        $altnoti = i18n("Escalate to this user via E-Mail", "workflow");
        $title .= formGenerateCheckbox("wfemailnoti[" . $id . "]", "1", $email) . '<label for="wfemailnoti[' . $id . ']1"><img alt="' . $altmail . '" title="' . $altmail . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_email_noti.gif" . '"></label>';
        $title .= formGenerateCheckbox("wfescalnoti[" . $id . "]", "1", $escalation) . '<label for="wfescalnoti[' . $id . ']1"><img alt="' . $altnoti . '" title="' . $altnoti . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_escal_noti.gif" . '"></label>';
        $ui->setTitle($id, $title);
        $ui->setLink($id, NULL);
        if ($pos > 1) {
            $ui->setActions($id, "moveup", $moveup->render());
        } else {
            $ui->setActions($id, "moveup", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
        }
        if ($pos < $workflowusers->count()) {
            $ui->setActions($id, "movedown", $movedown->render());
        } else {
            $ui->setActions($id, "movedown", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">');
        }
        $ui->setActions($id, "delete", $deletestep->render());
        $ui->setImage($id, $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_user.gif");
    }
    $createstep = new Link();
    $createstep->setCLink("workflow_steps", 4, "workflow_create_user");
    $createstep->setCustom("idworkflow", $idworkflow);
    $createstep->setCustom("idworkflowitem", $idworkflowitem);
    $ui->setLink("spacer", NULL);
    $ui->setTitle("create", '<input class="text_medium" type="submit" name="adduser" value="' . i18n("Add User", "workflow") . '">');
    $ui->setLink("create", NULL);
    $content = $ui->render(false);
    return $content;
}
function getWorkflowForUserSequence($usersequence)
{
    $usersequences = new WorkflowUserSequences();
    $workflowitems = new WorkflowItems();
    $usersequences->select("idusersequence = '{$usersequence}'");
    if ($obj = $usersequences->next()) {
        $idworkflowitem = $obj->get("idworkflowitem");
    } else {
        return false;
    }
    $workflowitems->select("idworkflowitem = '{$idworkflowitem}'");
    if ($obj = $workflowitems->next()) {
        return $obj->get("idworkflow");
    } else {
        return false;
    }
}
 * {@internal 
 *   created 2003-07-30
 *   
 *   $Id$
 * }}
 * 
 */
if (!defined('CON_FRAMEWORK')) {
    die('Illegal call');
}
plugin_include('workflow', 'classes/class.workflow.php');
plugin_include('workflow', 'includes/functions.workflow.php');
global $sess;
$sSession = $sess->id;
$wfa = new WorkflowArtAllocations();
$wfu = new WorkflowUserSequences();
$users = new User();
$db2 = new DB_Contenido();
ob_start();
if ($usershow == "") {
    $usershow = $auth->auth["uid"];
}
if (!$perm->have_perm_area_action($area, "workflow_task_user_select")) {
    $usershow = $auth->auth["uid"];
}
if ($action == "workflow_do_action") {
    $selectedAction = "wfselect" . $modidartlang;
    doWorkflowAction($modidartlang, $GLOBALS[$selectedAction]);
}
$wfa->select();
while ($wfaitem = $wfa->next()) {