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

Ticket #5360 - Organizations: Profile is auto invited to be itself's member.

AntonLV 8 месяцев назад
Родитель
Сommit
4ab92abeda
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

+ 9 - 4
modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

@@ -255,13 +255,18 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
      */ 
     protected function makeAuthorAdmin ($oGroupProfile, $aInitialProfiles)
     {
-        $iAdminProfileId = bx_get_logged_profile_id();
+        $iAuthorProfileId = 0;
+        if($oGroupProfile && ($sModule = $oGroupProfile->getModule()) && ($sMethod = 'get_author') && bx_is_srv($sModule, $sMethod))
+            $iAuthorProfileId = bx_srv($sModule, $sMethod, [$oGroupProfile->getContentId()]);
+        if(!$iAuthorProfileId)
+            return;
+
         if(!is_array($aInitialProfiles))
             $aInitialProfiles = [];
-        if(!in_array($iAdminProfileId, $aInitialProfiles))
-            $aInitialProfiles[] = $iAdminProfileId;
+        if(!in_array($iAuthorProfileId, $aInitialProfiles))
+            $aInitialProfiles[] = $iAuthorProfileId;
 
-        $this->makeAdmin($iAdminProfileId, $oGroupProfile, $aInitialProfiles);
+        $this->makeAdmin($iAuthorProfileId, $oGroupProfile, $aInitialProfiles);
     }
 
     /**