Useful properties: - newLink: (string, optional) Link of the "New" button - newText: (string) Text of the "New" button - newExtra: (string, optional) HTML content of the extra link - containers: (array, optional) HTML content of any sidebar sections. A list of hashes with the following properties: - id: (string, optional) The container's DOM ID. - header: (array, optional) Container header, also used to toggle the section: - id: (string) The header's DOM ID. - label: (string) Header label. - collapsed: (boolean, optional) Start section collapsed? Overriden by cookies. - add: (string|array, optional) Link to add something: - url: (string) Link URL. - label: (string) Link text. - content: (string, optional) The container's HTML content. - rows: (array, optional) A list of row hashes, if 'content' is not specified. @see addRow(). - resources: (boolean, optional) Does the container contain switchable resource lists? Automatically set through addRow(). - type: (string, optional) @see addRow(). - content: (string, optional) HTML content of the sidebar, if 'containers' is not specified. Copyright 2012-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL-2). If you did not receive this file, see http://www.horde.org/licenses/lgpl.
저자: Jan Schneider (jan@horde.org)
상속: extends Horde_View
예제 #1
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if (Sesha::isAdmin(Horde_Perms::READ) || $perms->hasPermission('sesha:addStock', $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         $sidebar->addNewButton(_("_Add Stock"), Horde::url('stock.php')->add('actionId', 'add_stock'));
     }
 }
예제 #2
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $sidebar->addNewButton(_("_New Bookmark"), Horde::url('add.php'));
     $sidebar->containers['tags'] = array('header' => array('id' => 'trean-toggle-tags', 'label' => _("Tags"), 'collapsed' => false));
     $tagger = $GLOBALS['injector']->getInstance('Trean_Tagger');
     $tags = $tagger->listBookmarkTags();
     natcasesort($tags);
     foreach ($tags as $tag) {
         $url = Horde::url("tag/{$tag}");
         $row = array('url' => $url, 'cssClass' => 'trean-tag', 'label' => $tag);
         $sidebar->addRow($row, 'tags');
     }
 }
예제 #3
0
 /**
  * Adds additional items to the sidebar.
  * This is only for traditional/static view.
  * For dynamic view, see Boneyard_View_Sidebar.php and templates/dynamic/sidebar.html.php
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $sidebar->addNewButton(_("_Add Item"), Horde::url('new.php'));
     /* Checkbox lists are for resources that can be incrementally added to
      * the current content. */
     $sidebar->containers['foo'] = array('header' => array('id' => 'boneyard-toggle-foo', 'label' => _("Foo"), 'collapsed' => false, 'add' => array('url' => Horde::url('foo.php'), 'label' => _("Create a new Foo"))));
     $sidebar->addRow(array('selected' => true, 'url' => Horde::url('foo.php')->add('foo', 1), 'label' => _("One"), 'color' => '#113355', 'edit' => Horde::url('edit.php')->add('foo', 1), 'type' => 'checkbox'), 'foo');
     $sidebar->addRow(array('selected' => false, 'url' => Horde::url('foo.php')->add('foo', 2), 'label' => _("Two"), 'color' => '#557799', 'type' => 'checkbox'), 'foo');
     /* Radiobox lists are for resources that can be displayed mutually
      * exclusive in the current content. */
     $sidebar->containers['bar'] = array('header' => array('id' => 'boneyard-toggle-bar', 'label' => _("Bar"), 'collapsed' => true));
     $sidebar->addRow(array('selected' => true, 'url' => Horde::url('bar.php')->add('bar', 1), 'label' => _("One"), 'color' => '#553311', 'edit' => Horde::url('edit.php')->add('bar', 1), 'type' => 'radiobox'), 'bar');
     $sidebar->addRow(array('selected' => false, 'url' => Horde::url('bar.php')->add('bar', 2), 'label' => _("Two"), 'color' => '#997755', 'type' => 'radiobox'), 'bar');
 }
예제 #4
0
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     $this->content = $sidebar->render('dynamic/sidebar');
 }
