[geeklog-hg] geeklog: Topic tree array now relies on date of cache file inste...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Jul 4 15:19:45 EDT 2013


changeset 9164:28c31ef7d691
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/28c31ef7d691
user: Tom <websitemaster at cogeco.net>
date: Thu Jul 04 14:52:11 2013 -0400
description:
Topic tree array now relies on date of cache file instead of Geeklog DB var last_topic_update. Topics Block now cached. PLG_submissionSaved and PLG_submissionDeleted API added to notify template lib whem a submission happens or is deleted.

diffstat:

 public_html/admin/moderation.php     |    6 +
 public_html/admin/topic.php          |  114 +---------------------------------
 public_html/lib-common.php           |   25 +++---
 public_html/submit.php               |    6 +
 sql/mssql_tableanddata.php           |    3 -
 sql/mysql_tableanddata.php           |    1 -
 sql/pgsql_tableanddata.php           |    1 -
 sql/updates/mssql_2.0.0_to_2.0.1.php |    3 -
 sql/updates/mysql_2.0.0_to_2.0.1.php |    3 -
 sql/updates/pgsql_2.0.0_to_2.0.1.php |    3 -
 system/lib-plugins.php               |   76 +++++++++++++++++++++++
 system/lib-template.php              |   57 +++++++++++++++-
 system/lib-topic.php                 |   18 -----
 13 files changed, 158 insertions(+), 158 deletions(-)

diffs (truncated from 543 to 300 lines):

diff -r 12833ad7e3f4 -r 28c31ef7d691 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/public_html/admin/moderation.php	Thu Jul 04 14:52:11 2013 -0400
@@ -378,6 +378,9 @@
             // There may be some plugin specific processing that needs to
             // happen first.
             $retval .= PLG_deleteSubmission($type, $mid[$i]);
+            
+            // Notify plugins of a submission that is deleted
+            PLG_submissionDeleted($type);
 
             DB_delete($submissiontable, $id, $mid[$i]);
             break;
@@ -462,6 +465,9 @@
                 // There may be some plugin specific processing that needs
                 // to happen first.
                 $retval .= PLG_deleteSubmission($type, $delitem);
+                
+                // Notify plugins of a submission type that is deleted
+                PLG_submissionDeleted($type);
 
                 DB_delete($submissiontable, $id, $delitem);
             }
diff -r 12833ad7e3f4 -r 28c31ef7d691 public_html/admin/topic.php
--- a/public_html/admin/topic.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/public_html/admin/topic.php	Thu Jul 04 14:52:11 2013 -0400
@@ -523,9 +523,6 @@
                 PLG_itemSaved($tid, 'topic');
             }
             
-            // Update date of change to a topic
-            TOPIC_updateLastTopicUpdate();
-            
             // update feed(s) and Older Stories block
             COM_rdfUpToDateCheck('article', $tid);
             COM_olderStuff();
@@ -559,106 +556,11 @@
 *
 * Lists all the topics and their icons.
 *
