Passwd: First pass at converting to H4 standards
authorBen Klang <ben@alkaloid.net>
Wed, 19 May 2010 01:46:08 +0000 (21:46 -0400)
committerBen Klang <ben@alkaloid.net>
Wed, 19 May 2010 01:46:08 +0000 (21:46 -0400)
passwd/lib/Application.php [new file with mode: 0644]
passwd/lib/Exception.php [new file with mode: 0644]
passwd/lib/base.php [deleted file]
passwd/main.php

diff --git a/passwd/lib/Application.php b/passwd/lib/Application.php
new file mode 100644 (file)
index 0000000..a7dd420
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Passwd application interface.
+ *
+ * This file brings in all of the dependencies that every PASSWD script will
+ * need, and sets up objects that all scripts use.
+ *
+ * Copyright 2002-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.horde.org/licenses/gpl.php.
+ *
+ * @author  Eric Rostetter <eric.rostetter@physics.utexas.edu>
+ * @author  Ben Klang <ben@alkaloid.net>
+ * @package Passwd
+ */
+
+if (!defined('PASSWD_BASE')) {
+    define('PASSWD_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(PASSWD_BASE. '/config/horde.local.php')) {
+        include PASSWD_BASE . '/config/horde.local.php';
+    } else {
+        define('HORDE_BASE', PASSWD_BASE . '/..');
+    }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+class Passwd_Application extends Horde_Registry_Application
+{
+    /**
+     * Initialization function.
+     *
+     * Global variables defined:
+     */
+    protected function _init()
+    {
+
+    }
+}
\ No newline at end of file
diff --git a/passwd/lib/Exception.php b/passwd/lib/Exception.php
new file mode 100644 (file)
index 0000000..56d2f50
--- /dev/null
@@ -0,0 +1 @@
+<?php class Passwd_Exception extends Horde_Exception {}
\ No newline at end of file
diff --git a/passwd/lib/base.php b/passwd/lib/base.php
deleted file mode 100644 (file)
index 658b270..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Passwd base inclusion file.
- *
- * This file brings in all of the dependencies that every PASSWD script will
- * need, and sets up objects that all scripts use.
- *
- * $Horde: passwd/lib/base.php,v 1.33.2.7 2009/10/19 23:34:20 jan Exp $
- *
- * Copyright 2002-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.horde.org/licenses/gpl.php.
- *
- * @author  Eric Rostetter <eric.rostetter@physics.utexas.edu>
- * @package Passwd
- */
-
-// 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__) . '/../..');
-}
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = &Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('passwd', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
-    if ($pushed->getCode() == 'permission_denied') {
-        Horde::authenticationFailureRedirect();
-    }
-    Horde::fatal($pushed, __FILE__, __LINE__, false);
-}
-$conf = &$GLOBALS['conf'];
-@define('PASSWD_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = &Notification::singleton();
-$notification->attach('status');
-
-// Find the base file path of Passwd
-@define('PASSWD_BASE', dirname(__FILE__) . '/..');
-
-// Passwd base library.
-require_once PASSWD_BASE . '/lib/Passwd.php';
-
-// Start compression.
-if (!Util::nonInputVar('no_compress')) {
-     Horde::compressOutput();
-}
-
-// Horde libraries.
-require_once 'Horde/Help.php';
-require_once 'Horde/Secret.php';
index d58ee30..6a84047 100644 (file)
  * @package Passwd
  */
 
-@define('PASSWD_BASE', dirname(__FILE__));
-require_once PASSWD_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
 require PASSWD_BASE . '/config/backends.php';
 
 // Get the backend details.
-$backend_key = Util::getFormData('backend', false);
+$backend_key = Horde_Util::getFormData('backend', false);
 if (!isset($backends[$backend_key])) {
     $backend_key = null;
 }
@@ -28,7 +27,7 @@ do {
     }
 
     // Has the user submitted the form yet?
-    $submit = Util::getFormData('submit', false);
+    $submit = Horde_Util::getFormData('submit', false);
     if (!$submit) {
         // No so we don't need to do anything in this loop.
         break;
@@ -42,7 +41,7 @@ do {
 
     // Get the username.
     if ($conf['user']['change'] === true) {
-        $userid = Util::getFormData('userid');
+        $userid = Horde_Util::getFormData('userid');
     } else {
         if ($conf['hooks']['default_username']) {
             $userid = Horde::callHook('_passwd_hook_default_username',
@@ -63,7 +62,7 @@ do {
     }
 
     // We must be passed the old (current) password, or its an error.
-    $old_password = Util::getFormData('oldpassword', false);
+    $old_password = Horde_Util::getFormData('oldpassword', false);
     if (!$old_password) {
         $notification->push(_("You must give your current password"),
                             'horde.warning');
@@ -71,8 +70,8 @@ do {
     }
 
     // See if they entered the new password and verified it.
-    $new_password0 = Util::getFormData('newpassword0', false);
-    $new_password1 = Util::getFormData('newpassword1', false);
+    $new_password0 = Horde_Util::getFormData('newpassword0', false);
+    $new_password1 = Horde_Util::getFormData('newpassword1', false);
     if (!$new_password0) {
         $notification->push(_("You must give your new password"), 'horde.warning');
         break;
@@ -226,7 +225,7 @@ do {
                         array($backend_userid, $old_password, $new_password0),
                         'passwd');
 
-        $return_to = Util::getFormData('return_to');
+        $return_to = Horde_Util::getFormData('return_to');
         if (!empty($return_to)) {
             header('Location: ' . $return_to);
             exit;