function getTabs($tabs, $showTabs = true, $selectedGroup = 'All')
 {
     //$groups = array('Tasks'=> array('activities','history', 'projects' ), 'People'=>array('contacts','leads', 'campaigns'),'Sales'=>array('opportunities', 'quotes', 'campaigns'), 'Support'=>array('cases','bugs' ), );
     require_once 'include/GroupedTabs/GroupedTabStructure.php';
     $groupedTabsClass = new GroupedTabStructure();
     $groups = $groupedTabsClass->get_tab_structure($tabs);
     /* Move history to same tab as activities */
     if (in_array('history', $tabs) && in_array('activities', $tabs)) {
         foreach ($groups as $mainTab => $group) {
             if (in_array('activities', array_map('strtolower', $group['modules']))) {
                 if (!in_array('history', array_map('strtolower', $group['modules']))) {
                     /* Move hist from there to here */
                     $groups[$mainTab]['modules'][] = 'history';
                 }
             } else {
                 if (false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) {
                     unset($groups[$mainTab]['modules'][$i]);
                     if (empty($groups[$mainTab]['modules'])) {
                         unset($groups[$mainTab]);
                     }
                 }
             }
         }
     }
     /* Add the 'All' group.
      * Note that if a tab group already exists with the name 'All',
      * it will be overwritten in this union operation.
      */
     if (count($groups) <= 1) {
         $groups = array('All' => array('label' => 'LBL_TABGROUP_ALL', 'modules' => $tabs));
     } else {
         $groups = array('All' => array('label' => 'LBL_TABGROUP_ALL', 'modules' => $tabs)) + $groups;
     }
     /* Note - all $display checking and array_intersects with $tabs
      * are now redundant (thanks to GroupedTabStructure), and could
      * be removed for performance, but for now can stay to help ensure
      * that the tabs get renedered correctly. 
      */
     $retTabs = array();
     if ($showTabs) {
         require_once 'include/SubPanel/SugarTab.php';
         $sugarTab = new SugarTab();
         $displayTabs = array();
         $otherTabs = array();
         foreach ($groups as $key => $tab) {
             $display = false;
             foreach ($tab['modules'] as $subkey => $subtab) {
                 if (in_array(strtolower($subtab), $tabs)) {
                     $display = true;
                     break;
                 }
             }
             $selected = 'other';
             if ($selectedGroup == $key) {
                 $selected = 'current';
             }
             if ($display) {
                 $relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key);
                 $sugarTabs[$key] = array('label' => $key, 'type' => $selected);
                 $otherTabs[$key] = array('key' => $key, 'tabs' => array());
                 $orderedTabs = array_intersect($relevantTabs, array_map('strtolower', $groups[$key]['modules']));
                 foreach ($orderedTabs as $subkey => $subtab) {
                     $otherTabs[$key]['tabs'][$subkey] = array('key' => $subtab, 'label' => translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$subtab]['title_key']));
                 }
                 if ($selectedGroup == $key) {
                     $displayTabs = $otherTabs[$key]['tabs'];
                     $retTabs = $orderedTabs;
                 }
             }
         }
         if (empty($displayTabs)) {
             $selectedGroup = 'All';
             $displayTabs = $otherTabs[$selectedGroup]['tabs'];
             $sugarTabs[$selectedGroup]['type'] = 'current';
             $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
         }
         $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup);
         $sugarTab->display();
     } else {
         $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $selectedGroup);
         $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
     }
     return $retTabs;
 }
