Example #1
0
// --------------------------------------------- Mountpoints
$mountpoints = $REX['USER']->getMountpoints();
if (count($mountpoints) == 1 && $category_id == 0) {
    // Nur ein Mointpoint -> Sprung in die Kategory
    $category_id = current($mountpoints);
}
// --------------------------------------------- Rechte prŸfen
require $REX['INCLUDE_PATH'] . '/functions/function_rex_category.inc.php';
require $REX['INCLUDE_PATH'] . '/functions/function_rex_content.inc.php';
// --------------------------------------------- TITLE
rex_title($I18N->msg('title_structure'), $KATout);
$sprachen_add = '&category_id=' . $category_id;
require $REX['INCLUDE_PATH'] . '/functions/function_rex_languages.inc.php';
// -------------- STATUS_TYPE Map
$catStatusTypes = rex_categoryStatusTypes();
$artStatusTypes = rex_articleStatusTypes();
// --------------------------------------------- KATEGORIE FUNKTIONEN
if (rex_post('catedit_function', 'boolean') && $edit_id != '' && $KATPERM) {
    // --------------------- KATEGORIE EDIT
    $data = array();
    $data['catprior'] = rex_post('Position_Category', 'int');
    $data['catname'] = rex_post('kat_name', 'string');
    $data['path'] = $KATPATH;
    list($success, $message) = rex_editCategory($edit_id, $clang, $data);
    if ($success) {
        $info = $message;
    } else {
        $warning = $message;
    }
} elseif ($function == 'catdelete_function' && $edit_id != '' && $KATPERM && !$REX['USER']->hasPerm('editContentOnly[]')) {
    // --------------------- KATEGORIE DELETE
/**
 * Ändert den Status des Artikels
 *
 * @param int      $article_id Id des Artikels die gelöscht werden soll
 * @param int      $clang      Id der Sprache
 * @param int|null $status     Status auf den der Artikel gesetzt werden soll, oder NULL wenn zum nächsten Status weitergeschaltet werden soll
 *
 * @return array Ein Array welches den status sowie eine Fehlermeldung beinhaltet
 */
function rex_articleStatus($article_id, $clang, $status = null)
{
    global $REX, $I18N;
    if (!is_object($I18N)) {
        $I18N = rex_create_lang($REX['LANG']);
    }
    $success = false;
    $message = '';
    $artStatusTypes = rex_articleStatusTypes();
    $GA = rex_sql::factory();
    $GA->setQuery('select * from ' . $REX['TABLE_PREFIX'] . "article where id='{$article_id}' and clang={$clang}");
    if ($GA->getRows() == 1) {
        // Status wurde nicht von außen vorgegeben,
        // => zyklisch auf den nächsten Weiterschalten
        if (!$status) {
            $newstatus = ($GA->getValue('status') + 1) % count($artStatusTypes);
        } else {
            $newstatus = $status;
        }
        $EA = rex_sql::factory();
        $EA->setTable($REX['TABLE_PREFIX'] . 'article');
        $EA->setWhere("id='{$article_id}' and clang={$clang}");
        $EA->setValue('status', $newstatus);
        $EA->addGlobalUpdateFields($REX['REDAXO'] ? null : 'frontend');
        if (!$REX['REDAXO']) {
            include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
        }
        if ($EA->update()) {
            $message = $I18N->msg('article_status_updated');
            rex_deleteCacheArticle($article_id, $clang);
            // ----- EXTENSION POINT
            $message = rex_register_extension_point('ART_STATUS', $message, array('id' => $article_id, 'clang' => $clang, 'status' => $newstatus));
            $success = true;
        } else {
            $message = $EA->getError();
        }
    } else {
        $message = $I18N->msg('no_such_category');
    }
    return array($success, $message);
}
/**
 * Ändert den Status des Artikels
 * 
 * @param int       $article_id Id des Artikels die gelöscht werden soll
 * @param int       $clang      Id der Sprache
 * @param int|null  $status     Status auf den der Artikel gesetzt werden soll, oder NULL wenn zum nächsten Status weitergeschaltet werden soll
 * 
 * @return array Ein Array welches den status sowie eine Fehlermeldung beinhaltet
 */
function rex_articleStatus($article_id, $clang, $status = null)
{
    global $REX, $I18N;
    $success = false;
    $message = '';
    $artStatusTypes = rex_articleStatusTypes();
    $GA = new rex_sql();
    $GA->setQuery("select * from " . $REX['TABLE_PREFIX'] . "article where id='{$article_id}' and clang={$clang}");
    if ($GA->getRows() == 1) {
        // Status wurde nicht von außen vorgegeben,
        // => zyklisch auf den nächsten Weiterschalten
        if (!$status) {
            $newstatus = ($GA->getValue('status') + 1) % count($artStatusTypes);
        } else {
            $newstatus = $status;
        }
        $EA = new rex_sql();
        $EA->setTable($REX['TABLE_PREFIX'] . "article");
        $EA->setWhere("id='{$article_id}' and clang={$clang}");
        $EA->setValue('status', $newstatus);
        $EA->addGlobalUpdateFields();
        if ($EA->update()) {
            $message = $I18N->msg('article_status_updated');
            rex_deleteCacheArticle($article_id, $clang);
            // ----- EXTENSION POINT
            $message = rex_register_extension_point('ART_STATUS', $message, array('id' => $article_id, 'clang' => $clang, 'status' => $newstatus));
            $success = true;
        } else {
            $message = $EA->getError();
        }
    } else {
        $message = $I18N->msg("no_such_category");
    }
    return array($success, $message);
}