Fatal error: Class passwd_driver_xams: Cannot inherit from undefined class passwd_driver_sql

"Jan Johansson" <[email protected]>
Newsgroups gmane.comp.horde.sork
Message-ID <[email protected]>
Oliver Siegman (lead developer of the now 'dead' XAMS) wrote a plugin for
passwd that would interface to XAMS, but I get

Fatal error: Class passwd_driver_xams: Cannot inherit from undefined class
passwd_driver_sql

And I have no clue what might be wrong?


<?php
/**
 * The XAMS driver attempts to change a user's password stored in an
XAMS/SQL
 * databse and implements the Passwd_Driver API.
 *
 * $Horde: passwd/lib/Driver/sql.php,v 1.24 2005/08/23 11:15:06 jan Exp $
 *
 * Copyright 2000-2005 Horde Project (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (ASL). If you
 * did not receive this file, see http://www.horde.org/licenses/asl.php.
 *
 * @author  Mike Cochrane <[email protected]>
 * @author  Ilya Krel <[email protected]>
 * @author  Tjeerd van der Zee <[email protected]>
 * @author  Mattias Webjörn Eriksson <[email protected]>
 * @author  Eric Jon Rostetter <[email protected]>
 * @author  Oliver Siegmar <[email protected]>
 * @package Passwd
 */
class Passwd_Driver_xams extends Passwd_Driver_sql {

    /**
     * Constructs a new Passwd_Driver_sql object.
     *
     * @param array $params  A hash containing connection parameters.
     */
    function Passwd_Driver_xams($params = array())
    {
        if (isset($params['phptype'])) {
            $this->_params['phptype'] = $params['phptype'];
        } else {
            return PEAR::raiseError(_("Required 'phptype' not specified in
Passwd SQL configuration."));
        }

        /* Use defaults from Horde, but allow overriding in backends.php. */
        $this->_params = array_merge(Horde::getDriverConfig('', 'xams'),
$params);

        /* These default to matching the Auth_sql defaults. */
        $this->_params['encryption'] = isset($params['encryption']) ?
$params['encryption'] : 'md5';
        $this->_params['show_encryption'] =
isset($params['show_encryption']) ? $params['show_encryption'] : false;
    }

    /**
     * Find out if a username and password is valid.
     *
     * @param string $userID        The userID to check.
     * @param string $old_password  An old password to check.
     *
     * @return boolean  True on valid or PEAR_Error on invalid.
     */
    function _lookup($user, $old_password)
    {
        /* Connect to the database */
        $res = $this->_connect();
        if (is_a($res, 'PEAR_Error')) {
            return $res;
        }

        /* Build the SQL query. */
        if (strpos($username, '@') === false)
        {
            $sql = 'SELECT     pm_users.id,
                               pm_users.password
                    FROM       pm_sites
                    INNER JOIN pm_domains
                    ON         pm_sites.id = pm_domains.siteid
                    INNER JOIN pm_users
                    ON         pm_sites.id = pm_users.siteid
                    WHERE      pm_users.uniquename = ?';
            $values = array($user);
        }
        else
        {
            $sql = 'SELECT     pm_users.id,
                               pm_users.password
                    FROM       pm_sites
                    INNER JOIN pm_domains
                    ON         pm_sites.id = pm_domains.siteid
                    INNER JOIN pm_users
                    ON         pm_sites.id = pm_users.siteid
                    WHERE      pm_users.name = ?
                    AND        pm_domains.name = ?';
            $values = explode('@', $user);
        }

        Horde::logMessage('SQL Query by Passwd_Driver_sql::_lookup(): ' .
$sql, __FILE__, __LINE__, PEAR_LOG_DEBUG);

        /* Execute the query. */
        $result = $this->_db->query($sql, $values);
        if (!is_a($result, 'PEAR_Error')) {
            $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
            $result->free();
            if (is_array($row)) {
                /* Get the password from the database. */
                $current_password = $row['password'];

                /* Check the passwords match. */
                $ret = $this->comparePasswords($current_password,
$old_password);

                return ($ret === true) ? $row['id'] : $ret;
            }
        }
        return PEAR::raiseError(_("User not found"));
    }

    /**
     * Modify (update) a mysql password record for a user.
     *
     * @param string $user          The user whose record we will udpate.
     * @param string $new_password  The new password value to set.
     *
     * @return boolean  True or False based on success of the modify.
     */
    function _modify($user, $new_password)
    {
        /* Connect to the database. */
        $res = $this->_connect();
        if (is_a($res, 'PEAR_Error')) {
            return $res;
        }

        /* Encrypt the password. */
        $new_password = $this->encryptPassword($new_password,
$this->_params['show_encryption']);

        /* Build the SQL query. */
        $sql = 'UPDATE pm_users
                SET    password = ?
                WHERE  id = ?';
        $values = array($new_password, $user);
        Horde::logMessage('SQL Query by Passwd_Driver_sql::_modify(): ' .
$sql, __FILE__, __LINE__, PEAR_LOG_DEBUG);

        /* Execute the query. */
        $result = $this->_db->query($sql, $values);

        if (is_a($result, 'PEAR_Error')) {
            return $result;
        }

        return true;
    }

    /**
     * Change the user's password.
     *
     * @param string $username      The user for which to change the
password.
     * @param string $old_password  The old (current) user password.
     * @param string $new_password  The new user password to set.
     *
     * @return boolean  True or false based on success of the change.
     */
    function changePassword($username,  $old_password, $new_password)
    {
        /* Check the current password. */
        $res = $this->_lookup($username, $old_password);
        if (is_a($res, 'PEAR_Error'))  {
            return $res;
        }

        return $this->_modify($res, $new_password);
    }

}

-- 
Sork mailing list - Join the hunt: http://horde.org/bounties/#sork
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
smime.p7s (application/x-pkcs7-signature, 2.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.