[geeklog-cvs] geeklog: Stories now can belong to one or more topics.

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Wed Nov 30 10:42:59 EST 2011


changeset 8447:a27ab4b7c899
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/a27ab4b7c899
user: Tom <websitemaster at cogeco.net>
date: Wed Nov 30 10:41:46 2011 -0500
description:
Stories now can belong to one or more topics.
When topics are deleted blocks are also updated if needed. PLG_itemDeleted also added for articles if deleted when a topic is deleted.

diffstat:

 language/english.php                                                   |   15 +-
 language/english_utf-8.php                                             |   15 +-
 public_html/admin/block.php                                            |   19 +-
 public_html/admin/install/lib-upgrade.php                              |    2 +
 public_html/admin/moderation.php                                       |   10 +-
 public_html/admin/story.php                                            |   88 +-
 public_html/admin/syndication.php                                      |    6 +
 public_html/admin/topic.php                                            |  131 +-
 public_html/comment.php                                                |    9 +-
 public_html/index.php                                                  |   50 +-
 public_html/layout/professional/admin/common/edit_topics.thtml         |   14 +-
 public_html/layout/professional/admin/story/storyeditor.thtml          |    9 +-
 public_html/layout/professional/admin/story/storyeditor_advanced.thtml |    8 +-
 public_html/layout/professional/admin/topic/topiceditor.thtml          |    2 +-
 public_html/layout/professional/submit/submitstory.thtml               |    8 +-
 public_html/layout/professional/submit/submitstory_advanced.thtml      |    8 +-
 public_html/lib-common.php                                             |  167 +-
 public_html/submit.php                                                 |    7 +-
 sql/mssql_tableanddata.php                                             |    9 +-
 sql/mysql_tableanddata.php                                             |   10 +-
 sql/pgsql_tableanddata.php                                             |   10 +-
 sql/updates/mssql_1.8.1_to_1.9.0.php                                   |   35 +-
 sql/updates/mysql_1.8.1_to_1.9.0.php                                   |   36 +-
 sql/updates/pgsql_1.8.1_to_1.9.0.php                                   |   35 +-
 system/classes/search.class.php                                        |   19 +-
 system/classes/story.class.php                                         |  143 +-
 system/lib-admin.php                                                   |   70 +-
 system/lib-story.php                                                   |   88 +-
 system/lib-syndication.php                                             |   38 +-
 system/lib-topic.php                                                   |  531 +++++++--
 system/lib-trackback.php                                               |    9 +-
 system/lib-user.php                                                    |   17 +-
 32 files changed, 1118 insertions(+), 500 deletions(-)

diffs (truncated from 3054 to 300 lines):

diff -r d4f90d7462cd -r a27ab4b7c899 language/english.php
--- a/language/english.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/language/english.php	Wed Nov 30 10:41:46 2011 -0500
@@ -745,7 +745,7 @@
     61 => 'No Title',
     62 => 'Article Limit',
     63 => 'Bad Block Title',
-    64 => 'Your Title must not be empty and cannot contain HTML!',
+    64 => 'Your Title must not be empty and cannot contain HTML. You must also make a topic selection.',
     65 => 'Order',
     66 => 'Autotags',
     67 => 'Check to allow autotags',
@@ -786,7 +786,7 @@
     28 => '<p><b>PREVIEWING</b>: Previewing a story with images attached is best done by saving the article as a draft INSTEAD OF hitting the preview button.  Use the preview button only when images are not attached.</p>',
     29 => 'Trackbacks',
     30 => 'File Upload Errors',
-    31 => 'Please fill in the Title and Intro Text fields',
+    31 => 'Please fill in the Title and Intro Text fields and make sure at least one Topic is selected',
     32 => 'Featured',
     33 => 'There can only be one featured story',
     34 => 'Draft',
@@ -860,7 +860,7 @@
     3 => 'Topic Name',
     4 => 'Topic Image',
     5 => '(do not use spaces)',
-    6 => 'Deleting a topic deletes all stories and submissions associated with it.',
+    6 => 'Deleting a topic deletes all stories, submissions and blocks associated with it (as long as they are only associated with that deleted topic).',
     7 => 'Please fill in the Topic ID and Topic Name fields',
     8 => 'Topic Manager',
     9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
@@ -877,7 +877,7 @@
     20 => 'cancel',
     21 => 'delete',
     22 => 'Default',
-    23 => 'Make this the default topic for new story submissions',
+    23 => 'If needed, make this the default topic for new items and submissions',
     24 => '(*)',
     25 => 'Archive Topic',
     26 => 'Make this the default topic for archived stories. Only one topic allowed',