예제 #5
0
파일: Sidebar.php 프로젝트: horde/horde
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Event"), $blank, array('id' => 'kronolithNewEvent'));
     $this->newExtra = $blank->link(array_merge(array('id' => 'kronolithQuickEvent'), Horde::getAccessKeyAndTitle(_("Quick _insert"), false, true)));
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     /* Minical. */
     $today = new Horde_Date($_SERVER['REQUEST_TIME']);
     $sidebar->today = $today->format('F Y');
     $sidebar->weekdays = array();
     for ($i = $prefs->getValue('week_start_monday'), $c = $i + 7; $i < $c; $i++) {
         $weekday = Horde_Nls::getLangInfo(constant('DAY_' . ($i % 7 + 1)));
         $sidebar->weekdays[$weekday] = Horde_String::substr($weekday, 0, 2);
     }
     /* Calendars. */
     $sidebar->newShares = $registry->getAuth() && !$prefs->isLocked('default_share');
     $sidebar->admin = $registry->isAdmin();
     $sidebar->resourceAdmin = $registry->isAdmin() || $GLOBALS['injector']->getInstance('Horde_Core_Perms')->hasAppPermission('resource_management');
     $sidebar->resources = $GLOBALS['conf']['resources']['enabled'];
     $sidebar->addRemote = !$prefs->isLocked('remote_cals');
     $remotes = unserialize($prefs->getValue('remote_cals'));
     $sidebar->showRemote = !($prefs->isLocked('remote_cals') && empty($remotes));
     $this->content = $sidebar->render('dynamic/sidebar');
 }
