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

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

AntonLV 6 лет назад
Родитель
Сommit
dfd42ad89a

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

@@ -598,7 +598,15 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
     public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
     {
-        if ($this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $iProfileId))
+        $bInvited = false;
+        if (bx_get('key')){
+            $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
+            $mixedInvited = $this->isInvited(bx_get('key'), $oGroupProfile->id());
+            if ($mixedInvited === true)
+                $bInvited = true;
+        }
+        
+        if ($this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $iProfileId) || $bInvited)
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return parent::serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);
@@ -763,6 +771,19 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             return $oGroupProfile && ($oConnection = BxDolConnection::getObjectInstance($this->_oConfig->CNF['OBJECT_CONNECTIONS'])) && $oConnection->isConnected($iProfileId ? $iProfileId : bx_get_logged_profile_id(), $oGroupProfile->id(), true);
         return false;
     }
+    
+    public function isInvited ($sKey, $iProfileId) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+        $aData = $this->_oDb->getInviteByKey($sKey,  $iProfileId);
+        if (!isset($aData['invited_profile_id']))
+            return _t($CNF['T']['txt_invitation_popup_error_invitation_absent']);
+        
+        if ($aData['invited_profile_id'] != bx_get_logged_profile_id())
+            return  _t($CNF['T']['txt_invitation_popup_error_wrong_user']);
+        
+        return true;
+    }
 
     protected function _getImagesForTimelinePost($aEvent, $aContentInfo, $sUrl, $aBrowseParams = array())
     {

+ 11 - 16
modules/base/groups/classes/BxBaseModGroupsPageEntry.php

@@ -51,23 +51,18 @@ class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
             $sKey = bx_get('key');
             $sId = $this->_oModule->getName() . '_popup_invite';
             
-            $aData = $this->_oModule->_oDb->getInviteByKey($sKey,  $this->_oProfile->id());
-            if (!isset($aData['invited_profile_id'])){
-                $sRv = _t($CNF['T']['txt_invitation_popup_error_invitation_absent']);
+            $mixedInvited = $this->_oModule->isInvited($sKey, $this->_oProfile->id());
+            if ($mixedInvited === true){
+                $sRv = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
+                    'popup_id' => $sId,
+					'text' => _t($CNF['T']['txt_invitation_popup_text']),
+					'button_accept' => _t($CNF['T']['txt_invitation_popup_accept_button']),
+					'button_decline' => _t($CNF['T']['txt_invitation_popup_decline_button']),
+						
+                ));
             }
             else{
-                if ($aData['invited_profile_id'] != bx_get_logged_profile_id()){
-                    $sRv = _t($CNF['T']['txt_invitation_popup_error_wrong_user']);
-                }
-                else{
-                    $sRv = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
-                        'popup_id' => $sId,
-						'text' => _t($CNF['T']['txt_invitation_popup_text']),
-						'button_accept' => _t($CNF['T']['txt_invitation_popup_accept_button']),
-						'button_decline' => _t($CNF['T']['txt_invitation_popup_decline_button']),
-						
-                    ));
-                }
+                $sRv = $mixedInvited;
             }
         }
         $this->_oTemplate->addJs(array('invite_popup.js'));
@@ -77,7 +72,7 @@ class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
             'sAcceptUrl' =>  BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
             'sDeclineUrl' => BX_DOL_URL_ROOT,
             'iGroupProfileId' => $this->_oProfile->id(),
-        )) .  BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sRv, true) : '').parent::getCode();
+        )) .  BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sRv, true) : '') . parent::getCode();
     }
 }
 

+ 38 - 0
modules/boonex/oauth2/classes/BxOAuthModule.php

@@ -190,6 +190,44 @@ class BxOAuthModule extends BxDolModule
         $this->_oServer->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
     }
 
+    /**
+     * @page public_api API Public
+     * @section public_api_token /m/oauth2/revoke
+     * 
+     * Revoke token 
+     * 
+     * **HTTP Method:** 
+     * `POST`
+     *
+     * **Request params:**
+     * - `token` - token to revoke
+     *
+     * **Request header:**
+     * @code
+     * Authorization: Bearer 9802c4a34e1535d8c3b721604ee0e7fb04116c49
+     * @endcode
+     *
+     * **Response (success):**
+     * @code
+     * {  
+     *    "revoked":true,
+     * }
+     * @endcode
+     *
+     * **Response (error):**
+     * @code
+     * {  
+     *    "error":"short error description here",
+     *    "error_description":"long error description here"
+     * }
+     * @endcode
+     */
+    function actionRevoke ()
+    {
+        $this->initOAuth($this->getClientIdFromAccessTokenHeader());
+        $this->_oServer->handleRevokeRequest(OAuth2\Request::createFromGlobals())->send();
+    }
+
     /**
      * Authenicated or public call to the "safe" and "public" service methods 
      */