Пример #1
0
/**
 * Alias of DB::getNextSequence()
 *
 * @see DB::getNextSequence()
 * @return int
 */
function getNextSequence()
{
    $oDB = DB::getInstance();
    $seq = $oDB->getNextSequence();
    setUserSequence($seq);
    return $seq;
}
 function updateArtAllocation($idworkflowitem, $delete = false)
 {
     global $idworkflow, $cfg;
     $oDb = new DB_Contenido();
     $aUserSequences = array();
     $sSql = 'SELECT idusersequence FROM ' . $cfg["tab"]["workflow_user_sequences"] . ' WHERE idworkflowitem = ' . Contenido_Security::escapeDB($idworkflowitem, $oDb) . ';';
     $oDb->query($sSql);
     while ($oDb->next_record()) {
         array_push($aUserSequences, Contenido_Security::escapeDB($oDb->f('idusersequence'), $oDb));
     }
     $aIdArtLang = array();
     if (count($aUserSequences) > 0) {
         $sSql = 'SELECT idartlang FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
         $oDb->query($sSql);
         while ($oDb->next_record()) {
             array_push($aIdArtLang, $oDb->f('idartlang'));
         }
         $sSql = 'DELETE FROM ' . $cfg["tab"]["workflow_art_allocation"] . ' WHERE idusersequence in (' . implode(',', $aUserSequences) . ');';
         $oDb->query($sSql);
     }
     if ($delete) {
         parent::delete($idworkflowitem);
     }
     foreach ($aIdArtLang as $iIdArtLang) {
         setUserSequence($iIdArtLang, $idworkflow);
     }
 }
Пример #3
0
 /**
  * @brief Get information which has been auto-saved
  */
 function getSavedDoc($upload_target_srl)
 {
     $auto_save_args = new stdClass();
     // Find a document by using member_srl for logged-in user and ipaddress for non-logged user
     if (Context::get('is_logged')) {
         $logged_info = Context::get('logged_info');
         $auto_save_args->member_srl = $logged_info->member_srl;
     } else {
         $auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR'];
     }
     $auto_save_args->module_srl = Context::get('module_srl');
     // Get the current module if module_srl doesn't exist
     if (!$auto_save_args->module_srl) {
         $current_module_info = Context::get('current_module_info');
         $auto_save_args->module_srl = $current_module_info->module_srl;
     }
     // Extract auto-saved data from the DB
     $output = executeQuery('editor.getSavedDocument', $auto_save_args);
     $saved_doc = $output->data;
     // Return null if no result is auto-saved
     if (!$saved_doc) {
         return;
     }
     // Check if the auto-saved document already exists
     $oDocumentModel = getModel('document');
     $oSaved = $oDocumentModel->getDocument($saved_doc->document_srl);
     if ($oSaved->isExists()) {
         return;
     }
     // Move all the files if the auto-saved data contains document_srl and file
     // Then set document_srl to editor_sequence
     if ($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) {
         $saved_doc->module_srl = $auto_save_args->module_srl;
         $oFileController = getController('file');
         $oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl);
     } else {
         if ($upload_target_srl) {
             $saved_doc->document_srl = $upload_target_srl;
         }
     }
     // Change auto-saved data
     $oEditorController = getController('editor');
     $oEditorController->deleteSavedDoc(false);
     $oEditorController->doSaveDoc($saved_doc);
     setUserSequence($saved_doc->document_srl);
     return $saved_doc;
 }
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"));
}