Przeglądaj źródła

Ticket #1783 - Usage in Persons.

AntonLV 8 lat temu
rodzic
commit
82637e6070

+ 37 - 0
modules/base/profile/classes/BxBaseModProfileVote.php

@@ -0,0 +1,37 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    BaseProfile Base classes for profile modules
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxBaseModProfileVote extends BxTemplVote
+{
+    protected $_sModule;
+    protected $_oModule;
+
+    function __construct($sSystem, $iId, $iInit = 1)
+    {
+        parent::__construct($sSystem, $iId, $iInit);        
+
+    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
+    }
+
+    public function getObjectAuthorId($iObjectId = 0)
+    {
+        if(!BxDolService::call($this->_sModule, 'act_as_profile'))
+            return parent::getObjectAuthorId ($iObjectId);
+
+        $oProfile = BxDolProfile::getInstanceByContentAndType($iObjectId ? $iObjectId : $this->getId(), $this->_sModule);
+        if(!$oProfile)
+            return 0;
+
+        return $oProfile->id();
+    }
+}
+
+/** @} */

+ 22 - 0
modules/boonex/persons/classes/BxPersonsVote.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Persons Persons
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxPersonsVote extends BxBaseModProfileVote
+{
+    function __construct($sSystem, $iId, $iInit = 1)
+    {
+    	$this->_sModule = 'bx_persons';
+
+        parent::__construct($sSystem, $iId, $iInit);        
+    }
+}
+
+/** @} */

+ 1 - 1
modules/boonex/persons/install/sql/enable.sql

@@ -425,7 +425,7 @@ INSERT INTO `sys_objects_view` (`name`, `module`, `table_track`, `period`, `is_o
 
 -- VOTES
 INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_persons', 'bx_persons_votes', 'bx_persons_votes_track', '604800', '1', '1', '0', '1', 'bx_persons_data', 'id', 'author', 'rate', 'votes', '', '');
+('bx_persons', 'bx_persons_votes', 'bx_persons_votes_track', '604800', '1', '1', '0', '1', 'bx_persons_data', 'id', '', 'rate', 'votes', 'BxPersonsVote', 'modules/boonex/persons/classes/BxPersonsVote.php');
 
 -- SCORES
 INSERT INTO `sys_objects_score` (`name`, `module`, `table_main`, `table_track`, `post_timeout`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_author`, `trigger_field_score`, `trigger_field_cup`, `trigger_field_cdown`, `class_name`, `class_file`) VALUES