[geeklog-cvs] geeklog: Added new option $_CONF['article_comment_close_enabled'...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Oct 11 05:04:50 EDT 2009


changeset 7370:e5bbed84d3b1
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/e5bbed84d3b1
user: Dirk Haun <dirk at haun-online.de>
date: Sun Oct 11 11:00:55 2009 +0200
description:
Added new option $_CONF['article_comment_close_enabled'] to enable/disable automatically closing stories for comments after a certain amount of days (bug #0000959). Changed handling of comment_expire field in gl_stories such that 0 means the story is always open for comments.

diffstat:

 language/english.php                         |    1 +
 language/english_utf-8.php                   |    1 +
 language/german.php                          |    1 +
 language/german_formal.php                   |    1 +
 language/german_formal_utf-8.php             |    1 +
 language/german_utf-8.php                    |    1 +
 public_html/admin/install/config-install.php |    1 +
 public_html/admin/story.php                  |    6 +-
 public_html/docs/english/config.html         |    7 +
 public_html/docs/history                     |    4 +
 sql/updates/mssql_1.6.0_to_1.6.1.php         |    3 +
 sql/updates/mysql_1.6.0_to_1.6.1.php         |    3 +
 system/classes/story.class.php               |  110 ++++++++++++++++++---------
 13 files changed, 100 insertions(+), 40 deletions(-)

diffs (truncated from 382 to 300 lines):

diff -r 47573867cc1d -r e5bbed84d3b1 language/english.php
--- a/language/english.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/english.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1859,6 +1859,7 @@
     'atom_max_stories' => "Max. Stories in Webservices Feed",
     'disable_webservices' => 'Disable Webservices?',
     'restrict_webservices' => 'Restrict Webservices?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Days to close comments (default)',
     'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
     'allow_reply_notifications' => 'Allow comment reply notifications?',
diff -r 47573867cc1d -r e5bbed84d3b1 language/english_utf-8.php
--- a/language/english_utf-8.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/english_utf-8.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1859,6 +1859,7 @@
     'atom_max_stories' => "Max. Stories in Webservices Feed",
     'disable_webservices' => 'Disable Webservices?',
     'restrict_webservices' => 'Restrict Webservices?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Days to close comments (default)',
     'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
     'allow_reply_notifications' => 'Allow comment reply notifications?',
diff -r 47573867cc1d -r e5bbed84d3b1 language/german.php
--- a/language/german.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/german.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1853,6 +1853,7 @@
     'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
     'disable_webservices' => 'Webservices ausschalten?',
     'restrict_webservices' => 'Webservices beschränken?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Days to close comments (default)',
     'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
     'allow_reply_notifications' => 'Allow comment reply notifications?',
diff -r 47573867cc1d -r e5bbed84d3b1 language/german_formal.php
--- a/language/german_formal.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/german_formal.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1854,6 +1854,7 @@
     'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
     'disable_webservices' => 'Webservices ausschalten?',
     'restrict_webservices' => 'Webservices beschränken?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Tage nach denen Kommentare uneditierbar werden (hier nur Grundeinstellung)',
     'comment_close_rec_stories' => 'Anzahl letzter Artikel, die kommentierbar sein sollen',
     'allow_reply_notifications' => 'Benachrichtigung auf Kommentare erlauben?',
diff -r 47573867cc1d -r e5bbed84d3b1 language/german_formal_utf-8.php
--- a/language/german_formal_utf-8.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/german_formal_utf-8.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1854,6 +1854,7 @@
     'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
     'disable_webservices' => 'Webservices ausschalten?',
     'restrict_webservices' => 'Webservices beschränken?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Tage nach denen Kommentare uneditierbar werden (hier nur Grundeinstellung)',
     'comment_close_rec_stories' => 'Anzahl letzter Artikel, die kommentierbar sein sollen',
     'allow_reply_notifications' => 'Benachrichtigung auf Kommentare erlauben?',
diff -r 47573867cc1d -r e5bbed84d3b1 language/german_utf-8.php
--- a/language/german_utf-8.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/language/german_utf-8.php	Sun Oct 11 11:00:55 2009 +0200
@@ -1853,6 +1853,7 @@
     'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
     'disable_webservices' => 'Webservices ausschalten?',
     'restrict_webservices' => 'Webservices beschränken?',
+    'article_comment_close_enabled' => 'Automatically close comments (default)',
     'article_comment_close_days' => 'Days to close comments (default)',
     'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
     'allow_reply_notifications' => 'Allow comment reply notifications?',
diff -r 47573867cc1d -r e5bbed84d3b1 public_html/admin/install/config-install.php
--- a/public_html/admin/install/config-install.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/public_html/admin/install/config-install.php	Sun Oct 11 11:00:55 2009 +0200
@@ -232,6 +232,7 @@
     $c->add('comment_edit',0,'select',4,21,0,1680,TRUE);
     $c->add('commentsubmission',0,'select',4,21,0, 1682, TRUE);
     $c->add('comment_edittime',1800,'text',4,21,NULL,1684,TRUE);
+    $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
     $c->add('article_comment_close_days',30,'text',4,21,NULL,1686,TRUE);
     $c->add('comment_close_rec_stories',0,'text',4,21,NULL,1688,TRUE);
     $c->add('allow_reply_notifications',0,'select',4,21,0, 1689, TRUE);
diff -r 47573867cc1d -r e5bbed84d3b1 public_html/admin/story.php
--- a/public_html/admin/story.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/public_html/admin/story.php	Sun Oct 11 11:00:55 2009 +0200
@@ -577,9 +577,9 @@
             COM_optionList ($_TABLES['trackbackcodes'], 'code,name',
                             $story->EditElements('trackbackcode')));
     // comment expire 
-    $story_templates->set_var ('lang_cmt_disable', $LANG24[63]);
-    if ($story->EditElements('cmt_close') ) {
-        $story_templates->set_var('is_checked5', 'checked="checked"'); //check box if enabled
+    $story_templates->set_var('lang_cmt_disable', $LANG24[63]);
+    if ($story->EditElements('cmt_close')) {
+        $story_templates->set_var('is_checked5', 'checked="checked"');
         $story_templates->set_var('showcmtclosedisabled', 'false');
     } else {
         $story_templates->set_var('showcmtclosedisabled', 'true');
diff -r 47573867cc1d -r e5bbed84d3b1 public_html/docs/english/config.html
--- a/public_html/docs/english/config.html	Sat Oct 10 23:08:42 2009 +0200
+++ b/public_html/docs/english/config.html	Sun Oct 11 11:00:55 2009 +0200
@@ -949,6 +949,13 @@
     submitted it. Requires that comments are editable (see <a href="#desc_comment_edit">above</a>). Anonymous users (those that did not register an account) can
     never edit their comments while admins can always edit comments.</td></tr>
 <tr>
+  <td valign="top"><a name="desc_article_comment_close_enabled">article_comment_close_enabled</a></td>
+  <td valign="top">0</td>
+  <td valign="top">Whether or not stories should be closed for comments after
+    a certain amount of days (see next option). This is only the default
+    setting for new stories and can be changed separately for each
+    story.</td></tr>
+<tr>
   <td valign="top"><a name="desc_article_comment_close_days">article_comment_close_days</a></td>
   <td valign="top">30</td>
   <td valign="top">Number of days after which a story is to be automatically
diff -r 47573867cc1d -r e5bbed84d3b1 public_html/docs/history
--- a/public_html/docs/history	Sat Oct 10 23:08:42 2009 +0200
+++ b/public_html/docs/history	Sun Oct 11 11:00:55 2009 +0200
@@ -3,6 +3,10 @@
 Oct ??, 2009 (1.6.1)
 ------------
 
+- Added new option $_CONF['article_comment_close_enabled'] to enable/disable
+  automatically closing stories for comments after a certain amount of days
+  (bug #0000959). Changed handling of comment_expire field in gl_stories such
+  that 0 means the story is always open for comments [Dirk]
 - The "Admin Group" checkbox in the Group Editor didn't work (bug #0000995,
   reported & fix provided by Tsuchi)
 - Setting $_CONF['article_comment_close_days'] to a high value (to work around
diff -r 47573867cc1d -r e5bbed84d3b1 sql/updates/mssql_1.6.0_to_1.6.1.php
--- a/sql/updates/mssql_1.6.0_to_1.6.1.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/sql/updates/mssql_1.6.0_to_1.6.1.php	Sun Oct 11 11:00:55 2009 +0200
@@ -23,6 +23,9 @@
     $c->add('meta_description','Geeklog, the open source content management system designed with security in mind.','text',0,0,NULL,2010,TRUE);
     $c->add('meta_keywords','Geeklog, Blog, Content Management System, CMS, Open Source, Security','text',0,0,NULL,2020,TRUE);
 
+    // new option to enable / disable closing of comments after x days
+    $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
+
     return true;
 }
 
diff -r 47573867cc1d -r e5bbed84d3b1 sql/updates/mysql_1.6.0_to_1.6.1.php
--- a/sql/updates/mysql_1.6.0_to_1.6.1.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/sql/updates/mysql_1.6.0_to_1.6.1.php	Sun Oct 11 11:00:55 2009 +0200
@@ -24,6 +24,9 @@
     $c->add('meta_description','Geeklog, the open source content management system designed with security in mind.','text',0,0,NULL,2010,TRUE);
     $c->add('meta_keywords','Geeklog, Blog, Content Management System, CMS, Open Source, Security','text',0,0,NULL,2020,TRUE);
 
+    // new option to enable / disable closing of comments after x days
+    $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
+
     return true;
 }
 
diff -r 47573867cc1d -r e5bbed84d3b1 system/classes/story.class.php
--- a/system/classes/story.class.php	Sat Oct 10 23:08:42 2009 +0200
+++ b/system/classes/story.class.php	Sun Oct 11 11:00:55 2009 +0200
@@ -263,11 +263,6 @@
                 STORY_AL_NUMERIC,
                 '_frontpage'
               ),
-            'comment_expire' => array
-              (
-                STORY_AL_NUMERIC,
-                '_comment_expire'
-              ),
            'commentcode' => array
               (
                 STORY_AL_NUMERIC,
@@ -404,15 +399,17 @@
 
         // Overwrite the date with the timestamp.
         $this->_date = $story['unixdate'];
+
         if (!empty($story['expireunix'])) {
             $this->_expire = $story['expireunix'];
         } else {
-            $this->_expire = '0';
+            $this->_expire = 0;
         }
+
         if (!empty($story['cmt_expire_unix'])) {
             $this->_comment_expire = $story['cmt_expire_unix'];
         } else {
-            $this->_comment_expire = '0';
+            $this->_comment_expire = 0;
         }
 
         // Store the original SID
@@ -471,6 +468,12 @@
             }
             $this->_date = time();
             $this->_expire = time();
+            if ($_CONF['article_comment_close_enabled']) {
+                $this->_comment_expire = time() +
+                    ($_CONF['article_comment_close_days'] * 86400);
+            } else {
+                $this->_comment_expire = 0;
+            }
             $this->_commentcode = $_CONF['comment_code'];
             $this->_trackbackcode = $_CONF['trackback_code'];
             $this->_title = '';
@@ -570,7 +573,12 @@
             $this->_trackbackcode = $_CONF['trackback_code'];
             $this->_featured = 0;
             $this->_expire = time();
-            $this->_expiredate = 0;
+            if ($_CONF['article_comment_close_enabled']) {
+                $this->_comment_expire = time() +
+                    ($_CONF['article_comment_close_days'] * 86400);
+            } else {
+                $this->_comment_expire = 0;
+            }
 
             if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$this->_tid}'") == 1) {
                 $this->_frontpage = 0;
