AntonLV пре 5 година
родитељ
комит
bd92de7a1c

+ 19 - 8
modules/base/groups/classes/BxBaseModGroupsFormsEntryHelper.php

@@ -134,23 +134,34 @@ class BxBaseModGroupsFormsEntryHelper extends BxBaseModProfileFormsEntryHelper
      * @return nothing
      * @return nothing
      */ 
      */ 
     protected function makeAuthorAdmin ($oGroupProfile, $aInitialProfiles)
     protected function makeAuthorAdmin ($oGroupProfile, $aInitialProfiles)
+    {
+        $this->makeAdmin (bx_get_logged_profile_id(), $oGroupProfile, $aInitialProfiles);
+    }
+
+    /**
+     * Make profile admin if he is in initial invitations list
+     * @param $iProfileId profile id
+     * @param $oGroupProfile group id
+     * @param $aInitialProfiles array of initial profile ids
+     * @return nothing
+     */ 
+    protected function makeAdmin ($iProfileId, $oGroupProfile, $aInitialProfiles)
     {
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
         $CNF = &$this->_oModule->_oConfig->CNF;
-        $iAdminProfileId = bx_get_logged_profile_id();
 
 
-        if (!isset($CNF['OBJECT_CONNECTIONS']) || !$CNF['OBJECT_CONNECTIONS'] || !is_array($aInitialProfiles) || !in_array($iAdminProfileId, $aInitialProfiles))
+        if (!isset($CNF['OBJECT_CONNECTIONS']) || !$CNF['OBJECT_CONNECTIONS'] || !is_array($aInitialProfiles) || !in_array($iProfileId, $aInitialProfiles))
             return;
             return;
 
 
         if (!($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
         if (!($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
             return;
             return;
 
 
-        if (!$oConnection->isConnected($oGroupProfile->id(), (int)$iAdminProfileId))
-            $oConnection->addConnection($oGroupProfile->id(), (int)$iAdminProfileId);
-        if (!$oConnection->isConnected((int)$iAdminProfileId, $oGroupProfile->id()))
-            $oConnection->addConnection((int)$iAdminProfileId, $oGroupProfile->id());
+        if (!$oConnection->isConnected($oGroupProfile->id(), (int)$iProfileId))
+            $oConnection->addConnection($oGroupProfile->id(), (int)$iProfileId);
+        if (!$oConnection->isConnected((int)$iProfileId, $oGroupProfile->id()))
+            $oConnection->addConnection((int)$iProfileId, $oGroupProfile->id());
 
 
-        if (!$this->_oModule->_oDb->isAdmin ($oGroupProfile->id(), $iAdminProfileId))
-            $this->_oModule->_oDb->toAdmins ($oGroupProfile->id(), $iAdminProfileId);
+        if (!$this->_oModule->_oDb->isAdmin ($oGroupProfile->id(), $iProfileId))
+            $this->_oModule->_oDb->toAdmins ($oGroupProfile->id(), $iProfileId);
     }
     }
 }
 }
 
 

+ 33 - 0
modules/boonex/organizations/classes/BxOrgsFormsEntryHelper.php

@@ -18,6 +18,39 @@ class BxOrgsFormsEntryHelper extends BxBaseModGroupsFormsEntryHelper
     {
     {
         parent::__construct($oModule);
         parent::__construct($oModule);
     }
     }
+    
+    public function onDataAddAfter($iAccountId, $iContentId)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if($s = parent::onDataAddAfter($iAccountId, $iContentId))
+            return $s;
+
+        $aInvitedMembers = bx_get('initial_members');
+        if(empty($aInvitedMembers) || !is_array($aInvitedMembers))
+            return '';
+
+        $sGroupModule = $this->_oModule->_oConfig->getName();
+        $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $sGroupModule);
+        if(!$oGroupProfile)
+            return '';
+        
+        $aGroupContentInfo = bx_srv($sGroupModule, 'get_info', array($iContentId, false));
+        if(empty($aGroupContentInfo) || !is_array($aGroupContentInfo) || !in_array($aGroupContentInfo[$CNF['FIELD_AUTHOR']], $aInvitedMembers))
+            return '';
+
+        $oGroupAuthor = BxDolProfile::getInstance($aGroupContentInfo[$CNF['FIELD_AUTHOR']]);
+        if(!$oGroupAuthor)
+            return '';
+
+        $sGroupAuthorModule = $oGroupAuthor->getModule();
+        if(!BxDolRequest::serviceExists($sGroupAuthorModule, 'act_as_profile') || !bx_srv($sGroupAuthorModule, 'act_as_profile'))
+            return '';
+
+        $this->makeAdmin($oGroupAuthor->id(), $oGroupProfile, $aInvitedMembers);
+
+        return '';
+    }
 }
 }
 
 
 /** @} */
 /** @} */