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

Ticket #4971 - Build-in API support: Account picture.

AntonLV 8 месяцев назад
Родитель
Сommit
ae1dfdbbb4
2 измененных файлов с 26 добавлено и 2 удалено
  1. 19 0
      inc/classes/BxDolAccount.php
  2. 7 2
      template/scripts/BxBaseServices.php

+ 19 - 0
inc/classes/BxDolAccount.php

@@ -11,6 +11,8 @@ bx_import('BxDolAcl');
 
 class BxDolAccount extends BxDolFactory implements iBxDolSingleton
 {
+    protected $_bIsApi;
+
     protected $_iAccountID;
     protected $_aInfo;
     protected $_oQuery;
@@ -30,6 +32,8 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
 
         parent::__construct();
 
+        $this->_bIsApi = bx_is_api();
+
         $this->_iAccountID = $iAccountId; // since constructor is protected $iAccountId is always valid
         $this->_oQuery = BxDolAccountQuery::getInstance();
 
@@ -636,6 +640,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
      */
     public function getPicture($iAccountId = false)
     {
+        if($this->_bIsApi)
+            return '';
+
         $sImageUrl = $this->_getImageUrl('picture', $iAccountId);
         if(!$sImageUrl)
             $sImageUrl = BxDolTemplate::getInstance()->getImageUrl('account.svg');
@@ -648,6 +655,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
      */
     public function getAvatarBig($iAccountId = false)
     {
+        if($this->_bIsApi)
+            return '';
+
         $sImageUrl = $this->_getImageUrl('ava_big', $iAccountId);
         if(!$sImageUrl)
             $sImageUrl = BxDolTemplate::getInstance()->getImageUrl('account.svg');
@@ -660,6 +670,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
      */
     public function getAvatar($iAccountId = false)
     {
+        if($this->_bIsApi)
+            return '';
+
         $sImageUrl = $this->_getImageUrl('ava', $iAccountId);
         if(!$sImageUrl)
             $sImageUrl = BxDolTemplate::getInstance()->getImageUrl('account.svg');
@@ -672,6 +685,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
      */
     public function getThumb($iAccountId = false)
     {
+        if($this->_bIsApi)
+            return '';
+
         $sImageUrl = $this->_getImageUrl('thumb', $iAccountId);
         if(!$sImageUrl)
             $sImageUrl = BxDolTemplate::getInstance()->getImageUrl('account.svg');
@@ -684,6 +700,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
      */
     public function getIcon($iAccountId = false)
     {
+        if($this->_bIsApi)
+            return '';
+
         $sImageUrl = $this->_getImageUrl('icon', $iAccountId);
         if(!$sImageUrl)
             $sImageUrl = BxDolTemplate::getInstance()->getImageUrl('account.svg');

+ 7 - 2
template/scripts/BxBaseServices.php

@@ -581,12 +581,17 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
 
     public function serviceProfilePicture ($iContentId)
     {
-        return BxDolTemplate::getInstance()->getImageUrl('account.svg');
+        return $this->_serviceProfileFunc('getPicture', $iContentId);
     }
 
     public function serviceProfileAvatar ($iContentId)
     {
-        return BxDolTemplate::getInstance()->getImageUrl('account.svg');
+        return $this->_serviceProfileFunc('getAvatar', $iContentId);
+    }
+
+    public function serviceProfileAvatarBig ($iContentId)
+    {
+        return $this->_serviceProfileFunc('getAvatarBig', $iContentId);
     }
 
     public function serviceProfileCover ($iContentId)