Переглянути джерело

Merge branch 'master' of https://github.com/unaio/una

AntonLV 8 роки тому
батько
коміт
8eee7a99d3

+ 33 - 0
inc/classes/BxDolAccount.php

@@ -113,6 +113,39 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
         return false;
     }
 
+    /**
+     * Switch context automatically to the first available profile
+     * @param $iProfileIdFilterOut profile ID to exclude from the list of possible profiles
+     * @param $iAccountId account ID to use istead of current account
+     * @return true on success or false on error
+     */ 
+    public function updateProfileContextAuto($iProfileIdFilterOut = false, $iAccountId = false)
+    {
+        $oAccount = (!$iAccountId || $iAccountId == $this->_iAccountID ? $this : BxDolAccount::getInstance ($iAccountId));
+        if (!$oAccount)
+            return false;
+        $aAccountInfo = $oAccount->getInfo();
+        $aProfiles = $oAccount->getProfiles();
+        $oProfileAccount = BxDolProfile::getInstanceAccountProfile($oAccount->id());
+
+        // unset deleted profile and account profile
+        if ($iProfileIdFilterOut)
+            unset($aProfiles[$iProfileIdFilterOut]);
+        unset($aProfiles[$oProfileAccount->id()]);
+
+        if ($aProfiles) {
+            // try to use another profile
+            reset($aProfiles);
+            $iProfileId = key($aProfiles);
+        } 
+        else {
+            // if no profiles exist, use account profile
+            $iProfileId = $oProfileAccount->id();
+        }
+
+        return $oAccount->updateProfileContext($iProfileId);
+    }
+    
     public function updateProfileContext($iSwitchToProfileId, $iAccountId = false)
     {
         $iId = (int)$iAccountId ? (int)$iAccountId : $this->_iAccountID;

+ 1 - 1
inc/classes/BxDolConnection.php

@@ -175,7 +175,7 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
         if (!$iContent)
             $iContent = bx_process_input($_POST['id'], BX_DATA_INT);
         
-        if ($iContent != bx_get_logged_profile_id()) {
+        if ($iContent != bx_get_logged_profile_id() && BX_CONNECTIONS_TYPE_MUTUAL == $this->_aObject['type']) {
             $a = $this->actionReject($iContent);
             if (false == $a['err'])
                 return $a;

+ 2 - 21
inc/classes/BxDolProfile.php

@@ -348,27 +348,8 @@ class BxDolProfile extends BxDolFactory implements iBxDolProfile
         // switch profile context if deleted profile is active profile context
         $oAccount = BxDolAccount::getInstance ($aProfileInfo['account_id']);
         $aAccountInfo = $oAccount->getInfo();
-        if (!$bForceDelete && $ID == $aAccountInfo['profile_id']) {
-
-            $aProfiles = $oAccount->getProfiles();            
-            $oProfileAccount = BxDolProfile::getInstanceAccountProfile($aProfileInfo['account_id']);
-
-            // unset deleted profile and account profile
-            unset($aProfiles[$ID]);
-            unset($aProfiles[$oProfileAccount->id()]);
-
-            if ($aProfiles) {
-                // try to use another profile
-                reset($aProfiles);
-                $iProfileId = key($aProfiles);
-            } 
-            else {
-                // if no profiles exist, use account profile
-                $iProfileId = $oProfileAccount->id();
-            }
-
-            $oAccount->updateProfileContext($iProfileId);
-        }
+        if (!$bForceDelete && $ID == $aAccountInfo['profile_id'])
+            $oAccount->updateProfileContextAuto($ID);
 
         // create system event before deletion
         $isStopDeletion = false;

+ 1 - 0
inc/classes/BxDolTemplate.php

@@ -448,6 +448,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             'media-phone.css',
             'media-print.css',
             BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'marka/|marka.min.css',
+            BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'tinymce-mention/css/|autocomplete.css',
         ));
 
         //--- Load default JS ---//

+ 1 - 1
modules/base/general/classes/BxBaseModGeneralCmtsSearchResult.php

@@ -58,7 +58,7 @@ class BxBaseModGeneralCmtsSearchResult extends BxBaseModGeneralSearchResult
 			));
 		}
 		else
