*
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('SHOUT_BASE', dirname(__FILE__));
-require_once SHOUT_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+
+$shout = new Shout_Application(array('init' => true));
+$context = $_SESSION['shout']['context'];
+
require_once SHOUT_BASE . '/lib/Forms/DeviceForm.php';
$action = Horde_Util::getFormData('action');
// Create a new add/edit form
$devid = Horde_Util::getFormData('devid');
- $devices = $shout_devices->getDevices($context);
+ $devices = $shout->devices->getDevices($context);
$vars = new Horde_Variables($devices[$devid]);
$vars->set('action', $action);
}
// Fetch the (possibly updated) list of extensions
-$devices = $shout_devices->getDevices($context);
+$devices = $shout->devices->getDevices($context);
Horde::addScriptFile('stripe.js', 'horde');
require SHOUT_TEMPLATES . '/common-header.inc';
*
* @author Ben Klang <ben@alkaloid.net>
*/
-@define('SHOUT_BASE', dirname(__FILE__));
-require_once SHOUT_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+
+$shout = new Shout_Application(array('init' => true));
+$context = $_SESSION['shout']['context'];
+
require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php';
-//require_once SHOUT_BASE . '/lib/Shout.php';
$action = Horde_Util::getFormData('action');
// Create a new add/edit form
$extension = Horde_Util::getFormData('extension');
- $extensions = $shout_extensions->getExtensions($context);
+ $extensions = $shout->extensions->getExtensions($context);
$vars = new Horde_Variables($extensions[$extension]);
if ($action == 'edit') {
$vars->set('oldextension', $extension);
}
// Fetch the (possibly updated) list of extensions
-$extensions = $shout_extensions->getExtensions($context);
+$extensions = $shout->extensions->getExtensions($context);
Horde::addScriptFile('stripe.js', 'horde');
require SHOUT_TEMPLATES . '/common-header.inc';
* @author Ben Klang <ben@alkaloid.net>
* @package Shout
*/
-define('SHOUT_BASE', dirname(__FILE__) . '/..');
+if (!defined('SHOUT_BASE')) {
+ define('SHOUT_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(SHOUT_BASE. '/config/horde.local.php')) {
+ include SHOUT_BASE . '/config/horde.local.php';
+ } else {
+ define('HORDE_BASE', SHOUT_BASE . '/..');
+ }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
class Shout_Application extends Horde_Registry_Application
{
public $version = 'H4 (1.0-git)';
- protected $_contexts = null;
- protected $_extensions = null;
- protected $_devices = null;
+ public $contexts = null;
+ public $extensions = null;
+ public $devices = null;
public function __construct($args = array())
{
+ if (!empty($args['init'])) {
+ $GLOBALS['registry'] = &Horde_Registry::singleton();
+ $registry = &$GLOBALS['registry'];
+ try {
+ $registry->pushApp('shout', array('check_perms' => true,
+ 'logintasks' => true));
+ } catch (Horde_Exception $e) {
+ Horde::authenticationFailure('shout', $e);
+ }
+
+ // Ensure Shout is properly configured before use
+ $shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php'));
+ if (!$shout_configured) {
+ Horde_Test::configFilesMissing('Shout', SHOUT_BASE, array('conf.php'));
+ }
+
+ define('SHOUT_TEMPLATES', $registry->get('templates'));
+ $this->contexts = Shout_Driver::factory('storage');
+ $this->extensions = Shout_Driver::factory('extensions');
+ $this->devices = Shout_Driver::factory('devices');
+
+ try {
+ $contexts = $this->contexts->getContexts();
+ } catch (Shout_Exception $e) {
+ $notification->push($e);
+ $contexts = false;
+ }
+
+ $notification = Horde_Notification::singleton();
+ $GLOBALS['notification'] = $notification;
+ $notification->attach('status');
+
+ if (count($contexts) == 1) {
+ // Default to the user's only context
+ if (!empty($context) && $context != $contexts[0]) {
+ $notification->push(_("You do not have permission to access that context."), 'horde.error');
+ }
+ $context = $contexts[0];
+ } elseif (!empty($context) && !in_array($context, $contexts)) {
+ $notification->push(_("You do not have permission to access that context."), 'horde.error');
+ $context = false;
+ } elseif (!empty($context)) {
+ $notification->push("Please select a context to continue.", 'horde.info');
+ $context = false;
+ }
+
+ $_SESSION['shout']['context'] = $context;
+ }
}
public function perms()
}
require_once dirname(__FILE__) . '/base.php';
- $shout_contexts = Shout_Driver::factory('storage');
$perms['tree']['shout']['superadmin'] = false;
$perms['title']['shout:superadmin'] = _("Super Administrator");
- $contexts = $shout_contexts->getContexts();
+ $contexts = $this->contexts->getContexts();
$perms['tree']['shout']['contexts'] = false;
$perms['title']['shout:contexts'] = _("Contexts");
}
}
- // function _shout_getContexts($searchfilters = SHOUT_CONTEXT_ALL,
- // $filterperms = null)
-
return $perms;
}
}
/**
* ExtensionDetailsForm constructor.
*
- * @global <type> $shout_extensions
+ * @global <type> $shout->extensions
* @param <type> $vars
* @return <type>
*/
function __construct(&$vars)
{
- global $shout_extensions;
+ global $shout;
$context = $_SESSION['shout']['context'];
$action = $vars->get('action');
* Process this form, saving its information to the backend.
*
* @param string $context Context in which to execute this save
- * FIXME: is there a better way to get the $context and $shout_extensions?
+ * FIXME: is there a better way to get the $context and $shout->extensions?
*/
function execute()
{
- global $shout_extensions;
+ global $shout;
$extension = $this->_vars->get('extension');
$context = $this->_vars->get('context');
'mailboxpin' => $this->_vars->get('mailboxpin'),
);
- $shout_extensions->saveExtension($context, $extension, $details);
+ $shout->extensions->saveExtension($context, $extension, $details);
}
}
function execute()
{
- global $shout_extensions;
+ global $shout;
$context = $this->_vars->get('context');
$extension = $this->_vars->get('extension');
- $shout_extensions->deleteExtension($context, $extension);
+ $shout->extensions->deleteExtension($context, $extension);
}
}
+++ /dev/null
-<?php
-/**
- * Shout base inclusion file.
- *
- * Copyright 2005-2010 Alkaloid Networks LLC (http://projects.alkaloid.net)
- *
- * See the enclosed file COPYING for license information (BSD). If you
- * did not receive this file, see
- * http://www.opensource.org/licenses/bsd-license.php.
- *
- * @author Ben Klang <ben@alkaloid.net>
- * @since Shout 0.1
- * @package Shout
- */
-
-if (!defined('SHOUT_BASE')) {
- define('SHOUT_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(SHOUT_BASE. '/config/horde.local.php')) {
- include SHOUT_BASE . '/config/horde.local.php';
- } else {
- define('HORDE_BASE', SHOUT_BASE . '/..');
- }
-}
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-$registry = &Horde_Registry::singleton();
-try {
- $registry->pushApp('shout', array('check_perms' => true, 'logintasks' => true));
-} catch (Horde_Exception $e) {
- Horde::authenticationFailureRedirect('shout', $e);
-}
-
-$conf = &$GLOBALS['conf'];
-@define('SHOUT_TEMPLATES', $registry->get('templates'));
-
-// Ensure Shout is properly configured before use
-$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php'));
-if (!$shout_configured) {
- Horde_Test::configFilesMissing('Shout', SHOUT_BASE, array('conf.php'));
-}
-
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-//// Shout base libraries.
-//require_once SHOUT_BASE . '/lib/Shout.php';
-//require_once SHOUT_BASE . '/lib/Driver.php';
-//
-//// Form libraries.
-//require_once 'Horde/Form.php';
-//require_once 'Horde/Form/Renderer.php';
-//
-//// Variable handling libraries
-//require_once 'Horde/Variables.php';
-//require_once 'Horde/Text/Filter.php';
-//
-//// UI classes.
-//require_once 'Horde/UI/Tabs.php';
-
-$shout_contexts = Shout_Driver::factory('storage');
-$shout_extensions = Shout_Driver::factory('extensions');
-$shout_devices = Shout_Driver::factory('devices');
-
-$context = Horde_Util::getFormData('context');
-$section = Horde_Util::getFormData('section');
-
-try {
- $contexts = $shout_contexts->getContexts();
-} catch (Shout_Exception $e) {
- $notification->push($e);
- $contexts = false;
-}
-
-if (count($contexts) == 1) {
- // Default to the user's only context
- if (!empty($context) && $context != $contexts[0]) {
- $notification->push(_("You do not have permission to access that context."), 'horde.error');
- }
- $context = $contexts[0];
-} elseif (!empty($context) && !in_array($context, $contexts)) {
- $notification->push(_("You do not have permission to access that context."), 'horde.error');
- $context = false;
-} elseif (!empty($context)) {
- $notification->push("Please select a context to continue.", 'horde.info');
- $context = false;
-}
-
-$_SESSION['shout']['context'] = $context;