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

Ticket #5626 - Contexts: Edit tabs shouldn't show tabs which aren't active or unavailable by visibility.

AntonLV 2 місяців тому
батько
коміт
322a71eb52

+ 19 - 2
modules/base/profile/classes/BxBaseModProfileFormEntry.php

@@ -139,10 +139,27 @@ class BxBaseModProfileFormEntry extends BxBaseModGeneralFormEntry
             $this->aInputs[$sField]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName('form_ghost_template.html', $this->_getProfilePhotoGhostTmplVars($sField, $aContentInfo));
             $this->aInputs[$sField]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName('form_ghost_template.html', $this->_getProfilePhotoGhostTmplVars($sField, $aContentInfo));
         }
         }
 
 
+        //--- Edit Settings: Fill in tabs list
+        if(($sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT_SETTINGS'] ?? false) && $sDisplay == $this->aParams['display'])
+            if(($sField = $CNF['FIELD_STG_TABS'] ?? false) && !empty($this->aInputs[$sField]) && is_array($this->aInputs[$sField])) 
+                if(($sMenu = 'OBJECT_MENU_SUBMENU_VIEW_ENTRY') && !empty($CNF[$sMenu]) && ($oMenu = BxDolMenu::getObjectInstance($CNF[$sMenu])) !== false) {
+                    $oMenu->setContentId($aContentInfo[$CNF['FIELD_ID']]);
+                    if(($aMenuItems = $oMenu->getQueryObject()->getMenuItems()))
+                        foreach($aMenuItems as $aMenuItem) {
+                            if(!$oMenu->isMenuItemActive($aMenuItem) || !$oMenu->isMenuItemVisible($aMenuItem) || $aMenuItem['name'] == 'more-auto')
+                                continue;
+
+                            $this->aInputs[$sField]['values'][] = [
+                                'key' => $aMenuItem['name'],
+                                'value' => _t($aMenuItem['title'])
+                            ];
+                        }
+                }
+        
         parent::initChecker($aValues, $aSpecificValues);
         parent::initChecker($aValues, $aSpecificValues);
 
 
-        if(($sField = 'FIELD_STG_TABS') && !empty($CNF[$sField]) && !empty($this->aInputs[$CNF[$sField]]) && is_array($this->aInputs[$CNF[$sField]]) && ($sValue = $this->aInputs[$CNF[$sField]]['value']))
-            $this->aInputs[$CNF[$sField]]['value'] = !is_array($sValue) ? explode(',', $sValue) : [];
+        if(($sField = $CNF['FIELD_STG_TABS'] ?? false) && !empty($this->aInputs[$sField]) && is_array($this->aInputs[$sField]) && ($sValue = $this->aInputs[$sField]['value']))
+            $this->aInputs[$sField]['value'] = !is_array($sValue) ? explode(',', $sValue) : [];
 
 
         if(($sDisplay = 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_BADGE') && !empty($CNF[$sDisplay]) && $this->aParams['display'] == $CNF[$sDisplay]) {
         if(($sDisplay = 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_BADGE') && !empty($CNF[$sDisplay]) && $this->aParams['display'] == $CNF[$sDisplay]) {
             $sBadgeLink = $aContentInfo[$CNF['FIELD_BADGE_LINK']] ?? '';
             $sBadgeLink = $aContentInfo[$CNF['FIELD_BADGE_LINK']] ?? '';

+ 0 - 25
modules/base/profile/classes/BxBaseModProfileFormsEntryHelper.php

@@ -45,31 +45,6 @@ class BxBaseModProfileFormsEntryHelper extends BxBaseModGeneralFormsEntryHelper
         return ($this->_sAutoApproval = $mValue);
         return ($this->_sAutoApproval = $mValue);
     }
     }
 
 
-    public function getObjectFormEdit ($sDisplay = false)
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $oForm = parent::getObjectFormEdit ($sDisplay);
-        if(!$oForm)
-            return $oForm;
-
-        //--- Edit Settings: Fill in tabs list
-        if(($sKey = 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_SETTINGS') && isset($CNF[$sKey]) && $CNF[$sKey] == $sDisplay)
-            if(($sField = 'FIELD_STG_TABS') && !empty($CNF[$sField]) && !empty($oForm->aInputs[$CNF[$sField]]) && is_array($oForm->aInputs[$CNF[$sField]])) 
-                if(($sMenu = 'OBJECT_MENU_SUBMENU_VIEW_ENTRY') && !empty($CNF[$sMenu]) && ($oMenu = BxDolMenu::getObjectInstance($CNF[$sMenu])) !== false && ($aMenuItems = $oMenu->getQueryObject()->getMenuItems()))
-                    foreach($aMenuItems as $aMenuItem) {
-                        if($aMenuItem['name'] == 'more-auto' || (int)$aMenuItem['active'] == 0)
-                            continue;
-
-                        $oForm->aInputs[$CNF[$sField]]['values'][] = [
-                            'key' => $aMenuItem['name'],
-                            'value' => _t($aMenuItem['title'])
-                        ];
-                    }
-
-        return $oForm;
-    }
-
     protected function _getProfileAndContentData ($iContentId)
     protected function _getProfileAndContentData ($iContentId)
     {
     {
         $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
         $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);

+ 10 - 0
modules/base/profile/classes/BxBaseModProfileMenuView.php

@@ -60,6 +60,16 @@ class BxBaseModProfileMenuView extends BxTemplMenuMoreAuto
         ));
         ));
     }
     }
 
 
+    public function isMenuItemActive($a)
+    {
+        return parent::_isActive($a);
+    }
+
+    public function isMenuItemVisible($a)
+    {
+        return parent::_isVisible($a);
+    }
+
     /**
     /**
      * Check if menu items is visible with extended checking linked to "allow*" method of particular module
      * Check if menu items is visible with extended checking linked to "allow*" method of particular module
      * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.
      * Associated "allow*" method with particular menu item is stored in module config in MENU_ITEM_TO_METHOD array.