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

Ticket #4558 - Build-in API support: Profile actions.

AntonLV 2 лет назад
Родитель
Сommit
53c6b2c540

+ 26 - 2
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1096,7 +1096,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
 
         list($iContentId, $aContentInfo) = $mixedContent;
 
-        if(bx_is_api()) {
+        if($this->_bIsApi) {
             $CNF = &$this->_oConfig->CNF;
 
             $aContentInfo['cover'] = $this->serviceGetCover($iContentId);
@@ -1106,10 +1106,31 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
             if(!empty($CNF[$sKey]) && ($oMetaMenu = BxTemplMenu::getObjectInstance($CNF[$sKey])) !== false)
                 $aContentInfo['meta_menu'] = $oMetaMenu->getCodeAPI();
 
-            $sKey = 'OBJECT_MENU_ACTIONS_VIEW_ENTRY';
+            $sKey = 'OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL';
             if(!empty($CNF[$sKey]) && ($oActionMenu = BxTemplMenu::getObjectInstance($CNF[$sKey])) !== false)
                 $aContentInfo['actions_menu'] = $oActionMenu->getCodeAPI();
 
+            if(($oMenuManage = BxDolMenu::getObjectInstance('sys_site_manage')) !== false) {
+                if(!empty($CNF['FIELD_ID']))
+                    $oMenuManage->setContentId($aContentInfo[$CNF['FIELD_ID']]);
+
+                $aObjectManage = [];
+                if(!empty($CNF['OBJECT_MENU_MANAGE_VIEW_ENTRY']))
+                    $aObjectManage = [$CNF['OBJECT_MENU_MANAGE_VIEW_ENTRY']];
+                else if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE']))
+                    $aObjectManage = [$CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_MORE'], true];
+
+                call_user_func_array([$oMenuManage, 'setObjectManage'], $aObjectManage);
+
+                $aMenuManage = $oMenuManage->getCodeAPI();
+                if(!empty($aMenuManage) && is_array($aMenuManage)) {
+                    if(isset($aContentInfo['actions_menu']) && is_array($aContentInfo['actions_menu']))
+                        $aContentInfo['actions_menu']['items'] = array_merge($aContentInfo['actions_menu']['items'], $aMenuManage['items']);
+                    else
+                       $aContentInfo['actions_menu'] = $aMenuManage;
+                }   
+            }
+
             if(($oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName())) !== false);
                 $aContentInfo['profile'] = BxDolProfile::getData($oProfile, [
                     'get_avatar' => 'getAvatarBig',
@@ -2464,6 +2485,9 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         if(!$oCmts || !$oCmts->isEnabled())
             return false;
 
+        if (bx_is_api())
+            return [bx_srv('system', 'get_data_api', [['module' => $sObject, 'object_id' => $iId]], 'TemplCmtsServices')];
+
         return $oCmts->getCommentsBlock(array(), array('in_designbox' => false));
     }
 

+ 2 - 2
template/scripts/BxBasePage.php

@@ -567,7 +567,7 @@ class BxBasePage extends BxDolPage
                     if(!empty($CNF['OBJECT_CONNECTIONS']) && ($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])) !== false)
                         $a['cover_block']['members_list'] = $oConnection->getConnectedListAPI($this->_aProfileInfo['id'], false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 10);
 
-                    if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']) && ($oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL'])) !== false)
+                    if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']) && ($oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL'])) !== false)
                         $a['cover_block']['actions_menu'] = $oActionMenu->getCodeAPI();
                 }
                 
@@ -591,7 +591,7 @@ class BxBasePage extends BxDolPage
                         if(isset($a['cover_block'], $a['cover_block']['actions_menu']) && is_array($a['cover_block']['actions_menu']))
                             $a['cover_block']['actions_menu']['items'] = array_merge($a['cover_block']['actions_menu']['items'], $aMenuManage['items']);
                         else
-                            $a['menu'] = $aMenuManage;
+                            $a['cover_block']['actions_menu'] = $aMenuManage;
                     }
                 }
             }