From d1e6a706ed6b29addaae7c06d3ee74476130a962 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 8 Jan 2010 10:33:35 -0500 Subject: [PATCH] Hylax: Deprecate and remove lib/base.php --- hylax/compose.php | 8 ++--- hylax/folder.php | 6 ++-- hylax/img.php | 7 ++-- hylax/lib/Application.php | 9 +++-- hylax/lib/Storage.php | 4 +-- hylax/lib/base.php | 66 ---------------------------------- hylax/print.php | 4 +-- hylax/scripts/fax_create.php | 11 ++---- hylax/scripts/fax_create_recv.php | 9 ++--- hylax/scripts/fax_save_data.php | 9 ++--- hylax/scripts/fax_save_recv_data.php | 11 ++---- hylax/scripts/install_cups_drivers.php | 8 ++--- hylax/send.php | 9 +++-- hylax/summary.php | 10 +++--- hylax/view.php | 6 ++-- 15 files changed, 43 insertions(+), 134 deletions(-) delete mode 100644 hylax/lib/base.php diff --git a/hylax/compose.php b/hylax/compose.php index 931fc2d3d..dc4e94e41 100644 --- a/hylax/compose.php +++ b/hylax/compose.php @@ -12,12 +12,8 @@ * @author Joel Vandal */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Horde/Form.php'; -require_once 'Horde/Form/Renderer.php'; -require_once 'Horde/Form/Action.php'; -require_once 'Horde/Template.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); /* Load Cover Page templates */ require HYLAX_BASE . '/config/covers.php'; diff --git a/hylax/folder.php b/hylax/folder.php index 410a382ee..c0e6adbbe 100644 --- a/hylax/folder.php +++ b/hylax/folder.php @@ -7,8 +7,8 @@ * * $Horde: incubator/hylax/folder.php,v 1.7 2009/06/10 05:24:17 slusarz Exp $ */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $folder = strtolower(Horde_Util::getFormData('folder', 'inbox')); $path = Horde_Util::getFormData('path'); @@ -71,7 +71,7 @@ foreach ($folder_list as $key => $value) { } elseif (empty($value['fax_number']) && $value['fax_type'] == 0) { $folder_list[$key]['fax_number'] = _("unknown"); } - $folder_list[$key]['fax_status'] = $gateway->getStatus($value['job_id']); + $folder_list[$key]['fax_status'] = $hylax->gateway->getStatus($value['job_id']); } /* Set up actions. */ diff --git a/hylax/img.php b/hylax/img.php index 2a8970b89..97c052525 100644 --- a/hylax/img.php +++ b/hylax/img.php @@ -8,9 +8,10 @@ * $Horde: incubator/hylax/img.php,v 1.4 2009/06/10 05:24:17 slusarz Exp $ */ -@define('AUTH_HANDLER', true); -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; +// FIXME: Do we need AUTH_HANDLER here? +//@define('AUTH_HANDLER', true); +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $fax_id = Horde_Util::getFormData('fax_id'); $page = Horde_Util::getFormData('page'); diff --git a/hylax/lib/Application.php b/hylax/lib/Application.php index e033c832f..6af544d77 100644 --- a/hylax/lib/Application.php +++ b/hylax/lib/Application.php @@ -10,7 +10,6 @@ * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * - * $Horde: incubator/hylax/lib/base.php,v 1.16 2009/07/13 20:05:46 slusarz Exp $ */ if (!defined('HYLAX_BASE')) { @@ -33,6 +32,9 @@ require_once HORDE_BASE . '/lib/core.php'; class Hylax_Application extends Horde_Registry_Application { + public $gateway = null; + public $storage = null; + function __constructor($args = array()) { if (!empty($args['init'])) { @@ -62,10 +64,11 @@ class Hylax_Application extends Horde_Registry_Application define('HYLAX_BASE', dirname(__FILE__) . '/..'); /* Hylax Driver */ - $gateway = Hylax_Driver::singleton($conf['fax']['driver'], $conf['fax']['params']); + $this->gateway = Hylax_Driver::singleton($conf['fax']['driver'], + $conf['fax']['params']); /* Hylax storage driver. */ - $hylax_storage = Hylax_Storage::singleton('sql', $conf['sql']); + $this->storage = Hylax_Storage::singleton('sql', $conf['sql']); /* Start compression, if requested. */ Horde::compressOutput(); diff --git a/hylax/lib/Storage.php b/hylax/lib/Storage.php index 94a80cad6..72ac9be59 100644 --- a/hylax/lib/Storage.php +++ b/hylax/lib/Storage.php @@ -127,13 +127,13 @@ class Hylax_Storage { function send($fax_id, $number) { - global $conf, $gateway; + global $hylax; $this->_setFaxNumber($fax_id, $number); $data = $this->getFaxData($fax_id); - $job_id = $gateway->send($number, $data); + $job_id = $hylax->gateway->send($number, $data); $this->_setJobId($fax_id, $job_id); } diff --git a/hylax/lib/base.php b/hylax/lib/base.php deleted file mode 100644 index fc01b6f03..000000000 --- a/hylax/lib/base.php +++ /dev/null @@ -1,66 +0,0 @@ -pushApp('hylax', !defined('AUTH_HANDLER')); -} catch (Horde_Exception $e) { - if ($e->getCode() == 'permission_denied') { - Horde::authenticationFailureRedirect(); - } - Horde::fatal($e, __FILE__, __LINE__, false); -} - -$conf = &$GLOBALS['conf']; -@define('HYLAX_TEMPLATES', $registry->get('templates')); - -/* Notification system. */ -$notification = &Horde_Notification::singleton(); -$notification->attach('status'); - -/* Find the base file path of Hylax. */ -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -/* Hylax base libraries. */ -require_once HYLAX_BASE . '/lib/Hylax.php'; -require_once HYLAX_BASE . '/lib/Driver.php'; -require_once HYLAX_BASE . '/lib/Storage.php'; - -/* Hylax Driver */ -$gateway = &Hylax_Driver::singleton($conf['fax']['driver'], $conf['fax']['params']); - -/* Hylax storage driver. */ -$hylax_storage = &Hylax_Storage::singleton('sql', $conf['sql']); - -/* Start compression, if requested. */ -Horde::compressOutput(); diff --git a/hylax/print.php b/hylax/print.php index 82db9b1fd..10cf0e0f6 100644 --- a/hylax/print.php +++ b/hylax/print.php @@ -8,8 +8,8 @@ * $Horde: incubator/hylax/print.php,v 1.5 2009/06/10 05:24:17 slusarz Exp $ */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $fax_id = Horde_Util::getFormData('fax_id'); $url = Horde_Util::getFormData('url', 'folder.php'); diff --git a/hylax/scripts/fax_create.php b/hylax/scripts/fax_create.php index 03c06f885..317be3cdd 100755 --- a/hylax/scripts/fax_create.php +++ b/hylax/scripts/fax_create.php @@ -7,13 +7,8 @@ // No need for auth. @define('AUTH_HANDLER', true); -// Find the base file paths. -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -// Do CLI checks and environment setup first. -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Console/Getopt.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { @@ -39,4 +34,4 @@ if (isset($args[2])) { } Horde::logMessage(sprintf('Creating fax ID %s for user %s.', $info['fax_id'], $info['fax_user']), __FILE__, __LINE__, PEAR_LOG_DEBUG); -$hylax_storage->createFax($info, true); +$hylax->storage->createFax($info, true); diff --git a/hylax/scripts/fax_create_recv.php b/hylax/scripts/fax_create_recv.php index 7f6dc4c01..eccc81c3a 100755 --- a/hylax/scripts/fax_create_recv.php +++ b/hylax/scripts/fax_create_recv.php @@ -7,13 +7,8 @@ // No need for auth. @define('AUTH_HANDLER', true); -// Find the base file paths. -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -// Do CLI checks and environment setup first. -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Console/Getopt.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { diff --git a/hylax/scripts/fax_save_data.php b/hylax/scripts/fax_save_data.php index ba926f5c4..7f1999744 100755 --- a/hylax/scripts/fax_save_data.php +++ b/hylax/scripts/fax_save_data.php @@ -7,13 +7,8 @@ // No need for auth. @define('AUTH_HANDLER', true); -// Find the base file paths. -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -// Do CLI checks and environment setup first. -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Console/Getopt.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { diff --git a/hylax/scripts/fax_save_recv_data.php b/hylax/scripts/fax_save_recv_data.php index 0ae2c262d..3c5ba32b2 100755 --- a/hylax/scripts/fax_save_recv_data.php +++ b/hylax/scripts/fax_save_recv_data.php @@ -7,13 +7,8 @@ // No need for auth. @define('AUTH_HANDLER', true); -// Find the base file paths. -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -// Do CLI checks and environment setup first. -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Console/Getopt.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { @@ -41,7 +36,7 @@ if (empty($data)) { } /* Get the file and store into VFS. */ -$fax_id = $hylax_storage->saveFaxData($data, '.ps'); +$fax_id = $hylax->storage->saveFaxData($data, '.ps'); if (is_a($fax_id, 'PEAR_Error')) { echo '0'; exit; diff --git a/hylax/scripts/install_cups_drivers.php b/hylax/scripts/install_cups_drivers.php index 384ed7cb1..94d7dbf23 100755 --- a/hylax/scripts/install_cups_drivers.php +++ b/hylax/scripts/install_cups_drivers.php @@ -7,12 +7,8 @@ // No need for auth. @define('AUTH_HANDLER', true); -// Find the base file paths. -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); -@define('HYLAX_BASE', dirname(__FILE__) . '/..'); - -// Do CLI checks and environment setup first. -require_once HYLAX_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { diff --git a/hylax/send.php b/hylax/send.php index 8c21c005c..c9f09b51f 100644 --- a/hylax/send.php +++ b/hylax/send.php @@ -8,9 +8,8 @@ * $Horde: incubator/hylax/send.php,v 1.8 2009/06/10 17:33:26 slusarz Exp $ */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; -require_once 'Horde/Form.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $fax_id = Horde_Util::getFormData('fax_id'); $folder = strtolower(Horde_Util::getFormData('folder')); @@ -21,7 +20,7 @@ $vars = Horde_Variables::getDefaultVariables(); $fax_id = $vars->get('fax_id'); $url = $vars->get('url', 'folder.php'); -$fax = $hylax_storage->getFax($fax_id); +$fax = $hylax->storage->getFax($fax_id); if (is_a($fax, 'PEAR_Error')) { $notification->push(sprintf(_("Could not open fax ID \"%s\". %s"), $fax_id, $fax->getMessage()), 'horde.error'); $url = Horde::applicationUrl($url, true); @@ -45,7 +44,7 @@ $form->addVariable(_("Fax destination"), 'fax_number', 'text', true, false, null if ($form->validate($vars)) { $form->getInfo($vars, $info); - $send = $hylax_storage->send($info['fax_id'], $info['fax_number']); + $send = $hylax->storage->send($info['fax_id'], $info['fax_number']); if (is_a($send, 'PEAR_Error')) { $notification->push(sprintf(_("Could not send fax ID \"%s\". %s"), $info['fax_id'], $send->getMessage()), 'horde.error'); } else { diff --git a/hylax/summary.php b/hylax/summary.php index 81569ad54..5c7f6e4c7 100644 --- a/hylax/summary.php +++ b/hylax/summary.php @@ -8,11 +8,11 @@ * $Horde: incubator/hylax/summary.php,v 1.6 2009/06/10 05:24:17 slusarz Exp $ */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $fmt_inbox = array(); -$inbox = $gateway->getInbox(); +$inbox = $hylax->gateway->getInbox(); foreach ($inbox as $item) { $fmt_inbox[] = array('owner' => $item[2]); } @@ -27,8 +27,8 @@ foreach ($outbox as $item) { /* Set up actions. */ $template = new Horde_Template(); -$template->set('in_faxes', $gateway->numFaxesIn()); -$template->set('out_faxes', $gateway->numFaxesOut()); +$template->set('in_faxes', $hylax->gateway->numFaxesIn()); +$template->set('out_faxes', $hylax->gateway->numFaxesOut()); $template->set('inbox', $fmt_inbox, true); $template->set('outbox', $fmt_outbox, true); $template->set('menu', Hylax::getMenu('string')); diff --git a/hylax/view.php b/hylax/view.php index bf725fbca..b25d10ecf 100644 --- a/hylax/view.php +++ b/hylax/view.php @@ -8,8 +8,8 @@ * $Horde: incubator/hylax/view.php,v 1.7 2009/06/10 05:24:18 slusarz Exp $ */ -@define('HYLAX_BASE', dirname(__FILE__)); -require_once HYLAX_BASE . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +$hylax = new Hylax_Application(array('init' => true)); $fax_id = Horde_Util::getFormData('fax_id'); $url = Horde_Util::getFormData('url'); @@ -24,7 +24,7 @@ if (Horde_Util::getFormData('action') == 'download') { exit; } -$fax = $hylax_storage->getFax($fax_id); +$fax = $hylax->storage->getFax($fax_id); if (is_a($fax, 'PEAR_Error')) { $notification->push(sprintf(_("Could not open fax ID \"%s\". %s"), $fax_id, $fax->getMessage()), 'horde.error'); if (empty($url)) { -- 2.11.0