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.
1.1 --- a/language/english.php Sat Oct 10 23:08:42 2009 +0200
1.2 +++ b/language/english.php Sun Oct 11 11:00:55 2009 +0200
1.3 @@ -1859,6 +1859,7 @@
1.4 'atom_max_stories' => "Max. Stories in Webservices Feed",
1.5 'disable_webservices' => 'Disable Webservices?',
1.6 'restrict_webservices' => 'Restrict Webservices?',
1.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
1.8 'article_comment_close_days' => 'Days to close comments (default)',
1.9 'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
1.10 'allow_reply_notifications' => 'Allow comment reply notifications?',
2.1 --- a/language/english_utf-8.php Sat Oct 10 23:08:42 2009 +0200
2.2 +++ b/language/english_utf-8.php Sun Oct 11 11:00:55 2009 +0200
2.3 @@ -1859,6 +1859,7 @@
2.4 'atom_max_stories' => "Max. Stories in Webservices Feed",
2.5 'disable_webservices' => 'Disable Webservices?',
2.6 'restrict_webservices' => 'Restrict Webservices?',
2.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
2.8 'article_comment_close_days' => 'Days to close comments (default)',
2.9 'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
2.10 'allow_reply_notifications' => 'Allow comment reply notifications?',
3.1 --- a/language/german.php Sat Oct 10 23:08:42 2009 +0200
3.2 +++ b/language/german.php Sun Oct 11 11:00:55 2009 +0200
3.3 @@ -1853,6 +1853,7 @@
3.4 'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
3.5 'disable_webservices' => 'Webservices ausschalten?',
3.6 'restrict_webservices' => 'Webservices beschränken?',
3.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
3.8 'article_comment_close_days' => 'Days to close comments (default)',
3.9 'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
3.10 'allow_reply_notifications' => 'Allow comment reply notifications?',
4.1 --- a/language/german_formal.php Sat Oct 10 23:08:42 2009 +0200
4.2 +++ b/language/german_formal.php Sun Oct 11 11:00:55 2009 +0200
4.3 @@ -1854,6 +1854,7 @@
4.4 'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
4.5 'disable_webservices' => 'Webservices ausschalten?',
4.6 'restrict_webservices' => 'Webservices beschränken?',
4.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
4.8 'article_comment_close_days' => 'Tage nach denen Kommentare uneditierbar werden (hier nur Grundeinstellung)',
4.9 'comment_close_rec_stories' => 'Anzahl letzter Artikel, die kommentierbar sein sollen',
4.10 'allow_reply_notifications' => 'Benachrichtigung auf Kommentare erlauben?',
5.1 --- a/language/german_formal_utf-8.php Sat Oct 10 23:08:42 2009 +0200
5.2 +++ b/language/german_formal_utf-8.php Sun Oct 11 11:00:55 2009 +0200
5.3 @@ -1854,6 +1854,7 @@
5.4 'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
5.5 'disable_webservices' => 'Webservices ausschalten?',
5.6 'restrict_webservices' => 'Webservices beschränken?',
5.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
5.8 'article_comment_close_days' => 'Tage nach denen Kommentare uneditierbar werden (hier nur Grundeinstellung)',
5.9 'comment_close_rec_stories' => 'Anzahl letzter Artikel, die kommentierbar sein sollen',
5.10 'allow_reply_notifications' => 'Benachrichtigung auf Kommentare erlauben?',
6.1 --- a/language/german_utf-8.php Sat Oct 10 23:08:42 2009 +0200
6.2 +++ b/language/german_utf-8.php Sun Oct 11 11:00:55 2009 +0200
6.3 @@ -1853,6 +1853,7 @@
6.4 'atom_max_stories' => 'Max. Artikel im Webservices-Feed',
6.5 'disable_webservices' => 'Webservices ausschalten?',
6.6 'restrict_webservices' => 'Webservices beschränken?',
6.7 + 'article_comment_close_enabled' => 'Automatically close comments (default)',
6.8 'article_comment_close_days' => 'Days to close comments (default)',
6.9 'comment_close_rec_stories' => 'Number of most recent stories enabled for comments',
6.10 'allow_reply_notifications' => 'Allow comment reply notifications?',
7.1 --- a/public_html/admin/install/config-install.php Sat Oct 10 23:08:42 2009 +0200
7.2 +++ b/public_html/admin/install/config-install.php Sun Oct 11 11:00:55 2009 +0200
7.3 @@ -232,6 +232,7 @@
7.4 $c->add('comment_edit',0,'select',4,21,0,1680,TRUE);
7.5 $c->add('commentsubmission',0,'select',4,21,0, 1682, TRUE);
7.6 $c->add('comment_edittime',1800,'text',4,21,NULL,1684,TRUE);
7.7 + $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
7.8 $c->add('article_comment_close_days',30,'text',4,21,NULL,1686,TRUE);
7.9 $c->add('comment_close_rec_stories',0,'text',4,21,NULL,1688,TRUE);
7.10 $c->add('allow_reply_notifications',0,'select',4,21,0, 1689, TRUE);
8.1 --- a/public_html/admin/story.php Sat Oct 10 23:08:42 2009 +0200
8.2 +++ b/public_html/admin/story.php Sun Oct 11 11:00:55 2009 +0200
8.3 @@ -577,9 +577,9 @@
8.4 COM_optionList ($_TABLES['trackbackcodes'], 'code,name',
8.5 $story->EditElements('trackbackcode')));
8.6 // comment expire
8.7 - $story_templates->set_var ('lang_cmt_disable', $LANG24[63]);
8.8 - if ($story->EditElements('cmt_close') ) {
8.9 - $story_templates->set_var('is_checked5', 'checked="checked"'); //check box if enabled
8.10 + $story_templates->set_var('lang_cmt_disable', $LANG24[63]);
8.11 + if ($story->EditElements('cmt_close')) {
8.12 + $story_templates->set_var('is_checked5', 'checked="checked"');
8.13 $story_templates->set_var('showcmtclosedisabled', 'false');
8.14 } else {
8.15 $story_templates->set_var('showcmtclosedisabled', 'true');
9.1 --- a/public_html/docs/english/config.html Sat Oct 10 23:08:42 2009 +0200
9.2 +++ b/public_html/docs/english/config.html Sun Oct 11 11:00:55 2009 +0200
9.3 @@ -949,6 +949,13 @@
9.4 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
9.5 never edit their comments while admins can always edit comments.</td></tr>
9.6 <tr>
9.7 + <td valign="top"><a name="desc_article_comment_close_enabled">article_comment_close_enabled</a></td>
9.8 + <td valign="top">0</td>
9.9 + <td valign="top">Whether or not stories should be closed for comments after
9.10 + a certain amount of days (see next option). This is only the default
9.11 + setting for new stories and can be changed separately for each
9.12 + story.</td></tr>
9.13 +<tr>
9.14 <td valign="top"><a name="desc_article_comment_close_days">article_comment_close_days</a></td>
9.15 <td valign="top">30</td>
9.16 <td valign="top">Number of days after which a story is to be automatically
10.1 --- a/public_html/docs/history Sat Oct 10 23:08:42 2009 +0200
10.2 +++ b/public_html/docs/history Sun Oct 11 11:00:55 2009 +0200
10.3 @@ -3,6 +3,10 @@
10.4 Oct ??, 2009 (1.6.1)
10.5 ------------
10.6
10.7 +- Added new option $_CONF['article_comment_close_enabled'] to enable/disable
10.8 + automatically closing stories for comments after a certain amount of days
10.9 + (bug #0000959). Changed handling of comment_expire field in gl_stories such
10.10 + that 0 means the story is always open for comments [Dirk]
10.11 - The "Admin Group" checkbox in the Group Editor didn't work (bug #0000995,
10.12 reported & fix provided by Tsuchi)
10.13 - Setting $_CONF['article_comment_close_days'] to a high value (to work around
11.1 --- a/sql/updates/mssql_1.6.0_to_1.6.1.php Sat Oct 10 23:08:42 2009 +0200
11.2 +++ b/sql/updates/mssql_1.6.0_to_1.6.1.php Sun Oct 11 11:00:55 2009 +0200
11.3 @@ -23,6 +23,9 @@
11.4 $c->add('meta_description','Geeklog, the open source content management system designed with security in mind.','text',0,0,NULL,2010,TRUE);
11.5 $c->add('meta_keywords','Geeklog, Blog, Content Management System, CMS, Open Source, Security','text',0,0,NULL,2020,TRUE);
11.6
11.7 + // new option to enable / disable closing of comments after x days
11.8 + $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
11.9 +
11.10 return true;
11.11 }
11.12
12.1 --- a/sql/updates/mysql_1.6.0_to_1.6.1.php Sat Oct 10 23:08:42 2009 +0200
12.2 +++ b/sql/updates/mysql_1.6.0_to_1.6.1.php Sun Oct 11 11:00:55 2009 +0200
12.3 @@ -24,6 +24,9 @@
12.4 $c->add('meta_description','Geeklog, the open source content management system designed with security in mind.','text',0,0,NULL,2010,TRUE);
12.5 $c->add('meta_keywords','Geeklog, Blog, Content Management System, CMS, Open Source, Security','text',0,0,NULL,2020,TRUE);
12.6
12.7 + // new option to enable / disable closing of comments after x days
12.8 + $c->add('article_comment_close_enabled',0,'select',4,21,0, 1685, TRUE);
12.9 +
12.10 return true;
12.11 }
12.12
13.1 --- a/system/classes/story.class.php Sat Oct 10 23:08:42 2009 +0200
13.2 +++ b/system/classes/story.class.php Sun Oct 11 11:00:55 2009 +0200
13.3 @@ -263,11 +263,6 @@
13.4 STORY_AL_NUMERIC,
13.5 '_frontpage'
13.6 ),
13.7 - 'comment_expire' => array
13.8 - (
13.9 - STORY_AL_NUMERIC,
13.10 - '_comment_expire'
13.11 - ),
13.12 'commentcode' => array
13.13 (
13.14 STORY_AL_NUMERIC,
13.15 @@ -404,15 +399,17 @@
13.16
13.17 // Overwrite the date with the timestamp.
13.18 $this->_date = $story['unixdate'];
13.19 +
13.20 if (!empty($story['expireunix'])) {
13.21 $this->_expire = $story['expireunix'];
13.22 } else {
13.23 - $this->_expire = '0';
13.24 + $this->_expire = 0;
13.25 }
13.26 +
13.27 if (!empty($story['cmt_expire_unix'])) {
13.28 $this->_comment_expire = $story['cmt_expire_unix'];
13.29 } else {
13.30 - $this->_comment_expire = '0';
13.31 + $this->_comment_expire = 0;
13.32 }
13.33
13.34 // Store the original SID
13.35 @@ -471,6 +468,12 @@
13.36 }
13.37 $this->_date = time();
13.38 $this->_expire = time();
13.39 + if ($_CONF['article_comment_close_enabled']) {
13.40 + $this->_comment_expire = time() +
13.41 + ($_CONF['article_comment_close_days'] * 86400);
13.42 + } else {
13.43 + $this->_comment_expire = 0;
13.44 + }
13.45 $this->_commentcode = $_CONF['comment_code'];
13.46 $this->_trackbackcode = $_CONF['trackback_code'];
13.47 $this->_title = '';
13.48 @@ -570,7 +573,12 @@
13.49 $this->_trackbackcode = $_CONF['trackback_code'];
13.50 $this->_featured = 0;
13.51 $this->_expire = time();
13.52 - $this->_expiredate = 0;
13.53 + if ($_CONF['article_comment_close_enabled']) {
13.54 + $this->_comment_expire = time() +
13.55 + ($_CONF['article_comment_close_days'] * 86400);
13.56 + } else {
13.57 + $this->_comment_expire = 0;
13.58 + }
13.59
13.60 if (DB_getItem($_TABLES['topics'], 'archive_flag', "tid = '{$this->_tid}'") == 1) {
13.61 $this->_frontpage = 0;
13.62 @@ -697,7 +705,8 @@
13.63 if ($save === 1) {
13.64 $varname = '_' . $fieldname;
13.65 $sql .= $fieldname . ', ';
13.66 - if (($fieldname == 'date') || ($fieldname == 'expire') || ($fieldname == 'comment_expire')) {
13.67 + if (($fieldname == 'date') || ($fieldname == 'expire') ||
13.68 + ($fieldname == 'comment_expire')) {
13.69 // let the DB server do this conversion (cf. timezone hack)
13.70 $values .= 'FROM_UNIXTIME(' . $this->{$varname} . '), ';
13.71 } else {
13.72 @@ -861,7 +870,12 @@
13.73
13.74 $this->_expire = time();
13.75 $this->_date = time();
13.76 - $this->_expiredate = 0;
13.77 + if ($_CONF['article_comment_close_enabled']) {
13.78 + $this->_comment_expire = time() +
13.79 + ($_CONF['article_comment_close_days'] * 86400);
13.80 + } else {
13.81 + $this->_comment_expire = 0;
13.82 + }
13.83
13.84 // Handle Magic GPC Garbage:
13.85 while (list($key, $value) = each($array))
13.86 @@ -1292,7 +1306,7 @@
13.87 /**
13.88 * Provide access to story elements. For the editor.
13.89 *
13.90 - * This is a peudo-property, implementing a getter for story
13.91 + * This is a pseudo-property, implementing a getter for story
13.92 * details as if as an associative array. Personally, I'd
13.93 * rather be able to assign getters and setters to actual
13.94 * properties to mask controlled access to private member
13.95 @@ -1383,43 +1397,67 @@
13.96 break;
13.97
13.98 case 'cmt_close':
13.99 - if (isset($this->_comment_expire) && $this->_comment_expire != 0) {
13.100 - $return = true;
13.101 + $return = ($this->_comment_expire == 0) ? false : true;
13.102 +
13.103 + break;
13.104 +
13.105 + case 'cmt_close_second':
13.106 + if ($this->_comment_expire == 0) {
13.107 + $return = date('s', time() +
13.108 + ($_CONF['article_comment_close_days'] * 86400));
13.109 } else {
13.110 - $return = false;
13.111 - //return default expire time to form
13.112 - $this->_comment_expire = $this->_date + ($_CONF['article_comment_close_days']*86400);
13.113 + $return = date('s', $this->_comment_expire);
13.114 }
13.115 -
13.116 - break;
13.117 -
13.118 - case 'cmt_close_second':
13.119 - $return = date('s', $this->_comment_expire);
13.120
13.121 break;
13.122
13.123 case 'cmt_close_minute':
13.124 - $return = date('i', $this->_comment_expire);
13.125 + if ($this->_comment_expire == 0) {
13.126 + $return = date('i', time() +
13.127 + ($_CONF['article_comment_close_days'] * 86400));
13.128 + } else {
13.129 + $return = date('i', $this->_comment_expire);
13.130 + }
13.131
13.132 break;
13.133
13.134 case 'cmt_close_hour':
13.135 - $return = date('H', $this->_comment_expire);
13.136 + if ($this->_comment_expire == 0) {
13.137 + $return = date('H', time() +
13.138 + ($_CONF['article_comment_close_days'] * 86400));
13.139 + } else {
13.140 + $return = date('H', $this->_comment_expire);
13.141 + }
13.142
13.143 break;
13.144
13.145 case 'cmt_close_day':
13.146 - $return = date('d', $this->_comment_expire);
13.147 + if ($this->_comment_expire == 0) {
13.148 + $return = date('d', time() +
13.149 + ($_CONF['article_comment_close_days'] * 86400));
13.150 + } else {
13.151 + $return = date('d', $this->_comment_expire);
13.152 + }
13.153
13.154 break;
13.155
13.156 case 'cmt_close_month':
13.157 - $return = date('m', $this->_comment_expire);
13.158 + if ($this->_comment_expire == 0) {
13.159 + $return = date('m', time() +
13.160 + ($_CONF['article_comment_close_days'] * 86400));
13.161 + } else {
13.162 + $return = date('m', $this->_comment_expire);
13.163 + }
13.164
13.165 break;
13.166
13.167 case 'cmt_close_year':
13.168 - $return = date('Y', $this->_comment_expire);
13.169 + if ($this->_comment_expire == 0) {
13.170 + $return = date('Y', time() +
13.171 + ($_CONF['article_comment_close_days'] * 86400));
13.172 + } else {
13.173 + $return = date('Y', $this->_comment_expire);
13.174 + }
13.175
13.176 break;
13.177
13.178 @@ -1573,11 +1611,11 @@
13.179 break;
13.180
13.181 case 'commentcode':
13.182 - //check to see if comment_time has passed
13.183 + // check to see if comment_time has passed
13.184 if ($this->_comment_expire != 0 && (time() > $this->_comment_expire) && $this->_commentcode == 0 ) {
13.185 + // if comment code is not 1, change it to 1
13.186 + DB_query("UPDATE {$_TABLES['stories']} SET commentcode = '1' WHERE sid = '$this->_sid'");
13.187 $return = 1;
13.188 - //if comment code is not 1, change it to 1
13.189 - DB_query("UPDATE {$_TABLES['stories']} SET commentcode = '1' WHERE sid = '$this->_sid'");
13.190 } else {
13.191 $return = $this->_commentcode;
13.192 }
13.193 @@ -1895,7 +1933,7 @@
13.194
13.195 $this->_expire = $expiredate;
13.196
13.197 - //comment expire time
13.198 + // comment expire time
13.199 if (isset($array['cmt_close_flag'])) {
13.200 $cmt_close_ampm = COM_applyFilter($array['cmt_close_ampm']);
13.201 $cmt_close_hour = COM_applyFilter($array['cmt_close_hour'], true);
13.202 @@ -1914,11 +1952,13 @@
13.203 if ($cmt_close_ampm == 'am' AND $cmt_close_hour == 12) {
13.204 $cmt_close_hour = '00';
13.205 }
13.206 -
13.207 +
13.208 $cmt_close_date
13.209 = strtotime("$cmt_close_month/$cmt_close_day/$cmt_close_year $cmt_close_hour:$cmt_close_minute:$cmt_close_second");
13.210 -
13.211 +
13.212 $this->_comment_expire = $cmt_close_date;
13.213 + } else {
13.214 + $this->_comment_expire = 0;
13.215 }
13.216
13.217
13.218 @@ -2028,12 +2068,8 @@
13.219 } elseif ($this->_show_topic_icon != 1) {
13.220 $this->_show_topic_icon = 0;
13.221 }
13.222 + }
13.223
13.224 - if (empty($this->_comment_expire)) {
13.225 - $this->_comment_expire = $this->_date
13.226 - + ($_CONF['article_comment_close_days'] * 86400);
13.227 - }
13.228 - }
13.229 // End Private Methods.
13.230
13.231 /**************************************************************************/