Exemplo n.º 2
0
 function getTabs($showTabs = true, $selectedGroup = '')
 {
     global $current_user;
     //get all the "tabs" - this actually means all the subpanels available for display within a tab
     $tabs = $this->subpanel_definitions->get_available_tabs();
     if (!empty($selectedGroup)) {
         // Bug #44344 : Custom relationships under same module only show once in subpanel tabs
         // use object property instead new object to have ability run unit test (can override subpanel_definitions)
         $objSubPanelTilesTabs = new SubPanelTilesTabs($this->focus);
         $tabs = $objSubPanelTilesTabs->getTabs($tabs, $showTabs, $selectedGroup);
         unset($objSubPanelTilesTabs);
         return $tabs;
     } else {
         // see if user current user has custom subpanel layout
         $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs);
         /* Check if the preference is set now,
          * because there's no point in executing this code if
          * we aren't going to render anything.
          */
         $subpanelLinksPref = $current_user->getPreference('subpanel_links');
         if (!isset($subpanelLinksPref)) {
             $subpanelLinksPref = $GLOBALS['sugar_config']['default_subpanel_links'];
         }
         if ($showTabs && $subpanelLinksPref) {
             require_once 'include/SubPanel/SugarTab.php';
             $sugarTab = new SugarTab();
             $displayTabs = array();
             foreach ($tabs as $tab) {
                 $displayTabs[] = array('key' => $tab, 'label' => translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']));
                 //echo '<td nowrap="nowrap"><a class="subTabLink" href="#' . $tab . '">' .  translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']) .  '</a></td><td> | </td>';
             }
             $sugarTab->setup(array(), array(), $displayTabs);
             $sugarTab->display();
         }
         //echo '<td width="100%">&nbsp;</td></tr></table>';
     }
     return $tabs;
 }