예제 #6
0
파일: Application.php 프로젝트: horde/horde
 /**
  * Adds additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     if ($this->curdomain) {
         $sidebar->addNewButton(_("_New User"), Horde::url('users/edit.php'));
     } else {
         $sidebar->addNewButton(_("_New Domain"), Horde::url('domains/edit.php'));
     }
 }
예제 #7
0
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     global $prefs, $registry;
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Job"), $blank, array('id' => 'boneyardNewJob'));
     $sidebar = $GLOBALS['injector']->createInstance('Horde_View');
     $this->content = $sidebar->render('dynamic/sidebar');
 }
예제 #8
0
파일: Application.php 프로젝트: horde/horde
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if (Mnemo::getDefaultNotepad(Horde_Perms::EDIT) && ($perms->hasAppPermission('max_notes') === true || $perms->hasAppPermission('max_notes') > Mnemo::countMemos())) {
         $sidebar->addNewButton(_("_New Note"), Horde::url('memo.php')->add('actionID', 'add_memo'));
     }
     $url = Horde::url('');
     $edit = Horde::url('notepads/edit.php');
     $user = $GLOBALS['registry']->getAuth();
     $sidebar->containers['my'] = array('header' => array('id' => 'mnemo-toggle-my', 'label' => _("My Notepads"), 'collapsed' => false));
     if (!$GLOBALS['prefs']->isLocked('default_notepad')) {
         $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('notepads/create.php'), 'label' => _("Create a new Notepad"));
     }
     $sidebar->containers['shared'] = array('header' => array('id' => 'mnemo-toggle-shared', 'label' => _("Shared Notepads"), 'collapsed' => true));
     foreach (Mnemo::listNotepads() as $name => $notepad) {
         $url->add(array('display_notepad' => $name, 'actionID' => in_array($name, $GLOBALS['display_notepads']) ? 'remove_displaylist' : 'add_displaylist'));
         $row = array('selected' => in_array($name, $GLOBALS['display_notepads']), 'url' => $url, 'label' => Mnemo::getLabel($notepad), 'color' => $notepad->get('color') ?: '#dddddd', 'edit' => $edit->add('n', $notepad->getName()), 'type' => 'checkbox');
         if ($notepad->get('owner') == $user) {
             $sidebar->addRow($row, 'my');
         } else {
             $sidebar->addRow($row, 'shared');
         }
     }
 }
예제 #9
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     // @TODO: Implement an injector factory for this.
     global $display_tasklists, $page_output, $prefs;
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if (Nag::getDefaultTasklist(Horde_Perms::EDIT) && ($perms->hasAppPermission('max_tasks') === true || $perms->hasAppPermission('max_tasks') > Nag::countTasks())) {
         $sidebar->addNewButton(_("_New Task"), Horde::url('task.php')->add('actionID', 'add_task'));
         if ($GLOBALS['browser']->hasFeature('dom')) {
             $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
             $page_output->addScriptFile('redbox.js', 'horde');
             $blank = new Horde_Url();
             $sidebar->newExtra = $blank->link(array_merge(array('onclick' => 'RedBox.showInline(\'quickAddInfoPanel\'); $(\'quickText\').focus(); return false;'), Horde::getAccessKeyAndTitle(_("_Quick Add"), false, true)));
             require_once NAG_TEMPLATES . '/quick.inc';
         }
     }
     $list = Horde::url('list.php');
     $edit = Horde::url('tasklists/edit.php');
     $user = $GLOBALS['registry']->getAuth();
     $sidebar->containers['my'] = array('header' => array('id' => 'nag-toggle-my', 'label' => _("My Task Lists"), 'collapsed' => false));
     if (!$GLOBALS['prefs']->isLocked('default_tasklist')) {
         $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('tasklists/create.php'), 'label' => _("Create a new Task List"));
     }
     if ($GLOBALS['registry']->isAdmin()) {
         $sidebar->containers['system'] = array('header' => array('id' => 'nag-toggle-system', 'label' => _("System Task Lists"), 'collapsed' => true));
         $sidebar->containers['system']['header']['add'] = array('url' => Horde::url('tasklists/create.php')->add('system', 1), 'label' => _("Create a new System Task List"));
     }
     $sidebar->containers['shared'] = array('header' => array('id' => 'nag-toggle-shared', 'label' => _("Shared Task Lists"), 'collapsed' => true));
     foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $name => $tasklist) {
         $url = $list->add(array('display_tasklist' => $name, 'actionID' => in_array($name, $display_tasklists) ? 'remove_displaylist' : 'add_displaylist'));
         $row = array('selected' => in_array($name, $display_tasklists), 'url' => $url, 'label' => Nag::getLabel($tasklist), 'color' => $tasklist->get('color') ?: '#dddddd', 'edit' => $edit->add('t', $tasklist->getName()), 'type' => 'checkbox');
         if ($GLOBALS['registry']->isAdmin() && is_null($tasklist->get('owner'))) {
             $sidebar->addRow($row, 'system');
         } elseif ($tasklist->get('owner') == $user) {
             $sidebar->addRow($row, 'my');
         } else {
             $sidebar->addRow($row, 'shared');
         }
     }
 }
예제 #10
0
파일: Application.php 프로젝트: horde/horde
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     foreach (Chora::sourceroots() as $key => $val) {
         $row = array('selected' => $GLOBALS['sourceroot'] == $key, 'url' => Chora::url('browsedir', '', array('rt' => $key)), 'label' => $val['name'], 'type' => 'radiobox');
         $sidebar->addRow($row, 'backends');
     }
 }
예제 #11
0
 /**
  * Adds additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     /* Let authenticated users create new galleries. */
     if ($GLOBALS['registry']->isAdmin() || !$GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && $GLOBALS['registry']->getAuth() || $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
         $sidebar->addNewButton(_("_New Gallery"), Horde::url('gallery.php')->add('url', Horde::selfUrl(true, false, true))->add('actionID', 'add'));
     }
 }
예제 #12
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $backend = Gollem_Auth::getPreferredBackend();
     $url = $GLOBALS['registry']->getServiceLink('login', 'horde')->add(array('url' => (string) Horde::url('manager.php', true), 'app' => 'gollem'));
     if ($GLOBALS['conf']['backend']['backend_list'] == 'shown') {
         foreach (Gollem_Auth::getBackend() as $key => $val) {
             $row = array('selected' => $backend == $key, 'url' => $url->add('backend_key', $key), 'label' => $val['name'], 'type' => 'radiobox');
             $sidebar->addRow($row, 'backends');
         }
     }
 }
