Ejemplo n.º 1
0
                 // drücken der Entertaste übermittelt
                 if (rex_post('btn_save', 'string')) {
                     $function = '';
                 }
             }
         }
     }
 }
 // ------------------------------------------ END: Slice add/edit/delete
 // ------------------------------------------ START: COPY LANG CONTENT
 if (rex_post('copycontent', 'boolean')) {
     $clang_a = rex_post('clang_a', 'int');
     $clang_b = rex_post('clang_b', 'int');
     $user = rex::getUser();
     if ($user->hasPerm('copyContent[]') && $user->getComplexPerm('clang')->hasPerm($clang_a) && $user->getComplexPerm('clang')->hasPerm($clang_b)) {
         if (rex_content_service::copyContent($article_id, $article_id, $clang_a, $clang_b, $slice_revision)) {
             $info = rex_i18n::msg('content_contentcopy');
         } else {
             $warning = rex_i18n::msg('content_errorcopy');
         }
     } else {
         $warning = rex_i18n::msg('no_rights_to_this_function');
     }
 }
 // ------------------------------------------ END: COPY LANG CONTENT
 // ------------------------------------------ START: MOVE ARTICLE
 if (rex_post('movearticle', 'boolean') && $category_id != $article_id) {
     $category_id_new = rex_post('category_id_new', 'int');
     if (rex::getUser()->hasPerm('moveArticle[]') && rex::getUser()->getComplexPerm('structure')->hasCategoryPerm($category_id_new)) {
         if (rex_article_service::moveArticle($article_id, $category_id, $category_id_new)) {
             $info = rex_i18n::msg('content_articlemoved');
Ejemplo n.º 2
0
 /**
  * Kopieren eines Artikels von einer Kategorie in eine andere.
  *
  * @param int $id        ArtikelId des zu kopierenden Artikels
  * @param int $to_cat_id KategorieId in die der Artikel kopiert werden soll
  *
  * @return bool FALSE bei Fehler, sonst die Artikel Id des neue kopierten Artikels
  */
 public static function copyArticle($id, $to_cat_id)
 {
     $id = (int) $id;
     $to_cat_id = (int) $to_cat_id;
     $new_id = '';
     // Artikel in jeder Sprache kopieren
     foreach (rex_clang::getAllIds() as $clang) {
         // validierung der id & from_cat_id
         $from_sql = rex_sql::factory();
         $qry = 'select * from ' . rex::getTablePrefix() . 'article where clang_id="' . $clang . '" and id="' . $id . '"';
         $from_sql->setQuery($qry);
         if ($from_sql->getRows() == 1) {
             // validierung der to_cat_id
             $to_sql = rex_sql::factory();
             $to_sql->setQuery('select * from ' . rex::getTablePrefix() . 'article where clang_id="' . $clang . '" and startarticle=1 and id="' . $to_cat_id . '"');
             if ($to_sql->getRows() == 1 || $to_cat_id == 0) {
                 if ($to_sql->getRows() == 1) {
                     $path = $to_sql->getValue('path') . $to_sql->getValue('id') . '|';
                     $catname = $to_sql->getValue('catname');
                 } else {
                     // In RootEbene
                     $path = '|';
                     $catname = $from_sql->getValue('name');
                 }
                 $art_sql = rex_sql::factory();
                 $art_sql->setTable(rex::getTablePrefix() . 'article');
                 if ($new_id == '') {
                     $new_id = $art_sql->setNewId('id');
                 }
                 $art_sql->setValue('id', $new_id);
                 // neuen auto_incrment erzwingen
                 $art_sql->setValue('parent_id', $to_cat_id);
                 $art_sql->setValue('catname', $catname);
                 $art_sql->setValue('catpriority', 0);
                 $art_sql->setValue('path', $path);
                 $art_sql->setValue('name', $from_sql->getValue('name') . ' ' . rex_i18n::msg('structure_copy'));
                 $art_sql->setValue('priority', 99999);
                 // Artikel als letzten Artikel in die neue Kat einfügen
                 $art_sql->setValue('status', 0);
                 // Kopierter Artikel offline setzen
                 $art_sql->setValue('startarticle', 0);
                 $art_sql->addGlobalUpdateFields();
                 $art_sql->addGlobalCreateFields();
                 // schon gesetzte Felder nicht wieder überschreiben
                 $dont_copy = ['id', 'pid', 'parent_id', 'catname', 'name', 'catpriority', 'path', 'priority', 'status', 'updatedate', 'updateuser', 'createdate', 'createuser', 'startarticle'];
                 foreach (array_diff($from_sql->getFieldnames(), $dont_copy) as $fld_name) {
                     $art_sql->setValue($fld_name, $from_sql->getValue($fld_name));
                 }
                 $art_sql->setValue('clang_id', $clang);
                 $art_sql->insert();
                 // TODO Doublecheck... is this really correct?
                 $revisions = rex_sql::factory();
                 $revisions->setQuery('select revision from ' . rex::getTablePrefix() . "article_slice where priority=1 AND ctype_id=1 AND article_id='{$id}' AND clang_id='{$clang}'");
                 foreach ($revisions as $rev) {
                     // FIXME this dependency is very ugly!
                     // ArticleSlices kopieren
                     rex_content_service::copyContent($id, $new_id, $clang, $clang, $rev->getValue('revision'));
                 }
                 // Prios neu berechnen
                 self::newArtPrio($to_cat_id, $clang, 1, 0);
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     // Caches des Artikels löschen, in allen Sprachen
     rex_article_cache::delete($id);
     // Caches der Kategorien löschen, da sich derin befindliche Artikel geändert haben
     rex_article_cache::delete($to_cat_id);
     return $new_id;
 }