public $applications = array();
/**
+ * Application initialization (called from within an application).
+ * Solves chicken-and-egg problem - need a way to init Horde environment
+ * from application without an active Horde_Registry object.
+ *
+ * Page compression will be started (if configured) via this function.
+ *
+ * Global variables defined:
+ * $registry - Registry object
+ *
+ * @param string $app The application to initialize.
+ * @param array $args Optional arguments:
+ * <pre>
+ * 'admin' - (boolean) Require authenticated user to be an admin?
+ * 'authentication' - (string) The type of authentication to use:
+ * 'none' - Do not authenticate
+ * 'throw' - Authenticate; on no auth, throw a Horde_Exception
+ * [DEFAULT] - Authenticate; on no auth redirect to login screen
+ * 'nocompress' - (boolean) Controls whether the page should be
+ * compressed.
+ * 'nologintasks' - (boolean) If set, don't perform logintasks (never
+ * performed if authentication is 'none').
+ * 'session_control' - (string) Sets special session control limitations:
+ * 'netscape' - TODO; start read/write session
+ * 'none' - Do not start a session
+ * 'readonly' - Start session readonly
+ * [DEFAULT] - Start read/write session
+ * </pre>
+ *
+ * @return Horde_Registry_Application The application object.
+ * @throws Horde_Exception
+ */
+ static public function appInit($app, $args = array())
+ {
+ $args = array_merge(array(
+ 'admin' => false,
+ 'authentication' => null,
+ 'nocompress' => false,
+ 'nologintasks' => false,
+ 'session_control' => null
+ ), $args);
+
+ // Registry.
+ $s_ctrl = 0;
+ switch ($args['session_control']) {
+ case 'netscape':
+ if ($GLOBALS['browser']->isBrowser('mozilla')) {
+ session_cache_limiter('private, must-revalidate');
+ }
+ break;
+
+ case 'none':
+ $s_ctrl = self::SESSION_NONE;
+ break;
+
+ case 'readonly':
+ $s_ctrl = self::SESSION_READONLY;
+ break;
+ }
+
+ $GLOBALS['registry'] = self::singleton($s_ctrl);
+ $appob = $GLOBALS['registry']->getApiInstance($app, 'application');
+ $appob->initParams = $args;
+
+ try {
+ $GLOBALS['registry']->pushApp($app, array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => !$args['nologintasks']));
+
+ if ($args['admin'] && !Horde_Auth::isAdmin()) {
+ throw new Horde_Exception('Not an admin');
+ }
+ } catch (Horde_Exception $e) {
+ $appob->appInitFailure($e);
+
+ if ($args['authentication'] == 'throw') {
+ throw $e;
+ }
+
+ Horde_Auth::authenticateFailure($app, $e);
+ }
+
+ if (!$args['nocompress']) {
+ Horde::compressOutput();
+ }
+
+ $appob->init();
+
+ return $appob;
+ }
+
+ /**
* Returns a reference to the global Horde_Registry object, only creating
* it if it doesn't already exist.
*
foreach (array_keys($this->applications) as $app) {
if (in_array($this->applications[$app]['status'], $status)) {
try {
- $api = $this->_getApiInstance($app, 'api');
+ $api = $this->getApiInstance($app, 'api');
$this->_cache['api'][$app] = array(
'api' => array_diff(get_class_methods($api), array('__construct'), $api->disabled),
'links' => $api->links,
* @return Horde_Registry_Api|Horde_Registry_Application The API object.
* @throws Horde_Exception
*/
- protected function _getApiInstance($app, $type)
+ public function getApiInstance($app, $type)
{
if (isset($this->_cache['ob'][$app][$type])) {
return $this->_cache['ob'][$app][$type];
throw new Horde_Exception("$app does not have an API");
}
- $this->_cache['ob'][$app][$type] = new $classname;
+ $this->_cache['ob'][$app][$type] = new $classname();
return $this->_cache['ob'][$app][$type];
}
public function hasAppMethod($app, $method)
{
try {
- $appob = $this->_getApiInstance($app, 'application');
+ $appob = $this->getApiInstance($app, 'application');
} catch (Horde_Exception $e) {
return false;
}
}
/* Load the API now. */
- $api = $this->_getApiInstance($app, 'api');
+ $api = $this->getApiInstance($app, 'api');
/* Make sure that the function actually exists. */
if (!method_exists($api, $call)) {
}
/* Load the API now. */
- $api = $this->_getApiInstance($app, 'application');
+ $api = $this->getApiInstance($app, 'application');
/* Switch application contexts now, if necessary, before
* including any files which might do it for us. Return an
}
try {
- $api = $this->_getApiInstance($app, 'application');
+ $api = $this->getApiInstance($app, 'application');
return $api->version;
} catch (Horde_Exception $e) {
return 'unknown';
}
try {
- $api = $this->_getApiInstance($app, 'application');
+ $api = $this->getApiInstance($app, 'application');
return $api->mobileView;
} catch (Horde_Exception $e) {
return false;
public $disabled = array();
/**
+ * The init params used.
+ *
+ * @var array
+ */
+ public $initParams = array();
+
+ /**
+ * Has init() previously been called?
+ *
+ * @var boolean
+ */
+ protected $_initDone = false;
+
+ /**
+ * Application-specific code to run if application auth fails.
+ * Called from Horde_Registry::appInit().
+ *
+ * @param Horde_Exception $e The exception object.
+ */
+ public function appInitFailure($e)
+ {
+ }
+
+ /**
* Initialization. Does any necessary init needed to setup the full
* environment for the application.
*/
public function init()
{
+ if (!$this->_initDone) {
+ $this->_initDone = true;
+ $this->_init();
+ }
+ }
+
+ /**
+ * Initialization code for an application should be defined in this
+ * function.
+ */
+ protected function _init()
+ {
}
}
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$horde_alarm = Horde_Alarm::factory();
$methods = array();
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$title = _("Command Shell");
require HORDE_TEMPLATES . '/common-header.inc';
}
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
require_once 'Horde/DataTree.php';
$tree = Horde_Tree::factory('datatree', 'Html');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
require_once 'Horde/Group.php';
$groups = Group::singleton();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/* Set up the form variables. */
$vars = Horde_Variables::getDefaultVariables();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/* Set up the form variables. */
$vars = Horde_Variables::getDefaultVariables();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/* Set up the form variables. */
$vars = &Horde_Variables::getDefaultVariables();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$perm_id = Horde_Util::getFormData('perm_id');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$title = _("PHP Shell");
Horde::addScriptFile('stripe.js', 'horde');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$type = !empty($conf['sessionhandler']['type']) ? $conf['sessionhandler']['type'] : 'none';
if ($type == 'external') {
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
if (!Horde_Util::extensionExists('domxml') &&
!Horde_Util::extensionExists('dom')) {
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/* Set up the diff renderer. */
$render_type = Horde_Util::getFormData('render', 'inline');
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/**
* Does an FTP upload to save the configuration.
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
/* Get form data. */
$setup = Horde_Util::getFormData('setup');
*/
require_once dirname(__FILE__) . '/../lib/base.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
// Make sure signups are enabled before proceeding
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$title = _("SQL Shell");
Horde::addScriptFile('stripe.js', 'horde');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
$auth = Horde_Auth::singleton($conf['auth']['driver']);
Horde_Cli::init();
// Include needed libraries.
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
// Authenticate as administrator.
if (!count($conf['auth']['admins'])) {
$cli = Horde_Cli::singleton();
// Include needed libraries.
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
// Get a database connection
$db = $GLOBALS['injector']->getInstance('db-manager');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application(array('authentication' => 'none', 'nologintasks' => true));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'nologintasks' => true));
$main_page = Horde_Util::nonInputVar('horde_login_url', Horde_Util::getFormData('url'));
public $version = '4.0-git';
/**
- * Constructor.
+ * Application initialization.
*
* Global variables defined:
* $notification - Notification object
- * $registry - Registry object
*
* Global constants defined:
* HORDE_TEMPLATES - (string) Location of template files.
- *
- * @param array $args Optional arguments:
- * <pre>
- * 'admin' - (boolean) Require authenticated user to be and admin?
- * 'authentication' - (string) The type of authentication to use:
- * 'none' - Do not authenticate
- * 'throw' - Authenticate; on no auth, throw a Horde_Exception
- * [DEFAULT] - Authenticate; on no auth redirect to login screen
- * 'nocompress' - (boolean) Controls whether the page should be
- * compressed.
- * 'nologintasks' - (boolean) If set, don't perform logintasks (never
- * performed if authentication is 'none').
- * 'session_control' - (string) Sets special session control limitations:
- * 'none' - Do not start a session
- * 'readonly' - Start session readonly
- * [DEFAULT] - Start read/write session
- * </pre>
*/
- public function __construct($args = array())
+ protected function _init()
{
- $args = array_merge(array(
- 'admin' => false,
- 'authentication' => null,
- 'nocompress' => false,
- 'nologintasks' => false,
- 'session_control' => null
- ), $args);
-
- // Registry.
- $s_ctrl = 0;
- switch ($args['session_control']) {
- case 'none':
- $s_ctrl = Horde_Registry::SESSION_NONE;
- break;
-
- case 'readonly':
- $s_ctrl = Horde_Registry::SESSION_READONLY;
- break;
- }
- $GLOBALS['registry'] = Horde_Registry::singleton($s_ctrl);
-
- try {
- $GLOBALS['registry']->pushApp('horde', array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => !$args['nologintasks']));
-
- if ($args['admin'] && !Horde_Auth::isAdmin()) {
- throw new Horde_Exception('Not an admin');
- }
- } catch (Horde_Exception $e) {
- if ($args['authentication'] == 'throw') {
- throw $e;
- }
-
- Horde_Auth::authenticateFailure('horde', $e);
- }
-
if (!defined('HORDE_TEMPLATES')) {
define('HORDE_TEMPLATES', $GLOBALS['registry']->get('templates'));
}
$GLOBALS['notification'] = Horde_Notification::singleton();
$GLOBALS['notification']->attach('status');
-
- // Start compression.
- if (!$args['nocompress']) {
- Horde::compressOutput();
- }
}
/**
* Returns a list of available permissions.
+ *
+ * @return array TODO
*/
public function perms()
{
* constructor. */
require_once dirname(__FILE__) . '/lib/Application.php';
try {
- new Horde_Application(array('authentication' => 'throw', 'nologintasks' => true));
+ Horde_Registry::appInit('horde', array('authentication' => 'throw', 'nologintasks' => true));
} catch (Horde_Exception $e) {}
$app = Horde_Util::getFormData('app');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
// Set up our request and routing objects
$request = new Horde_Controller_Request_Http();
}
/* Load base libraries. */
-new Horde_Application(array('authentication' => 'none', 'nocompress' => $nocompress, 'session_control' => $session_control));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'nocompress' => $nocompress, 'session_control' => $session_control));
/* Load the RPC backend based on $serverType. */
$server = Horde_Rpc::factory($serverType, $params);
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
$auth = Horde_Auth::singleton($conf['auth']['driver']);
// Make sure we load Horde base to get the auth config
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
$dsn = $argv[1];
// Make sure we load Horde base to get the auth config
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
Horde_Cli::init();
$cli = Horde_Cli::singleton();
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
require_once 'Horde/DataTree.php';
$datatree = DataTree::factory('sql',
// some variables, etc.
Horde_Cli::init();
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
require_once 'Horde/Group.php';
$g = Group::factory();
// some variables, etc.
Horde_Cli::init();
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$p = Perms::factory('datatree');
// some variables, etc.
Horde_Cli::init();
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$cli = Horde_Cli::singleton();
$cManager = new Horde_Prefs_CategoryManager();
$cli->writeln($cli->yellow("Beginning migration. This may take a very long time to complete."));
$cli->writeln();
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
require_once 'Horde/DataTree.php';
$datatree = DataTree::factory('sql', array_merge(Horde::getDriverConfig('datatree', 'sql'),
$session_cache_limiter = 'nocache';
}
-new Horde_Application(array('authentication' => 'none', 'session_control' => 'readonly'));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'readonly'));
switch ($type) {
case 'app':
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
$cid = Horde_Util::getFormData('cid');
if (empty($cid)) {
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
// Make sure auth backend allows passwords to be reset.
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
$identity = Horde_Prefs_Identity::singleton();
list($message, $type) = $identity->confirmIdentity(Horde_Util::getFormData('h'));
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
if (empty($GLOBALS['conf']['facebook']['enabled']) ||
empty($GLOBALS['conf']['facebook']['key']) ||
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none', 'session_control' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'none'));
if (empty($_GET['url'])) {
exit;
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$rtl = isset(Horde_Nls::$config['rtl'][$language]);
$title = _("Help");
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
/* Get file info. The following parameters are available:
* 'f' - the filename.
}
}
-new Horde_Application(array('nologintasks' => true, 'session_control' => empty($args['sessionWrite']) ? 'readonly' : null));
+Horde_Registry::appInit('horde', array('nologintasks' => true, 'session_control' => empty($args['sessionWrite']) ? 'readonly' : null));
$impleargs = $impleName;
if (isset($args['impleApp'])) {
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('session_control' => 'readonly'));
+Horde_Registry::appInit('horde', array('session_control' => 'readonly'));
// Figure out if we've been inlined, or called directly.
$send_headers = strstr($_SERVER['PHP_SELF'], 'javascript.php');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
$title = _("Special Character Input");
require HORDE_TEMPLATES . '/common-header.inc';
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
/* Set the language. */
$_SESSION['horde_language'] = Horde_Nls::select();
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
/* If no 'module' parameter passed in, die with an error. */
if (!($app = basename(Horde_Util::getFormData('app')))) {
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
$path = Horde_Util::getFormData('path');
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('nologintaks' => true));
+Horde_Registry::appInit('horde', array('nologintaks' => true));
// If/when more apps support the searchTags api calls, we should probably
// find a better solution to putting the apps hardcoded like this.
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
// Instantiate the blocks objects.
$blocks = Horde_Block_Collection::singleton('portal');
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
// Get full name.
$identity = Horde_Prefs_Identity::singleton();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
$identity = Horde_Prefs_Identity::singleton();
$fullname = $identity->getValue('fullname');
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
$rpc_servers = @unserialize($prefs->getValue('remote_summaries'));
if (!is_array($rpc_servers)) {
}
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
if (!Horde_Auth::getAuth() && !$conf['menu']['always']) {
Horde_Auth::authenticateFailure();
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
$backend = SyncML_Backend::factory('Horde');
}
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
if (!Horde::showService('problem')) {
_returnToPage();
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
// Make sure auth backend allows passwords to be reset.
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
// Exit if the user shouldn't be able to change share permissions.
if (!empty($conf['share']['no_sharing'])) {
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
$alarm = Horde_Alarm::factory();
$id = Horde_Util::getPost('alarm');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
if (empty($GLOBALS['conf']['twitter']['enabled'])) {
$horde_url = Horde::url($registry->get('webroot', 'horde') . '/index.php');
*/
require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
$twitter = new Services_Twitter($_SESSION['horde']['twitterblock']['username'],
$_SESSION['horde']['twitterblock']['password']);
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-$api = new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
if (!empty($conf['testdisable'])) {
echo '<h2 style="color:red">Horde test scripts have been disabled in the local configuration.</h2>';
/* If we've gotten this far, we should have found enough of Horde to run
* tests. Create the testing object. */
if ($app != 'horde') {
- $registry->pushApp($app, array('check_perms' => false));
- print "C";
+ $registry->pushApp($app, array('check_perms' => false, 'init' => true));
}
$classname = ucfirst($app) . '_Test';
if (!class_exists($classname)) {
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
/* Redirect back to the options screen if ACL is not enabled. */
$prefs_url = Horde::getServiceLink('options', 'imp');
}
try {
- new IMP_Application(array('init' => array('authentication' => 'throw', 'session_control' => $session_control)));
+ Horde_Registry::appInit('imp', array('authentication' => 'throw', 'session_control' => $session_control));
} catch (Horde_Exception $e) {
/* Handle session timeouts when they come from an AJAX request. */
if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
// We do not need to be authenticated to get the file. Most users won't send
// linked attachments just to other IMP users.
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'none', 'session_control' => 'none')));
+Horde_Registry::appInit('imp', array('authentication' => 'none', 'session_control' => 'none'));
// Lets see if we are even able to send the user an attachment.
if (!$conf['compose']['link_attachments']) {
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* Determine if compose mode is disabled. */
$compose_disable = !IMP::canCompose();
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* The message text and headers. */
$expand = array();
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('session_control' => 'netscape'), 'tz' => true));
+Horde_Registry::appInit('imp', array('session_control' => 'netscape', 'tz' => true));
/* The message headers and text. */
$header = array();
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'horde')));
+Horde_Registry::appInit('imp', array('authentication' => 'horde'));
/* Get the lists of address books through the API. */
$source_list = $registry->call('contacts/sources');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
/* Are preferences locked? */
$login_locked = $prefs->isLocked('filter_on_login') || empty($_SESSION['imp']['filteravail']);
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
/* Redirect back to the mailbox if folder use is not allowed. */
if (empty($conf['user']['allow_folders'])) {
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
+
Horde::addScriptFile('folders.js', 'imp');
/* Redirect back to the mailbox if folder use is not allowed. */
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
$scripts = array(
array('ContextSensitive.js', 'imp'),
// Will redirect to login page if not authenticated.
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
// Load initial page as defined by view mode & preferences.
require IMP_Auth::getInitialPage();
public $version = 'H4 (5.0-git)';
/**
- * Disable compression of pages?
- *
- * @var boolean
- */
- protected $_noCompress = false;
-
- /**
- * The auth type to use.
- *
- * @var string
- */
- static public $authType = null;
-
- /**
* Cached data for prefs pages.
*
* @var array
static public $prefsCache = array();
/**
- * Has init previously been called?
- *
- * @var boolean
+ * Constructor.
*/
- static protected $_init = false;
+ public function __construct()
+ {
+ /* Methods only available if admin config is set for this
+ * server/login. */
+ if (empty($_SESSION['imp']['admin'])) {
+ $this->disabled = array_merge($this->disabled, array('authAddUser', 'authRemoveUser', 'authUserList'));
+ }
+ }
/**
- * Constructor.
+ * Application-specific code to run if application auth fails.
*
- * @param array $args The following entries:
- * <pre>
- * 'init' - (boolean|array) If true, perform application init. If an
- * array, perform application init and pass the array to
- * self::_impInit().
- * 'tz' - (boolean) If true, sets the current time zone on the server.
- * </pre>
+ * @param Horde_Exception $e The exception object.
*/
- public function __construct($args = array())
+ public function appInitFailure($e)
{
- if (!empty($args['init'])) {
- $this->_impInit(is_array($args['init']) ? $args['init'] : array());
- }
-
- if (!empty($args['tz'])) {
- Horde_Nls::setTimeZone();
- }
-
- /* Only available if admin config is set for this server/login. */
- if (empty($_SESSION['imp']['admin'])) {
- $this->disabled = array_merge($this->disabled, array('authAddUser', 'authRemoveUser', 'authUserList'));
+ if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
+ Horde_Util::getFormData('composeCache')) {
+ $imp_compose = IMP_Compose::singleton();
+ $imp_compose->sessionExpireDraft();
}
}
/**
- * IMP base initialization.
+ * Initialization function.
*
* Global variables defined:
* $imp_imap - An IMP_Imap object
* $imp_notify - A Horde_Notification_Listener object
* $imp_search - An IMP_Search object
* $notification - Notification object
- * $registry - Registry object
*
* Global constants defined:
* IMP_TEMPLATES - (string) Location of template files.
*
- * @param array $args Optional arguments:
+ * When calling Horde_Registry::appInit(), the following parameters are
+ * also supported:
* <pre>
- * 'authentication' - (string) The type of authentication to use:
- * 'horde' - Only use horde authentication
- * 'none' - Do not authenticate
- * 'throw' - Authenticate to IMAP/POP server; on no auth, throw a
- * Horde_Exception
- * [DEFAULT] - Authenticate to IMAP/POP server; on no auth redirect to
- * login screen
- * 'nocompress' - (boolean) Controls whether the page should be
- * compressed.
- * 'session_control' - (string) Sets special session control limitations:
- * 'netscape' - TODO; start read/write session
- * 'none' - Do not start a session
- * 'readonly' - Start session readonly
- * [DEFAULT] - Start read/write session
+ * 'tz' - (boolean) If true, sets the current time zone on the server.
* </pre>
*/
- protected function _impInit($args = array())
+ protected function _init()
{
- $args = array_merge(array(
- 'authentication' => null,
- 'nocompress' => false,
- 'session_control' => null
- ), $args);
-
- self::$authType = $args['authentication'];
- $this->_noCompress = $args['nocompress'];
-
- // Registry.
- $s_ctrl = 0;
- switch ($args['session_control']) {
- case 'netscape':
- if ($GLOBALS['browser']->isBrowser('mozilla')) {
- session_cache_limiter('private, must-revalidate');
- }
- break;
-
- case 'none':
- $s_ctrl = Horde_Registry::SESSION_NONE;
- break;
-
- case 'readonly':
- $s_ctrl = Horde_Registry::SESSION_READONLY;
- break;
- }
- $GLOBALS['registry'] = Horde_Registry::singleton($s_ctrl);
-
- try {
- $GLOBALS['registry']->pushApp('imp', array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => true));
- } catch (Horde_Exception $e) {
- if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
- if (Horde_Util::getFormData('composeCache')) {
- $imp_compose = IMP_Compose::singleton();
- $imp_compose->sessionExpireDraft();
- }
-
- if ($args['authentication'] == 'throw') {
- throw $e;
- }
- }
-
- Horde_Auth::authenticateFailure('imp', $e);
- }
-
- $this->init();
- }
-
- /**
- * Initialization function.
- */
- public function init()
- {
- if (self::$_init) {
- return;
+ if (!empty($this->initParams['tz'])) {
+ Horde_Nls::setTimeZone();
}
if (!defined('IMP_TEMPLATES')) {
define('IMP_TEMPLATES', $registry->get('templates'));
}
- // Start compression.
- if (!$this->_noCompress) {
- Horde::compressOutput();
- }
-
// Initialize global $imp_imap object.
if (!isset($GLOBALS['imp_imap'])) {
$GLOBALS['imp_imap'] = new IMP_Imap();
// Initialize global $imp_mbox array. This call also initializes the
// IMP_Search object.
IMP::setCurrentMailboxInfo();
-
- self::$_init = true;
}
/* Horde permissions. */
*/
public function authAuthenticate($userId, $credentials)
{
- $this->_impInit(array('authentication' => 'none'));
+ $this->init();
$new_session = IMP_Auth::authenticate(array(
'password' => $credentials['password'],
*/
public function authTransparent($auth_ob)
{
- $this->_impInit(array('authentication' => 'none'));
+ $this->init();
return IMP_Auth::transparent($auth_ob);
}
public function authAuthenticateCallback()
{
if (Horde_Auth::getAuth()) {
- $this->_impInit();
+ $this->init();
IMP_Auth::authenticateCallback();
}
}
*/
public function prefsStatus()
{
- require_once dirname(__FILE__) . '/Application.php';
- new IMP_Application(array('init' => array('authentication' => 'none')));
-
$notification = Horde_Notification::singleton();
$notification->replace('status', array('prefs' => true, 'viewmode' => 'dimp'), 'IMP_Notification_Listener_Status');
}
*/
public function changeLanguage()
{
- try {
- $this->_impInit(array('authentication' => 'throw'));
- } catch (Horde_Exception $e) {
- return;
- }
-
+ $this->init();
$this->_mailboxesChanged();
$GLOBALS['imp_search']->initialize(true);
}
static public function authenticate($credentials = array())
{
// Do 'horde' authentication.
- if (IMP_Application::$authType == 'horde') {
+ $imp_app = $GLOBALS['registry']->getApiInstance('imp', 'application');
+ if ($imp_app->initParams['authentication'] == 'horde') {
if (Horde_Auth::getAuth()) {
return false;
}
protected function _content()
{
- try {
- new IMP_Application(array('init' => array('authentication' => 'throw')));
- } catch (Horde_Exception $e) {
- return;
- }
-
/* Filter on INBOX display, if requested. */
if ($GLOBALS['prefs']->getValue('filter_on_display')) {
$imp_filter = new IMP_Filter();
protected function _content()
{
- try {
- new IMP_Application(array('init' => array('authentication' => 'throw')));
- } catch (Horde_Exception $e) {
- return;
- }
-
/* Filter on INBOX display, if requested. */
if ($GLOBALS['prefs']->getValue('filter_on_display')) {
$imp_filter = new IMP_Filter();
{
global $notification, $prefs, $registry;
- try {
- new IMP_Application(array('init' => array('authentication' => 'throw')));
- } catch (Horde_Exception $e) {
- return;
- }
-
$html = '<table cellspacing="0" width="100%">';
/* Filter on INBOX display, if requested. */
protected function _buildTree(&$tree, $indent = 0, $parent = null)
{
- try {
- new IMP_Application(array('init' => array('authentication' => 'throw')));
- } catch (Horde_Exception $e) {
- return;
- }
-
/* Run filters now */
if ($GLOBALS['prefs']->getValue('filter_on_sidebar')) {
$imp_filter = new IMP_Filter();
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* Determine if mailbox is readonly. */
$readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* Call the mailbox redirection hook, if requested. */
try {
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
$folder = Horde_Util::getFormData('folder');
$uid = Horde_Util::getFormData('uid');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* Make sure we have a valid index. */
$imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']);
}
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* We know we are going to be exclusively dealing with this mailbox, so
* select it on the IMAP server (saves some STATUS calls). Open R/W to clear
}
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
$imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
$secure_check = Horde::isConnectionSecure();
require_once dirname(__FILE__) . '/lib/Application.php';
try {
- new IMP_Application(array('init' => array('authentication' => 'throw')));
+ Horde_Registry::appInit('imp', array('authentication' => 'throw'));
} catch (Horde_Exception $e) {
//!$auth->authenticate($_SERVER['PHP_AUTH_USER'], array('password' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)))) {
header('WWW-Authenticate: Basic realm="IMP RSS Interface"');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
$id = Horde_Util::getFormData('id');
$muid = Horde_Util::getFormData('muid');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
if ($_SESSION['imp']['protocol'] == 'pop') {
if ($_SESSION['imp']['view'] == 'imp') {
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
/* Load basic search if javascript is not enabled or searching is not
* allowed (basic page will do the required redirection in the latter case). */
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
$imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
$secure_check = Horde::isConnectionSecure();
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'horde')));
+Horde_Registry::appInit('imp', array('authentication' => 'horde'));
$compose_url = Horde::getServiceLink('options', 'imp');
*/
require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
/* What mode are we in?
* DEFAULT/'thread' - Thread mode
/* Don't compress if we are already sending in compressed format. */
$actionID = Horde_Util::getFormData('actionID');
-new IMP_Application(array('init' => array(
+Horde_Registry::appInit('imp', array(
'nocompress' => (($actionID == 'download_all') || Horde_Util::getFormData('zip')),
'session_control' => 'readonly'
-)));
+));
$ctype = Horde_Util::getFormData('ctype');
$id = Horde_Util::getFormData('id');
--- /dev/null
+<?php
+/* Defines the location of the Horde base directory, if it is not in its
+ * default location (TODO: where is default). */
+define('HORDE_BASE', '/path/to/horde');
<?php
+/**
+ * Skeleton application API.
+ *
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Horde through this API.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package IMP
+ */
+
+/* Determine the base directories. */
+if (!defined('SKELETON_BASE')) {
+ define('SKELETON_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If Horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(SKELETON_BASE . '/config/horde.local.php')) {
+ include SKELETON_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', SKELETON_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
class Skeleton_Application extends Horde_Registry_Application
{
+ /**
+ * The application's version.
+ *
+ * @var string
+ */
public $version = 'H4 (0.1-git)';
/**
+ * Initialization function.
+ *
+ * Global variables defined:
+ * $notification - Notification object
+ *
+ * Global constants defined:
+ * SKELETON_TEMPLATES - (string) Location of template files.
+ */
+ protected function _init()
+ {
+ if (!defined('SKELETON_TEMPLATES')) {
+ define('SKELETON_TEMPLATES', $GLOBALS['registry']->get('templates'));
+ }
+
+ // Notification system.
+ $notification = Horde_Notification::singleton();
+ $notification->attach('status');
+ }
+
+ /**
* Generate the menu to use on the prefs page.
*
* @return Horde_Menu A Horde_Menu object.
+++ /dev/null
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Skeleton
- */
-
-if (!defined('SKELETON_BASE')) {
- define('SKELETON_BASE', dirname(__FILE__). '/..');
-}
-
-if (!defined('HORDE_BASE')) {
- /* If horde does not live directly under the app directory, the HORDE_BASE
- * constant should be defined in config/horde.local.php. */
- if (file_exists(SKELETON_BASE. '/config/horde.local.php')) {
- include SKELETON_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', SKELETON_BASE . '/..');
- }
-}
+++ /dev/null
-<?php
-/**
- * Skeleton base application file.
- *
- * This file brings in all of the dependencies that every Skeleton script will
- * need, and sets up objects that all scripts use.
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// // Load the Horde Framework core.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
- $registry->pushApp('skeleton', array('check_perms' => true, 'logintasks' => true));
-} catch (Horde_Exception $e) {
- Horde_Auth::authenticateFailure('skeleton', $e);
-}
-
-$conf = &$GLOBALS['conf'];
-@define('SKELETON_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Start output compression.
-Horde::compressOutput();
* @author Your Name <you@example.com>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('skeleton');
$title = _("List");
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
require_once TURBA_BASE . '/lib/Forms/AddContact.php';
/* Setup some variables. */
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*/
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
require_once TURBA_BASE . '/lib/Forms/CreateAddressBook.php';
// Exit if this isn't an authenticated user, or if there's no source
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*/
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
require_once TURBA_BASE . '/lib/Forms/DeleteAddressBook.php';
// Exit if this isn't an authenticated user, or if there's no source
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*/
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
require_once TURBA_BASE . '/lib/Forms/EditAddressBook.php';
// Exit if this isn't an authenticated user, or if there's no source
* did not receive this file, see http://www.horde.org/licenses/asl.php.
*/
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
// Exit if this isn't an authenticated user, or if there's no source
// configured for shares.
* @package Turba
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
$params = array(
'vars' => Horde_Variables::getDefaultVariables(),
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
$vars = Horde_Variables::getDefaultVariables();
$source = $vars->get('source');
return implode(', ', $result);
}
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
if (!$conf['menu']['import_export']) {
require TURBA_BASE . '/index.php';
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
$source = Horde_Util::getFormData('source');
$key = Horde_Util::getFormData('key');
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
if ($conf['documents']['type'] == 'none') {
exit;
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
require_once TURBA_BASE . '/lib/Forms/EditContact.php';
$listView = null;
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
require TURBA_BASE . '/' . ($browse_source_count
? basename($prefs->getValue('initial_page'))
: 'search.php');
return false;
}
- require_once dirname(__FILE__) . '/base.php';
- global $cfgSources;
-
@list($source, $key) = explode('.', $id, 2);
- if (isset($cfgSources[$source]) && $key) {
+ if (isset($GLOBALS['cfgSources'][$source]) && $key) {
$driver = Turba_Driver::singleton($source);
if (!is_a($driver, 'PEAR_Error')) {
$object = $driver->getObject($key);
*/
public function sources($writeable = false)
{
- require_once dirname(__FILE__) . '/base.php';
-
$addressbooks = Turba::getAddressBooks($writeable ? Horde_Perms::EDIT : Horde_Perms::READ);
foreach ($addressbooks as $addressbook => $config) {
$addressbooks[$addressbook] = $config['title'];
*/
public function fields($source = null)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $attributes;
if (empty($source) || !isset($cfgSources[$source])) {
{
global $prefs;
- // Bring in turba's base and a clean copy of sources.
- require_once dirname(__FILE__) . '/base.php';
+ // Bring in a clean copy of sources.
require TURBA_BASE . '/config/sources.php';
if (!empty($_SESSION['turba']['has_share'])) {
*/
public function browse($path = '', $properties = array())
{
- require_once dirname(__FILE__) . '/base.php';
global $registry, $cfgSources;
// Default properties.
*/
public function path_delete($path)
{
- require_once dirname(__FILE__) . '/base.php';
global $registry, $cfgSources;
// Strip off the application name if present
*/
public function listContacts($sources = null)
{
- require_once dirname(__FILE__) . '/base.php';
-
global $cfgSources, $prefs;
/* Get default address book from user preferences. */
public function listBy($action, $timestamp, $sources = null)
{
global $prefs, $cfgSources;
- require_once dirname(__FILE__) . '/base.php';
/* Get default address book from user preferences. */
if (empty($sources)) {
public function getActionTimestamp($uid, $action, $sources = null)
{
global $prefs, $cfgSources;
- require_once dirname(__FILE__) . '/base.php';
/* Get default address book from user preferences. */
if (empty($sources)) {
public function import($content, $contentType = 'array',
$import_source = null)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $prefs;
/* Get default address book from user preferences. */
*/
public function export($uid, $contentType, $sources = null, $fields = null)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $prefs;
/* Get default address book from user preferences. */
*/
public function getOwnContactObject()
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
$own_contact = $GLOBALS['prefs']->getValue('own_contact');
return true;
}
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $prefs;
/* Get default address book from user preferences. */
*/
public function replace($uid, $content, $contentType, $sources = null)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $prefs;
/* Get default address book from user preferences. */
$fields = array(), $matchBegin = false,
$forceSource = false)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources, $attributes, $prefs;
if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
*/
public function getContact($source = null, $objectId = '')
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
*/
public function getContacts($source = '', $objectIds = array())
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
$results = array();
if (!is_array($objectIds)) {
*/
public function getAllAttributeValues($field = '', $sources = array())
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
*/
public function listTimeObjectCategories()
{
- require_once dirname(__FILE__) . '/base.php';
-
$categories = array();
foreach ($GLOBALS['attributes'] as $key => $attribute) {
if ($attribute['type'] == 'monthdayyear' &&
*/
public function listTimeObjects($time_categories, $start, $end)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
$start = new Horde_Date($start);
$value = '',
$source = '')
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
if (empty($source) || !isset($cfgSources[$source])) {
public function getField($address = '', $field = '', $sources = array(),
$strict = false, $multiple = false)
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
if (empty($address)) {
*/
public function deleteField($address = '', $field = '', $sources = array())
{
- require_once dirname(__FILE__) . '/base.php';
global $cfgSources;
if (empty($address)) {
/**
* Turba application API.
*
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Horde through this API.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
* @package Turba
*/
+
+/* Determine the base directories. */
+if (!defined('TURBA_BASE')) {
+ define('TURBA_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+ /* If Horde does not live directly under the app directory, the HORDE_BASE
+ * constant should be defined in config/horde.local.php. */
+ if (file_exists(TURBA_BASE . '/config/horde.local.php')) {
+ include TURBA_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', TURBA_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
class Turba_Application extends Horde_Registry_Application
{
/**
public $version = 'H4 (3.0-git)';
/**
+ * Initialization.
+ *
+ * Global variables defined:
+ * $addSources - TODO
+ * $attributes - TODO
+ * $browse_source_count - TODO
+ * $browse_source_options - TODO
+ * $cfgSources - TODO
+ * $copymove_source_options - TODO
+ * $copymoveSources - TODO
+ * $notification - Notification object
+ * $turba_shares - TODO
+ *
+ * Global constants defined:
+ * TURBA_TEMPLATES - (string) Location of template files.
+ *
+ * When calling Horde_Registry::appInit(), the following parameters are
+ * also supported:
+ * <pre>
+ * 'user' - (string) Set authentication to this user.
+ * </pre>
+ */
+ protected function _init()
+ {
+ if (isset($this->initParams['user'])) {
+ Horde_Auth::setAuth($this->initParams['user'], array());
+ }
+
+ if (!defined('TURBA_TEMPLATES')) {
+ define('TURBA_TEMPLATES', $GLOBALS['registry']->get('templates'));
+ }
+
+ $GLOBALS['notification'] = Horde_Notification::singleton();
+ $GLOBALS['notification']->attach('status');
+
+ // Turba source and attribute configuration.
+ include TURBA_BASE . '/config/attributes.php';
+ include TURBA_BASE . '/config/sources.php';
+
+ /* 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['turba']['has_share'] = true;
+ $GLOBALS['turba_shares'] = Horde_Share::singleton('turba');
+ $cfgSources = Turba::getConfigFromShares($cfgSources);
+ break;
+ }
+ }
+
+ $GLOBALS['attributes'] = $attributes;
+ $cfgSources = Turba::permissionsFilter($cfgSources);
+
+ // Build the directory sources select widget.
+ $default_source = Horde_Util::nonInputVar('source');
+ if (empty($default_source)) {
+ $default_source = empty($_SESSION['turba']['source'])
+ ? Turba::getDefaultAddressBook()
+ : $_SESSION['turba']['source'];
+ $default_source = Horde_Util::getFormData('source', $default_source);
+ }
+
+ $GLOBALS['browse_source_count'] = 0;
+ $GLOBALS['browse_source_options'] = '';
+
+ foreach (Turba::getAddressBooks() as $key => $curSource) {
+ if (!empty($curSource['browse'])) {
+ $selected = ($key == $default_source) ? ' selected="selected"' : '';
+ $GLOBALS['browse_source_options'] .= '<option value="' . htmlspecialchars($key) . '" ' . $selected . '>' .
+ htmlspecialchars($curSource['title']) . '</option>';
+
+ ++$GLOBALS['browse_source_count'];
+
+ if (empty($default_source)) {
+ $default_source = $key;
+ }
+ }
+ }
+
+ if (empty($cfgSources[$default_source]['browse'])) {
+ $default_source = Turba::getDefaultAddressBook();
+ }
+ $_SESSION['turba']['source'] = $default_source;
+ $GLOBALS['default_source'] = $default_source;
+
+ /* Only set $add_source_options if there is at least one editable
+ * address book that is not the current address book. */
+ $addSources = Turba::getAddressBooks(Horde_Perms::EDIT, array('require_add' => true));
+ $copymove_source_options = '';
+ $copymoveSources = $addSources;
+ unset($copymoveSources[$default_source]);
+ foreach ($copymoveSources as $key => $curSource) {
+ if ($key != $default_source) {
+ $copymove_source_options .= '<option value="' . htmlspecialchars($key) . '">' .
+ htmlspecialchars($curSource['title']) . '</option>';
+ }
+ }
+
+ $GLOBALS['addSources'] = $addSources;
+ $GLOBALS['copymove_source_options'] = $copymove_source_options;
+ $GLOBALS['copymoveSources'] = $copymoveSources;
+ }
+
+ /**
* Returns a list of available permissions.
*
* @return array An array describing all available permissions.
return $perms;
}
- require_once dirname(__FILE__) . '/base.php';
require TURBA_BASE . '/config/sources.php';
$perms['tree']['turba']['sources'] = false;
*/
public function removeUserData($user)
{
- require_once dirname(__FILE__) . '/base.php';
-
if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
return PEAR::raiseError(_("You are not allowed to remove user data."));
}
*/
function _content()
{
- require_once dirname(__FILE__) . '/../base.php';
-
if ($GLOBALS['browser']->hasFeature('iframes')) {
Horde::addScriptFile('prototype.js', 'horde');
return Horde_Util::bufferOutput(
{
global $registry;
- require_once dirname(__FILE__) . '/../base.php';
-
$browse = Horde::applicationUrl('browse.php');
$add = Horde::applicationUrl('add.php');
$icondir = $registry->getImageDir() . '/menu';
+++ /dev/null
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Turba
- */
-
-if (!defined('TURBA_BASE')) {
- define('TURBA_BASE', dirname(__FILE__) . '/..');
-}
-
-if (!defined('HORDE_BASE')) {
- /* If horde does not live directly under the app directory, the HORDE_BASE
- * constant should be defined in config/horde.local.php. */
- if (file_exists(TURBA_BASE . '/config/horde.local.php')) {
- include TURBA_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', TURBA_BASE . '/..');
- }
-}
+++ /dev/null
-<?php
-/**
- * Turba base inclusion file.
- *
- * This file brings in all of the dependencies that every Turba script will
- * need, and sets up objects that all scripts use.
- *
- * The following global variables are used:
- * <pre>
- * $ingo_authentication - The type of authentication to use:
- * 'none' - Do not authenticate
- * [DEFAULT] - Authenticate; on failed auth redirect to login screen
- * $no_compress - Controls whether the page should be compressed
- * </pre>
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
- $registry->pushApp('turba', array('check_perms' => (Horde_Util::nonInputVar('turba_authentication') != 'none'), 'logintasks' => true));
-} catch (Horde_Exception $e) {
- Horde_Auth::authenticateFailure('turba', $e);
-}
-$conf = $GLOBALS['conf'];
-define('TURBA_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Turba source and attribute configuration.
-include TURBA_BASE . '/config/attributes.php';
-include TURBA_BASE . '/config/sources.php';
-
-// Ensure we have cfgSources in global scope since base.php might be loaded
-// within a function scope and the share hooks require access to cfgSources.
-$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'])) {
- $_SESSION['turba']['has_share'] = true;
- break;
- }
-}
-if (!empty($_SESSION['turba']['has_share'])) {
- // Create a share instance.
- $GLOBALS['turba_shares'] = Horde_Share::singleton($registry->getApp());
- $GLOBALS['cfgSources'] = Turba::getConfigFromShares($cfgSources);
-}
-$GLOBALS['cfgSources'] = Turba::permissionsFilter($GLOBALS['cfgSources']);
-$GLOBALS['attributes'] = $attributes;
-
-// Build the directory sources select widget.
-$default_source = Horde_Util::nonInputVar('source');
-if (empty($default_source)) {
- $default_source = empty($_SESSION['turba']['source']) ? Turba::getDefaultAddressBook() : $_SESSION['turba']['source'];
- $default_source = Horde_Util::getFormData('source', $default_source);
-}
-$GLOBALS['browse_source_options'] = '';
-$GLOBALS['browse_source_count'] = 0;
-foreach (Turba::getAddressBooks() as $key => $curSource) {
- if (!empty($curSource['browse'])) {
- $selected = ($key == $default_source) ? ' selected="selected"' : '';
- $GLOBALS['browse_source_options'] .= '<option value="' . htmlspecialchars($key) . '" ' . $selected . '>' .
- htmlspecialchars($curSource['title']) . '</option>';
-
- $GLOBALS['browse_source_count']++;
-
- if (empty($default_source)) {
- $default_source = $key;
- }
- }
-}
-if (empty($cfgSources[$default_source]['browse'])) {
- $default_source = Turba::getDefaultAddressBook();
-}
-$_SESSION['turba']['source'] = $default_source;
-
-// Only set $add_source_options if there is at least one editable address book
-// that is not the current address book.
-$addSources = Turba::getAddressBooks(Horde_Perms::EDIT, array('require_add' => true));
-$copymove_source_options = '';
-$copymoveSources = $addSources;
-unset($copymoveSources[$default_source]);
-foreach ($copymoveSources as $key => $curSource) {
- if ($key != $default_source) {
- $copymove_source_options .= '<option value="' . htmlspecialchars($key) . '">' .
- htmlspecialchars($curSource['title']) . '</option>';
- }
-}
-$GLOBALS['addSources'] = $addSources;
-
-// Start compression, if requested.
-if (!Horde_Util::nonInputVar('no_compress')) {
- Horde::compressOutput();
-}
return;
}
- require_once TURBA_BASE . '/lib/base.php';
$GLOBALS['source'] = '_test_sql';
$GLOBALS['cfgSources'] = array('_test_sql' => $this->getDriverConfig());
$GLOBALS['registry']->pushApp('turba', array('check_perms' => false));
// Turba base libraries.
- require_once dirname(__FILE__) . '/../../lib/base.load.php';
require_once TURBA_BASE . '/lib/Turba.php';
require_once TURBA_BASE . '/lib/Driver.php';
require_once TURBA_BASE . '/lib/Object.php';
$GLOBALS['cfgSources'] = Turba::getConfigFromShares($cfgSources);
}
- function provideServerName() {
+ function provideServerName()
+ {
return 'localhost.localdomain';
}
- function provideHordeBase() {
- require_once dirname(__FILE__) . '/../../lib/base.load.php';
+ function provideHordeBase()
+ {
+ require_once dirname(__FILE__) . '/../Application.php';
return HORDE_BASE;
}
}
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
$search = Horde_Util::getFormData('search');
$results = array();
*/
// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Makre sure no one runs this from the web.
if (!Horde_Cli::runningFromCli()) {
$data = $argv[1];
// Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
- Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
-// Now that we are authenticated, we can load Turba's base. Otherwise, the
-// share code breaks, causing a new, completely empty share to be created on
-// the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
require_once TURBA_BASE . '/lib/Object/Group.php';
// Get list of SquirrelMail address book files
*/
// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Makre sure no one runs this from the web.
if (!Horde_Cli::runningFromCli()) {
}
$dsn = $argv[1];
-// Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
- Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
-// Now that we are authenticated, we can load Turba's base. Otherwise, the
-// share code breaks, causing a new, completely empty share to be created on
-// the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
require_once TURBA_BASE . '/lib/Object/Group.php';
-require_once 'Horde/Mime/Address.php';
// Connect to database.
$db = DB::connect($dsn);
/* YOU SHOULD NOT HAVE TO TOUCH ANYTHING BELOW THIS LINE */
/* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../../lib/Application.php';
if (!Horde_Cli::runningFromCli()) {
exit("Must be run from the command line\n");
}
*/
// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Make sure no one runs this from the web.
if (!Horde_Cli::runningFromCLI()) {
// variables, etc.
Horde_Cli::init();
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
// Instantiate DataTree.
require_once 'Horde/DataTree.php';
$driver = $conf['datatree']['driver'];
$params = array_merge(Horde::getDriverConfig('datatree', $driver),
array('group' => 'agora.forums.turba'));
-$datatree = &DataTree::singleton($driver, $params);
+$datatree = DataTree::singleton($driver, $params);
// Load comments.
$forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT);
*/
// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Make sure no one runs this from the web.
if (!Horde_Cli::runningFromCLI()) {
// some variables, etc.
Horde_Cli::init();
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
// Re-load source config.
// require TURBA_BASE . '/config/sources.php';
*/
// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Make sure no one runs this from the web.
if (!Horde_Cli::runningFromCLI()) {
// some variables, etc.
Horde_Cli::init();
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
// Re-load source config.
require TURBA_BASE . '/config/sources.php';
*/
/* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../../lib/Application.php';
if (!Horde_Cli::runningFromCli()) {
exit("Must be run from the command line\n");
}
*/
// Load Horde and Turba enviroments
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
// Set up the CLI enviroment.
if (!Horde_Cli::runningFromCLI()) {
$CLI = Horde_Cli::singleton();
// Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
- Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
-
-// Now that we are authenticated, we can load Turba's base. Otherwise,
-// the share code breaks, causing a new, completely empty share to be
-// created on the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
$CLI->writeln('This script will turn all entries in the SQL address book into a globally shared address book.');
$CLI->writeln('Make sure you read the script comments and be sure you know what you are doing.');
}
}
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
/* Verify if the search mode variable is passed in form or is
* registered in the session. Always use basic search by default. */
* @author Chuck Hagenbuch <chuck@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
$source = Horde_Util::getFormData('source');
if (!isset($cfgSources[$source])) {
* @author Jan Schneider <jan@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
if ($conf['documents']['type'] == 'none') {
throw new Turba_Exception(_("The VFS backend needs to be configured to enable attachment uploads."));