예제 #13
0
파일: Application.php 프로젝트: horde/horde
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     global $injector, $session;
     $actions = array();
     foreach ($injector->getInstance('Ingo_Factory_Script')->createAll() as $script) {
         $actions = array_merge($actions, $script->availableActions());
     }
     if (!empty($actions) && !$injector->getInstance('Ingo_Factory_Storage')->create()->maxRules()) {
         $sidebar->addNewButton(_("New Rule"), Ingo_Basic_Rule::url());
     }
     if ($injector->getInstance('Ingo_Shares') && count($all_rulesets = $this->_listRulesets()) > 1) {
         $url = Ingo_Basic_Filters::url();
         $current = $session->get('ingo', 'current_share');
         $sidebar->containers['rulesets'] = array('header' => array('id' => 'ingo-toggle-rules', 'label' => _("Ruleset"), 'collapsed' => false));
         foreach ($all_rulesets as $id => $ruleset) {
             $row = array('selected' => $current == $id, 'url' => $url->add('ruleset', $id), 'label' => $ruleset->get('name'), 'type' => 'radiobox');
             $sidebar->addRow($row, 'rulesets');
         }
     }
 }
예제 #14
0
 /**
  * Add additional items to the sidebar. This is for the Basic view. For the
  * Dynamic view @see Hermes_View_Sidebar
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $sidebar->addNewButton(_("_New Time"), Horde::url('entry.php'));
 }
예제 #15
0
파일: Application.php 프로젝트: horde/horde
 /**
  * Adds additional items to the sidebar.
  *
  * This is for the traditional view. For the dynamic view, see
  * Kronolith_View_Sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     global $calendar_manager, $conf, $injector, $prefs, $registry, $session;
     $admin = $registry->isAdmin();
     $perms = $injector->getInstance('Horde_Core_Perms');
     if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && ($perms->hasAppPermission('max_events') === true || $perms->hasAppPermission('max_events') > Kronolith::countEvents())) {
         $sidebar->addNewButton(_("_New Event"), Horde::url('new.php')->add('url', Horde::selfUrl(true, false, true)));
     }
     if (strlen($session->get('kronolith', 'display_cal'))) {
         $calendars = Kronolith::displayedCalendars();
         $sidebar->containers['calendars'] = array('header' => array('id' => 'kronolith-toggle-calendars', 'label' => ngettext("Showing calendar:", "Showing calendars:", count($calendars)), 'collapsed' => false));
         foreach ($calendars as $calendar) {
             $row = array('label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox');
             $sidebar->addRow($row, 'calendars');
         }
         return;
     }
     $user = $registry->getAuth();
     $url = Horde::selfUrl();
     $edit = Horde::url('calendars/edit.php');
     $sidebar->containers['my'] = array('header' => array('id' => 'kronolith-toggle-my', 'label' => _("My Calendars"), 'collapsed' => false));
     if (!$prefs->isLocked('default_share')) {
         $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('calendars/create.php'), 'label' => _("Create a new Local Calendar"));
     }
     if ($admin) {
         $sidebar->containers['system'] = array('header' => array('id' => 'kronolith-toggle-system', 'label' => _("System Calendars"), 'collapsed' => true));
         $sidebar->containers['system']['header']['add'] = array('url' => Horde::url('calendars/create.php')->add('system', 1), 'label' => _("Create a new System Calendar"));
     }
     $sidebar->containers['shared'] = array('header' => array('id' => 'kronolith-toggle-shared', 'label' => _("Shared Calendars"), 'collapsed' => true));
     foreach (Kronolith::listInternalCalendars() as $id => $calendar) {
         $owner = $calendar->get('owner');
         if ($admin && empty($owner)) {
             continue;
         }
         $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', $id), 'label' => Kronolith::getLabel($calendar), 'color' => Kronolith::backgroundColor($calendar), 'edit' => $edit->add('c', $calendar->getName()), 'type' => 'checkbox');
         if ($calendar->get('owner') && $calendar->get('owner') == $user) {
             $sidebar->addRow($row, 'my');
         } else {
             $sidebar->addRow($row, 'shared');
         }
     }
     if ($admin) {
         foreach ($injector->getInstance('Kronolith_Shares')->listSystemShares() as $id => $calendar) {
             $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', $id), 'label' => $calendar->get('name'), 'color' => Kronolith::backgroundColor($calendar), 'edit' => $edit->add('c', $calendar->getName()), 'type' => 'checkbox');
             $sidebar->addRow($row, 'system');
         }
     }
     if (!empty($conf['resources']['enabled']) && ($admin || $perms->hasAppPermission('resource_management'))) {
         $sidebar->containers['groups'] = array('header' => array('id' => 'kronolith-toggle-groups', 'label' => _("Resource Groups"), 'collapsed' => true, 'add' => array('url' => Horde::url('resources/groups/create.php'), 'label' => _("Create a new Resource Group"))));
         $editGroups = Horde::url('resources/groups/edit.php');
         $sidebar->containers['resources'] = array('header' => array('id' => 'kronolith-toggle-resources', 'label' => _("Resources"), 'collapsed' => true, 'add' => array('url' => Horde::url('resources/create.php'), 'label' => _("Create a new Resource"))));
         $edit = Horde::url('resources/edit.php');
         foreach (Kronolith::getDriver('Resource')->listResources() as $resource) {
             if ($resource->get('isgroup')) {
                 $row = array('label' => $resource->get('name'), 'color' => '#dddddd', 'edit' => $editGroups->add('c', $resource->getId()), 'type' => 'radiobox');
                 $sidebar->addRow($row, 'groups');
             } else {
                 $calendar = new Kronolith_Calendar_Resource(array('resource' => $resource));
                 $row = array('selected' => in_array($resource->get('calendar'), $calendar_manager->get(Kronolith::DISPLAY_RESOURCE_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'resource_' . $resource->get('calendar')), 'label' => $calendar->name(), 'color' => $calendar->background(), 'edit' => $edit->add('c', $resource->getId()), 'type' => 'checkbox');
                 $sidebar->addRow($row, 'resources');
             }
         }
     }
     foreach ($calendar_manager->get(Kronolith::ALL_EXTERNAL_CALENDARS) as $id => $calendar) {
         if (!$calendar->display()) {
             continue;
         }
         $app = $registry->get('name', $registry->hasInterface($calendar->api()));
         if (!strlen($app)) {
             $app = _("Other events");
         }
         $container = 'external_' . $app;
         if (!isset($sidebar->containers[$container])) {
             $sidebar->containers[$container] = array('header' => array('id' => 'kronolith-toggle-external-' . $calendar->api(), 'label' => $app, 'collapsed' => true));
         }
         $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_EXTERNAL_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'external_' . $id), 'label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox');
         $sidebar->addRow($row, $container);
     }
     $sidebar->containers['remote'] = array('header' => array('id' => 'kronolith-toggle-remote', 'label' => _("Remote Calendars"), 'collapsed' => true, 'add' => array('url' => Horde::url('calendars/remote_subscribe.php'), 'label' => _("Subscribe to a Remote Calendar"))));
     $edit = Horde::url('calendars/remote_edit.php');
     foreach ($calendar_manager->get(Kronolith::ALL_REMOTE_CALENDARS) as $calendar) {
         $row = array('selected' => in_array($calendar->url(), $calendar_manager->get(Kronolith::DISPLAY_REMOTE_CALENDARS)), 'url' => $url->copy()->add('toggle_calendar', 'remote_' . $calendar->url()), 'label' => $calendar->name(), 'color' => $calendar->background(), 'edit' => $edit->add('url', $calendar->url()), 'type' => 'checkbox');
         $sidebar->addRow($row, 'remote');
     }
     if (!empty($conf['holidays']['enable'])) {
         $sidebar->containers['holidays'] = array('header' => array('id' => 'kronolith-toggle-holidays', 'label' => _("Holidays"), 'collapsed' => true));
         foreach ($calendar_manager->get(Kronolith::ALL_HOLIDAYS) as $id => $calendar) {
             $row = array('selected' => in_array($id, $calendar_manager->get(Kronolith::DISPLAY_HOLIDAYS)), 'url' => $url->copy()->add('toggle_calendar', 'holiday_' . $id), 'label' => $calendar->name(), 'color' => $calendar->background(), 'type' => 'checkbox');
             $sidebar->addRow($row, 'holidays');
         }
     }
 }
예제 #16
0
 /**
  * Constructor.
  *
  * @param array $config  Configuration key-value pairs.
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $blank = new Horde_Url();
     $this->addNewButton(_("_New Task"), $blank, array('id' => 'kronolithNewTask'));
 }
예제 #17
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     if (count($GLOBALS['addSources'])) {
         $sidebar->addNewButton(_("_New Contact"), Horde::url('add.php'));
     }
     $user = $GLOBALS['registry']->getAuth();
     $url = Horde::url('');
     $edit = Horde::url('addressbooks/edit.php');
     $sidebar->containers['my'] = array('header' => array('id' => 'turba-toggle-my', 'label' => _("My Address Books"), 'collapsed' => false));
     if ($GLOBALS['registry']->getAuth() && $GLOBALS['session']->get('turba', 'has_share')) {
         $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('addressbooks/create.php'), 'label' => _("Create a new Address Book"));
     }
     $sidebar->containers['shared'] = array('header' => array('id' => 'turba-toggle-shared', 'label' => _("Shared Address Books"), 'collapsed' => true));
     $shares = array();
     foreach (Turba::listShares(false, Horde_Perms::SHOW) as $id => $abook) {
         $row = array('selected' => $id == Turba::$source, 'url' => $url->add('source', $id), 'label' => $abook->get('name'), 'edit' => $edit->add('a', $abook->getName()), 'type' => 'radiobox');
         if ($abook->get('owner') && $abook->get('owner') == $user) {
             $sidebar->addRow($row, 'my');
             if ($row['selected']) {
                 $sidebar->containers['my']['header']['collapsed'] = false;
             }
         } else {
             if ($abook->get('owner')) {
                 $row['label'] .= ' [' . $GLOBALS['registry']->convertUsername($abook->get('owner'), false) . ']';
             }
             $sidebar->addRow($row, 'shared');
             if ($row['selected']) {
                 $sidebar->containers['shared']['header']['collapsed'] = false;
             }
         }
         $shares[$id] = true;
     }
     $sidebar->containers['other'] = array('header' => array('id' => 'turba-toggle-other', 'label' => _("Other Address Books"), 'collapsed' => true));
     foreach (Turba::getAddressBooks(Horde_Perms::SHOW) as $id => $abook) {
         if (isset($shares[$id])) {
             continue;
         }
         $row = array('selected' => $id == Turba::$source, 'url' => $url->add('source', $id), 'label' => $abook['title'], 'type' => 'radiobox');
         $sidebar->addRow($row, 'other');
         if ($row['selected']) {
             $sidebar->containers['other']['header']['collapsed'] = false;
         }
     }
 }
예제 #18
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     global $injector;
     if (IMP_Compose::canCompose()) {
         $clink = new IMP_Compose_Link();
         $sidebar->addNewButton(_("_New Message"), $clink->link());
     }
     /* Folders. */
     if ($injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) {
         try {
             $tree = $injector->getInstance('Horde_Core_Factory_Tree')->create('imp_menu', 'Horde_Tree_Renderer_Sidebar', array('nosession' => true));
             $ftree = $injector->getInstance('IMP_Ftree');
             $iterator = new IMP_Ftree_IteratorFilter($ftree);
             $iterator->add(array($iterator::REMOTE, $iterator::VFOLDER));
             $tree = $ftree->createTree($tree, array('iterator' => $iterator, 'open' => false, 'poll_info' => true));
             $sidebar->containers['imp-menu'] = array('content' => $tree->getTree());
         } catch (Exception $e) {
         }
     }
 }