-			return $oCmts->getComment($aData['cmt_id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
+			return $oCmts->getComment($aData['id'], array(), array('type' => BX_CMT_DISPLAY_FLAT, 'view_only' => true));
     }
 
     function displayResultBlock ()

+ 23 - 5
modules/base/groups/classes/BxBaseModGroupsDb.php

@@ -32,24 +32,42 @@ class BxBaseModGroupsDb extends BxBaseModProfileDb
 
     public function toAdmins ($iGroupProfileId, $mixedFansIds)
     {
-        if (is_array($mixedFansIds))
+        if (is_array($mixedFansIds)) {
             foreach ($mixedFansIds as $iFanId)
                 $this->toAdmins ($iFanId);
+            return true;
+        }
 
         $iFanId = (int)$mixedFansIds;
         $sQuery = $this->prepare("INSERT IGNORE INTO `" . $this->_oConfig->CNF['TABLE_ADMINS'] . "` SET `group_profile_id` = ?, `fan_id` = ?", $iGroupProfileId, $iFanId);
-        return $this->res($sQuery);
+        if (!$this->res($sQuery))
+            return false;
+
+        $oModule = BxDolModule::getInstance($this->_oConfig->getName());
+        if ($oModule && method_exists($oModule, 'onFanAddedToAdmins'))
+            $oModule->onFanAddedToAdmins($iGroupProfileId, $iFanId);
+
+        return true;
     }
 
     public function fromAdmins ($iGroupProfileId, $mixedFansIds)
     {
-        if (is_array($mixedFansIds))
+        if (is_array($mixedFansIds)) {
             foreach ($mixedFansIds as $iFanId)
-                $this->toAdmins ($iFanId);
+                $this->fromAdmins ($iFanId);
+            return true;
+        }
 
         $iFanId = (int)$mixedFansIds;
         $sQuery = $this->prepare("DELETE FROM `" . $this->_oConfig->CNF['TABLE_ADMINS'] . "` WHERE `group_profile_id` = ? AND `fan_id` = ?", $iGroupProfileId, $iFanId);
-        return $this->res($sQuery);
+        if (!$this->res($sQuery))
+            return false;
+
+        $oModule = BxDolModule::getInstance($this->_oConfig->getName());
+        if ($oModule && method_exists($oModule, 'onFanRemovedFromAdmins'))
+            $oModule->onFanRemovedFromAdmins($iGroupProfileId, $iFanId);
+        
+        return true;
     }
 
     public function deleteAdminsByGroupId ($iGroupProfileId)

+ 3 - 1
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -138,7 +138,9 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         $this->_oDb->fromAdmins($iGroupProfileId, $iProfileId);
 
         if ($oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions'))
-            $oConn->removeConnection($iProfileId, $iGroupProfileId);
+            return $oConn->removeConnection($iProfileId, $iGroupProfileId);
+
+        return false;
     }
 
     public function serviceAddMutualConnection ($iGroupProfileId, $iInitiatorId, $iIgnoreJoinConfirmation = false)

+ 8 - 0
modules/boonex/organizations/classes/BxOrgsModule.php

@@ -44,6 +44,14 @@ class BxOrgsModule extends BxBaseModGroupsModule
     {
     	return array();
     }
+
+    public function onFanRemovedFromAdmins($iGroupProfileId, $iProfileId)
+    {
+        if (!($oProfile = BxDolProfile::getInstance($iProfileId)))
+            return false;
+        $oAccount = $oProfile->getAccountObject();
+        $oAccount->updateProfileContextAuto();
+    }
 }
 
 /** @} */

+ 0 - 1
template/scripts/BxBaseEditorTinyMCE.php

@@ -252,7 +252,6 @@ EOS;
         if ($this->_bJsCssAdded)
             return '';
         $this->_oTemplate->addJs(array('tinymce/tinymce.min.js', 'tinymce/jquery.tinymce.min.js', 'editor.tinymce.js'));
-        $this->_oTemplate->addCss(array(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'tinymce-mention/css/|autocomplete.css'));
         $this->_bJsCssAdded = true;
         return '';
     }