Overview

Packages

  • Auth
  • Core
  • Horde
    • Imsp
  • None
  • Notification

Classes

  • Horde
  • Horde_Config
  • Horde_Config_Form
  • Horde_Core_ActiveSync_Connector
  • Horde_Core_ActiveSync_Driver
  • Horde_Core_Ajax_Application
  • Horde_Core_Ajax_Imple
  • Horde_Core_Ajax_Imple_AutoCompleter
  • Horde_Core_Ajax_Imple_Geocoder_Geonames
  • Horde_Core_Ajax_Imple_SpellChecker
  • Horde_Core_Alarm_Handler_Notify
  • Horde_Core_Auth_Application
  • Horde_Core_Auth_Composite
  • Horde_Core_Auth_Ldap
  • Horde_Core_Auth_Msad
  • Horde_Core_Auth_Shibboleth
  • Horde_Core_Auth_Signup_Base
  • Horde_Core_Auth_Signup_Form
  • Horde_Core_Auth_Signup_Null
  • Horde_Core_Auth_Signup_Sql
  • Horde_Core_Auth_Signup_SqlObject
  • Horde_Core_Autoloader_Callback_Mime
  • Horde_Core_Autoloader_Callback_Nls
  • Horde_Core_Block
  • Horde_Core_Block_Collection
  • Horde_Core_Block_Layout
  • Horde_Core_Block_Layout_Manager
  • Horde_Core_Block_Layout_View
  • Horde_Core_Block_Upgrade
  • Horde_Core_Browser
  • Horde_Core_Bundle
  • Horde_Core_Cli
  • Horde_Core_Controller_NotFound
  • Horde_Core_Controller_RequestConfiguration
  • Horde_Core_Controller_RequestMapper
  • Horde_Core_Controller_SettingsFinder
  • Horde_Core_Db_Migration
  • Horde_Core_Factory_ActiveSyncBackend
  • Horde_Core_Factory_ActiveSyncServer
  • Horde_Core_Factory_ActiveSyncState
  • Horde_Core_Factory_Ajax
  • Horde_Core_Factory_Alarm
  • Horde_Core_Factory_Auth
  • Horde_Core_Factory_AuthSignup
  • Horde_Core_Factory_Base
  • Horde_Core_Factory_BlockCollection
  • Horde_Core_Factory_Browser
  • Horde_Core_Factory_Cache
  • Horde_Core_Factory_Crypt
  • Horde_Core_Factory_Data
  • Horde_Core_Factory_Db
  • Horde_Core_Factory_DbBase
  • Horde_Core_Factory_DbPear
  • Horde_Core_Factory_Dns
  • Horde_Core_Factory_Editor
  • Horde_Core_Factory_Facebook
  • Horde_Core_Factory_Group
  • Horde_Core_Factory_History
  • Horde_Core_Factory_HttpClient
  • Horde_Core_Factory_Identity
  • Horde_Core_Factory_Image
  • Horde_Core_Factory_Imple
  • Horde_Core_Factory_Imsp
  • Horde_Core_Factory_ImspAuth
  • Horde_Core_Factory_Injector
  • Horde_Core_Factory_KolabServer
  • Horde_Core_Factory_KolabSession
  • Horde_Core_Factory_KolabStorage
  • Horde_Core_Factory_Ldap
  • Horde_Core_Factory_Lock
  • Horde_Core_Factory_Logger
  • Horde_Core_Factory_LoginTasks
  • Horde_Core_Factory_Mail
  • Horde_Core_Factory_Mapper
  • Horde_Core_Factory_Matcher
  • Horde_Core_Factory_Memcache
  • Horde_Core_Factory_MimeViewer
  • Horde_Core_Factory_Notification
  • Horde_Core_Factory_Perms
  • Horde_Core_Factory_PermsCore
  • Horde_Core_Factory_Prefs
  • Horde_Core_Factory_Request
  • Horde_Core_Factory_Secret
  • Horde_Core_Factory_SessionHandler
  • Horde_Core_Factory_Share
  • Horde_Core_Factory_ShareBase
  • Horde_Core_Factory_Template
  • Horde_Core_Factory_TextFilter
  • Horde_Core_Factory_ThemesCache
  • Horde_Core_Factory_Token
  • Horde_Core_Factory_Tree
  • Horde_Core_Factory_Twitter
  • Horde_Core_Factory_UrlShortener
  • Horde_Core_Factory_Vfs
  • Horde_Core_Factory_View
  • Horde_Core_Factory_Weather
  • Horde_Core_Group_Ldap
  • Horde_Core_Log_Logger
  • Horde_Core_LoginTasks
  • Horde_Core_LoginTasks_Backend_Horde
  • Horde_Core_LoginTasks_SystemTask_Upgrade
  • Horde_Core_Mime_Viewer_Syntaxhighlighter
  • Horde_Core_Mime_Viewer_Vcard
  • Horde_Core_Notification_Event_Status
  • Horde_Core_Notification_Handler_Decorator_Hordelog
  • Horde_Core_Notification_Storage_Session
  • Horde_Core_Perms
  • Horde_Core_Perms_Ui
  • Horde_Core_Prefs_Cache_Session
  • Horde_Core_Prefs_Identity
  • Horde_Core_Prefs_Storage_Configuration
  • Horde_Core_Prefs_Storage_Hooks
  • Horde_Core_Prefs_Storage_Upgrade
  • Horde_Core_Prefs_Ui
  • Horde_Core_Prefs_Ui_Widgets
  • Horde_Core_Share_Driver
  • Horde_Core_Share_FactoryCallback
  • Horde_Core_Sidebar
  • Horde_Core_Text_Filter_Bbcode
  • Horde_Core_Text_Filter_Emails
  • Horde_Core_Text_Filter_Emoticons
  • Horde_Core_Text_Filter_Highlightquotes
  • Horde_Core_Translation
  • Horde_Core_Tree_Html
  • Horde_Core_Tree_Javascript
  • Horde_Core_Tree_Simplehtml
  • Horde_Core_Ui_FlagImage
  • Horde_Core_Ui_JsCalendar
  • Horde_Core_Ui_Language
  • Horde_Core_Ui_Layout
  • Horde_Core_Ui_ModalFormRenderer
  • Horde_Core_Ui_Pager
  • Horde_Core_Ui_Tabs
  • Horde_Core_Ui_TagCloud
  • Horde_Core_Ui_VarRenderer
  • Horde_Core_Ui_VarRenderer_Html
  • Horde_Core_Ui_VarRenderer_TablesetHtml
  • Horde_Core_Ui_Widget
  • Horde_ErrorHandler
  • Horde_Help
  • Horde_Menu
  • Horde_Registry
  • Horde_Registry_Api
  • Horde_Registry_Application
  • Horde_Registry_Caller
  • Horde_Registry_Nlsconfig
  • Horde_Script_Files
  • Horde_Session
  • Horde_Session_Null
  • Horde_Themes
  • Horde_Themes_Cache
  • Horde_Themes_Css
  • Horde_Themes_Element
  • Horde_Themes_Image
  • Horde_Themes_Sound

