Преглед изворни кода

Ticket #194: Integration with Timeline

AntonLV пре 10 година
родитељ
комит
5ae11d08fc

+ 12 - 0
modules/base/text/classes/BxBaseModTextModule.php

@@ -345,6 +345,17 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
                 'count' => $aContentInfo['votes']
                 'count' => $aContentInfo['votes']
             );
             );
 
 
+		//--- Reports
+        $oReports = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aEvent['object_id']);
+
+        $aReports = array();
+        if ($oReports && $oReports->isEnabled())
+            $aReports = array(
+                'system' => $CNF['OBJECT_REPORTS'],
+                'object_id' => $aContentInfo[$CNF['FIELD_ID']],
+                'count' => $aContentInfo['reports']
+            );
+
         //--- Comments
         //--- Comments
         $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']);
         $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']);
 
 
@@ -367,6 +378,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
             ), //a string to display or array to parse default template before displaying.
             ), //a string to display or array to parse default template before displaying.
             'date' => $aContentInfo[$CNF['FIELD_ADDED']],
             'date' => $aContentInfo[$CNF['FIELD_ADDED']],
             'votes' => $aVotes,
             'votes' => $aVotes,
+            'reports' => $aReports,
             'comments' => $aComments,
             'comments' => $aComments,
             'title' => '', //may be empty.
             'title' => '', //may be empty.
             'description' => '' //may be empty.
             'description' => '' //may be empty.

