* @author Michael Slusarz <slusarz@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Redirect if blacklist is not available. */
if (!in_array(Ingo_Storage::ACTION_BLACKLIST, $_SESSION['ingo']['script_categories'])) {
* @author Mike Cochrane <mike@graftonhall.co.nz>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Get the list of filter rules. */
$filters = &$ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
* @author Todd Merritt <tmerritt@email.arizona.edu>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Redirect if forward is not available. */
if (!in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
*/
public function blacklistFrom($addresses)
{
- require_once dirname(__FILE__) . '/../lib/base.php';
if (!empty($GLOBALS['ingo_shares'])) {
$_SESSION['ingo']['current_share'] = $signature;
}
*/
public function whitelistFrom($addresses)
{
- require_once dirname(__FILE__) . '/../lib/base.php';
if (!empty($GLOBALS['ingo_shares'])) {
$_SESSION['ingo']['current_share'] = $signature;
}
*/
public function canApplyFilters()
{
- require_once dirname(__FILE__) . '/../lib/base.php';
-
$ingo_script = Ingo::loadIngoScript();
return $ingo_script
? $ingo_script->performAvailable()
*/
public function applyFilters($params = array())
{
- require_once dirname(__FILE__) . '/../lib/base.php';
if (!empty($GLOBALS['ingo_shares'])) {
$_SESSION['ingo']['current_share'] = $signature;
}
*/
public function setVacation($info)
{
- require_once dirname(__FILE__) . '/../lib/base.php';
if (!empty($GLOBALS['ingo_shares'])) {
$_SESSION['ingo']['current_share'] = $signature;
}
*/
public function disableVacation()
{
- require_once dirname(__FILE__) . '/../lib/base.php';
if (!empty($GLOBALS['ingo_shares'])) {
$_SESSION['ingo']['current_share'] = $signature;
}
/**
* Ingo application API.
*
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Horde through this API.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/asl.php.
+ *
+ * @package Ingo
+ */
+
+/* Determine the base directories. */
+if (!defined('INGO_BASE')) {
+ define('INGO_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(INGO_BASE . '/config/horde.local.php')) {
+ include INGO_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', INGO_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+/**
+ * Ingo application API.
+ *
*/
class Ingo_Application extends Horde_Registry_Application
{
public $version = 'H4 (2.0-git)';
/**
+ * Initialization function.
+ *
+ * Global variables defined:
+ * $all_rulesets - TODO
+ * $ingo_shares - TODO
+ * $ingo_storage - TODO
+ */
+ protected function _init()
+ {
+ // Load the Ingo_Storage driver.
+ $GLOBALS['ingo_storage'] = Ingo_Storage::factory();
+
+ // Create the ingo session (if needed).
+ if (!isset($_SESSION['ingo']) || !is_array($_SESSION['ingo'])) {
+ Ingo_Session::createSession();
+ }
+
+ // Create shares if necessary.
+ $driver = Ingo::getDriver();
+ if ($driver->supportShares()) {
+ $GLOBALS['ingo_shares'] = Horde_Share::singleton($registry->getApp());
+ $GLOBALS['all_rulesets'] = Ingo::listRulesets();
+
+ /* If personal share doesn't exist then create it. */
+ $signature = $_SESSION['ingo']['backend']['id'] . ':' . Horde_Auth::getAuth();
+ if (!$GLOBALS['ingo_shares']->exists($signature)) {
+ $identity = Horde_Prefs_Identity::singleton();
+ $name = $identity->getValue('fullname');
+ if (trim($name) == '') {
+ $name = Horde_Auth::getOriginalAuth();
+ }
+ $share = $GLOBALS['ingo_shares']->newShare($signature);
+ $share->set('name', $name);
+ $GLOBALS['ingo_shares']->addShare($share);
+ $GLOBALS['all_rulesets'][$signature] = $share;
+ }
+
+ /* Select current share. */
+ $_SESSION['ingo']['current_share'] = Horde_Util::getFormData('ruleset', @$_SESSION['ingo']['current_share']);
+ if (empty($_SESSION['ingo']['current_share']) ||
+ empty($GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]) ||
+ !$GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
+ $_SESSION['ingo']['current_share'] = $signature;
+ }
+ } else {
+ $GLOBALS['ingo_shares'] = null;
+ }
+ }
+
+ /**
* Returns a list of available permissions.
*
* @return array An array describing all available permissions.
return PEAR::raiseError(_("You are not allowed to remove user data."));
}
- require_once dirname(__FILE__) . '/../lib/base.php';
-
/* Remove all filters/rules owned by the user. */
$result = $GLOBALS['ingo_storage']->removeUserData($user);
if (is_a($result, 'PEAR_Error')) {
*/
function _content()
{
- require_once dirname(__FILE__) . '/../base.php';
-
/* Get list of filters */
$filters = &$GLOBALS['ingo_storage']->retrieve(Ingo_Storage::ACTION_FILTERS);
$html = '<table width="100%" height="100%">';
+++ /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 Ingo
- */
-
-if (!defined('INGO_BASE')) {
- define('INGO_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(INGO_BASE . '/config/horde.local.php')) {
- include INGO_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', INGO_BASE . '/..');
- }
-}
+++ /dev/null
-<?php
-/**
- * Ingo base inclusion file.
- *
- * This file brings in all of the dependencies that every Ingo
- * 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
- * </pre>
- *
- * Global variables defined:
- * $ingo_shared - TODO
- * $ingo_storage - The Ingo_Storage:: object to use for storing rules.
- * $no_compress - Controls whether the page should be compressed
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- */
-
-// 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('ingo', array('check_perms' => (Horde_Util::nonInputVar('ingo_authentication') != 'none'), 'logintasks' => true));
-} catch (Horde_Exception $e) {
- Horde_Auth::authenticateFailure('ingo', $e);
-}
-$conf = &$GLOBALS['conf'];
-
-if (!defined('INGO_TEMPLATES')) {
- define('INGO_TEMPLATES', $registry->get('templates'));
-}
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Start compression.
-if (!Horde_Util::nonInputVar('no_compress')) {
- Horde::compressOutput();
-}
-
-// Load the Ingo_Storage driver. It appears in the global variable
-// $ingo_storage.
-$GLOBALS['ingo_storage'] = Ingo_Storage::factory();
-
-// Create the ingo session (if needed).
-if (!isset($_SESSION['ingo']) || !is_array($_SESSION['ingo'])) {
- Ingo_Session::createSession();
-}
-
-// Create shares if necessary.
-$driver = Ingo::getDriver();
-if ($driver->supportShares()) {
- $GLOBALS['ingo_shares'] = Horde_Share::singleton($registry->getApp());
- $GLOBALS['all_rulesets'] = Ingo::listRulesets();
-
- /* If personal share doesn't exist then create it. */
- $signature = $_SESSION['ingo']['backend']['id'] . ':' . Horde_Auth::getAuth();
- if (!$GLOBALS['ingo_shares']->exists($signature)) {
- $identity = Horde_Prefs_Identity::singleton();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = Horde_Auth::getOriginalAuth();
- }
- $share = &$GLOBALS['ingo_shares']->newShare($signature);
- $share->set('name', $name);
- $GLOBALS['ingo_shares']->addShare($share);
- $GLOBALS['all_rulesets'][$signature] = &$share;
- }
-
- /* Select current share. */
- $_SESSION['ingo']['current_share'] = Horde_Util::getFormData('ruleset', @$_SESSION['ingo']['current_share']);
- if (empty($_SESSION['ingo']['current_share']) ||
- empty($GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]) ||
- !$GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
- $_SESSION['ingo']['current_share'] = $signature;
- }
-} else {
- $GLOBALS['ingo_shares'] = null;
-}
* @author Michael Slusarz <slusarz@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Check rule permissions. */
if (!$GLOBALS['perms']->hasAppPermission('allow_rules')) {
* @author Mike Cochrane <mike@graftonhall.co.nz>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Redirect if script updating is not available. */
if (!$_SESSION['ingo']['script_generate']) {
* sender is blacklisted.
*/
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../../lib/core.php';
-
-// Make sure no one runs this from the web.
-if (!Horde_Cli::runningFromCLI()) {
- exit(1);
-}
-
-// Load the CLI environment - make sure there's no time limit, init some
-// variables, etc.
-Horde_Cli::init();
-
-// Include needed libraries.
-$ingo_authentication = 'none';
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../../lib/Application.php';
+Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
// Initialize authentication manager.
$auth = Horde_Auth::singleton($conf['auth']['driver']);
*/
/* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../../../lib/core.php';
-if (!Horde_Cli::runningFromCli()) {
- exit("Must be run from the command line\n");
-}
+require_once dirname(__FILE__) . '/../../../lib/Application.php';
+Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
$cli = Horde_Cli::singleton();
-$cli->init();
-
-/* Grab what we need to steal the DB config */
-require_once HORDE_BASE . '/config/conf.php';
$config = $GLOBALS['conf']['sql'];
unset($config['charset']);
* @author Jan Schneider <jan@horde.org>
*/
-/* Do CLI checks and environment setup first. */
-require_once dirname(__FILE__) . '/../../../lib/core.php';
-
-/* Make sure no one runs this from the web. */
-if (!Horde_Cli::runningFromCLI()) {
- exit("Must be run from the command line\n");
-}
-
-/* Load the CLI environment - make sure there's no time limit, init some
- * variables, etc. */
-Horde_Cli::init();
+require_once dirname(__FILE__) . '/../../../lib/Application.php';
+Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
$cli = Horde_Cli::singleton();
-/* Initialize the needed libraries. */
-$ingo_authentication = 'none';
-require_once dirname(__FILE__) . '/../../lib/base.php';
-
/* Initialize storage backends. */
if ($conf['storage']['driver'] != 'sql') {
$cli->fatal('You need to configure an SQL storage backend in Ingo\'s configuration', __FILE__, __LINE__);
}
-
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
if (!in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
$notification->push(_("Simple spam filtering is not supported in the current filtering driver."), 'horde.error');
* @author Mike Cochrane <mike@graftonhall.co.nz>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Redirect if vacation is not available. */
if (!in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
* @author Michael Slusarz <slusarz@horde.org>
*/
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('ingo');
/* Redirect if whitelist not available. */
if (!in_array(Ingo_Storage::ACTION_WHITELIST, $_SESSION['ingo']['script_categories'])) {