@@ -894,12 +894,15 @@
     37 => 'Root',
     38 => 'All',
     39 => 'Homepage Only', 
-    40 => 'Assign one or more topics.',
+    40 => 'Assign one or more topics. ',
     41 => 'If "All" is selected then the item will appear for all topics. If "Homepage Only" is selected then item will appear just on the homepage. Else you must select at least one topic to assign the item too. ', 
     42 => 'Inherit contains the list of assigned topics. If the topic is selected then the item will be inherited by the parent topic. You must save your item first before anything is listed in the inherit box. ',
     43 => 'Default contains the list of assigned topics. This is the default topic that will be used when displaying the item if the actually topic the user is in is not found. ', 
     44 => 'Inherit',
-    45 => 'Default'
+    45 => 'Default',
+    46 => 'Your parent topic cannot be the Archive topic. Please choose a different Parent Topic.',
+    47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.', 
+    48 => 'Parent Topic Id not found.'
 );
 
 ###############################################################################
diff -r d4f90d7462cd -r a27ab4b7c899 language/english_utf-8.php
--- a/language/english_utf-8.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/language/english_utf-8.php	Wed Nov 30 10:41:46 2011 -0500
@@ -745,7 +745,7 @@
     61 => 'No Title',
     62 => 'Article Limit',
     63 => 'Bad Block Title',
-    64 => 'Your Title must not be empty and cannot contain HTML!',
+    64 => 'Your Title must not be empty and cannot contain HTML. You must also make a topic selection.',
     65 => 'Order',
     66 => 'Autotags',
     67 => 'Check to allow autotags',
@@ -786,7 +786,7 @@
     28 => '<p><b>PREVIEWING</b>: Previewing a story with images attached is best done by saving the article as a draft INSTEAD OF hitting the preview button.  Use the preview button only when images are not attached.</p>',
     29 => 'Trackbacks',
     30 => 'File Upload Errors',
-    31 => 'Please fill in the Title and Intro Text fields',
+    31 => 'Please fill in the Title and Intro Text fields and make sure at least one Topic is selected',
     32 => 'Featured',
     33 => 'There can only be one featured story',
     34 => 'Draft',
@@ -860,7 +860,7 @@
     3 => 'Topic Name',
     4 => 'Topic Image',
     5 => '(do not use spaces)',
-    6 => 'Deleting a topic deletes all stories and submissions associated with it.',
+    6 => 'Deleting a topic deletes all stories, submissions and blocks associated with it (as long as they are only associated with that deleted topic).',
     7 => 'Please fill in the Topic ID and Topic Name fields',
     8 => 'Topic Manager',
     9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
@@ -877,7 +877,7 @@
     20 => 'cancel',
     21 => 'delete',
     22 => 'Default',
-    23 => 'Make this the default topic for new story submissions',
+    23 => 'If needed, make this the default topic for new items and submissions',
     24 => '(*)',
     25 => 'Archive Topic',
     26 => 'Make this the default topic for archived stories. Only one topic allowed',
@@ -894,12 +894,15 @@
     37 => 'Root',
     38 => 'All',
     39 => 'Homepage Only', 
-    40 => 'Assign one or more topics.',
+    40 => 'Assign one or more topics. ',
     41 => 'If "All" is selected then the item will appear for all topics. If "Homepage Only" is selected then item will appear just on the homepage. Else you must select at least one topic to assign the item too. ', 
     42 => 'Inherit contains the list of assigned topics. If the topic is selected then the item will be inherited by the parent topic. You must save your item first before anything is listed in the inherit box. ',
     43 => 'Default contains the list of assigned topics. This is the default topic that will be used when displaying the item if the actually topic the user is in is not found. ', 
     44 => 'Inherit',
-    45 => 'Default'
+    45 => 'Default',
+    46 => 'Your parent topic cannot be the Archive topic. Please choose a different Parent Topic.',
+    47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.', 
+    48 => 'Parent Topic Id not found.'
 );
 
 ###############################################################################
diff -r d4f90d7462cd -r a27ab4b7c899 public_html/admin/block.php
--- a/public_html/admin/block.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/public_html/admin/block.php	Wed Nov 30 10:41:46 2011 -0500
@@ -206,7 +206,6 @@
         $A['name'] = '';
         $A['type'] = 'normal';
         $A['title'] = '';
-        $A['topic_option'] = TOPIC_ALL_OPTION;
         $A['tid'] = '';
         $A['blockorder'] = 0;
         $A['content'] = '';
