Hylax: Deprecate and remove lib/base.php
authorBen Klang <ben@alkaloid.net>
Fri, 8 Jan 2010 15:33:35 +0000 (10:33 -0500)
committerBen Klang <ben@alkaloid.net>
Fri, 8 Jan 2010 15:33:35 +0000 (10:33 -0500)
15 files changed:
hylax/compose.php
hylax/folder.php
hylax/img.php
hylax/lib/Application.php
hylax/lib/Storage.php
hylax/lib/base.php [deleted file]
hylax/print.php
hylax/scripts/fax_create.php
hylax/scripts/fax_create_recv.php
hylax/scripts/fax_save_data.php
hylax/scripts/fax_save_recv_data.php
hylax/scripts/install_cups_drivers.php
hylax/send.php
hylax/summary.php
hylax/view.php

index 931fc2d..dc4e94e 100644 (file)
  * @author Joel Vandal <joel@scopserv.com>
  */
 
-@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';
index 410a382..c0e6adb 100644 (file)
@@ -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. */
index 2a8970b..97c0525 100644 (file)
@@ -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');
index e033c83..6af544d 100644 (file)
@@ -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();
index 94a80ca..72ac9be 100644 (file)
@@ -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 (file)
index fc01b6f..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * Hylax base inclusion file.
- *
- * This file brings in all of the dependencies that every Hylax script will
- * need, and sets up objects that all scripts use.
- *
- * Copyright 2003-2009 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.
- *
- * $Horde: incubator/hylax/lib/base.php,v 1.16 2009/07/13 20:05:46 slusarz Exp $
- */
-
-if (!defined('HYLAX_BASE')) {
-    define('HYLAX_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(HYLAX_BASE. '/config/horde.local.php')) {
-        include HYLAX_BASE . '/config/horde.local.php';
-    } else {
-        define('HORDE_BASE', HYLAX_BASE . '/..');
-    }
-}
-
-// 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('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();
index 82db9b1..10cf0e0 100644 (file)
@@ -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');
index 03c06f8..317be3c 100755 (executable)
@@ -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);
index 7f6dc4c..eccc81c 100755 (executable)
@@ -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()) {
index ba926f5..7f19997 100755 (executable)
@@ -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()) {
index 0ae2c26..3c5ba32 100755 (executable)
@@ -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;
index 384ed7c..94d7dbf 100755 (executable)
@@ -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()) {
index 8c21c00..c9f09b5 100644 (file)
@@ -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 {
index 81569ad..5c7f6e4 100644 (file)
@@ -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'));
index bf725fb..b25d10e 100644 (file)
@@ -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)) {