-* @return   string      HTML for the topic list
-*
-*/
-function listtopics()
-{
-    global $_CONF, $_TABLES, $LANG27, $LANG_ACCESS, $LANG_ADMIN;
-
-    require_once( $_CONF['path_system'] . 'lib-admin.php' );
-
-    $retval = '';
-
-    $retval .= COM_startBlock ($LANG27[8], '',
-                               COM_getBlockTemplate ('_admin_block', 'header'));
-
-    $topic_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/topic');
-    $topic_templates->set_file(array('list'=>'topiclist.thtml', 'item'=>'listitem.thtml'));
-    $topic_templates->set_var('lang_newtopic', $LANG_ADMIN['create_new']);
-    $topic_templates->set_var('lang_adminhome', $LANG27[18]);
-    $topic_templates->set_var('lang_instructions', $LANG27[9]);
-    $topic_templates->set_var('begin_row', '<tr align="center" valign="bottom">');
-
-    $result = DB_query("SELECT * FROM {$_TABLES['topics']}");
-    $nrows = DB_numRows($result);
-    $counter = 1;
-
-    $menu_arr = array (
-        array('url' => $_CONF['site_admin_url'] . '/topic.php?mode=edit',
-              'text' => $LANG_ADMIN['create_new']),
-        array('url' => $_CONF['site_admin_url'],
-              'text' => $LANG_ADMIN['admin_home']));
-    $menu = ADMIN_createMenu(
-        $menu_arr,
-        $LANG27[9],
-        $_CONF['layout_url'] . "/images/icons/topic.png"
-    );
-    $topic_templates->set_var('top_menu', $menu);
-
-    for ($i = 0; $i < $nrows; $i++) {
-        $A = DB_fetchArray($result);
-
-        $access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
-
-        if ($access > 0) {
-            if ($access == 3) {
-                $access = $LANG_ACCESS['edit'];
-            } else {
-                $access = $LANG_ACCESS['readonly'];
-            }
-
-            $topic_templates->set_var('topic_id', $A['tid']);
-            $topic_templates->set_var('topic_name', stripslashes ($A['topic']));
-            $topic_templates->set_var('topic_access', $access);
-            if ($A['is_default'] == 1) {
-                $topic_templates->set_var ('default_topic', $LANG27[24]);
-            } else {
-                $topic_templates->set_var ('default_topic', '');
-            }
-            if (empty ($A['imageurl'])) {
-                $topic_templates->set_var ('image_tag', '');
-            } else {
-                $imageurl = COM_getTopicImageUrl ($A['imageurl']);
-                $topic_templates->set_var ('image_tag', '<img src="' . $imageurl
-                                           . '" alt=""' . XHTML . '>');
-            }
-            if ($counter == 5) {
-                $counter = 1;
-                $topic_templates->set_var('end_row','</tr>');
-                $topic_templates->parse('list_row','item',true);
-                $topic_templates->set_var('begin_row','<tr align="center" valign="bottom">');
-            } else {
-                if ($i == $nrows - 1) {
-                    $topic_templates->set_var('end_row','</tr>');
-                } else {
-                    $topic_templates->set_var('end_row','');
-                }
-
-                $topic_templates->parse('list_row','item',true);
-                $topic_templates->set_var('begin_row','');
-                $counter = $counter + 1;
-            }
-        }
-    }
-    $topic_templates->parse('output', 'list');
-    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
-    $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block', 'footer'));
-
-    return $retval;
-}
-
-
-/**
-* Displays a list of topics
-*
-* Lists all the topics and their icons.
-*
 * @param    string      $token  Security token to use in list
 * @return   string      HTML for the topic list
 *
 */