@@ -489,7 +488,7 @@
 
     $title = addslashes (COM_stripslashes (strip_tags ($title)));
     $phpblockfn = addslashes (COM_stripslashes (trim ($phpblockfn)));
-    if (empty($title)) {
+    if (empty($title) || !TOPIC_checkTopicSelectionControl()) {
         $retval .= COM_siteHeader('menu', $LANG21[63])
                 . COM_showMessageText($LANG21[64], $LANG21[63])
                 . editblock($bid)
@@ -620,20 +619,6 @@
         }
         
         TOPIC_saveTopicSelectionControl('block', $bid);
-        /*
-        // Save Topic link(s)
-        DB_delete($_TABLES['topic_assignments'], array('type', 'id'), array('block', $bid));
-        if (is_array($tid) && $topic_option == TOPIC_SELECTED_OPTION) {
-            foreach ($tid as $value) {
-                $value = COM_applyFilter($value);
-                DB_save ($_TABLES['topic_assignments'], 'tid,type,id', "'$value', 'block', '$bid'");
-            }
-        } else {
-            if ($topic_option == TOPIC_ALL_OPTION || $topic_option == TOPIC_HOMEONLY_OPTION) {
-                DB_save ($_TABLES['topic_assignments'], 'tid,type,id', "'$topic_option', 'block', '$bid'");
-            }
-        }        
-        */
         
         return COM_refresh ($_CONF['site_admin_url'] . '/block.php?msg=11');
     } else {
@@ -790,7 +775,7 @@
         return COM_refresh ($_CONF['site_admin_url'] . '/block.php');
     }
 
-    DB_delete($_TABLES['topic_assignments'], array('type', 'id'), array('block', $bid));
+    TOPIC_deleteTopicAssignments('block', $bid);
     
     DB_delete ($_TABLES['blocks'], 'bid', $bid);
 
diff -r d4f90d7462cd -r a27ab4b7c899 public_html/admin/install/lib-upgrade.php
--- a/public_html/admin/install/lib-upgrade.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/public_html/admin/install/lib-upgrade.php	Wed Nov 30 10:41:46 2011 -0500
@@ -486,6 +486,8 @@
             
             update_BlockTopicAssignmentsFor190();
             
+            update_StoryTopicAssignmentsFor190();
+            
             $current_gl_version = '1.9.0';
             $_SQL = '';
             break;
diff -r d4f90d7462cd -r a27ab4b7c899 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/public_html/admin/moderation.php	Wed Nov 30 10:41:46 2011 -0500
@@ -496,7 +496,11 @@
 
         case 'approve':
             if ($type == 'story') {
-                $result = DB_query ("SELECT * FROM {$_TABLES['storysubmission']} WHERE sid = '$mid[$i]'");
+                $sql = "SELECT *, ta.tid 
+                    FROM {$_TABLES['storysubmission']}, {$_TABLES['topic_assignments']} ta 
+                    WHERE ta.type = 'article' AND ta.id = sid  AND sid = '$mid[$i]'";
+                
+                $result = DB_query ($sql);
                 $A = DB_fetchArray ($result);
                 $A['related'] = addslashes (implode ("\n", STORY_extractLinks ($A['introtext'])));
                 $A['owner_id'] = $A['uid'];
@@ -512,8 +516,8 @@
                 } else {
                     $frontpage = 1;
                 }
-                DB_save ($_TABLES['stories'],'sid,uid,tid,title,introtext,bodytext,related,date,show_topic_icon,commentcode,trackbackcode,postmode,frontpage,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon',
-                "'{$A['sid']}',{$A['uid']},'{$A['tid']}','{$A['title']}','{$A['introtext']}','{$A['bodytext']}','{$A['related']}','{$A['date']}','{$_CONF['show_topic_icon']}','{$_CONF['comment_code']}','{$_CONF['trackback_code']}','{$A['postmode']}',$frontpage,{$A['owner_id']},{$T['group_id']},{$T['perm_owner']},{$T['perm_group']},{$T['perm_members']},{$T['perm_anon']}");
+                DB_save ($_TABLES['stories'],'sid,uid,title,introtext,bodytext,related,date,show_topic_icon,commentcode,trackbackcode,postmode,frontpage,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon',
+                "'{$A['sid']}',{$A['uid']},'{$A['title']}','{$A['introtext']}','{$A['bodytext']}','{$A['related']}','{$A['date']}','{$_CONF['show_topic_icon']}','{$_CONF['comment_code']}','{$_CONF['trackback_code']}','{$A['postmode']}',$frontpage,{$A['owner_id']},{$T['group_id']},{$T['perm_owner']},{$T['perm_group']},{$T['perm_members']},{$T['perm_anon']}");
                 DB_delete($_TABLES['storysubmission'],"$id",$mid[$i]);
 
                 PLG_itemSaved($A['sid'], 'article');
