[geeklog-cvs] geeklog: Staticpage Plugin now Version 1.6.5 and requires Geeklo...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Dec 23 15:44:49 EST 2011


changeset 8462:23db444e4c8d
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/23db444e4c8d
user: Tom <websitemaster at cogeco.net>
date: Fri Dec 23 13:19:32 2011 -0500
description:
Staticpage Plugin now Version 1.6.5 and requires Geeklog 1.9.0
Staticpage will now set the current topic.
You now can search for a staticpage by topic.
Staticpage menu item now only comes up in topics it is assigned to.
Staticpage displays the same blocks as the topic it is in. If last topic not known then use default
If staticpage is a centerblock it can appear in all topics it is assigned too.
Only one entire page centerblock is allowed per topic (each language can have one).

diffstat:

 plugins/staticpages/autoinstall.php                       |    4 +-
 plugins/staticpages/functions.inc                         |  101 ++++++++++++-
 plugins/staticpages/install_updates.php                   |   25 +++
 plugins/staticpages/language/english.php                  |    6 +-
 plugins/staticpages/language/english_utf-8.php            |    6 +-
 plugins/staticpages/services.inc.php                      |   69 +++++---
 plugins/staticpages/sql/mssql_install.php                 |    1 -
 plugins/staticpages/sql/mysql_install.php                 |    2 -
 plugins/staticpages/sql/pgsql_install.php                 |    2 -
 plugins/staticpages/templates/admin/editor.thtml          |    6 +-
 plugins/staticpages/templates/admin/editor_advanced.thtml |    6 +-
 public_html/admin/plugins/staticpages/index.php           |   35 +---
 public_html/staticpages/index.php                         |    2 +
 13 files changed, 185 insertions(+), 80 deletions(-)

diffs (truncated from 666 to 300 lines):

diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/autoinstall.php
--- a/plugins/staticpages/autoinstall.php	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/autoinstall.php	Fri Dec 23 13:19:32 2011 -0500
@@ -51,8 +51,8 @@
     $info = array(
         'pi_name'         => $pi_name,
         'pi_display_name' => $pi_display_name,
-        'pi_version'      => '1.6.4',
-        'pi_gl_version'   => '1.8.0',
+        'pi_version'      => '1.6.5',
+        'pi_gl_version'   => '1.9.0',
         'pi_homepage'     => 'http://www.geeklog.net/'
     );
 
diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/functions.inc	Fri Dec 23 13:19:32 2011 -0500
@@ -86,7 +86,7 @@
 */
 function plugin_getmenuitems_staticpages()
 {
-    global $_CONF, $_TABLES, $_SP_CONF;
+    global $_CONF, $_TABLES, $_SP_CONF, $topic;
 
     $order = '';
     if (!empty($_SP_CONF['sort_menu_by'])) {
@@ -101,8 +101,25 @@
             $order .= 'sp_id';
         }
     }
+    
+    if (!empty($topic)) {
+        $topic_sql = " AND (ta.tid = '$topic' OR ta.tid = '" . TOPIC_ALL_OPTION . "')";
+    } else {
+        if (COM_onFrontpage()) {
+            $topic_sql = " AND (ta.tid = '" . TOPIC_HOMEONLY_OPTION . "' OR ta.tid = '" . TOPIC_ALL_OPTION . "')";
+        } else {
+            $topic_sql = " AND (ta.tid = '" . TOPIC_ALL_OPTION . "')";
+        }
+        $topic_sql .= COM_getTopicSQL('AND', 0, 'ta');
+    }
 
-    $result = DB_query("SELECT sp_id, sp_label FROM {$_TABLES['staticpage']} WHERE (sp_onmenu = 1) AND (draft_flag = 0) AND (template_flag = 0)" . COM_getPermSql('AND') . COM_getLangSql('sp_id', 'AND') . $order);
+    $sql = "SELECT sp.sp_id, sp.sp_label 
+        FROM {$_TABLES['staticpage']} sp, {$_TABLES['topic_assignments']} ta   
+        WHERE (sp.sp_onmenu = 1) AND (sp.draft_flag = 0) AND (sp.template_flag = 0)
+        AND ta.type = 'staticpages' AND ta.id = sp_id $topic_sql 
+        " . COM_getPermSql('AND', 0 , 2, 'sp') . COM_getLangSql('sp_id', 'AND', 'sp') . $order;
+
+    $result = DB_query($sql);
     $nrows = DB_numRows($result);
 
     $menuitems = array();