-function draft_listTopics($token)
+function listTopics($token)
 {
     global $_CONF, $_TABLES, $LANG27, $LANG_ACCESS, $LANG_ADMIN;
 
@@ -793,8 +695,8 @@
 
     DB_query("UPDATE {$_TABLES['topics']} SET sortnum = $order WHERE tid = '$tid'");
     
-    // Update date of change to a topic
-    TOPIC_updateLastTopicUpdate();
+    PLG_itemSaved($tid, 'topic');
+    
 }
 
 /**
@@ -891,9 +793,6 @@
     // Update Topics Array to reflect any changes since not sure what is called after
     $_TOPICS = TOPIC_buildTree(TOPIC_ROOT, true);
     
-    // Update date of change to a topic
-    TOPIC_updateLastTopicUpdate();
-    
     // update feed(s) and Older Stories block
     COM_rdfUpToDateCheck('article');
     COM_olderStuff();
@@ -1086,16 +985,13 @@
     $display .= COM_showMessageFromParameter();
     moveTopics(COM_applyFilter($_GET['tid']), COM_applyFilter($_GET['where']));
     reorderTopics();
-    $display .= draft_listTopics(SEC_createToken());
+    $display .= listTopics(SEC_createToken());
     $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
 
 } else { // 'cancel' or no mode at all
     $display .= COM_showMessageFromParameter();
-
-//    $display .= listtopics();
-
     reorderTopics();
-    $display .= draft_listTopics(SEC_createToken());
+    $display .= listTopics(SEC_createToken());
 
     $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
 }
diff -r 12833ad7e3f4 -r 28c31ef7d691 public_html/lib-common.php
--- a/public_html/lib-common.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/public_html/lib-common.php	Thu Jul 04 14:52:11 2013 -0400
@@ -502,23 +502,15 @@
 
 // Figure out if we need to update topic tree or retrieve it from the cache
 // For anonymous users topic tree data can be shared
-// Retrieve when last topic update happened
-$last_topic_update = DB_getItem($_TABLES['vars'], 'value', "name='last_topic_update'");
-// Figure out how old stored topic tree is
 $cacheInstance = 'topic_tree__' . CACHE_security_hash();
-$topic_tree_date = date("Y-m-d H:i:s", CACHE_get_instance_update($cacheInstance, true));
-// See if Topic Tree has changed for users, if so rebuild tree   
-if ($last_topic_update > $topic_tree_date || empty($last_topic_update)) {
+$serialized_topic_tree = CACHE_check_instance($cacheInstance, true);
+// See if Topic Tree cache exists   
+if (empty($serialized_topic_tree)) {
     $_TOPICS = TOPIC_buildTree(TOPIC_ROOT, true);
-    if (empty($last_topic_update)) {
-        TOPIC_updateLastTopicUpdate();
-        $last_topic_update = DB_getItem($_TABLES['vars'], 'value', "name='last_topic_update'");
-    }
 
     // Save updated topic tree and date
     CACHE_create_instance($cacheInstance, serialize($_TOPICS), true);
 } else {
-    $serialized_topic_tree = CACHE_check_instance($cacheInstance, true);
     $_TOPICS = unserialize($serialized_topic_tree);
 }    
 
@@ -2938,6 +2930,13 @@
  
     $retval = '';
     
+    // See if topic block cache is there for specified topic (since topics can be hidden here depending on what topic is clicked)
+    $cacheInstance = 'topicsblock__' . $topic . '__' . CACHE_security_hash() . '__' . $_CONF['theme'];
+    $retval = CACHE_check_instance($cacheInstance, 0);
+    if ($retval) {
+        return $retval;
+    }    
+    
     $topicnavigation = COM_newTemplate($_CONF['path_layout']);
     if (isset($_BLOCK_TEMPLATE['topicnavigation'])) {
         $topicnavigation->set_file('topicnavigation', $_BLOCK_TEMPLATE['topicnavigation']);
@@ -3125,6 +3124,9 @@
         }
     }
 
+    // Create cache so don't need to recreate unless change
+    CACHE_create_instance($cacheInstance, $retval, 0);
+    
     return $retval;
 }
 
@@ -5170,7 +5172,6 @@
     global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $_USER;
 
     if ($_CONF['whatsnew_cache_time'] > 0) {
-
         $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme'];
         $retval = CACHE_check_instance($cacheInstance, 0);
         if ( $retval ) {
diff -r 12833ad7e3f4 -r 28c31ef7d691 public_html/submit.php
--- a/public_html/submit.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/public_html/submit.php	Thu Jul 04 14:52:11 2013 -0400
@@ -351,8 +351,12 @@
         } elseif (empty ($retval)) {
             // plugin should include its own redirect - but in case handle
             // it here and redirect to the main page
+            PLG_submissionSaved($type);
+            
             return COM_refresh ($_CONF['site_url'] . '/index.php');
         } else {
+            PLG_submissionSaved($type);
+            
             return $retval;
         }
     }
@@ -360,6 +364,8 @@
 
     if (!empty($A['title']) && !empty($A['introtext']) && TOPIC_checkTopicSelectionControl()) {
         $retval = savestory ($A);
+        
+        PLG_submissionSaved($type);
     } else {
         $retval = COM_showMessageText($LANG12[23], $LANG12[22]) // return missing fields error
                 . submissionform($type);
diff -r 12833ad7e3f4 -r 28c31ef7d691 sql/mssql_tableanddata.php
--- a/sql/mssql_tableanddata.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/sql/mssql_tableanddata.php	Thu Jul 04 14:52:11 2013 -0400
@@ -1559,9 +1559,6 @@
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('lastemailedstories','')";
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_scheduled_run','')";
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_article_publish','') ";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','') ";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree_date','')";
-$_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('anon_topic_tree','')";
 $_SQL[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_version','0.0.0')";
 
 $_SQL[] = "INSERT INTO {$_TABLES['trackbackcodes']} (code, name) VALUES (0,'Trackback Enabled')";
diff -r 12833ad7e3f4 -r 28c31ef7d691 sql/mysql_tableanddata.php
--- a/sql/mysql_tableanddata.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/sql/mysql_tableanddata.php	Thu Jul 04 14:52:11 2013 -0400
@@ -831,7 +831,6 @@
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('lastemailedstories','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_scheduled_run','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_article_publish','') ";
-$_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('last_topic_update','') ";
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('database_version','0.0.0') ";
 
 $_DATA[] = "INSERT INTO {$_TABLES['trackbackcodes']} (code, name) VALUES (0,'Trackback Enabled') ";
diff -r 12833ad7e3f4 -r 28c31ef7d691 sql/pgsql_tableanddata.php
--- a/sql/pgsql_tableanddata.php	Thu Jul 04 09:11:42 2013 -0400
+++ b/sql/pgsql_tableanddata.php	Thu Jul 04 14:52:11 2013 -0400
@@ -849,7 +849,6 @@
 $_DATA[] = "INSERT INTO {$_TABLES['vars']} (name, value) VALUES ('lastemailedstories','') ";



More information about the geeklog-cvs mailing list