Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/j3/plugins/authentication/email/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/j3/plugins/authentication/email/email.php

<?php

/**
 * @version		$Id: email.php 20196 2011-03-04 02:40:25Z mrichey $
 * @package		plg_auth_email
 * @copyright	Copyright (C) 2005 - 2011 Michael Richey. All rights
reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
// No direct access
defined('_JEXEC') or die;

jimport('joomla.plugin.plugin');

class plgAuthenticationEmail extends JPlugin {

    /**
     * This method should handle any authentication and report back to the
subject
     */
    function onUserAuthenticate(&$credentials, $options,
&$response) {


        // Get a database object
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->select('u.id, username, password');
       
$query->from($db->quoteName('#__users','u'));
       
$query->join('inner',$db->quoteName('#__reservation_consultant','co')
.'on
('.$db->quoteName('co.userid').'='.$db->quoteName('u.id').')'
);
        $query->where(
$db->quoteName('co.phonenumber').'='.$db->Quote($credentials['username']));

        $db->setQuery($query);
        $result = $db->loadObject();
        if (empty($result))
        {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);

            $query->select('u.id, username, password');
           
$query->from($db->quoteName('#__users','u'));
           
$query->join('inner',$db->quoteName('#__reservation_sick','s')
.'on
('.$db->quoteName('s.userid').'='.$db->quoteName('u.id').')'
);
            $query->where(
$db->quoteName('s.phoneNumber').'='.$db->Quote($credentials['username']));

            $db->setQuery($query);
            $result = $db->loadObject();
        }


        if ($result) {
            // why mess with re-creating authentication - just use the
system.
            $credentials['username'] = $result->username;
            require_once JPATH_PLUGINS .
'/authentication/joomla/joomla.php';
            PlgAuthenticationJoomla::onUserAuthenticate($credentials,
$options, $response);
        } else {
            $response->status = JAuthentication::STATUS_FAILURE;
            $response->error_message =
JText::_('JGLOBAL_AUTH_INVALID_PASS');            
        }
    }

}