Exemplo n.º 3
0
 function getTabs($tabs, $showTabs = true, $selectedGroup = 'All')
 {
     //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
     if ($selectedGroup == 'All') {
         $selectedGroup = translate('LBL_TABGROUP_ALL');
     }
     // Set up a mapping from subpanelID, found in the $tabs list, to the source module name
     // As the $GLOBALS['tabStructure'] array holds the Group Tabs by module name we need to efficiently convert between the two
     // when constructing the subpanel tabs
     // Note that we can't use the very similar GroupedTabStructure class as it lacks this mapping, and logically, it is designed
     // for use when constructing the module by module tabs, not the subpanel tabs, as we move away from using module names to represent
     // subpanels, and use unique subpanel IDs instead.
     $moduleNames = array();
     foreach ($tabs as $subpanelID) {
         // Bug #44344 : Custom relationships under same module only show once in subpanel tabs
         // use object property instead new object to have ability run unit test (can override subpanel_definitions)
         $subpanel = $this->subpanel_definitions->load_subpanel($subpanelID);
         if ($subpanel !== false) {
             $moduleNames[$subpanelID] = $subpanel->get_module_name();
         }
     }
     $groups = array();
     $found = array();
     foreach ($GLOBALS['tabStructure'] as $mainTab => $subModules) {
         foreach ($subModules['modules'] as $key => $subModule) {
             foreach ($tabs as $subpanelID) {
                 if (isset($moduleNames[$subpanelID]) && strcasecmp($subModule, $moduleNames[$subpanelID]) === 0) {
                     // Bug #44344 : Custom relationships under same module only show once in subpanel tabs
                     $groups[translate($mainTab)]['modules'][] = $subpanelID;
                     $found[$subpanelID] = true;
                 }
             }
         }
     }
     // Put all the remaining subpanels into the 'Other' tab.
     foreach ($tabs as $subpanelID) {
         if (!isset($found[$subpanelID])) {
             $groups[translate('LBL_TABGROUP_OTHER')]['modules'][] = $subpanelID;
         }
     }
     /* Move history to same tab as activities */
     if (in_array('history', $tabs) && in_array('activities', $tabs)) {
         foreach ($groups as $mainTab => $group) {
             if (in_array('activities', array_map('strtolower', $group['modules']))) {
                 if (!in_array('history', array_map('strtolower', $group['modules']))) {
                     /* Move hist from there to here */
                     $groups[$mainTab]['modules'][] = 'history';
                 }
             } else {
                 if (false !== ($i = array_search('history', array_map('strtolower', $group['modules'])))) {
                     unset($groups[$mainTab]['modules'][$i]);
                     if (empty($groups[$mainTab]['modules'])) {
                         unset($groups[$mainTab]);
                     }
                 }
             }
         }
     }
     /* Add the 'All' group.
      * Note that if a tab group already exists with the name 'All',
      * it will be overwritten in this union operation.
      */
     if (count($groups) <= 1) {
         $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs));
     } else {
         $groups = array(translate('LBL_TABGROUP_ALL') => array('label' => translate('LBL_TABGROUP_ALL'), 'modules' => $tabs)) + $groups;
     }
     /* Note - all $display checking and array_intersects with $tabs
      * are now redundant (thanks to GroupedTabStructure), and could
      * be removed for performance, but for now can stay to help ensure
      * that the tabs get renedered correctly.
      */
     $retTabs = array();
     if ($showTabs) {
         require_once 'include/SubPanel/SugarTab.php';
         $sugarTab = new SugarTab();
         $displayTabs = array();
         $otherTabs = array();
         foreach ($groups as $key => $tab) {
             $display = false;
             foreach ($tab['modules'] as $subkey => $subtab) {
                 if (in_array(strtolower($subtab), $tabs)) {
                     $display = true;
                     break;
                 }
             }
             $selected = '';
             if ($selectedGroup == $key) {
                 $selected = 'current';
             }
             if ($display) {
                 $relevantTabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $key);
                 $sugarTabs[$key] = array('label' => !empty($tab['label']) ? $tab['label'] : $key, 'type' => $selected);
                 $otherTabs[$key] = array('key' => $key, 'tabs' => array());
                 $orderedTabs = array_intersect($relevantTabs, array_map('strtolower', $groups[$key]['modules']));
                 foreach ($orderedTabs as $subkey => $subtab) {
                     $otherTabs[$key]['tabs'][$subkey] = array('key' => $subtab, 'label' => translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$subtab]['title_key']));
                 }
                 if ($selectedGroup == $key) {
                     $displayTabs = $otherTabs[$key]['tabs'];
                     $retTabs = $orderedTabs;
                 }
             }
         }
         if (empty($displayTabs) && !empty($otherTabs)) {
             //WDong Bug: 12258 "All" tab in the middle of a record's detail view is not localized.
             $selectedGroup = translate('LBL_TABGROUP_ALL');
             $displayTabs = $otherTabs[$selectedGroup]['tabs'];
             $sugarTabs[$selectedGroup]['type'] = 'current';
             $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
         }
         if (!empty($sugarTabs) || !empty($otherTabs)) {
             $sugarTab->setup($sugarTabs, $otherTabs, $displayTabs, $selectedGroup);
             $sugarTab->display();
         }
     } else {
         $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs, $selectedGroup);
         $retTabs = array_intersect($tabs, array_map('strtolower', $groups[$selectedGroup]['modules']));
     }
     return $retTabs;
 }
 function getTabs($showTabs = true, $selectedGroup = '')
 {
     global $current_user;
     //get all the tabs
     $tabs = $this->subpanel_definitions->get_available_tabs();
     if (!empty($selectedGroup)) {
         return SubPanelTilesTabs::getTabs($tabs, $showTabs, $selectedGroup);
     } else {
         // see if user current user has custom subpanel layout
         $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs);
         /* Check if the preference is set now,
          * because there's no point in executing this code if
          * we aren't going to render anything. 
          */
         $subpanelLinksPref = $current_user->getPreference('subpanel_links');
         if (!isset($subpanelLinksPref)) {
             $subpanelLinksPref = $GLOBALS['sugar_config']['default_subpanel_links'];
         }
         if ($showTabs && $subpanelLinksPref) {
             require_once 'include/SubPanel/SugarTab.php';
             $sugarTab = new SugarTab();
             $displayTabs = array();
             foreach ($tabs as $tab) {
                 $displayTabs[] = array('key' => $tab, 'label' => translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']));
                 //echo '<td nowrap="nowrap"><a class="subTabLink" href="#' . $tab . '">' .  translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']) .  '</a></td><td> | </td>';
             }
             $sugarTab->setup(array(), array(), $displayTabs);
             $sugarTab->display();
         }
         //echo '<td width="100%">&nbsp;</td></tr></table>';
     }
     return $tabs;
 }