Просмотр исходного кода

Ticket #194: Integration with Text based modules and especially with Posts module.

AntonLV 10 лет назад
Родитель
Сommit
da6d0a22e0

+ 8 - 2
modules/base/text/classes/BxBaseModTextModule.php

@@ -101,7 +101,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
 
         $CNF = &$this->_oConfig->CNF;
 
-        return $this->_entitySocialSharing ($iContentId, $iContentId, $aContentInfo[$CNF['FIELD_THUMB']], $aContentInfo[$CNF['FIELD_TITLE']], $CNF['OBJECT_STORAGE'], false, $CNF['OBJECT_VOTES'], $CNF['URI_VIEW_ENTRY']);
+        return $this->_entitySocialSharing ($iContentId, $iContentId, $aContentInfo[$CNF['FIELD_THUMB']], $aContentInfo[$CNF['FIELD_TITLE']], $CNF['OBJECT_STORAGE'], false, $CNF['OBJECT_VOTES'], $CNF['OBJECT_REPORTS'], $CNF['URI_VIEW_ENTRY']);
     }
 
     public function serviceEntityAllActions ($iContentId = 0)
@@ -436,7 +436,7 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
         return $oCmts->getCommentsBlock(0, 0, false);
     }
 
-    protected function _entitySocialSharing ($iId, $iIdForTimeline, $iIdThumb, $sTitle, $sObjectStorage, $sObjectTranscoder, $sObjectVote, $sUriViewEntry, $sCommentsObject = '', $bEnableSocialSharing = true)
+    protected function _entitySocialSharing ($iId, $iIdForTimeline, $iIdThumb, $sTitle, $sObjectStorage, $sObjectTranscoder, $sObjectVote, $sObjectReport, $sUriViewEntry, $sCommentsObject = '', $bEnableSocialSharing = true)
     {
         $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $sUriViewEntry . '&id=' . $iId);
 
@@ -479,12 +479,18 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
         if ($iIdForTimeline && BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
             $sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), $this->_aModule['name'], 'added', $iIdForTimeline, array('show_do_share_as_button' => true)));
 
+		$sReport = '';
+        $oReport = BxDolReport::getObjectInstance($sObjectReport, $iId);
+        if ($oReport)
+            $sReport = $oReport->getElementBlock(array('show_do_report_as_button' => true));
+
         $sSocial = $bEnableSocialSharing ? BxTemplSocialSharing::getInstance()->getCode($iId, $this->_aModule['name'], BX_DOL_URL_ROOT . $sUrl, $sTitle, $aCustomParams) : '';
 
         return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
             'comments' => $sComments,
             'vote' => $sVotes,
             'share' => $sShare,
+        	'report' => $sReport,
             'social' => $sSocial,
         ));
         //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.

+ 1 - 0
modules/base/text/template/css/main.css

@@ -158,6 +158,7 @@
 }
 
 .bx-base-text-entity-share .bx-vote,
+.bx-base-text-entity-share .bx-report,
 .bx-base-text-entity-share .bx-tl-share,
 .bx-base-text-entity-share .bx-social-sharing {
 	position: relative;

+ 1 - 1
modules/base/text/template/entry-share.html

@@ -1 +1 @@
-<div class="bx-base-text-entity-share bx-clearfix">__comments____vote____share____social__</div>
+<div class="bx-base-text-entity-share bx-clearfix">__comments____vote____share____report____social__</div>

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

@@ -66,6 +66,7 @@ class BxPostsConfig extends BxBaseModTextConfig
             'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_posts_preview',
             'OBJECT_IMAGES_TRANSCODER_GALLERY' => 'bx_posts_gallery',
             'OBJECT_VIDEOS_TRANSCODERS' => array(),
+        	'OBJECT_REPORTS' => 'bx_posts',
             'OBJECT_VIEWS' => 'bx_posts',
             'OBJECT_VOTES' => 'bx_posts',
             'OBJECT_METATAGS' => 'bx_posts',

+ 25 - 0
modules/boonex/posts/install/sql/install.sql

@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `bx_posts_posts` (
   `rate` float NOT NULL default '0',
   `votes` int(11) NOT NULL default '0',
   `comments` int(11) NOT NULL default '0',
+  `reports` int(11) NOT NULL default '0',
   `allow_view_to` int(11) NOT NULL DEFAULT '3',
   `status` enum('active','hidden') NOT NULL DEFAULT 'active',
   PRIMARY KEY (`id`),
@@ -124,6 +125,25 @@ CREATE TABLE `bx_posts_meta_locations` (
   KEY `country_state_city` (`country`,`state`(8),`city`(8))
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
+-- TABLE: reports
+
+CREATE TABLE IF NOT EXISTS `bx_posts_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_posts_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
 
@@ -249,6 +269,11 @@ INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`,
 INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
 ('bx_posts', 'bx_posts_votes', 'bx_posts_votes_track', '604800', '1', '1', '0', '1', 'bx_posts_posts', 'id', 'author', 'rate', 'votes', '', '');
 
+-- 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_posts', 'bx_posts_reports', 'bx_posts_reports_track', '1', 'bx_posts_posts', 'id', 'author', 'reports', '', '');
+
 -- VIEWS
 
 INSERT INTO `sys_objects_view` (`name`, `table_track`, `period`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_count`, `class_name`, `class_file`) VALUES 

+ 5 - 1
modules/boonex/posts/install/sql/uninstall.sql

@@ -1,7 +1,7 @@
 
 -- TABLES
 
-DROP TABLE IF EXISTS `bx_posts_posts`, `bx_posts_files`, `bx_posts_photos_resized`, `bx_posts_cmts`, `bx_posts_votes`, `bx_posts_votes_track`, `bx_posts_views_track`, `bx_posts_meta_keywords`, `bx_posts_meta_locations`;
+DROP TABLE IF EXISTS `bx_posts_posts`, `bx_posts_files`, `bx_posts_photos_resized`, `bx_posts_cmts`, `bx_posts_votes`, `bx_posts_votes_track`, `bx_posts_views_track`, `bx_posts_meta_keywords`, `bx_posts_meta_locations`, `bx_posts_reports`, `bx_posts_reports_track`;
 
 -- STORAGES & TRANSCODERS
 
@@ -33,6 +33,10 @@ DELETE FROM `sys_objects_cmts` WHERE `Name` = 'bx_posts';
 
 DELETE FROM `sys_objects_vote` WHERE `Name` = 'bx_posts';
 
+-- REPORTS
+
+DELETE FROM `sys_objects_report` WHERE `Name` = 'bx_posts';
+
 -- VIEWS
 
 DELETE FROM `sys_objects_view` WHERE `Name` = 'bx_posts';