/** * Global variables defined: * $addSources - TODO * $attributes - (array) Attribute data from the config/attributes.php * file. * $browse_source_count - TODO * $cfgSources - TODO * $copymoveSources - TODO */ protected function _init() { global $injector, $registry, $session; /* For now, autoloading the Content_* classes depend on there being a * registry entry for the 'content' application that contains at least * the fileroot entry. */ $injector->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Content_/', $registry->get('fileroot', 'content') . '/lib/')); if (!class_exists('Content_Tagger')) { throw new Horde_Exception(_("The Content_Tagger class could not be found. Make sure the Content application is installed.")); } // Turba source and attribute configuration. $attributes = $registry->loadConfigFile('attributes.php', 'attributes', 'turba')->config['attributes']; $cfgSources = Turba::availableSources(); /* UGLY UGLY UGLY - we should NOT be using this as a global * variable all over the place. */ $GLOBALS['cfgSources'] =& $cfgSources; // See if any of our sources are configured to use Horde_Share. foreach ($cfgSources as $key => $cfg) { if (!empty($cfg['use_shares'])) { // Create a share instance. $session->set('turba', 'has_share', true); $cfgSources = Turba::getConfigFromShares($cfgSources); break; } } $GLOBALS['attributes'] = $attributes; $cfgSources = Turba::permissionsFilter($cfgSources); // Build the directory sources select widget. if (empty(Turba::$source)) { if (!(Turba::$source = $session->get('turba', 'source'))) { Turba::$source = Turba::getDefaultAddressbook(); } Turba::$source = Horde_Util::getFormData('source', Turba::$source); } $GLOBALS['browse_source_count'] = 0; foreach (Turba::getAddressBooks() as $key => $curSource) { if (!empty($curSource['browse'])) { $GLOBALS['browse_source_count']++; if (empty(Turba::$source)) { Turba::$source = $key; } } } if (empty($cfgSources[Turba::$source]['browse'])) { Turba::$source = Turba::getDefaultAddressbook(); } $session->set('turba', 'source', Turba::$source); $GLOBALS['addSources'] = Turba::getAddressBooks(Horde_Perms::EDIT, array('require_add' => true)); $GLOBALS['copymoveSources'] = $GLOBALS['addSources']; unset($GLOBALS['copymoveSources'][Turba::$source]); }
<?php /** * Turba browse.php. * * Copyright 2000-2016 Horde LLC (http://www.horde.org/) * * See the enclosed file LICENSE for license information (ASL). If you did * did not receive this file, see http://www.horde.org/licenses/apache. * * @author Chuck Hagenbuch <*****@*****.**> * @package Turba */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('turba'); /* If default source is not browsable, try one from the addressbooks pref */ if (empty($cfgSources[Turba::$source]['browse'])) { $addressbooks = Turba::getAddressBooks(); foreach ($addressbooks as $source) { if (!empty($cfgSources[$source]['browse'])) { Turba::$source = $source; break; } } } $params = array('addSources' => $addSources, 'attributes' => $attributes, 'browse_source_count' => $browse_source_count, 'browser' => $browser, 'cfgSources' => $cfgSources, 'copymoveSources' => $copymoveSources, 'conf' => $conf, 'factory' => $injector->getInstance('Turba_Factory_Driver'), 'history' => $injector->getInstance('Horde_History'), 'notification' => $notification, 'page_output' => $page_output, 'prefs' => $prefs, 'registry' => $registry, 'source' => Turba::$source, 'turba_shares' => $injector->getInstance('Turba_Shares'), 'vars' => Horde_Variables::getDefaultVariables()); $browse = new Turba_View_Browse($params); $browse->run();