Exemple #1
0
 function run()
 {
     require_once 'CRM/Utils/Menu.php';
     $items =& CRM_Utils_Menu::items();
     $config =& CRM_Core_Config::singleton();
     $groups = array(ts('Manage'), ts('Configure'), ts('Setup'));
     if (in_array("CiviContribute", $config->enableComponents)) {
         $groups[] = 'CiviContribute';
     }
     $adminPanel = array();
     foreach ($groups as $group) {
         $adminPanel[$group] = array();
         foreach ($items as $item) {
             if ($config->userFramework == 'Mambo' && $item['path'] == 'civicrm/admin/access') {
                 // access control not yet implemented for mambo
                 continue;
             }
             if (CRM_Utils_Array::value('adminGroup', $item) == $group) {
                 $value = array('title' => $item['title'], 'url' => CRM_Utils_System::url($item['path'], CRM_Utils_Array::value('qs', $item)), 'icon' => $item['icon'], 'extra' => CRM_Utils_Array::value('extra', $item));
                 $adminPanel[$group][$item['weight'] . '.' . $item['title']] = $value;
             }
         }
         ksort($adminPanel[$group]);
     }
     require_once 'CRM/Utils/VersionCheck.php';
     $versionCheck =& CRM_Utils_VersionCheck::singleton();
     $this->assign('newVersion', $versionCheck->newerVersion());
     $this->assign('localVersion', $versionCheck->localVersion);
     $this->assign('adminPanel', $adminPanel);
     return parent::run();
 }
Exemple #2
0
 /**
  * create the list of shortcuts for the application and format is as a block
  *
  * @return void
  * @access private
  */
 function setTemplateMenuValues()
 {
     $config =& CRM_Core_Config::singleton();
     $items =& CRM_Utils_Menu::items();
     $values = array();
     foreach ($items as $item) {
         if (!CRM_Utils_Array::value('crmType', $item)) {
             continue;
         }
         if ($item['crmType'] & CRM_UTILS_MENU_NORMAL_ITEM && $item['crmType'] >= CRM_UTILS_MENU_NORMAL_ITEM && $item['access']) {
             $value = array();
             $value['url'] = CRM_Utils_System::url($item['path'], CRM_Utils_Array::value('qs', $item));
             $value['title'] = $item['title'];
             $value['path'] = $item['path'];
             $value['class'] = 'leaf';
             $value['parent'] = null;
             $value['start'] = $value['end'] = null;
             if (strpos(CRM_Utils_Array::value($config->userFrameworkURLVar, $_REQUEST), $item['path']) === 0) {
                 $value['active'] = 'class="active"';
             } else {
                 $value['active'] = '';
             }
             // check if there is a parent
             foreach ($values as $weight => $v) {
                 if (strpos($item['path'], $v['path']) !== false) {
                     $value['parent'] = $weight;
                     // only reset if still a leaf
                     if ($values[$weight]['class'] == 'leaf') {
                         $values[$weight]['class'] = 'collapsed';
                     }
                     // if a child or the parent is active, expand the menu
                     if ($value['active'] || $values[$weight]['active']) {
                         $values[$weight]['class'] = 'expanded';
                     }
                     // make the parent inactive if the child is active
                     if ($value['active'] && $values[$weight]['active']) {
                         $values[$weight]['active'] = '';
                     }
                 }
             }
             $values[$item['weight'] . '.' . $item['title']] = $value;
         }
     }
     // remove all collapsed menu items from the array
     $activeChildren = array();
     foreach ($values as $weight => $v) {
         if ($v['parent']) {
             if ($values[$v['parent']]['class'] == 'collapsed') {
                 unset($values[$weight]);
             } else {
                 $activeChildren[] = $weight;
             }
         }
     }
     // add the start / end tags
     $len = count($activeChildren) - 1;
     if ($len >= 0) {
         $values[$activeChildren[0]]['start'] = true;
         $values[$activeChildren[$len]]['end'] = true;
     }
     ksort($values);
     CRM_Core_Block::setProperty(CRM_CORE_BLOCK_MENU, 'templateValues', array('menu' => $values));
 }
Exemple #3
0
 /**
  * Get max weight for a path
  *
  * @param  string $path  parent menu path
  *
  * @return int    max weight for the path           
  *
  * @static
  * @access public
  */
 function getMaxWeight($path)
 {
     $path = trim($path, '/');
     // since we need children only
     $path .= '/';
     $maxWeight = -1024;
     // weights can have -ve numbers hence cant initialize it to 0
     $firstChild = true;
     foreach (CRM_Utils_Menu::items() as $menu) {
         if (strpos($menu['path'], $path) === 0) {
             if ($firstChild) {
                 // maxWeight is initialized to the weight of the first child
                 $maxWeight = $menu['weight'];
                 $firstChild = false;
             } else {
                 $maxWeight = $menu['weight'] > $maxWeight ? $menu['weight'] : $maxWeight;
             }
         }
     }
     return $maxWeight;
 }