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

#919 Connect* Modules: auto-friends making friends accounts instead of profiles

Alex Trofimov 9 лет назад
Родитель
Сommit
c2e1394bbf

+ 2 - 2
inc/classes/BxDolProfile.php

@@ -87,10 +87,10 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
     /**
      * Get singleton instance of Profile by Account id (currently active profile is returned)
      */
-    public static function getInstanceByAccount($iAccountId = false)
+    public static function getInstanceByAccount($iAccountId = false, $bClearCache = false)
     {
         $oQuery = BxDolProfileQuery::getInstance();
-        $mixedProfileId = $oQuery->getCurrentProfileByAccount($iAccountId);
+        $mixedProfileId = $oQuery->getCurrentProfileByAccount($iAccountId, $bClearCache);
 
         return self::getInstance($mixedProfileId);
     }

+ 5 - 2
inc/classes/BxDolProfileQuery.php

@@ -117,10 +117,13 @@ class BxDolProfileQuery extends BxDolDb implements iBxDolSingleton
      * @param  string  $iAccountId account id
      * @return current account's profile id
      */
-    public function getCurrentProfileByAccount ($iAccountId)
+    public function getCurrentProfileByAccount ($iAccountId, $bClearCache = false)
     {
-        $sSql = $this->prepare("SELECT `profile_id` FROM `sys_accounts` WHERE `id` = ? LIMIT 1", $iAccountId);
         $sKey = 'BxDolProfileQuery::getCurrentProfileByAccount' . $iAccountId;
+        if ($bClearCache)
+            $this->cleanMemory($sKey);
+
+        $sSql = $this->prepare("SELECT `profile_id` FROM `sys_accounts` WHERE `id` = ? LIMIT 1", $iAccountId);        
         $iProfileId = $this->fromMemory($sKey, 'getOne', $sSql);
         if (!$iProfileId) {
             $this->cleanMemory($sKey);

+ 2 - 2
modules/base/connect/classes/BxBaseModConnectModule.php

@@ -164,7 +164,7 @@ class BxBaseModConnectModule extends BxBaseModGeneralModule
         // create new profile
         if ($oExistingAccount) {
 
-            if (!($oExistingProfile = BxDolProfile::getInstanceByAccount($oExistingAccount->id())))
+            if (!($oExistingProfile = BxDolProfile::getInstanceByAccount($oExistingAccount->id(), true)))
                 return _t('_sys_txt_error_account_creation');
 
             $iProfileId = $oExistingProfile->id();
@@ -195,7 +195,7 @@ class BxBaseModConnectModule extends BxBaseModGeneralModule
                 if ($sErrorMsg = $oFormHelperProfile->onDataAddAfter ($iAccountId, $iContentId))
                     return $sErrorMsg;
                 
-                $oProfile = BxDolProfile::getInstanceByAccount($iAccountId);
+                $oProfile = BxDolProfile::getInstanceByAccount($iAccountId, true);
                 $iProfileId = $oProfile->id();
             } 
             else {