public function execute() { $config = rex_plugin::get('cronjob', 'article_status')->getProperty('config'); $from = $config['from']; $to = $config['to']; $from['before'] = (array) $from['before']; $to['before'] = (array) $to['before']; $sql = rex_sql::factory(); // $sql->setDebug(); $sql->setQuery(' SELECT name FROM ' . rex::getTablePrefix() . 'metainfo_field WHERE name="' . $from['field'] . '" OR name="' . $to['field'] . '" '); $rows = $sql->getRows(); if ($rows < 2) { if ($rows == 0) { $msg = 'Metainfo fields "' . $from['field'] . '" and "' . $to['field'] . '" not found'; } else { $field = $sql->getValue('name') == $from['field'] ? $to['field'] : $from['field']; $msg = 'Metainfo field "' . $field . '" not found'; } $this->setMessage($msg); return false; } $time = time(); $sql->setQuery(' SELECT id, clang_id, status FROM ' . rex::getTablePrefix() . 'article WHERE ( ' . $from['field'] . ' > 0 AND ' . $from['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $from['before']) . ') AND (' . $to['field'] . ' > ' . $time . ' OR ' . $to['field'] . ' = 0 OR ' . $to['field'] . ' = "") ) OR ( ' . $to['field'] . ' > 0 AND ' . $to['field'] . ' < ' . $time . ' AND status IN (' . implode(',', $to['before']) . ') ) '); $rows = $sql->getRows(); include_once rex_path::addon('structure', 'functions/function_rex_structure.php'); for ($i = 0; $i < $rows; ++$i) { if (in_array($sql->getValue('status'), $from['before'])) { $status = $from['after']; } else { $status = $to['after']; } rex_article_service::articleStatus($sql->getValue('id'), $sql->getValue('clang_id'), $status); $sql->next(); } $this->setMessage('Updated articles: ' . $rows); return true; }
function rex_metainfo_content_sidebar($extionPointParams) { $params = $extionPointParams->getParams(); $article = rex_article::get($params['article_id'], $params['clang']); $articleStatusTypes = rex_article_service::statusTypes(); $panel = ''; $panel .= '<dl class="dl-horizontal">'; $panel .= '<dt>' . rex_i18n::msg('created_by') . '</dt>'; $panel .= '<dd>' . $article->getValue('createuser') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('created_on') . '</dt>'; $panel .= '<dd>' . rex_formatter::strftime($article->getValue('createdate'), 'date') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('updated_by') . '</dt>'; $panel .= '<dd>' . $article->getValue('updateuser') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('updated_on') . '</dt>'; $panel .= '<dd>' . rex_formatter::strftime($article->getValue('updatedate'), 'date') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('status') . '</dt>'; $panel .= '<dd class="' . $articleStatusTypes[$article->getValue('status')][1] . '">' . $articleStatusTypes[$article->getValue('status')][0] . '</dd>'; $panel .= '</dl>'; $fragment = new rex_fragment(); $fragment->setVar('title', rex_i18n::msg('metadata'), false); $fragment->setVar('body', $panel, false); $content = $fragment->parse('core/page/section.php'); return $content; }
/** * Löscht eine Kategorie und reorganisiert die Prioritäten verbleibender Geschwister-Kategorien. * * @param int $category_id Id der Kategorie die gelöscht werden soll * * @throws rex_api_exception * * @return string Eine Statusmeldung */ public static function deleteCategory($category_id) { $clang = 1; $thisCat = rex_sql::factory(); $thisCat->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'article WHERE id=' . $category_id . ' and clang_id=' . $clang); // Prüfen ob die Kategorie existiert if ($thisCat->getRows() == 1) { $KAT = rex_sql::factory(); $KAT->setQuery('select * from ' . rex::getTablePrefix() . "article where parent_id='{$category_id}' and clang_id='{$clang}' and startarticle=1"); // Prüfen ob die Kategorie noch Unterkategorien besitzt if ($KAT->getRows() == 0) { $KAT->setQuery('select * from ' . rex::getTablePrefix() . "article where parent_id='{$category_id}' and clang_id='{$clang}' and startarticle=0"); // Prüfen ob die Kategorie noch Artikel besitzt (ausser dem Startartikel) if ($KAT->getRows() == 0) { $thisCat = rex_sql::factory(); $thisCat->setQuery('SELECT * FROM ' . rex::getTablePrefix() . 'article WHERE id=' . $category_id); $parent_id = $thisCat->getValue('parent_id'); $message = rex_article_service::_deleteArticle($category_id); foreach ($thisCat as $row) { $_clang = $row->getValue('clang_id'); // ----- PRIOR self::newCatPrio($parent_id, $_clang, 0, 1); // ----- EXTENSION POINT $message = rex_extension::registerPoint(new rex_extension_point('CAT_DELETED', $message, ['id' => $category_id, 'parent_id' => $parent_id, 'clang' => $_clang, 'name' => $row->getValue('catname'), 'priority' => $row->getValue('catpriority'), 'path' => $row->getValue('path'), 'status' => $row->getValue('status')])); } rex_complex_perm::removeItem('structure', $category_id); } else { throw new rex_api_exception(rex_i18n::msg('category_could_not_be_deleted') . ' ' . rex_i18n::msg('category_still_contains_articles')); } } else { throw new rex_api_exception(rex_i18n::msg('category_could_not_be_deleted') . ' ' . rex_i18n::msg('category_still_contains_subcategories')); } } else { throw new rex_api_exception(rex_i18n::msg('category_could_not_be_deleted')); } return $message; }
<?php rex_extension::register('STRUCTURE_CONTENT_SIDEBAR', function (rex_extension_point $ep) { $params = $ep->getParams(); $subject = $ep->getSubject(); $article = rex_article::get($params['article_id'], $params['clang']); $articleStatusTypes = rex_article_service::statusTypes(); $panel = ''; $panel .= '<dl class="dl-horizontal text-left">'; $panel .= '<dt>' . rex_i18n::msg('created_by') . '</dt>'; $panel .= '<dd>' . $article->getValue('createuser') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('created_on') . '</dt>'; $panel .= '<dd>' . rex_formatter::strftime($article->getValue('createdate'), 'date') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('updated_by') . '</dt>'; $panel .= '<dd>' . $article->getValue('updateuser') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('updated_on') . '</dt>'; $panel .= '<dd>' . rex_formatter::strftime($article->getValue('updatedate'), 'date') . '</dd>'; $panel .= '<dt>' . rex_i18n::msg('status') . '</dt>'; $panel .= '<dd class="' . $articleStatusTypes[$article->getValue('status')][1] . '">' . $articleStatusTypes[$article->getValue('status')][0] . '</dd>'; $panel .= '</dl>'; $fragment = new rex_fragment(); $fragment->setVar('title', '<i class="rex-icon rex-icon-info"></i> ' . rex_i18n::msg('metadata'), false); $fragment->setVar('body', $panel, false); $fragment->setVar('collapse', true); $fragment->setVar('collapsed', true); $content = $fragment->parse('core/page/section.php'); return $content . $subject; });
public function execute() { $article_id = rex_request('article_id', 'int'); $ooArticle = rex_article::get($article_id); $category_id = $ooArticle->getCategoryId(); /** * @var rex_user */ $user = rex::getUser(); // article2category und category2article verwenden das gleiche Recht: article2category if ($user->hasPerm('article2startarticle[]') && rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($category_id)) { if (rex_article_service::article2startarticle($article_id)) { $result = new rex_api_result(true, rex_i18n::msg('content_tostartarticle_ok')); } else { $result = new rex_api_result(false, rex_i18n::msg('content_tostartarticle_failed')); } return $result; } else { throw new rex_api_exception('user has no permission for this article!'); } }
$info = rex_i18n::msg('content_articlemoved'); ob_end_clean(); rex_response::sendRedirect($context->getUrl(['page' => 'content/edit', 'info' => $info], false)); } else { $warning = rex_i18n::msg('content_errormovearticle'); } } else { $warning = rex_i18n::msg('no_rights_to_this_function'); } } // ------------------------------------------ END: MOVE ARTICLE // ------------------------------------------ START: COPY ARTICLE if (rex_post('copyarticle', 'boolean')) { $category_copy_id_new = rex_post('category_copy_id_new', 'int'); if (rex::getUser()->hasPerm('copyArticle[]') && rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($category_copy_id_new)) { if (($new_id = rex_article_service::copyArticle($article_id, $category_copy_id_new)) !== false) { $info = rex_i18n::msg('content_articlecopied'); ob_end_clean(); rex_response::sendRedirect($context->getUrl(['page' => 'content/edit', 'article_id' => $new_id, 'info' => $info], false)); } else { $warning = rex_i18n::msg('content_errorcopyarticle'); } } else { $warning = rex_i18n::msg('no_rights_to_this_function'); } } // ------------------------------------------ END: COPY ARTICLE // ------------------------------------------ START: MOVE CATEGORY if (rex_post('movecategory', 'boolean')) { $category_id_new = rex_post('category_id_new', 'int'); if (rex::getUser()->hasPerm('moveCategory[]') && rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($article->getValue('parent_id')) && rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($category_id_new)) {