Exceptions

  • Horde_Exception_HookNotSet
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * This class provides the code needed to generate the Horde sidebar.
  4:  *
  5:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (LGPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  9:  *
 10:  * @author   Michael Slusarz <slusarz@horde.org>
 11:  * @category Horde
 12:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 13:  * @package  Core
 14:  */
 15: class Horde_Core_Sidebar
 16: {
 17:     /**
 18:      * A tree object.
 19:      *
 20:      * @var Horde_Tree_Base
 21:      */
 22:     protected $_tree;
 23: 
 24:     /**
 25:      * Constructor.
 26:      */
 27:     public function __construct()
 28:     {
 29:         // Set up the tree.
 30:         $this->_tree = $GLOBALS['injector']
 31:             ->getInstance('Horde_Core_Factory_Tree')
 32:             ->create('horde_menu', 'Javascript',
 33:                      array('jsvar' => 'HordeSidebar.tree'));
 34:     }
 35: 
 36:     /**
 37:      * Returns whether the sidebar tree is rendered through JavaScript.
 38:      *
 39:      * @return boolean  True if the sidebar is a JavaScript tree.
 40:      */
 41:     public function isJavascript()
 42:     {
 43:         return $this->_tree instanceof Horde_Core_Tree_Javascript;
 44:     }
 45: 
 46:     /**
 47:      * Returns the current tree object, without adding any nodes or further
 48:      * processing.
 49:      *
 50:      * @return Horde_Tree_Base  The current tree object.
 51:      */
 52:     public function getBaseTree()
 53:     {
 54:         return $this->_tree;
 55:     }
 56: 
 57:     /**
 58:      * Generates the sidebar tree object.
 59:      *
 60:      * @return Horde_Tree_Base  The sidebar tree object.
 61:      */
 62:     public function getTree()
 63:     {
 64:         global $registry;
 65: 
 66:         $isAdmin = $registry->isAdmin();
 67:         $menu = $children = array();
 68: 
 69:         foreach ($registry->listApps(array('active', 'admin', 'noadmin', 'heading', 'notoolbar', 'sidebar'), true, null) as $app => $params) {
 70:             /* Check if the current user has permisson to see this application,
 71:              * and if the application is active. Headings are visible to
 72:              * everyone (but get filtered out later if they have no
 73:              * children). Administrators always see all applications except
 74:              * those marked 'inactive'. */
 75:             if ($params['status'] == 'heading' ||
 76:                 (in_array($params['status'], array('active', 'admin', 'noadmin', 'sidebar')) &&
 77:                  $registry->hasPermission((!empty($params['app']) ? $params['app'] : $app), Horde_Perms::SHOW) &&
 78:                  !($isAdmin && $params['status'] == 'noadmin'))) {
 79:                 $menu[$app] = $params;
 80: 
 81:                 if (isset($params['menu_parent'])) {
 82:                     $children[$params['menu_parent']] = true;
 83:                 }
 84:             }
 85:         }
 86: 
 87:         foreach (array_keys($menu) as $key) {
 88:             if (($menu[$key]['status'] == 'heading') &&
 89:                 !isset($children[$key])) {
 90:                 unset($menu[$key]);
 91:             }
 92:         }
 93: 
 94:         /* Add the administration menu if the user is an admin or has any admin
 95:          * permissions. */
 96:         $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
 97:         $admin_item_count = 0;
 98:         try {
 99:             foreach ($registry->callByPackage('horde', 'admin_list') as $method => $val) {
100:                 if ($isAdmin ||
101:                     $perms->hasPermission('horde:administration:' . $method, $registry->getAuth(), Horde_Perms::SHOW)) {
102:                     $admin_item_count++;
103:                     $menu['administration_' . $method] = array(
104:                         'icon' => $val['icon'],
105:                         'menu_parent' => 'administration',
106:                         'name' => Horde::stripAccessKey($val['name']),
107:                         'status' => 'active',
108:                         'url' => Horde::url($registry->applicationWebPath($val['link'], 'horde')),
109:                     );
110:                 }
111:             }
112:         } catch (Horde_Exception $e) {
113:         }
114: 
115:         if ($admin_item_count) {
116:             $menu['administration'] = array(
117:                 'name' => Horde_Core_Translation::t("Administration"),
118:                 'icon' => Horde_Themes::img('administration.png'),
119:                 'status' => 'heading'
120:             );
121:         }
122: 
123:         if (Horde_Menu::showService('prefs') &&
124:             !($GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create() instanceof Horde_Prefs_Session)) {
125:             $menu['prefs'] = array(
126:                 'icon' => Horde_Themes::img('prefs.png'),
127:                 'name' => Horde_Core_Translation::t("Preferences"),
128:                 'status' => 'active'
129:             );
130: 
131:             /* Get a list of configurable applications. */
132:             $prefs_apps = $registry->listApps(array('active', 'admin'), true, Horde_Perms::READ);
133: 
134:             if (!empty($prefs_apps['horde'])) {
135:                 $menu['prefs_' . 'horde'] = array(
136:                     'icon' => $registry->get('icon', 'horde'),
137:                     'menu_parent' => 'prefs',
138:                     'name' => Horde_Core_Translation::t("Global Preferences"),
139:                     'status' => 'active',
140:                     'url' => Horde::getServiceLink('prefs', 'horde')
141:                 );
142:                 unset($prefs_apps['horde']);
143:             }
144: 
145:             uasort($prefs_apps, array($this, '_sortByName'));
146:             foreach ($prefs_apps as $app => $params) {
147:                 $menu['prefs_' . $app] = array(
148:                     'icon' => $registry->get('icon', $app),
149:                     'menu_parent' => 'prefs',
150:                     'name' => $params['name'],
151:                     'status' => 'active',
152:                     'url' => Horde::getServiceLink('prefs', $app)
153:                 );
154:             }
155:         }
156: 
157:         if ($registry->getAuth()) {
158:             $menu['logout'] = array(
159:                 'icon' => Horde_Themes::img('logout.png'),
160:                 'name' => Horde_Core_Translation::t("Log out"),
161:                 'status' => 'active',
162:                 'url' => Horde::getServiceLink('logout', 'horde')
163:             );
164:         } else {
165:             $menu['login'] = array(
166:                 'icon' => Horde_Themes::img('login.png'),
167:                 'name' => Horde_Core_Translation::t("Log in"),
168:                 'status' => 'active',
169:                 'url' => Horde::getServiceLink('login', 'horde')
170:             );
171:         }
172: 
173:         foreach ($menu as $app => $params) {
174:             switch ($params['status']) {
175:             case 'sidebar':
176:                 try {
177:                     $registry->callAppMethod($params['app'], 'sidebarCreate', array('args' => array($this->_tree, empty($params['menu_parent']) ? null : $params['menu_parent'], isset($params['sidebar_params']) ? $params['sidebar_params'] : array())));
178:                 } catch (Horde_Exception $e) {
179:                     if ($e->getCode() != Horde_Registry::NOT_ACTIVE) {
180:                         Horde::logMessage($e, 'ERR');
181:                     }
182:                 }
183:                 break;
184: 
185:             default:
186:                 // Need to run the name through Horde's gettext since the
187:                 // user's locale may not have been loaded when registry.php was
188:                 // parsed, and the translations of the application names are
189:                 // not in the Core package.
190:                 $name = _($params['name']);
191: 
192:                 // Headings have no webroot; they're just containers for other
193:                 // menu items.
194:                 if (isset($params['url'])) {
195:                     $url = $params['url'];
196:                 } elseif (($params['status'] == 'heading') ||
197:                           !isset($params['webroot'])) {
198:                     $url = null;
199:                 } else {
200:                     $url = Horde::url($registry->getInitialPage($app), false, array('app' => $app));
201:                 }
202: 
203:                 $this->_tree->addNode(
204:                     $app,
205:                     empty($params['menu_parent']) ? null : $params['menu_parent'],
206:                     $name,
207:                     0,
208:                     false,
209:                     array(
210:                         'icon' => strval((isset($params['icon']) ? $params['icon'] : $registry->get('icon', $app))),
211:                         'target' => isset($params['target']) ? $params['target'] : null,
212:                         'url' => $url
213:                     )
214:                 );
215:                 break;
216:             }
217:         }
218: 
219:         return $this->_tree;
220:     }
221: 
222:     /**
223:      * Helper method for uasort to sort applications by name.
224:      *
225:      * @param string $a
226:      * @param string $a
227:      *
228:      * @return integer
229:      */
230:     protected function _sortByName($a, $b)
231:     {
232:         return strcoll(_($a['name']), _($b['name']));
233:     }
234: }
235: 
API documentation generated by ApiGen