[geeklog-cvs] geeklog: Use IN to exlude topics instead of a (possibly long) li...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Feb 15 14:14:34 EST 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/3a3d0cd63d7b
changeset: 6782:3a3d0cd63d7b
user:      Dirk Haun <dirk at haun-online.de>
date:      Sun Feb 15 10:59:22 2009 +0100
description:
Use IN to exlude topics instead of a (possibly long) list of ORs

diffstat:

1 file changed, 14 insertions(+), 17 deletions(-)
public_html/admin/story.php |   31 ++++++++++++++-----------------

diffs (53 lines):

diff -r 9a83087b80b0 -r 3a3d0cd63d7b public_html/admin/story.php
--- a/public_html/admin/story.php	Sat Feb 14 17:02:00 2009 +0100
+++ b/public_html/admin/story.php	Sun Feb 15 10:59:22 2009 +0100
@@ -116,35 +116,32 @@
         $current_topic = $LANG09[9];
     }
 
-    if ($current_topic == $LANG09[9]) {
+    if ($current_topic == $LANG09[9]) { // "All"
         $excludetopics = '';
         $seltopics = '';
-        $topicsql = "SELECT tid,topic FROM {$_TABLES['topics']}" . COM_getPermSQL ();
-        $tresult = DB_query( $topicsql );
-        $trows = DB_numRows( $tresult );
-        if( $trows > 0 )
-        {
-            $excludetopics .= ' (';
-            for( $i = 1; $i <= $trows; $i++ )  {
-                $T = DB_fetchArray ($tresult);
-                if ($i > 1)  {
-                    $excludetopics .= ' OR ';
-                }
-                $excludetopics .= "tid = '{$T['tid']}'";
-                $seltopics .= '<option value="' .$T['tid']. '"';
-                if ($current_topic == "{$T['tid']}") {
+        $topicsql = "SELECT tid,topic FROM {$_TABLES['topics']}"
+                  . COM_getPermSQL ();
+        $tresult = DB_query($topicsql);
+        $trows = DB_numRows($tresult);
+        if ($trows > 0) {
+            $exclude = array();
+            for ($i = 0; $i < $trows; $i++)  {
+                $T = DB_fetchArray($tresult);
+                $exclude[] = $T['tid'];
+                $seltopics .= '<option value="' . $T['tid'] . '"';
+                if ($current_topic == $T['tid']) {
                     $seltopics .= ' selected="selected"';
                 }
                 $seltopics .= '>' . $T['topic'] . '</option>' . LB;
             }
-            $excludetopics .= ') ';
+            $excludetopics = " (tid IN ('" . implode( "','", $exclude ) . "')) ";
         } else {
             $retval .= COM_showMessage(101);
             return $retval;
         }
     } else {
         $excludetopics = " tid = '$current_topic' ";
-        $seltopics = COM_topicList ('tid,topic', $current_topic, 1, true);
+        $seltopics = COM_topicList('tid,topic', $current_topic, 1, true);
         if (empty($seltopics)) {
             $retval .= COM_showMessage(101);
             return $retval;



More information about the geeklog-cvs mailing list