+ 1 - 0
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -83,6 +83,7 @@
     <string name="_bx_timeline_menu_item_title_item_comment"><![CDATA[Комментарий]]></string>
     <string name="_bx_timeline_menu_item_title_item_comment"><![CDATA[Комментарий]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_vote"><![CDATA[Голосовать]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_vote"><![CDATA[Голосовать]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_share"><![CDATA[Поделиться]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_share"><![CDATA[Поделиться]]></string>
+    <string name="_bx_timeline_menu_item_title_system_item_report"><![CDATA[Пожаловаться]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_more"><![CDATA[Ещё]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_more"><![CDATA[Ещё]]></string>
 
 
 	<string name="_bx_timeline_menu_title_post_attachments"><![CDATA[Форма - Прикрепления]]></string>
 	<string name="_bx_timeline_menu_title_post_attachments"><![CDATA[Форма - Прикрепления]]></string>

+ 3 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -47,6 +47,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         	// objects
         	// objects
             'OBJECT_COMMENTS' => $this->_sName,
             'OBJECT_COMMENTS' => $this->_sName,
         	'OBJECT_VOTES' => $this->_sName,
         	'OBJECT_VOTES' => $this->_sName,
+        	'OBJECT_REPORTS' => $this->_sName,
 
 
         	// some language keys
         	// some language keys
             'T' => array (
             'T' => array (
@@ -66,7 +67,8 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
 
 
         $this->_aObjects = array_merge($this->_aObjects, array(
         $this->_aObjects = array_merge($this->_aObjects, array(
         	'comment' => $this->CNF['OBJECT_COMMENTS'],
         	'comment' => $this->CNF['OBJECT_COMMENTS'],
-        	'vote' => $this->_sName,
+        	'vote' => $this->CNF['OBJECT_VOTES'],
+        	'report' => $this->CNF['OBJECT_REPORTS'],
         	'metatags' => $this->_sName,
         	'metatags' => $this->_sName,
 
 
         	'storage_photos' => $this->_sName . '_photos',
         	'storage_photos' => $this->_sName . '_photos',

+ 14 - 0
modules/boonex/timeline/classes/BxTimelineMenuItemActions.php

@@ -79,6 +79,16 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
     	return $this->_oModule->getVoteObject($sVotesSystem, $iVotesObject)->getElementInline(array('dynamic_mode' => $this->_bDynamicMode));
     	return $this->_oModule->getVoteObject($sVotesSystem, $iVotesObject)->getElementInline(array('dynamic_mode' => $this->_bDynamicMode));
     }
     }
 
 
+	protected function _getMenuItemItemReport($aItem)
+    {
+        if(!isset($this->_aEvent['reports']) || !is_array($this->_aEvent['reports']) || !isset($this->_aEvent['reports']['system'])) 
+        	return false;
+
+		$sReportsSystem = $this->_aEvent['reports']['system'];
+		$iReportsObject = $this->_aEvent['reports']['object_id'];
+    	return $this->_oModule->getReportObject($sReportsSystem, $iReportsObject)->getElementInline(array('dynamic_mode' => $this->_bDynamicMode));
+    }
+
 	protected function _getMenuItemItemShare($aItem)
 	protected function _getMenuItemItemShare($aItem)
     {
     {
 		$iOwnerId = $this->_oModule->getUserId(); //--- in whose timeline the content will be shared
 		$iOwnerId = $this->_oModule->getUserId(); //--- in whose timeline the content will be shared
@@ -108,6 +118,10 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
 
 
             case 'item-vote':
             case 'item-vote':
                 $sCheckFuncName = 'isAllowedVote';
                 $sCheckFuncName = 'isAllowedVote';
+                break;
+
+			case 'item-report':
+                $sCheckFuncName = 'isAllowedReport';
                 break;
                 break;
 
 
             case 'item-more':
             case 'item-more':

+ 42 - 0
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -714,6 +714,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return $oVote;
         return $oVote;
     }
     }
 
 
+	public function getReportObject($sSystem, $iId)
+    {
+        if(empty($sSystem) || (int)$iId == 0)
+            return false;
+
+        $oReport = BxDolReport::getObjectInstance($sSystem, $iId, true, $this->_oTemplate);
+        if(!$oReport->isEnabled())
+            return false;
+
+        return $oReport;
+    }
+
     public function getAttachmentsMenuObject()
     public function getAttachmentsMenuObject()
     {
     {
         $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
         $oMenu = BxDolMenu::getObjectInstance($this->_oConfig->getObject('menu_post_attachments'), $this->_oTemplate);
@@ -788,6 +800,22 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return true;
         return true;
     }
     }
 
 
+    public function isAllowedReport($aEvent, $bPerform = false)
+    {
+        $mixedReports = $this->getReportsData($aEvent['reports']);
+        if($mixedReports === false)
+            return false;
+
+        list($sSystem, $iObjectId) = $mixedReports;
+        $oReport = $this->getReportObject($sSystem, $iObjectId);
+        $oReport->addCssJs();
+
+        if(isAdmin())
+            return true;
+
+        return true;
+    }
+
     public function isAllowedShare($aEvent, $bPerform = false)
     public function isAllowedShare($aEvent, $bPerform = false)
     {
     {
         if(isAdmin())
         if(isAdmin())
@@ -905,6 +933,20 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         return array($sSystem, $iObjectId, $iCount);
         return array($sSystem, $iObjectId, $iCount);
     }
     }
 
 
+    public function getReportsData(&$aReports)
+    {
+        if(empty($aReports) || !is_array($aReports))
+            return false;
+
+        $sSystem = isset($aReports['system']) ? $aReports['system'] : '';
+        $iObjectId = isset($aReports['object_id']) ? (int)$aReports['object_id'] : 0;
+        $iCount = isset($aReports['count']) ? (int)$aReports['count'] : 0;
+        if($sSystem == '' || $iObjectId == 0)
+            return false;
+
+        return array($sSystem, $iObjectId, $iCount);
+    }
+
     public function getCommentsData(&$aComments)
     public function getCommentsData(&$aComments)
     {
     {
         if(empty($aComments) || !is_array($aComments))
         if(empty($aComments) || !is_array($aComments))

+ 20 - 0
modules/boonex/timeline/classes/BxTimelineReport.php

@@ -0,0 +1,20 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Timeline Timeline
+ * @ingroup     TridentModules
+ *
+ * @{
+ */
+
+class BxTimelineReport extends BxTemplReport
+{
+    function __construct($sSystem, $iId, $iInit = 1)
+    {
+        parent::__construct($sSystem, $iId, $iInit);
+    }
+}
+
+/** @} */

+ 10 - 0
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -116,6 +116,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aEvent['object_owner_id'] = $aResult['owner_id'];
         $aEvent['object_owner_id'] = $aResult['owner_id'];
         $aEvent['content'] = $aResult['content'];
         $aEvent['content'] = $aResult['content'];
         $aEvent['votes'] = $aResult['votes'];
         $aEvent['votes'] = $aResult['votes'];
+        $aEvent['reports'] = $aResult['reports'];
         $aEvent['comments'] = $aResult['comments'];
         $aEvent['comments'] = $aResult['comments'];
 
 
         $sType = !empty($aResult['content_type']) ? $aResult['content_type'] : BX_TIMELINE_PARSE_TYPE_DEFAULT;
         $sType = !empty($aResult['content_type']) ? $aResult['content_type'] : BX_TIMELINE_PARSE_TYPE_DEFAULT;
@@ -843,6 +844,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 'url' => $this->_oConfig->getItemViewUrl($aEvent)
                 'url' => $this->_oConfig->getItemViewUrl($aEvent)
             ), //a string to display or array to parse default template before displaying.
             ), //a string to display or array to parse default template before displaying.
             'votes' => '',
             'votes' => '',
+            'reports' => '',
             'comments' => '',
             'comments' => '',
             'title' => '', //may be empty.
             'title' => '', //may be empty.
             'description' => '' //may be empty.
             'description' => '' //may be empty.
@@ -936,6 +938,14 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 'count' => $aEvent['votes']
                 'count' => $aEvent['votes']
             );
             );
 
 
+		$sSystem = $this->_oConfig->getObject('report');
+        if($oModule->getReportObject($sSystem, $aEvent['id']) !== false)
+            $aResult['reports'] = array(
+                'system' => $sSystem,
+                'object_id' => $aEvent['id'],
+                'count' => $aEvent['reports']
+            );
+
         $sSystem = $this->_oConfig->getObject('comment');
         $sSystem = $this->_oConfig->getObject('comment');
         if($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
         if($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
             $aResult['comments'] = array(
             $aResult['comments'] = array(

+ 1 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -83,6 +83,7 @@
     <string name="_bx_timeline_menu_item_title_item_comment"><![CDATA[Comment]]></string>
     <string name="_bx_timeline_menu_item_title_item_comment"><![CDATA[Comment]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_vote"><![CDATA[Vote]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_vote"><![CDATA[Vote]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_share"><![CDATA[Repost]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_share"><![CDATA[Repost]]></string>
+    <string name="_bx_timeline_menu_item_title_system_item_report"><![CDATA[Report]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_more"><![CDATA[More]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_more"><![CDATA[More]]></string>
 
 
 	<string name="_bx_timeline_menu_title_post_attachments"><![CDATA[Form Attachments]]></string>
 	<string name="_bx_timeline_menu_title_post_attachments"><![CDATA[Form Attachments]]></string>

+ 7 - 1
modules/boonex/timeline/install/sql/enable.sql

@@ -52,7 +52,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-comment', '_bx_timeline_menu_item_title_system_item_comment', '_bx_timeline_menu_item_title_item_comment', 'javascript:void(0)', 'javascript:{comment_onclick}', '_self', 'comment', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_menu_item_addon_comment";s:6:"params";a:2:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";}}', '', 0, 2147483647, 1, 0, 1, 1),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-comment', '_bx_timeline_menu_item_title_system_item_comment', '_bx_timeline_menu_item_title_item_comment', 'javascript:void(0)', 'javascript:{comment_onclick}', '_self', 'comment', 'a:3:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:27:"get_menu_item_addon_comment";s:6:"params";a:2:{i:0;s:16:"{comment_system}";i:1;s:16:"{comment_object}";}}', '', 0, 2147483647, 1, 0, 1, 1),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 0, 2),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-vote', '_bx_timeline_menu_item_title_system_item_vote', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 0, 2),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 0, 3),
 ('bx_timeline_menu_item_actions', 'bx_timeline', 'item-share', '_bx_timeline_menu_item_title_system_item_share', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 0, 3),
-('bx_timeline_menu_item_actions', 'bx_timeline', 'item-more', '_bx_timeline_menu_item_title_system_item_more', '', 'javascript:void(0)', 'bx_menu_popup(''bx_timeline_menu_item_manage'', this, {''id'':''bx_timeline_menu_item_manage_{content_id}''}, {content_id:{content_id}});', '', 'ellipsis-h', '', 'bx_timeline_menu_item_manage', 1, 2147483647, 1, 0, 0, 4);
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-report', '_bx_timeline_menu_item_title_system_item_report', '', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 1, 0, 0, 4),
+('bx_timeline_menu_item_actions', 'bx_timeline', 'item-more', '_bx_timeline_menu_item_title_system_item_more', '', 'javascript:void(0)', 'bx_menu_popup(''bx_timeline_menu_item_manage'', this, {''id'':''bx_timeline_menu_item_manage_{content_id}''}, {content_id:{content_id}});', '', 'ellipsis-h', '', 'bx_timeline_menu_item_manage', 1, 2147483647, 1, 0, 0, 5);
 
 
 -- MENU: Post form attachments (Link, Photo, Video)
 -- MENU: Post form attachments (Link, Photo, Video)
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
@@ -173,6 +174,11 @@ INSERT INTO `sys_objects_vote`(`Name`, `TableMain`, `TableTrack`, `PostTimeout`,
 ('bx_timeline', 'bx_timeline_votes', 'bx_timeline_votes_track', '604800', '1', '1', '0', '1', 'bx_timeline_events', 'id', 'object_id', 'rate', 'votes', 'BxTimelineVote', 'modules/boonex/timeline/classes/BxTimelineVote.php');
 ('bx_timeline', 'bx_timeline_votes', 'bx_timeline_votes_track', '604800', '1', '1', '0', '1', 'bx_timeline_events', 'id', 'object_id', 'rate', 'votes', 'BxTimelineVote', 'modules/boonex/timeline/classes/BxTimelineVote.php');
 
 
 
 
+-- REPORTS
+INSERT INTO `sys_objects_report` (`name`, `table_main`, `table_track`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_author`, `trigger_field_count`, `class_name`, `class_file`) VALUES 
+('bx_timeline', 'bx_timeline_reports', 'bx_timeline_reports_track', '1', 'bx_timeline_events', 'id', 'owner_id', 'reports',  'BxTimelineReport', 'modules/boonex/timeline/classes/BxTimelineReport.php');
+
+
 -- SEARCH
 -- SEARCH
 SET @iSearchOrder = (SELECT IFNULL(MAX(`Order`), 0) FROM `sys_objects_search`);
 SET @iSearchOrder = (SELECT IFNULL(MAX(`Order`), 0) FROM `sys_objects_search`);
 INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `ClassPath`) VALUES
 INSERT INTO `sys_objects_search` (`ObjectName`, `Title`, `Order`, `ClassName`, `ClassPath`) VALUES

+ 21 - 0
modules/boonex/timeline/install/sql/install.sql

@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_events` (
   `rate` float NOT NULL default '0',
   `rate` float NOT NULL default '0',
   `votes` int(11) unsigned NOT NULL default '0',
   `votes` int(11) unsigned NOT NULL default '0',
   `comments` int(11) unsigned NOT NULL default '0',
   `comments` int(11) unsigned NOT NULL default '0',
+  `reports` int(11) unsigned NOT NULL default '0',
   `shares` int(11) unsigned NOT NULL default '0',
   `shares` int(11) unsigned NOT NULL default '0',
   `date` int(11) NOT NULL default '0',
   `date` int(11) NOT NULL default '0',
   `active` tinyint(4) NOT NULL default '1',
   `active` tinyint(4) NOT NULL default '1',
@@ -205,6 +206,26 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_meta_locations` (
   KEY `country_state_city` (`country`,`state`(8),`city`(8))
   KEY `country_state_city` (`country`,`state`(8),`city`(8))
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 
+-- TABLE: reports
+CREATE TABLE IF NOT EXISTS `bx_timeline_reports` (
+  `object_id` int(11) NOT NULL default '0',
+  `count` int(11) NOT NULL default '0',
+  UNIQUE KEY `object_id` (`object_id`)
+) ENGINE=MYISAM DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `bx_timeline_reports_track` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `object_id` int(11) NOT NULL default '0',
+  `author_id` int(11) NOT NULL default '0',
+  `author_nip` int(11) unsigned NOT NULL default '0',
+  `type` varchar(32) NOT NULL default '',
+  `text` text NOT NULL default '',
+  `date` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`),
+  KEY `report` (`object_id`, `author_nip`)
+) ENGINE=MYISAM DEFAULT CHARSET=utf8;
+
+
 -- STORAGES, TRANSCODERS, UPLOADERS
 -- STORAGES, TRANSCODERS, UPLOADERS
 INSERT INTO `sys_objects_uploader` (`object`, `active`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_uploader` (`object`, `active`, `override_class_name`, `override_class_file`) VALUES
 ('bx_timeline_simple_photo', 1, 'BxTimelineUploaderSimplePhoto', 'modules/boonex/timeline/classes/BxTimelineUploaderSimplePhoto.php'),
 ('bx_timeline_simple_photo', 1, 'BxTimelineUploaderSimplePhoto', 'modules/boonex/timeline/classes/BxTimelineUploaderSimplePhoto.php'),

+ 3 - 0
modules/boonex/timeline/install/sql/uninstall.sql

@@ -22,6 +22,9 @@ DROP TABLE IF EXISTS `bx_timeline_votes_track`;
 DROP TABLE IF EXISTS `bx_timeline_meta_keywords`;
 DROP TABLE IF EXISTS `bx_timeline_meta_keywords`;
 DROP TABLE IF EXISTS `bx_timeline_meta_locations`;
 DROP TABLE IF EXISTS `bx_timeline_meta_locations`;
 
 
+DROP TABLE IF EXISTS `bx_timeline_reports`;
+DROP TABLE IF EXISTS `bx_timeline_reports_track`;
+
 
 
 -- STORAGES, TRANSCODERS, UPLOADERS
 -- STORAGES, TRANSCODERS, UPLOADERS
 DELETE FROM `sys_objects_uploader` WHERE `object` LIKE 'bx_timeline%';
 DELETE FROM `sys_objects_uploader` WHERE `object` LIKE 'bx_timeline%';

+ 1 - 1
template/css/report.css

@@ -56,7 +56,7 @@ div.bx-report div.bx-report-counter-holder {
 	line-height: 1.6rem;
 	line-height: 1.6rem;
 }
 }
 
 
-.bx-report-report .bx-report-element-holder .bx-report-do-report.bx-report-disabled {
+.bx-report .bx-report-element-holder .bx-report-do-report.bx-report-disabled {
 	color: #ddd;
 	color: #ddd;
 }
 }