@@ -697,7 +705,8 @@
             if ($save === 1) {
                 $varname = '_' . $fieldname;
                 $sql .= $fieldname . ', ';
-                if (($fieldname == 'date') || ($fieldname == 'expire') || ($fieldname == 'comment_expire')) {
+                if (($fieldname == 'date') || ($fieldname == 'expire') ||
+                        ($fieldname == 'comment_expire')) {
                     // let the DB server do this conversion (cf. timezone hack)
                     $values .= 'FROM_UNIXTIME(' . $this->{$varname} . '), ';
                 } else {
@@ -861,7 +870,12 @@
 
         $this->_expire = time();
         $this->_date = time();
-        $this->_expiredate = 0;
+        if ($_CONF['article_comment_close_enabled']) {
+            $this->_comment_expire = time() +
+                ($_CONF['article_comment_close_days'] * 86400);
+        } else {
+            $this->_comment_expire = 0;
+        }
 
         // Handle Magic GPC Garbage:
         while (list($key, $value) = each($array))
@@ -1292,7 +1306,7 @@
     /**
      * Provide access to story elements. For the editor.
      *
-     * This is a peudo-property, implementing a getter for story
+     * This is a pseudo-property, implementing a getter for story
      * details as if as an associative array. Personally, I'd
      * rather be able to assign getters and setters to actual
      * properties to mask controlled access to private member
@@ -1383,43 +1397,67 @@
             break;
 
         case 'cmt_close':
-            if (isset($this->_comment_expire) && $this->_comment_expire != 0) {
-                $return = true;
+            $return = ($this->_comment_expire == 0) ? false : true;
+
+            break;
+
+        case 'cmt_close_second':
+            if ($this->_comment_expire == 0) {
+                $return = date('s', time() +
+                               ($_CONF['article_comment_close_days'] * 86400));
             } else {
-                $return = false;
-                //return default expire time to form
-                $this->_comment_expire = $this->_date + ($_CONF['article_comment_close_days']*86400);
+                $return = date('s', $this->_comment_expire);
             }
-            
-            break;
-            
-        case 'cmt_close_second':
-            $return = date('s', $this->_comment_expire);
 
             break;
 
         case 'cmt_close_minute':
-            $return = date('i', $this->_comment_expire);
+            if ($this->_comment_expire == 0) {
+                $return = date('i', time() +
+                               ($_CONF['article_comment_close_days'] * 86400));
+            } else {
+                $return = date('i', $this->_comment_expire);
+            }
 
             break;
 
         case 'cmt_close_hour':
-            $return = date('H', $this->_comment_expire);
+            if ($this->_comment_expire == 0) {
+                $return = date('H', time() +
+                               ($_CONF['article_comment_close_days'] * 86400));
+            } else {
+                $return = date('H', $this->_comment_expire);
+            }
 
             break;
 
         case 'cmt_close_day':
-            $return = date('d', $this->_comment_expire);
+            if ($this->_comment_expire == 0) {
+                $return = date('d', time() +
+                               ($_CONF['article_comment_close_days'] * 86400));



More information about the geeklog-cvs mailing list