[geeklog-hg] geeklog: Fixed making an existing topic an archive topic. Also f...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat May 25 22:03:38 EDT 2013


changeset 9086:e37edd00d3d6
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/e37edd00d3d6
user: Tom <websitemaster at cogeco.net>
date: Sat May 25 22:00:10 2013 -0400
description:
Fixed making an existing topic an archive topic. Also fixed moving stories to archive topic once they expire. (partly contributed by gugu)(bug #0001579)

diffstat:

 public_html/admin/topic.php |  18 ++++++++++++++----
 public_html/index.php       |  14 ++++++++++++--
 2 files changed, 26 insertions(+), 6 deletions(-)

diffs (63 lines):

diff -r 571bad5fe624 -r e37edd00d3d6 public_html/admin/topic.php
--- a/public_html/admin/topic.php	Wed May 22 22:24:12 2013 +0900
+++ b/public_html/admin/topic.php	Sat May 25 22:00:10 2013 -0400
@@ -468,8 +468,13 @@
                 // $tid is the archive topic
                 // - if it wasn't already, mark all its stories "archived" now
                 if ($archive_tid != $tid) {
-                    DB_query ("UPDATE {$_TABLES['stories']} SET featured = 0, frontpage = 0, statuscode = " . STORY_ARCHIVE_ON_EXPIRE . " WHERE tid = '$tid'");
-                    DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
+                    $sql = "UPDATE {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta 
+                            SET s.featured = 0, s.frontpage = 0, s.statuscode = " . STORY_ARCHIVE_ON_EXPIRE . "
+                            WHERE ta.type = 'article' AND ta.tid = '$tid' AND ta.id = s.sid";
+                    DB_query($sql);
+                    
+                    $sql = "UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1";
+                    DB_query($sql);
                 }
                 
                 // Set hidden and inherit to false since archive topic now
@@ -479,8 +484,13 @@
                 // $tid is not the archive topic
                 // - if it was until now, reset the "archived" status of its stories
                 if ($archive_tid == $tid) {
-                    DB_query ("UPDATE {$_TABLES['stories']} SET statuscode = 0 WHERE tid = '$tid'");
-                    DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
+                    $sql = "UPDATE {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta
+                            SET s.statuscode = 0
+                            WHERE ta.type = 'article' AND ta.tid = '$tid' AND ta.id = s.sid";
+                    DB_query($sql);
+                    
+                    $sql = "UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1";
+                    DB_query($sql);
                 }
             }
             
diff -r 571bad5fe624 -r e37edd00d3d6 public_html/index.php
--- a/public_html/index.php	Wed May 22 22:24:12 2013 +0900
+++ b/public_html/index.php	Sat May 25 22:00:10 2013 -0400
@@ -220,12 +220,22 @@
 } else {
     $asql .= ' OR statuscode = ' . STORY_ARCHIVE_ON_EXPIRE . ") AND ta.tid != '$archivetid'";
 }
-$expiresql = DB_query ($asql);
+$expiresql = DB_query($asql);
 while (list ($sid, $expiretopic, $title, $expire, $statuscode) = DB_fetchArray ($expiresql)) {
     if ($statuscode == STORY_ARCHIVE_ON_EXPIRE) {
         if (!empty ($archivetid) ) {
             COM_errorLog("Archive Story: $sid, Topic: $archivetid, Title: $title, Expired: $expire");
-            DB_query ("UPDATE {$_TABLES['stories']} SET tid = '$archivetid', frontpage = '0', featured = '0' WHERE sid='{$sid}'");
+
+            // Delete all topic references to story except topic default
+            $asql = "DELETE FROM {$_TABLES['topic_assignments']} WHERE type = 'article' AND id = '{$sid}' AND tdefault = 0";
+            DB_query ($asql);
+            
+            // Now move over story to archive topic
+            $asql = "UPDATE {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta  
+                    SET ta.tid = '$archivetid', s.frontpage = '0', s.featured = '0' 
+                    WHERE s.sid='{$sid}' AND ta.type = 'article' AND ta.id = s.sid AND ta.tdefault = 1";
+            DB_query ($asql);
+            
         }
     } else if ($statuscode == STORY_DELETE_ON_EXPIRE) {
         COM_errorLog("Delete Story and comments: $sid, Topic: $expiretopic, Title: $title, Expired: $expire");



More information about the geeklog-cvs mailing list