AntonLV пре 10 година
родитељ
комит
671c0cf1fa

+ 2 - 2
inc/classes/BxDolFavorite.php

@@ -59,9 +59,9 @@ class BxDolFavorite extends BxDolObject
     /**
     /**
      * Constructor
      * Constructor
      */
      */
-    function __construct($sSystem, $iId, $iInit = true)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
     {
-        parent::__construct($sSystem, $iId, $iInit, $oTemplate = false);
+        parent::__construct($sSystem, $iId, $iInit);
         if(empty($this->_sSystem))
         if(empty($this->_sSystem))
             return;
             return;
 
 

+ 63 - 0
inc/classes/BxDolObject.php

@@ -91,6 +91,61 @@ class BxDolObject extends BxDol
 	/**
 	/**
 	 * Interface functions for outer usage
 	 * Interface functions for outer usage
 	 */
 	 */
+    public function getConditions($sMainTable, $sMainField)
+    {
+        if(!$this->isEnabled())
+            return array();
+
+        $sTable = isset($this->_aSystem['table_main']) ? $this->_aSystem['table_main'] : '';
+        if(empty($sTable) || empty($sMainTable) || empty($sMainField))
+            return array();
+
+        return array(
+            'join' => array (
+                'objects_' . $this->_sSystem => array(
+                    'type' => 'INNER',
+                    'table' => $sTable,
+                    'mainTable' => $sMainTable,
+                    'mainField' => $sMainField,
+                    'onField' => 'object_id',
+                    'joinFields' => array('count'),
+                ),
+            ),
+        );
+    }
+
+    public function getConditionsTrack($sMainTable, $sMainField, $iAuthorId = 0)
+    {
+        if(!$this->isEnabled())
+            return array();
+
+        $sTableTrack = isset($this->_aSystem['table_track']) ? $this->_aSystem['table_track'] : '';
+        if(empty($sTableTrack) || empty($sMainTable) || empty($sMainField))
+            return array();
+
+        return array(
+            'restriction' => array (
+                'objects_' . $this->_sSystem . '_author' => array(
+                    'value' => $iAuthorId,
+                    'field' => 'author_id',
+                    'operator' => '=',
+                    'table' => $sTableTrack,
+                ),
+            ),
+            'join' => array (
+                'objects_' . $this->_sSystem => array(
+                    'type' => 'INNER',
+                    'table' => $sTableTrack,
+                    'mainTable' => $sMainTable,
+                    'mainField' => $sMainField,
+                    'onField' => 'object_id',
+                    'joinFields' => array('author_id'),
+                ),
+            ),
+
+        );
+    }
+    
 	public function getSqlParts($sMainTable, $sMainField)
 	public function getSqlParts($sMainTable, $sMainField)
     {
     {
         if(!$this->isEnabled())
         if(!$this->isEnabled())
@@ -99,6 +154,14 @@ class BxDolObject extends BxDol
         return $this->_oQuery->getSqlParts($sMainTable, $sMainField);
         return $this->_oQuery->getSqlParts($sMainTable, $sMainField);
     }
     }
 
 
+    public function getSqlPartsTrack($sMainTable, $sMainField, $iAuthorId = 0)
+    {
+        if(!$this->isEnabled())
+            return array();
+
+        return $this->_oQuery->getSqlPartsTrack($sMainTable, $sMainField, $iAuthorId);
+    }
+
     public function addMarkers($aMarkers)
     public function addMarkers($aMarkers)
     {
     {
         if(empty($aMarkers) || !is_array($aMarkers))
         if(empty($aMarkers) || !is_array($aMarkers))

+ 8 - 1
inc/classes/BxDolObjectQuery.php

@@ -38,6 +38,9 @@ class BxDolObjectQuery extends BxDolDb
         $this->_sTriggerFieldCount = isset($aSystem['trigger_field_count']) ? $aSystem['trigger_field_count'] : '';
         $this->_sTriggerFieldCount = isset($aSystem['trigger_field_count']) ? $aSystem['trigger_field_count'] : '';
     }
     }
 
 
+    /**
+     * Get SQL parts for main table. 
+     */
     public function getSqlParts($sMainTable, $sMainField)
     public function getSqlParts($sMainTable, $sMainField)
     {
     {
         if(empty($this->_sTable) || empty($sMainTable) || empty($sMainField))
         if(empty($this->_sTable) || empty($sMainTable) || empty($sMainField))
@@ -49,13 +52,17 @@ class BxDolObjectQuery extends BxDolDb
         );
         );
     }
     }
 
 
-    public function getSqlPartsTrack($sMainTable, $sMainField)
+    /**
+     * Get SQL parts for track table. 
+     */
+    public function getSqlPartsTrack($sMainTable, $sMainField, $iAuthorId = 0)
     {
     {
         if(empty($this->_sTableTrack) || empty($sMainTable) || empty($sMainField))
         if(empty($this->_sTableTrack) || empty($sMainTable) || empty($sMainField))
             return array();
             return array();
 
 
         return array (
         return array (
             'fields' => ", `{$this->_sTableTrack}`.`author_id` as `favorer_id` ",
             'fields' => ", `{$this->_sTableTrack}`.`author_id` as `favorer_id` ",
+            'where' => $this->prepareAsString(" AND `{$this->_sTableTrack}`.`author_id` = ?", $iAuthorId),
             'join' => " LEFT JOIN `{$this->_sTableTrack}` ON (`{$this->_sTableTrack}`.`object_id` = `{$sMainTable}`.`{$sMainField}`) ",
             'join' => " LEFT JOIN `{$this->_sTableTrack}` ON (`{$this->_sTableTrack}`.`object_id` = `{$sMainTable}`.`{$sMainField}`) ",
         );
         );
     }
     }

+ 2 - 2
modules/boonex/ocean/data/template/system/scripts/BxTemplFavorite.php

@@ -12,9 +12,9 @@
  */
  */
 class BxTemplFavorite extends BxBaseFavorite
 class BxTemplFavorite extends BxBaseFavorite
 {
 {
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
     {
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
     }
     }
 }
 }
 
 

+ 2 - 2
modules/boonex/protean/data/template/system/scripts/BxTemplFavorite.php

@@ -12,9 +12,9 @@
  */
  */
 class BxTemplFavorite extends BxBaseFavorite
 class BxTemplFavorite extends BxBaseFavorite
 {
 {
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
     {
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
     }
     }
 }
 }