AntonLV 9 лет назад
Родитель
Сommit
cd9fba1868

+ 12 - 0
inc/classes/BxDolCmtsQuery.php

@@ -209,6 +209,18 @@ class BxDolCmtsQuery extends BxDolDb
 
 
                 break;
                 break;
 
 
+            case 'object_id':
+        		$aMethod['params'][1]['cmt_object_id'] = (int)$aParams['object_id'];
+
+        		$sWhereClause .= " AND `{$this->_sTable}`.`cmt_object_id` = :cmt_object_id";
+
+                $sOrderClause = "`{$this->_sTable}`.`cmt_time` ASC";
+                $sLimitClause = "";
+                if(isset($aParams['per_page']))
+                	$sLimitClause = $this->prepareAsString("?, ?", $aParams['start'], $aParams['per_page']);
+
+                break;
+
             case 'all_ids':
             case 'all_ids':
                 $aMethod['name'] = 'getColumn';
                 $aMethod['name'] = 'getColumn';
 
 

+ 41 - 2
modules/boonex/forum/classes/BxForumAlertsResponse.php

@@ -19,11 +19,50 @@ class BxForumAlertsResponse extends BxBaseModTextAlertsResponse
 
 
     public function response($oAlert)
     public function response($oAlert)
     {
     {
-        if ($this->MODULE == $oAlert->sUnit && 'commentPost' == $oAlert->sAction)
-            BxDolService::call($this->MODULE, 'trigger_comment_post', array($oAlert->iObject, $oAlert->aExtras['comment_author_id'], $oAlert->aExtras['comment_id'], 0, $oAlert->aExtras['comment_text']));
+        $sMethod = 'process' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
+    	if(method_exists($this, $sMethod))
+    		$this->$sMethod($oAlert);
 
 
         parent::response($oAlert);
         parent::response($oAlert);
     }
     }
+
+    protected function processBxForumCommentPost($oAlert)
+    {
+        $this->updateCommentsSummary($oAlert->iObject);
+
+        $this->_oModule->serviceTriggerCommentPost($oAlert->iObject, $oAlert->aExtras['comment_author_id'], $oAlert->aExtras['comment_id'], 0, $oAlert->aExtras['comment_text']);
+    }
+    
+    protected function processBxForumCommentUpdated($oAlert)
+    {
+        $this->updateCommentsSummary($oAlert->iObject);
+    }
+
+    protected function processBxForumCommentRemoved($oAlert)
+    {
+        $this->updateCommentsSummary($oAlert->iObject);
+    }
+    
+    protected function updateCommentsSummary($iContentId)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId)->getQueryObject()->getCommentsBy(array(
+        	'type' => 'object_id', 
+        	'object_id' => $iContentId
+        ));
+        if(empty($aCmts) || !is_array($aCmts))
+            return;
+
+        $sResult = '';
+        foreach($aCmts as $aCmt)
+            $sResult .= strip_tags($aCmt['cmt_text']) . "\n\r";
+
+        if(empty($sResult))
+            return;
+
+        $this->_oModule->_oDb->updateEntries(array($CNF['FIELD_TEXT_COMMENTS'] => $sResult), array($CNF['FIELD_ID'] => $iContentId));
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 1 - 0
modules/boonex/forum/classes/BxForumConfig.php

@@ -45,6 +45,7 @@ class BxForumConfig extends BxBaseModTextConfig
             'FIELD_TITLE' => 'title',
             'FIELD_TITLE' => 'title',
             'FIELD_TEXT' => 'text',
             'FIELD_TEXT' => 'text',
             'FIELD_TEXT_ID' => 'discussion-text',
             'FIELD_TEXT_ID' => 'discussion-text',
+            'FIELD_TEXT_COMMENTS' => 'text_comments',
         	'FIELD_CATEGORY' => 'cat',
         	'FIELD_CATEGORY' => 'cat',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
             'FIELD_PHOTO' => 'attachments',
             'FIELD_PHOTO' => 'attachments',

+ 6 - 5
modules/boonex/forum/install/sql/enable.sql

@@ -265,9 +265,9 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 
 
 -- GRIDS: main
 -- GRIDS: main
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
-(@sName, 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php'),
-('bx_forum_favorite', 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php'),
-('bx_forum_feature', 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php');
+(@sName, 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text,text_comments', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php'),
+('bx_forum_favorite', 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text,text_comments', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php'),
+('bx_forum_feature', 'Sql', 'SELECT `bx_forum_discussions`.*, `bx_forum_cmts`.`cmt_text` AS `cmt_text` FROM `bx_forum_discussions` LEFT JOIN `bx_forum_cmts` ON (`bx_forum_cmts`.`cmt_id` = `bx_forum_discussions`.`lr_comment_id`) %s WHERE 1 %s', 'bx_forum_discussions', 'id', 'lr_timestamp', '', 10, NULL, 'start', '', 'title,text,text_comments', 'auto', '', 2147483647, 'BxForumGrid', 'modules/boonex/forum/classes/BxForumGrid.php');
 
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
 (@sName, 'author', '', '10%', '', 1),
 (@sName, 'author', '', '10%', '', 1),
@@ -476,9 +476,10 @@ SET @iHandler := LAST_INSERT_ID();
 
 
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 ('system', 'save_setting', @iHandler),
 ('system', 'save_setting', @iHandler),
+('profile', 'delete', @iHandler),
 (@sName, 'commentPost', @iHandler),
 (@sName, 'commentPost', @iHandler),
-(@sName, 'commentRemoved', @iHandler),
-('profile', 'delete', @iHandler);
+(@sName, 'commentUpdated', @iHandler),
+(@sName, 'commentRemoved', @iHandler);
 
 
 
 
 -- EMAIL TEMPLATES
 -- EMAIL TEMPLATES

+ 2 - 1
modules/boonex/forum/install/sql/install.sql

@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
   `title` varchar(255) NOT NULL,
   `title` varchar(255) NOT NULL,
   `cat` int(11) NOT NULL,
   `cat` int(11) NOT NULL,
   `text` text NOT NULL,
   `text` text NOT NULL,
+  `text_comments` text NOT NULL,
   `lr_timestamp` int(11) NOT NULL,
   `lr_timestamp` int(11) NOT NULL,
   `lr_profile_id` int(10) unsigned NOT NULL,
   `lr_profile_id` int(10) unsigned NOT NULL,
   `lr_comment_id` int(11) NOT NULL,
   `lr_comment_id` int(11) NOT NULL,
@@ -26,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `bx_forum_discussions` (
   `status` enum('active','draft','hidden') NOT NULL DEFAULT 'active',
   `status` enum('active','draft','hidden') NOT NULL DEFAULT 'active',
   `status_admin` enum('active','hidden') NOT NULL DEFAULT 'active',
   `status_admin` enum('active','hidden') NOT NULL DEFAULT 'active',
   PRIMARY KEY (`id`),
   PRIMARY KEY (`id`),
-  FULLTEXT KEY `title_text` (`title`,`text`),
+  FULLTEXT KEY `title_text` (`title`,`text`,`text_comments`),
   KEY `lr_timestamp` (`lr_timestamp`)
   KEY `lr_timestamp` (`lr_timestamp`)
 );
 );