diff -r d4f90d7462cd -r a27ab4b7c899 public_html/admin/story.php
--- a/public_html/admin/story.php	Wed Oct 19 10:39:21 2011 -0400
+++ b/public_html/admin/story.php	Wed Nov 30 10:41:46 2011 -0500
@@ -120,49 +120,44 @@
     $retval = '';
 
     if (empty($current_topic)) {
-        $current_topic = $LANG09[9];
+        $current_topic = TOPIC_ALL_OPTION;
     }
 
-    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) {
-            $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 = " (tid IN ('" . implode( "','", $exclude ) . "')) ";
-        } else {
+    $seltopics = TOPIC_getTopicListSelect($current_topic, 2);
+    if (empty($seltopics)) {
+        $retval .= COM_showMessage(101);
+        return $retval;
+    }    
+    if ($current_topic == TOPIC_ALL_OPTION) {
+        // Retrieve list of inherited topics
+        // $tid_list = TOPIC_getChildList(TOPIC_ROOT);
+        
+        // Retrieve list of all topics user has access to (did not do inherit way since may not see all stories has access too)
+        $tid_list = TOPIC_getList(0, true, false);
+            
+        if (empty($tid_list)) {
             $retval .= COM_showMessage(101);
             return $retval;
         }
+        $excludetopics = " (tid IN ('" . implode( "','", $tid_list ) . "')) ";
     } else {
-        $excludetopics = " tid = '$current_topic' ";
+        // Retrieve list of inherited topics
+        $tid_list = TOPIC_getChildList($current_topic);
+        
+        // Get list of blocks to display (except for dynamic). This includes blocks for all topics, and child blocks that are inherited
+        $excludetopics = " (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$current_topic}')))";        
+        /*
         $seltopics = COM_topicList('tid,topic', $current_topic, 1, true);
         if (empty($seltopics)) {
             $retval .= COM_showMessage(101);
             return $retval;
         }
+        */
     }
 
-    $alltopics = '<option value="' .$LANG09[9]. '"';
-    if ($current_topic == $LANG09[9]) {
-        $alltopics .= ' selected="selected"';
-    }
-    $alltopics .= '>' .$LANG09[9]. '</option>' . LB;
     $filter = $LANG_ADMIN['topic']
         . ': <select name="tid" style="width: 125px" onchange="this.form.submit()">'
-        . $alltopics . $seltopics . '</select>';
+        . $seltopics . '</select>';
 
     $header_arr = array(
         array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false),
@@ -177,7 +172,7 @@
         $header_arr[] = array('text' => $LANG24[7], 'field' => 'username', 'sort' => true); // author
     }
     $header_arr[] = array('text' => $LANG24[15], 'field' => 'unixdate', 'sort' => true); // date
-    $header_arr[] = array('text' => $LANG_ADMIN['topic'], 'field' => 'tid', 'sort' => true);
+    $header_arr[] = array('text' => $LANG_ADMIN['topic'], 'field' => 'topic_ids', 'sort' => true);
     $header_arr[] = array('text' => $LANG24[32], 'field' => 'featured', 'sort' => true);
 
     if (SEC_hasRights ('story.ping') && ($_CONF['trackback_enabled'] ||
@@ -210,7 +205,8 @@
 
     $sql = "SELECT {$_TABLES['stories']}.*, {$_TABLES['users']}.username, {$_TABLES['users']}.fullname, "
           ."UNIX_TIMESTAMP(date) AS unixdate  FROM {$_TABLES['stories']} "
-          ."LEFT JOIN {$_TABLES['users']} ON {$_TABLES['stories']}.uid={$_TABLES['users']}.uid "
+          ."LEFT JOIN {$_TABLES['users']} ON {$_TABLES['stories']}.uid={$_TABLES['users']}.uid " 
+          ."LEFT JOIN {$_TABLES['topic_assignments']} ta ON ta.type = 'article' AND ta.id = sid "
           ."WHERE 1=1 ";
 
     if (!empty ($excludetopics)) {
@@ -219,6 +215,7 @@
     $query_arr = array(



More information about the geeklog-cvs mailing list