Răsfoiți Sursa

#32 - integration with Notes

AntonLV 13 ani în urmă
părinte
comite
094e7ad7bd

+ 1 - 0
modules/boonex/notes/classes/BxNotesConfig.php

@@ -28,6 +28,7 @@ class BxNotesConfig extends BxDolModuleConfig {
 
     public static $OBJECT_STORAGE = 'bx_notes_photos';
     public static $OBJECT_IMAGES_TRANSCODER_PREVIEW = 'bx_notes_preview';
+    public static $OBJECT_VOTES = 'bx_notes';
     public static $OBJECT_COMMENTS = 'bx_notes';
     public static $OBJECT_PRIVACY_VIEW = 'bx_notes_allow_view_to';
 

+ 13 - 0
modules/boonex/notes/classes/BxNotesModule.php

@@ -228,6 +228,18 @@ class BxNotesModule extends BxDolModule {
 				$sImage = $oStorage->getFileUrlById($aContentInfo[BxNotesConfig::$FIELD_THUMB]);
         }
 
+        //--- Votes
+        bx_import('BxDolVote');
+        $oVotes = BxDolVote::getObjectInstance(BxNotesConfig::$OBJECT_VOTES, $aEvent['object_id']);
+
+        $aVotes = array(); 
+		if($oVotes->isEnabled())
+			$aVotes = array(
+				'system' => BxNotesConfig::$OBJECT_VOTES,
+				'object_id' => $aContentInfo[BxNotesConfig::$FIELD_ID],
+				'count' => $aContentInfo['votes']
+			);
+
         //--- Comments
         bx_import('BxDolCmts');
         $oCmts = BxDolCmts::getObjectInstance(BxNotesConfig::$OBJECT_COMMENTS, $aEvent['object_id']);
@@ -255,6 +267,7 @@ class BxNotesModule extends BxDolModule {
     				)
     			)
     		), //a string to display or array to parse default template before displaying.
+    		'votes' => $aVotes,
     		'comments' => $aComments,
     		'title' => '', //may be empty.
     		'description' => '' //may be empty. 

+ 3 - 0
modules/boonex/notes/install/sql/disable.sql

@@ -39,3 +39,6 @@ DELETE FROM `sys_acl_actions` WHERE `Module` = 'bx_notes';
 
 -- COMMENTS
 DELETE FROM `sys_objects_cmts` WHERE `Name`='bx_notes';
+
+-- VOTES
+DELETE FROM `sys_objects_vote` WHERE `Name`='bx_notes';

+ 5 - 1
modules/boonex/notes/install/sql/enable.sql

@@ -252,6 +252,10 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 
 
 -- COMMENTS
-
 INSERT INTO `sys_objects_cmts` (`Name`, `TableCmts`, `TableTrack`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `BaseUrl`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldTitle`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
 ('bx_notes', 'bx_notes_cmts', 'bx_notes_cmts_track', 1, 5000, 1000, 1, 5, 3, 'tail', 1, 'bottom', 1, 1, 1, -3, 1, 'cmt', 'page/view-note&id={object_id}', 'bx_notes_posts', 'id', 'title', 'comments', '', '');
+
+
+-- VOTES
+INSERT INTO `sys_objects_vote`(`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
+('bx_notes', 'bx_notes_votes', 'bx_notes_votes_track', '604800', '1', '1', '1', '1', 'bx_notes_posts', 'id', 'rate', 'votes', '', '');

+ 20 - 3
modules/boonex/notes/install/sql/install.sql

@@ -10,7 +10,9 @@ CREATE TABLE IF NOT EXISTS `bx_notes_posts` (
   `title` varchar(255) NOT NULL,
   `text` text NOT NULL,
   `summary` text NOT NULL,
-  `comments` int(11) NOT NULL,
+  `rate` float NOT NULL default '0',
+  `votes` int(11) NOT NULL default '0',
+  `comments` int(11) NOT NULL default '0',
   `allow_view_to` int(11) NOT NULL DEFAULT '3',
   PRIMARY KEY (`id`)
 );
@@ -50,7 +52,6 @@ CREATE TABLE IF NOT EXISTS `bx_notes_photos_resized` (
 );
 
 -- TABLE: COMMENTS
-
 CREATE TABLE IF NOT EXISTS `bx_notes_cmts` (
   `cmt_id` int(11) NOT NULL AUTO_INCREMENT,
   `cmt_parent_id` int(11) NOT NULL DEFAULT '0',
@@ -78,8 +79,24 @@ CREATE TABLE IF NOT EXISTS `bx_notes_cmts_track` (
   PRIMARY KEY (`cmt_system_id`,`cmt_id`,`cmt_rate_author_nip`)
 );
 
--- FORMS
+-- TABLE: VOTES
+CREATE TABLE IF NOT EXISTS `bx_notes_votes` (
+  `object_id` int(11) NOT NULL default '0',
+  `count` int(11) NOT NULL default '0',
+  `sum` int(11) NOT NULL default '0',
+  UNIQUE KEY `object_id` (`object_id`)
+) ENGINE=MYISAM DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `bx_notes_votes_track` (
+  `object_id` int(11) NOT NULL default '0',
+  `author_id` int(11) NOT NULL default '0',
+  `author_nip` int(11) NOT NULL default '0',
+  `value` tinyint(4) NOT NULL default '0',
+  `date` int(11) NOT NULL default '0',
+  KEY `vote` (`object_id`, `author_nip`)
+) ENGINE=MYISAM DEFAULT CHARSET=utf8;
 
+-- FORMS
 INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_notes', 'bx_notes', '_bx_notes_form_note', '', 'a:1:{s:7:\"enctype\";s:19:\"multipart/form-data\";}', 'bx_notes_posts', 'id', '', '', 'do_submit', '', 0, 1, 'BxNotesFormNote', 'modules/boonex/notes/classes/BxNotesFormNote.php');
 

+ 4 - 1
modules/boonex/notes/install/sql/uninstall.sql

@@ -10,10 +10,13 @@ DROP TABLE IF EXISTS `bx_notes_photos`;
 DROP TABLE IF EXISTS `bx_notes_photos_resized`;
 
 -- TABLE: COMMENTS
-
 DROP TABLE IF EXISTS `bx_notes_cmts`;
 DROP TABLE IF EXISTS `bx_notes_cmts_track`;
 
+-- TABLE: VOTES
+DROP TABLE IF EXISTS `bx_notes_votes`;
+DROP TABLE IF EXISTS `bx_notes_votes_track`;
+
 -- FORMS
 
 DELETE FROM `sys_objects_form` WHERE `module` = 'bx_notes';