AntonLV 9 лет назад
Родитель
Сommit
9d82cb4c07

+ 1 - 1
inc/classes/BxDolAccount.php

@@ -198,7 +198,7 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
     {
         $sTitle = $this->getDisplayName($iAccountId);
         return BxDolTemplate::getInstance()->parseHtmlByName('unit_account.html', array(
-            'color' => implode(', ', BxDolTemplate::getColorCode('', 0.5)),
+            'color' => implode(', ', BxDolTemplate::getColorCode(($iAccountId ? $iAccountId : $this->_iAccountID), 0.5)),
 			'letter' => mb_strtoupper(mb_substr($sTitle, 0, 1))
         ));
     }

+ 2 - 1
inc/classes/BxDolCronAccount.php

@@ -73,6 +73,7 @@ class BxDolCronAccount extends BxDolCron
             if(!$oProfile)
                 continue;
 
+            $iId = $oProfile->id();
             $sUrl = $oProfile->getUrl();
             $bUrl = $oProfile->getModule() != 'system';
 
@@ -92,7 +93,7 @@ class BxDolCronAccount extends BxDolCron
                 'bx_if:show_thumb_letter' => array(
                     'condition' => !$bThumbUrl,
                     'content' => array(
-                        'color' => implode(', ', BxDolTemplate::getColorCode('', 0.5)),
+                        'color' => implode(', ', BxDolTemplate::getColorCode($iId, 0.5)),
                         'letter' => mb_strtoupper(mb_substr($sTitle, 0, 1))
                     )
                 ),

+ 6 - 4
inc/classes/BxDolTemplate.php

@@ -359,14 +359,16 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         return $aResult;
     }
 
-    public static function getColorCode($sName = '', $fOpacity = false)
+    public static function getColorCode($mixedName = false, $fOpacity = false)
     {
         $aClasses = array_keys(self::$_aColors);
 
-        if(empty($sName) || !in_array($sName, $aClasses))
-            $sName = $aClasses[rand(0, count($aClasses) - 1)];
+        if($mixedName === false || (is_string($mixedName) && !is_numeric($mixedName) && !in_array($mixedName, $aClasses)))
+            $mixedName = $aClasses[rand(0, count($aClasses) - 1)];
+        else if(is_numeric($mixedName))
+            $mixedName = $aClasses[(int)$mixedName % count($aClasses)];
 
-        $aColor = self::$_aColors[$sName];
+        $aColor = self::$_aColors[$mixedName];
         if($fOpacity !== false && is_numeric($fOpacity))
             $aColor[] = $fOpacity;
 

+ 5 - 4
modules/base/profile/classes/BxBaseModProfileTemplate.php

@@ -41,6 +41,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         //$aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
 
         $oProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->MODULE);
+        $iProfile = $oProfile->id();
 
         // get profile's title
         $sTitle = bx_process_output($aData[$CNF['FIELD_NAME']]);
@@ -51,7 +52,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         // connections object 
         $sConnectionsObject = isset($CNF['OBJECT_CONNECTIONS']) ? $CNF['OBJECT_CONNECTIONS'] : 'sys_profiles_friends';
         $oConn = BxDolConnection::getObjectInstance($sConnectionsObject);
-        $aConnectionTitles = $this->getModule()->serviceGetConnectionButtonsTitles($oProfile->id(), $sConnectionsObject);
+        $aConnectionTitles = $this->getModule()->serviceGetConnectionButtonsTitles($iProfile, $sConnectionsObject);
 
         $sCoverUrl = '';
         if($this->getModule()->checkAllowedViewCoverImage($aData) === CHECK_ACTION_RESULT_ALLOWED)
@@ -79,7 +80,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
             'bx_if:show_thumb_letter' => array(
                 'condition' => !$bThumbUrl,
                 'content' => array(
-                    'color' => implode(', ', BxDolTemplate::getColorCode('', 0.5)),
+                    'color' => implode(', ', BxDolTemplate::getColorCode($iProfile, 0.5)),
                     'letter' => mb_strtoupper(mb_substr($sTitle, 0, 1))
                 )
             ),
@@ -93,11 +94,11 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
             'bx_if:info' => array(
                 'condition' => true,
                 'content' => array (
-                    'members' => $isPublic ? _t($CNF['T']['txt_N_fans'], $oConn ? $oConn->getConnectedInitiatorsCount($oProfile->id(), true) : 0) : ' ',
+                    'members' => $isPublic ? _t($CNF['T']['txt_N_fans'], $oConn ? $oConn->getConnectedInitiatorsCount($iProfile, true) : 0) : ' ',
                     'bx_if:btn' => array (
                         'condition' => isLogged() && !empty($aConnectionTitles['add']) && CHECK_ACTION_RESULT_ALLOWED === $this->getModule()->checkAllowedFriendAdd($aData),
                         'content' => array (
-                            'id' => $oProfile->id(),
+                            'id' => $iProfile,
                             'title' => isset($aConnectionTitles['add']) ? $aConnectionTitles['add'] : '',
                             'object' => $sConnectionsObject,
                         ),