@@ -753,14 +770,25 @@
     $sql = "SELECT sp.sp_id AS id, sp.sp_title AS title, sp.sp_content AS description, ";
     $sql .= "UNIX_TIMESTAMP(sp.created) AS date, sp.owner_id AS uid, sp.sp_hits AS hits, ";
     $sql .= "CONCAT('/staticpages/index.php?page=', sp.sp_id) AS url ";
-    $sql .= "FROM {$_TABLES['staticpage']} AS sp,{$_TABLES['users']} AS u ";
-    $sql .= "WHERE (sp.owner_id = u.uid) AND (draft_flag = 0) AND (template_flag = 0)";
-    $sql .= COM_getPermSQL('AND') . COM_getLangSQL('sp_id', 'AND', 'sp') . ' ';
+    $sql .= "FROM {$_TABLES['staticpage']} AS sp,{$_TABLES['users']} AS u, {$_TABLES['topic_assignments']} ta ";
+    $sql .= "WHERE (sp.owner_id = u.uid) AND (draft_flag = 0) AND (template_flag = 0) ";
+    $sql .= "AND ta.type = 'staticpages' AND ta.id = sp.sp_id ";
+    $sql .= COM_getPermSQL('AND') . COM_getTopicSQL('AND', 0, 'ta') . COM_getLangSQL('sp_id', 'AND', 'sp') . ' ';
 
     if (!empty ($author)) {
         $sql .= "AND (owner_id = '$author') ";
     }
 
+    if (!empty($topic)) {
+        // Retrieve list of inherited topics
+        if ($topic == TOPIC_ALL_OPTION) {
+            $sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$topic."')) ";
+        } else {
+            $tid_list = TOPIC_getChildList($topic);
+            $sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$topic."'))) ";
+        }
+    }
+        
     if ($_SP_CONF['includesearchcenterblocks'] == 0) {
         $sql .='AND sp_centerblock = 0 ';
     }
@@ -791,15 +819,24 @@
         $sql .= "CONCAT('/comment.php?mode=view&cid=',c.cid) AS url ";
     }
 
-    $sql .= "FROM {$_TABLES['users']} AS u, {$_TABLES['comments']} AS c ";
+    $sql .= "FROM {$_TABLES['users']} AS u, {$_TABLES['topic_assignments']} ta , {$_TABLES['comments']} AS c ";
     $sql .= "LEFT JOIN {$_TABLES['staticpage']} AS s ON ((s.sp_id = c.sid) ";
     $sql .= COM_getPermSQL('AND',0,2,'s') . COM_getLangSQL('sp_id','AND','s') . ") ";
     $sql .= "WHERE (u.uid = c.uid) AND (s.draft_flag = 0) AND (s.template_flag = 0) AND (s.commentcode >= 0) AND (s.created <= NOW()) ";
+    $sql .= "AND ta.type = 'staticpages' AND ta.id = s.sp_id " . COM_getTopicSQL('AND',0,'ta');;
 
     if (!empty($author)) {
         $sql .= "AND (c.uid = '$author') ";
     }
 
+    if (!empty($topic)) {
+        if ($topic == TOPIC_ALL_OPTION) {
+            $sql .= "AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$topic."')) ";
+        } else {
+            $sql .= "AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '".$topic."'))) ";
+        }
+    }    
+    
     $search_c = new SearchCriteria('comments', array($LANG_STATIC['staticpages'],$LANG09[66]));
 
     $columns = array('title' => 'c.title', 'comment');
