RomanL il y a 7 ans
Parent
commit
2cd2e08922

+ 2 - 1
modules/boonex/posts/classes/BxPostsConfig.php

@@ -55,7 +55,8 @@ class BxPostsConfig extends BxBaseModTextConfig
             'FIELD_LABELS' => 'labels',
             'FIELD_ANONYMOUS' => 'anonymous',
             'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
-
+            'FIELD_DISABLE_COMMENTS' => 'disable_comments',
+            
             // page URIs
             'URI_VIEW_ENTRY' => 'view-post',
             'URI_AUTHOR_ENTRIES' => 'posts-author',

+ 20 - 0
modules/boonex/posts/classes/BxPostsModule.php

@@ -58,6 +58,26 @@ class BxPostsModule extends BxBaseModTextModule
 
         return '';
     }
+    
+    public function serviceCheckAllowedCommentsPost($iContentId, $sObjectComments) 
+    {
+		$CNF = &$this->_oConfig->CNF;
+		$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+		if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
+			return false;
+
+        return parent::serviceCheckAllowedCommentsPost($iContentId, $sObjectComments);
+    }
+	
+	public function serviceCheckAllowedCommentsView($iContentId, $sObjectComments) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+		$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+		if ($aContentInfo[$CNF['FIELD_DISABLE_COMMENTS']] == 1)
+			return false;
+
+        return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
+    }
 }
 
 /** @} */

+ 2 - 0
modules/boonex/posts/install/langs/en.xml

@@ -56,6 +56,8 @@
     <string name="_bx_posts_form_entry_input_date_published"><![CDATA[Publish at]]></string>
     <string name="_bx_posts_form_entry_input_date_published_info"><![CDATA[Leave empty to publish immediately.]]></string>
     <string name="_bx_posts_form_entry_input_sys_attachments"><![CDATA[Attachments]]></string>
+    <string name="_bx_posts_form_entry_input_sys_disable_comments"><![CDATA[Disable comments]]></string>
+    <string name="_bx_posts_form_entry_input_disable_comments"><![CDATA[Disable comments]]></string>
 
     <string name="_bx_posts_form_poll"><![CDATA[Polls]]></string>
     <string name="_bx_posts_form_poll_display_add"><![CDATA[Add Poll]]></string>

+ 9 - 4
modules/boonex/posts/install/sql/install.sql

@@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS `bx_posts_posts` (
   `reports` int(11) NOT NULL default '0',
   `featured` int(11) NOT NULL default '0',
   `allow_view_to` int(11) NOT NULL DEFAULT '3',
+  `disable_comments` tinyint(4) NOT NULL DEFAULT '0',
   `status` enum('active','awaiting','hidden') NOT NULL DEFAULT 'active',
   `status_admin` enum('active','hidden') NOT NULL DEFAULT 'active',
   PRIMARY KEY (`id`),
@@ -383,7 +384,9 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_posts', 'bx_posts', 'published', '', '', 0, 'datetime', '_bx_posts_form_entry_input_sys_date_published', '_bx_posts_form_entry_input_date_published', '_bx_posts_form_entry_input_date_published_info', 0, 0, 0, '', '', '', '', '', '', 'DateTimeUtc', '', 1, 0),
 ('bx_posts', 'bx_posts', 'attachments', '', '', 0, 'custom', '_bx_posts_form_entry_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_posts', 'bx_posts', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_posts', 'bx_posts', 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0);
+('bx_posts', 'bx_posts', 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_posts', 'bx_posts', 'disable_comments', '1', '', 0, 'switcher', '_bx_posts_form_entry_input_sys_disable_comments', '_bx_posts_form_entry_input_disable_comments', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0);
+
 
 
 INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES 
@@ -400,7 +403,8 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_posts_entry_add', 'allow_view_to', 2147483647, 1, 11),
 ('bx_posts_entry_add', 'location', 2147483647, 1, 12),
 ('bx_posts_entry_add', 'published', 192, 1, 13),
-('bx_posts_entry_add', 'do_publish', 2147483647, 1, 14),
+('bx_posts_entry_add', 'disable_comments', 192, 1, 14),
+('bx_posts_entry_add', 'do_publish', 2147483647, 1, 15),
 
 ('bx_posts_entry_delete', 'delete_confirm', 2147483647, 1, 1),
 ('bx_posts_entry_delete', 'do_submit', 2147483647, 1, 2),
@@ -418,8 +422,9 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_posts_entry_edit', 'covers', 2147483647, 1, 11),
 ('bx_posts_entry_edit', 'allow_view_to', 2147483647, 1, 12),
 ('bx_posts_entry_edit', 'location', 2147483647, 1, 13),
-('bx_posts_entry_edit', 'published', 192, 1, 14),
-('bx_posts_entry_edit', 'do_submit', 2147483647, 1, 15),
+('bx_posts_entry_edit', 'disable_comments', 192, 1, 14),
+('bx_posts_entry_edit', 'published', 192, 1, 15),
+('bx_posts_entry_edit', 'do_submit', 2147483647, 1, 16),
 
 ('bx_posts_entry_view', 'cat', 2147483647, 1, 1),
 ('bx_posts_entry_view', 'added', 2147483647, 1, 2),

+ 2 - 0
modules/boonex/russian/data/langs/bx_posts/ru.xml

@@ -56,6 +56,8 @@
     <string name="_bx_posts_form_entry_input_date_published"><![CDATA[Опубликовано]]></string>
     <string name="_bx_posts_form_entry_input_date_published_info"><![CDATA[Оставьте пустым, чтобы опубликовать немедленно.]]></string>
     <string name="_bx_posts_form_entry_input_sys_attachments"><![CDATA[Вложения]]></string>
+    <string name="_bx_posts_form_entry_input_sys_disable_comments"><![CDATA[Запретить комментарии]]></string>
+    <string name="_bx_posts_form_entry_input_disable_comments"><![CDATA[Запретить комментарии]]></string>
 
     <string name="_bx_posts_form_poll"><![CDATA[Голосования]]></string>
     <string name="_bx_posts_form_poll_display_add"><![CDATA[Добавить голосование]]></string>