From: Ben Klang Date: Sun, 20 Dec 2009 19:30:00 +0000 (+0000) Subject: Remove deprecated functionality X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=07908a325974fabc8c523f8bc5723b84b8b1cbdd;p=horde.git Remove deprecated functionality Continue converting classes to H4/PHP5 git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@490 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/config/defines.php.dist b/config/defines.php.dist deleted file mode 100644 index 12ca70501..000000000 --- a/config/defines.php.dist +++ /dev/null @@ -1,42 +0,0 @@ - _("Customers"), SHOUT_CONTEXT_EXTENSIONS => _("Dialplan"), SHOUT_CONTEXT_MOH => _("Music On Hold"), SHOUT_CONTEXT_CONFERENCE => _("Conference Calls")); } - - /** - * Given an integer value of permissions returns an array - * representation of the integer. - * - * @param integer $int The integer representation of permissions. - */ - function integerToArray($int) - { - static $array = array(); - if (isset($array[$int])) { - return $array[$int]; - } - - $array[$int] = array(); - - /* Get the available perms array. */ - $types = Shout::getContextTypes(); - - /* Loop through each perm and check if its value is included in the - * integer representation. */ - foreach ($types as $val => $label) { - if ($int & $val) { - $array[$int][$val] = true; - } - } - - return $array[$int]; - } - - /** - * Convert Asterisk's special extensions to friendly names - * - * @param string $extension Extension to search for friendly name. - */ - function exten2name($exten) - { - # Cast as a string to avoid misinterpreted digits - switch((string)$exten) { - case 'i': - $nodetext = 'Invalid Handler'; - break; - case 's': - $nodetext = 'Entry Point'; - break; - case 't': - $nodetext = 'Timeout Handler'; - break; - case 'o': - $nodetext = 'Operator'; - break; - case 'h': - $nodetext = 'Hangup Handler'; - break; - case 'fax': - $nodetext = 'FAX Detection'; - break; - default: - $nodetext = "Extension $exten"; - break; - } - - return $nodetext; - } - - /** - * Compare two inputs as extensions and return them in the following order: - * 's', numbers (low to high), single chars, multi-chars - * 's' comes first because in Asterisk it is commonly the 'starting' exten. - * This function is expected to be used with uksort() - * - * @param string $e1 - * - * @param string $e2 - * - * @return int Relation of $e1 to $e2 - */ - function extensort($e1, $e2) - { - # Assumptions: We don't have to deal with negative numbers. If we do - # they'll sort as strings - $e1 = (string)$e1; - $e2 = (string)$e2; - # Try to return quickly if either extension is 's' - if ($e1 == 's' || $e2 == 's') { - if ($e1 == $e2) { - # They are both s? - # FIXME Should we warn here? Or assume the rest of the app - # is smart enough to handle this condition? - return 0; - } - - return ($e1 == 's') ? -1 : 1; - } - - # Next check for numeric extensions - if (preg_match('/^[*#0-9]+$/', $e1)) { - # e1 is a numeric extension - if (preg_match('/^[*#0-9]+$/', $e2)) { - # e2 is also numeric - if (strlen($e1) == 1 || strlen($e2) == 1) { - if (strlen($e1) == strlen($e2)) { - # Both are 1 digit long - return ($e1 < $e2) ? -1 : 1; - } else { - return (strlen($e1) == 1) ? -1 : 1; - } - } - return ($e1 < $e2) ? -1 : 1; - } else { - # e2 is not a numeric extension so it must sort after e1 - return -1; - } - } elseif (preg_match('/^[*#0-9]+$/', $e2)) { - # e2 is numeric but e1 is not. e2 must sort before e1 - return 1; - } - - # e1 and e2 are both strings - if (strlen($e1) == 1 || strlen($e2) == 1) { - # e1 or e2 is a single char extension (reserved in Asterisk) - return (strlen($e1) == 1) ? -1 : 1; - } else { - # e1 and e2 are both multi-char strings. Sort them equally. - # FIXME Should add logic to make one multi-char take precedence - # over another? - return 0; - } - } - - function getApplist() - { - if (isset($_SESSION['shout']['applist'])) { - return $_SESSION['shout']['applist']; - } - - $file = SHOUT_BASE . '/config/applist.xml'; - - $xml_parser = xml_parser_create(); - $ShoutObject = new Shout; - xml_set_element_handler($xml_parser, - array(&$ShoutObject, '_xml2applist_startElement'), - array(&$ShoutObject, '_xml2applist_startElement')); - xml_set_character_data_handler($xml_parser, - array(&$ShoutObject, '_xml2applist_characterData')); - - if (!$fp = fopen($file, 'r')) { - return PEAR::raiseError('Unable to open applist.xml for reading'); - } - - while ($data = fread($fp, 4096)) { - if (!xml_parse($xml_parser, $data, feof($fp))) { - return PEAR::raiseError(sprintf("Invalid XML %s at line %d", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser))); - } - } - ksort($ShoutObject->applist); - xml_parser_free($xml_parser); - $_SESSION['shout']['applist'] = $ShoutObject->applist; - unset($ShoutObject); - return $_SESSION['shout']['applist']; - } - - function _xml2applist_startElement($parser, $name, $attrs = array()) - { - if (count($attrs) > 1) { print_r($attrs); } - switch($name) { - case 'APPLICATION': - if (isset($attrs['NAME'])) { - $this->_applist_curapp = $attrs['NAME']; - if (!isset($this->applist[$name])) { - $this->applist[$this->_applist_curapp] = array(); - } - $this->_applist_curfield = ''; - } - break; - case 'SYNOPSIS': - case 'USAGE': - $this->_applist_curfield = $name; - if (!isset($this->applist[$name])) { - $this->applist[$this->_applist_curapp][$name] = ""; - } - break; - } - } - - function _xml2applist_endElement($parser, $name) - { - print ''; #NOOP - } - - function _xml2applist_characterData($parser, $string) - { - $string = preg_replace('/^\s+/', '', $string); - $string = preg_replace('/\s+$/', '', $string); - if (strlen($string) > 1) { - $field = $this->_applist_curfield; - $app = $this->_applist_curapp; - $this->applist[$app][$field] .= "$string "; - } - } } diff --git a/lib/base.php b/lib/base.php index 3ff31aa92..b46161d33 100644 --- a/lib/base.php +++ b/lib/base.php @@ -8,84 +8,82 @@ * script will need and sets up objects that all scripts use. */ +if (!defined('SHOUT_BASE')) { + define('SHOUT_BASE', dirname(__FILE__). '/..'); +} -// Check for a prior definition of HORDE_BASE (perhaps by an -// auto_prepend_file definition for site customization). if (!defined('HORDE_BASE')) { - @define('HORDE_BASE', dirname(__FILE__) . '/../..'); + /* 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(); -if (is_a(($pushed = $registry->pushApp('shout', !defined('AUTH_HANDLER'))), -'PEAR_Error')) { - if ($pushed->getCode() == 'permission_denied') { - Horde::authenticationFailureRedirect(); - } - Horde::fatal($pushed, __FILE__, __LINE__, false); +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')); -// Find the base file path of Shout. -@define('SHOUT_BASE', dirname(__FILE__) . '/..'); - // Ensure Shout is properly configured before use -$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php') && - @is_readable(SHOUT_BASE . '/config/defines.php') && - @is_readable(SHOUT_BASE . '/config/applist.xml'));# && - #@is_readable(SHOUT_BASE . '/config/prefs.php')); +$shout_configured = (@is_readable(SHOUT_BASE . '/config/conf.php')); if (!$shout_configured) { require SHOUT_BASE . '/../lib/Test.php'; - Horde_Test::configFilesMissing('Shout', SHOUT_BASE, - array('conf.php', 'defines.php', 'applist.xml')); - #, 'prefs.php')); + Horde_Test::configFilesMissing('Shout', SHOUT_BASE, array('conf.php')); } -$notification = &Horde_Notification::singleton(); +$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 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 = Shout_Driver::singleton(); -// Horde libraries. -require_once 'Horde/Help.php'; +//// Horde libraries. +//require_once 'Horde/Help.php'; $context = Horde_Util::getFormData('context'); $section = Horde_Util::getFormData('section'); -$contexts = $shout->getContexts(); - -// Check that we are properly initialized -if (is_a($contexts, 'PEAR_Error')) { - $notification->push($contexts); +try { + $contexts = $shout->getContexts(); +} catch (Shout_Exception $e) { + $notification->push($e); $contexts = false; -} elseif (count($contexts) == 1) { +} + +if (count($contexts) == 1) { // Default to the user's only context $context = $contexts[0]; } elseif (!$context) { - // Attempt to locate the user's "home" context - $context = $shout->getHomeContext(); - if (is_a($context, 'PEAR_Error')) { - $notification->push($context); + try { + // Attempt to locate the user's "home" context + $context = $shout->getHomeContext(); + } catch (Shout_Exception $e) { + $notification->push($e); } - $context = ''; -} - -// We've passed the initialization tests. This flag allows other pages to run. -$SHOUT_RUNNING = true; + $context = false; +} \ No newline at end of file