function editWorkflowStep($idworkflowitem)
{
    global $area, $idworkflow, $idworkflowitem, $frame, $availableWorkflowActions;
    global $notification;
    $workflowitem = new WorkflowItem();
    if ($workflowitem->loadByPrimaryKey($idworkflowitem) == false) {
        return " ";
    }
    $workflowactions = new WorkflowActions();
    $stepname = $workflowitem->get("name");
    $stepdescription = $workflowitem->get("description");
    $id = $workflowitem->get("idworkflowitem");
    $task = $workflowitem->get("idtask");
    $form = new UI_Table_Form("workflow_edit");
    $form->setVar("area", $area);
    $form->setVar("action", "workflow_save_step");
    $form->setVar("idworkflow", $idworkflow);
    $form->setVar("idworkflowitem", $idworkflowitem);
    $form->setVar("frame", $frame);
    $form->addHeader(i18n("Edit workflow step", "workflow"));
    $form->add(i18n("Step name", "workflow"), formGenerateField("text", "wfstepname", $stepname, 40, 255));
    $form->add(i18n("Step description", "workflow"), formGenerateField("textbox", "wfstepdescription", $stepdescription, 60, 10));
    foreach ($availableWorkflowActions as $key => $value) {
        $actions .= formGenerateCheckbox("wfactions[" . $key . "]", "1", $workflowactions->get($id, $key)) . '<label for="wfactions[' . $key . ']1">' . $value . '</label>' . "<br>";
    }
    $form->add(i18n("Actions", "workflow"), $actions);
    $form->add(i18n("Assigned users", "workflow"), getWorkflowUsers($idworkflowitem));
    return $form->render(true);
}
 function swap($idworkflow, $pos1, $pos2)
 {
     $this->select("idworkflow = '{$idworkflow}' AND position = '{$pos1}'");
     if (($item = $this->next()) === false) {
         $this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
         return false;
     }
     $pos1ID = $item->getField("idworkflowitem");
     $this->select("idworkflow = '{$idworkflow}' AND position = '{$pos2}'");
     if (($item = $this->next()) === false) {
         $this->lasterror = i18n("Swapping items failed: Item doesn't exist", "workflow");
         return false;
     }
     $pos2ID = $item->getField("idworkflowitem");
     $item = new WorkflowItem();
     $item->loadByPrimaryKey($pos1ID);
     $item->setPosition($pos2);
     $item->store();
     $item->loadByPrimaryKey($pos2ID);
     $item->setPosition($pos1);
     $item->store();
     $this->updateArtAllocation($pos1ID);
     $this->updateArtAllocation($pos2ID);
     return true;
 }