@@ -937,9 +974,9 @@
     }
 
     if (empty ($topic)) {
-        $moresql .= "((sp_tid = 'none') OR (sp_tid = 'all'))";
+        $moresql .= "((ta.tid = '" . TOPIC_HOMEONLY_OPTION . "') OR (ta.tid = '" . TOPIC_ALL_OPTION . "'))";
     } else {
-        $moresql .= "((sp_tid = '{$topic}') OR (sp_tid = 'all'))";
+        $moresql .= "((ta.tid = '{$topic}') OR (ta.tid = '" . TOPIC_ALL_OPTION . "'))";
     }
 
     if ($_SP_CONF['sort_by'] == 'date') {
@@ -957,7 +994,12 @@
     if (!empty ($perms)) {
         $perms = ' AND ' . $perms;
     }
-    $spsql = "SELECT sp_id,sp_title,sp_content,sp_format,created,modified,sp_hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_php,sp_inblock,sp_help FROM {$_TABLES['staticpage']} WHERE (sp_centerblock = 1) AND (draft_flag = 0) AND (template_flag = 0)" . COM_getLangSql('sp_id', 'AND') . ' AND ' . $moresql . $perms . " ORDER BY " . $sort;
+    $spsql = "SELECT sp_id,sp_title,sp_content,sp_format,created,modified,sp_hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_php,sp_inblock,sp_help 
+        FROM {$_TABLES['staticpage']}, {$_TABLES['topic_assignments']} ta   
+        WHERE (sp_centerblock = 1) AND (draft_flag = 0) AND (template_flag = 0) 
+        AND ta.type = 'staticpages' AND ta.id = sp_id
+        " . COM_getLangSql('sp_id', 'AND') . ' AND ' . $moresql . $perms . " ORDER BY " . $sort;
+        
     $result = DB_query($spsql);
 
     $pages = DB_numRows($result);
@@ -1349,8 +1391,23 @@
             }
 
             $current_version = '1.6.4';
-            break;           
+            break;
+            
+        case '1.6.4':
+            if (isset($_UPDATES[$current_version])) {
+                $_SQL = $_UPDATES[$current_version];
+                foreach ($_SQL as $sql) {
+                    DB_query($sql);
+                }
+            }
 
+            if (! $current_config) {
+                SP_update_TopicAssignmentsFor_1_6_4();
+            }
+
+            $current_version = '1.6.5';
+            break; 
+            
         default:
             $done = true;
         }
