NAVIGATION
This is an old revision of the document!
Autom. move of expired article into a archive category
This script is working for one article list in one category and one archive category.
The ID of the source category (where the article list is) please register in $my_article_cat . The Target- or archive category (where the articles at expiration to be kept) please register in $my_archive_cat .
If the switch [x] archives is set in category and a visitor accesses the category where the article list is, the expired article is still indicated. At the same time it was shifted into archives. The script is only running if a user visits this category.
If you don´t like this behavior, please open the switch [ ] Archive in category. Thus the script runtime increases a little, since the database must be addressed immediately. With small sides (number of articles < 300) that is uncritical.
Condition: * Source category must be run in article list-mode: top article count > 1
Recommended:
obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die(“You Cannot Access This Script Directly, Have a Nice Day.”); } —————————————————————————–
USERINPUT ====================================================== Kategorie-ID in der das Artikel-Listing laeuft (Quelle) Category-ID where the article listing is running (source) $my_article_cat = 4; ID der Archiv-Kategorie in die verschoben werden soll (Ziel) ID of the archive category (target) $my_archive_cat = 70; USERINPUT END
Nur ausfuehren wenn der Listenmodus in der Kategorie eingeschaltet und die angegebene Kategorie aktiv ist Only run if list mode in category is true and the specified category is active if( $content['list_mode'] == true && $content['cat_id'] == $my_article_cat) {
$article = array();
// Kategorie-Schalter [x] Archive gesetzt? (fuer schnellere Abarbeitung)
// Category switch [x] archive set? (for faster prcessing)
if ( $content['struct'][$content['cat_id']]['acat_archive'] == 1 ) {
$my_time = time(); // for faster processing
// Gibt es einen Artikel bei dem das Datum abgelaufen ist?
// Is there an article with expired date?
foreach($content['articles'] as $key => $value) {
if ($content['articles'][$key]['article_killdate'] < $my_time ) {
$article[] = $value['article_id'];
}
}
// Kategorie-Schalter [ ] Archive offen ? - etwas langsamere Verarbeitung
// Category switch [x] archive unset? - slow down prcessing a little bit
} else
{
$article[0] = 0; // Fuer Aktivierung sql-Update // for activating sql-update
}
// Wenn mindestens ein Artikel vorhanden ist
// If minimum one article exists
if(count($article)) {
$sql = 'UPDATE '.DB_PREPEND.'phpwcms_article SET ';
$sql .= "article_cid= ".$my_archive_cat." "; $sql .= "WHERE article_cid= ".$my_article_cat." AND article_archive_status=1 AND article_deleted=0 "; $sql .= " AND article_public=1 AND article_aktiv=1 AND article_end < NOW() ";
$queryResult = _dbQuery($sql, 'UPDATE');
}
}
?> </code>