if ($action == "workflow_delete") { $workflows->delete($idworkflow); $sScript = '<script type="text/javascript"> var right_top = top.content.frames["right"].frames["right_top"]; var right_bottom = top.content.frames["right"].frames["right_bottom"]; if (right_top) { right_top.location.href = "' . $sess->url('main.php?area=workflow&frame=3') . '"; } if (right_bottom) { right_bottom.location.href = "' . $sess->url('main.php?area=workflow&frame=4') . '"; } </script>'; } $ui = new UI_Menu(); $workflows->select("idclient = '{$client}' AND idlang = '{$lang}'"); while ($workflow = $workflows->next()) { $wfid = $workflow->getField("idworkflow"); $wfname = $workflow->getField("name"); $wfdescription = $workflow->getField("description"); /* Create the link to show/edit the workflow */ $link = new Link(); $link->setMultiLink("workflow", "", "workflow_common", "workflow_show"); $link->setAlt($wfdescription); $link->setCustom("idworkflow", $wfid); $delTitle = i18n("Delete workflow", "workflow"); $delDescr = sprintf(i18n("Do you really want to delete the following workflow:<br><br>%s<br>", "workflow"), $wfname); $delete = '<a title="' . $delTitle . '" href="javascript://" onclick="box.confirm(\'' . $delTitle . '\', \'' . $delDescr . '\', \'deleteWorkflow(\\\'' . $wfid . '\\\')\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $delTitle . '" alt="' . $delTitle . '"></a>'; $ui->setTitle($wfid, $wfname); $ui->setLink($wfid, $link); $ui->setActions($wfid, 'delete', $delete);
/** * init initializes a new wf_items entry. Should * only be called by the create function. * @param int $idworkflow The workflow to set the item to */ function init($idworkflow, $idposition) { global $cfg; $workflows = new Workflows(); $workflows->select("idworkflow = '{$idworkflow}'"); if ($workflows->next() === false) { $this->lasterror = i18n("Workflow doesn't exist", "workflow"); return false; } $workflowItems = new WorkflowItems(); $workflowItems->select("position = '{$idposition}' AND idworkflow = '{$idworkflow}'"); if ($workflowItems->next()) { $this->lasterror = i18n("Position in this workflow already exists.", "workflow"); return false; } parent::setField("idworkflow", $idworkflow); parent::setField("position", $idposition); parent::store(); return true; }
/** * setWorkflow sets the workflow for the current item. * @param int $idworkflow Workflow-ID to set the item to */ function setWorkflow($idworkflow) { $workflows = new Workflows(); $workflows->select("idworkflow = '{$idworkflow}'"); if ($workflows->next() === false) { $this->lasterror = i18n("Workflow doesn't exist", "workflow"); return false; } parent::setField("idworkflow", $idworkflow); parent::store(); return true; }
function prepareWorkflowItems() { global $action, $lang, $modidcat, $workflowSelectBox, $workflowworkflows, $client, $tpl, $cfg; $workflowworkflows = new Workflows(); if ($action === 'workflow_inherit_down') { $tmp = strDeeperCategoriesArray($modidcat); $asworkflow = getWorkflowForCat($modidcat); $wfa = new WorkflowAllocations(); foreach ($tmp as $tmp_cat) { $idcatlang = getCatLang($tmp_cat, $lang); if ($asworkflow == 0) { $wfa->select("idcatlang = '{$idcatlang}'"); if ($item = $wfa->next()) { $wfa->delete($item->get("idallocation")); # delete user sequences for listing in tasklist for each included article $oArticles = new ArticleCollection(array('idcat' => $idcatlang, 'start' => true, 'offline' => true)); while ($oArticle = $oArticles->nextArticle()) { setUserSequence($oArticle->getField('idartlang'), -1); } } } else { $wfa->select("idcatlang = '{$idcatlang}'"); if ($item = $wfa->next()) { $item->setWorkflow($asworkflow); $item->store(); } else { $wfa->create($asworkflow, $idcatlang); # generate user sequences for listing in tasklist for each included article $oArticles = new ArticleCollection(array('idcat' => $tmp_cat, 'start' => true, 'offline' => true)); while ($oArticle = $oArticles->nextArticle()) { setUserSequence($oArticle->getField('idartlang'), $asworkflow); } } } } } if ($action == "workflow_cat_assign") { $seltpl = "wfselect" . $modidcat; $wfa = new WorkflowAllocations(); $idcatlang = getCatLang($modidcat, $lang); #associate workflow with category if ($GLOBALS[$seltpl] != 0) { $wfa->select("idcatlang = '{$idcatlang}'"); if ($item = $wfa->next()) { $item->setWorkflow($GLOBALS[$seltpl]); $item->store(); } else { $wfa->create($GLOBALS[$seltpl], $idcatlang); } # generate user sequences for listing in tasklist for each included article $oArticles = new ArticleCollection(array('idcat' => $modidcat, 'start' => true, 'offline' => true)); while ($oArticle = $oArticles->nextArticle()) { setUserSequence($oArticle->getField('idartlang'), $GLOBALS[$seltpl]); } #unlink workflow with category } else { $wfa->select("idcatlang = '{$idcatlang}'"); if ($item = $wfa->next()) { $alloc = $item->get("idallocation"); } $wfa->delete($alloc); # delete user sequences for listing in tasklist for each included article $oArticles = new ArticleCollection(array('idcat' => $modidcat, 'start' => true, 'offline' => true)); while ($oArticle = $oArticles->nextArticle()) { setUserSequence($oArticle->getField('idartlang'), -1); } } } $workflowSelectBox = new cHTMLSelectElement("foo"); $workflowSelectBox->setClass("text_medium"); $workflowworkflows->select("idclient = '{$client}' AND idlang = '" . Contenido_Security::escapeDB($lang, null) . "'"); $workflowOption = new cHTMLOptionElement("--- " . i18n("None", "workflow") . " ---", 0); $workflowSelectBox->addOptionElement(0, $workflowOption); while ($workflow = $workflowworkflows->next()) { $workflowOption = new cHTMLOptionElement($workflow->get("name"), $workflow->get("idworkflow")); $workflowSelectBox->addOptionElement($workflow->get("idworkflow"), $workflowOption); } $workflowSelectBox->updateAttributes(array("id" => "wfselect{IDCAT}")); $workflowSelectBox->updateAttributes(array("name" => "wfselect{IDCAT}")); $tpl->set('s', 'PLUGIN_WORKFLOW', $workflowSelectBox->render() . '<a href="javascript:setWorkflow({IDCAT}, \\\'wfselect{IDCAT}\\\')"><img src="' . $cfg["path"]["images"] . 'submit.gif" class="spaced"></a>'); $tpl->set('s', 'PLUGIN_WORKFLOW_TRANSLATION', i18n("Inherit workflow down", "workflow")); }