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

#4558 - Build-in API support (any core actions)

roman.lesnikov@gmail.com 2 лет назад
Родитель
Сommit
6aa6fffb24

+ 9 - 0
inc/classes/BxDolTemplate.php

@@ -3460,6 +3460,12 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         bx_import('BxDolLanguages');
         header('HTTP/1.0 403 Forbidden');
         header('Status: 403 Forbidden');
+        
+        $a = [
+            'title' => _t('_access_denied_page_title'),
+            'content' => _t('_access_denied_page_content'),
+        ];
+        
         $this->displayMsg($sMsg ? $sMsg : _t('_Access denied'), false, $iPage, $iDesignBox);
     }
 
@@ -3499,6 +3505,9 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
             $sTitle = _t($sTitle);
             $sContent = _t($sContent);
         }
+        
+        if (bx_is_api())
+            return [bx_api_get_msg($sContent)];
 
         $sContent = MsgBox($sContent);
         if($iPage == BX_PAGE_DEFAULT)

+ 10 - 2
modules/base/profile/classes/BxBaseModProfileMenuViewActionsAll.php

@@ -45,17 +45,25 @@ class BxBaseModProfileMenuViewActionsAll extends BxBaseModGeneralMenuViewActions
         ));
     }
 
+    protected function getMenuItemTitleByConnection($sConnection, $sAction, $iContentProfile, $iInitiatorProfile)
+    {
+        return '';
+    }
+
     protected function _getMenuItemConnectionApi($sConnection, $sAction, &$aItem)
     {
-        if(!isLogged() || $this->_oModule->{$this->_aConnectionToFunctionCheck[$sConnection][$sAction]}($this->_aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED)
+        if(!isLogged() || (isset($this->_aConnectionToFunctionCheck[$sConnection]) && $this->_oModule->{$this->_aConnectionToFunctionCheck[$sConnection][$sAction]}($this->_aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED))
             return false;
 
         $iInitiatorProfile = bx_get_logged_profile_id();
         $iContentProfile = $this->_oProfile->id();
         $sTitle = $this->_oModule->getMenuItemTitleByConnection($sConnection, $sAction, $iContentProfile, $iInitiatorProfile);
+        
+        if(empty($sTitle))
+            $sTitle = $this->getMenuItemTitleByConnection($sConnection, $sAction, $iContentProfile, $iInitiatorProfile);
         if(empty($sTitle))
             return false;
-
+        
         return [
             'id' => $aItem['id'],
             'name' => $aItem['name'],

+ 16 - 1
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1017,10 +1017,25 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             return false;
 
         list($iContentId, $aContentInfo) = $mixedContent;
-        
         if(bx_is_api()){
             $aContentInfo['cover'] = $this->serviceGetCover($iContentId);
             $aContentInfo['image'] = $this->serviceGetThumb($iContentId);
+            
+            $CNF = $this->_oConfig->CNF;
+            if(!empty($CNF['OBJECT_MENU_VIEW_ENTRY_META'])){
+                $oMetaMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_VIEW_ENTRY_META']);
+                $aContentInfo['meta_menu'] =  $oMetaMenu->getCodeAPI();
+            }
+            if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])){
+                $oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
+                 $aContentInfo['actions_menu'] = $oActionMenu->getCodeAPI();
+            }  
+            $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE);
+            $aContentInfo['profile'] = BxDolProfile::getData($this->_aProfileInfo['id'], [
+                'get_avatar' => 'getAvatarBig',
+                'with_info' => false
+            ]);
+            
             return [bx_api_get_block('entity_cover', $aContentInfo)];
         }
         

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -7,6 +7,8 @@
 	<string name="_ATT_SUSPENDED_E"><![CDATA[Your profile is temporarily out of {0} system services. You can activate it <a target=_blank href="change_status.php">here</a>. If you have any questions, please <a target=_blank href="contact.php">contact the administrators</a>.]]></string>
 	<string name="_ATT_UNCONFIRMED_E"><![CDATA[You will need to follow the link supplied in the e-mail to get your account submitted for approval. <br />Send me <a target=_blank href="activation_email.php">confirmation e-mail</a>.]]></string>
 	<string name="_Access denied"><![CDATA[Access denied]]></string>
+    <string name="_access_denied_page_title"><![CDATA[Page Not Available]]></string>
+     <string name="_access_denied_page_content"><![CDATA[Sorry, this content is no longer available. It may have been removed or is not accessible due to violation of our terms of service.]]></string>
 	<string name="_Action"><![CDATA[Action]]></string>
 	<string name="_all"><![CDATA[All]]></string>
 	<string name="_Allowed Since"><![CDATA[Allowed Since]]></string>

+ 4 - 0
template/scripts/BxBasePage.php

@@ -525,6 +525,10 @@ class BxBasePage extends BxDolPage
             'blocks' => $aBlocks,
             'data' => &$a,
         ];
+        
+        if (!$this->_isVisiblePage($this->_aObject))
+            $a['page_status'] = 403;
+        
         bx_alert('system', 'get_page_api', 0, 0, $aExtras);
 
         return $a;