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; }