@@ -1967,10 +2024,12 @@
 {
     global $_TABLES;
 
+    /* Not needed anymore since topic now stored in topic assignments
     // we're really only interested in Topic ID changes
     if (($type == 'topic') && !empty($old_id) && ($id != $old_id)) {
         DB_change($_TABLES['staticpage'], 'sp_tid', $id, 'sp_tid', $old_id);
     }
+    */
 }
 
 /**
@@ -1988,7 +2047,27 @@
 
     // we're really only interested in Topic Deletes
     if ($type == 'topic') {
-        DB_change($_TABLES['staticpage'], 'sp_tid', $id, 'sp_tid', TOPIC_ALL_OPTION);
+        // Need to make sure at least one topic left. Default is all
+        
+        // Find all staticpages that are assigned to the deleted topic
+        $sql = "SELECT id FROM {$_TABLES['topic_assignments']} WHERE type = 'staticpages' AND tid ='$id'";
+        
+        $result = DB_query($sql);
+        $nrows = DB_numRows($result);
+    
+        for($i = 0; $i < $nrows; $i++) {        
+            $A = DB_fetchArray($result);
+            
+            // Now check if staticpage has at least 2 topics (1 will be deleted)
+            $sql = "SELECT id FROM {$_TABLES['topic_assignments']} WHERE type = 'staticpages' AND id ='{$A['id']}'";
+            $resultB = DB_query($sql);
+            $nrowsB = DB_numRows($resultB);
+        
+            if ($nrowsB < 2) {
+                // Only deleted topic assigned so add all topic default assignment
+                TOPIC_addTopicAssignments('staticpages', $A['id']);
+            }
+        }
     }
 }
 
diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/install_updates.php
--- a/plugins/staticpages/install_updates.php	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/install_updates.php	Fri Dec 23 13:19:32 2011 -0500
@@ -28,4 +28,29 @@
     return true;
 }
 
+function SP_update_TopicAssignmentsFor_1_6_4()
+{
+    global $_TABLES;
+    
+    $sql = "SELECT * FROM {$_TABLES['staticpage']}";
+    $result = DB_query($sql);
+    $nrows = DB_numRows($result);
+
+    for ($i = 0; $i < $nrows; $i++) {
+        $A = DB_fetchArray($result);
+        
+        if ($A['sp_tid'] == 'all') {
+            $A['sp_tid'] == TOPIC_ALL_OPTION;
+        } elseif ($A['sp_tid'] == 'none') {
+            $A['sp_tid'] == TOPIC_HOMEONLY_OPTION;
+        }
+        
+        $sql = "INSERT INTO {$_TABLES['topic_assignments']} (tid, type, id, inherit, tdefault) VALUES ('{$A['sp_tid']}', 'staticpages', '{$A['sp_id']}', 1, 0)";
+        DB_query($sql);
+    }
+
+    // Remove Topic Id from blocks table
+    $sql = "ALTER TABLE {$_TABLES['staticpage']} DROP `sp_tid`";    
+    DB_query($sql);}
+
 ?>
\ No newline at end of file
diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/language/english.php
--- a/plugins/staticpages/language/english.php	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/language/english.php	Fri Dec 23 13:19:32 2011 -0500
@@ -64,7 +64,7 @@
     'all_html_allowed' => 'All HTML is allowed',
     'results' => 'Static Pages Results',
     'author' => 'Author',
-    'no_title_or_content' => 'You must at least fill in the <b>Title</b> and <b>Content</b> fields.',
+    'no_title_or_content' => 'You must at least fill in the <b>Title</b> and <b>Content</b> fields as well as make a <b>Topic</b> selection.',
     'no_such_page_anon' => 'Please log in..',
     'no_page_access_msg' => "This could be because you're not logged in, or not a member of {$_CONF['site_name']}. Please <a href=\"{$_CONF['site_url']}/users.php?mode=new\"> become a member</a> of {$_CONF['site_name']} to receive full membership access",
     'php_msg' => 'PHP: ',
@@ -80,8 +80,8 @@
     'duplicate_id' => 'The ID you chose for this static page is already in use. Please select another ID.',
     'instructions' => 'To modify or delete a static page, click on that page\'s edit icon below. To view a static page, click on the title of the page you wish to view. To create a new static page, click on "Create New" above. Click on on the copy icon to create a copy of an existing page.',
     'centerblock' => 'Centerblock: ',
-    'centerblock_msg' => 'When checked, this Static Page will be displayed as a center block on the index page.',
-    'topic' => 'Topic: ',
+    'centerblock_msg' => 'When checked, this Static Page will be displayed as a center block on the index page of the topics it is assigned too.',
+    'topic' => 'Topic',
     'position' => 'Position: ',
     'all_topics' => 'All',
     'no_topic' => 'Homepage Only',
diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/language/english_utf-8.php
--- a/plugins/staticpages/language/english_utf-8.php	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/language/english_utf-8.php	Fri Dec 23 13:19:32 2011 -0500
@@ -64,7 +64,7 @@
     'all_html_allowed' => 'All HTML is allowed',
     'results' => 'Static Pages Results',
     'author' => 'Author',
-    'no_title_or_content' => 'You must at least fill in the <b>Title</b> and <b>Content</b> fields.',
+    'no_title_or_content' => 'You must at least fill in the <b>Title</b> and <b>Content</b> fields as well as make a <b>Topic</b> selection.',
     'no_such_page_anon' => 'Please log in..',
     'no_page_access_msg' => "This could be because you're not logged in, or not a member of {$_CONF['site_name']}. Please <a href=\"{$_CONF['site_url']}/users.php?mode=new\"> become a member</a> of {$_CONF['site_name']} to receive full membership access",
     'php_msg' => 'PHP: ',
@@ -80,8 +80,8 @@
     'duplicate_id' => 'The ID you chose for this static page is already in use. Please select another ID.',
     'instructions' => 'To modify or delete a static page, click on that page\'s edit icon below. To view a static page, click on the title of the page you wish to view. To create a new static page, click on "Create New" above. Click on on the copy icon to create a copy of an existing page.',
     'centerblock' => 'Centerblock: ',
-    'centerblock_msg' => 'When checked, this Static Page will be displayed as a center block on the index page.',
-    'topic' => 'Topic: ',
+    'centerblock_msg' => 'When checked, this Static Page will be displayed as a center block on the index page of the topics it is assigned too.',
+    'topic' => 'Topic',
     'position' => 'Position: ',
     'all_topics' => 'All',
     'no_topic' => 'Homepage Only',
diff -r 75a544b48e66 -r 23db444e4c8d plugins/staticpages/services.inc.php
--- a/plugins/staticpages/services.inc.php	Fri Dec 23 13:13:22 2011 -0500
+++ b/plugins/staticpages/services.inc.php	Fri Dec 23 13:19:32 2011 -0500
@@ -110,11 +110,6 @@
         $args['sp_content'] = $args['content'];
     }
 
-    if (isset($args['category']) && is_array($args['category']) &&
-            !empty($args['category'][0])) {
-        $args['sp_tid'] = $args['category'][0];
-    }
-
     if (!isset($args['owner_id'])) {
         $args['owner_id'] = $_USER['uid'];
     }
@@ -140,7 +135,7 @@
 
     // Apply filters to the parameters passed by the webservice 
     if ($args['gl_svc']) {



More information about the geeklog-cvs mailing list