jimport('joomla.application.component.helper');
jimport('joomla.database.table');
+ jimport('joomla.user.helper');
+
+ $JUserTable = JTable::getInstance('User', 'JTable');
+
+ $db = $JUserTable->getDbo();
+ $query = $db->getQuery(TRUE);
+ $query->select('id, name, username, email, password');
+ $query->from($JUserTable->getTableName());
+ $query->where('(LOWER(username) = LOWER(\'' . $name . '\')) AND (block = 0)');
+ $db->setQuery($query, 0, 0);
+ $users = $db->loadObjectList();
+
+ $row = array();
+ if (count($users)) {
+ $row = $users[0];
+ }
if ( !defined('JVERSION') ) {
$joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
define('JVERSION', $jversion->getShortVersion());
}
- if ( version_compare(JVERSION, '2.5.18', 'lt') ||
- ( version_compare(JVERSION, '3.0', 'ge') && version_compare(JVERSION, '3.2.2', 'lt') )
- ) {
- //old method for authenticating
- $JUserTable = JTable::getInstance('User', 'JTable');
-
- $db = $JUserTable->getDbo();
- $query = $db->getQuery(TRUE);
- $query->select('id, username, email, password');
- $query->from($JUserTable->getTableName());
- $query->where('(LOWER(username) = LOWER(\'' . $name . '\')) AND (block = 0)');
- $db->setQuery($query, 0, 0);
- $users = $db->loadAssocList();
-
- $row = array();;
- if (count($users)) {
- $row = $users[0];
- }
-
- if (!empty($row)) {
- $dbPassword = CRM_Utils_Array::value('password', $row);
- $dbId = CRM_Utils_Array::value('id', $row);
- $dbEmail = CRM_Utils_Array::value('email', $row);
+ if (!empty($row)) {
+ $dbPassword = $row->password;
+ $dbId = $row->id;
+ $dbEmail = $row->email;
+ if ( version_compare(JVERSION, '2.5.18', 'lt') ||
+ ( version_compare(JVERSION, '3.0', 'ge') && version_compare(JVERSION, '3.2.1', 'lt') )
+ ) {
// now check password
if (strpos($dbPassword, ':') === FALSE) {
if ($dbPassword != md5($password)) {
}
}
}
- }
- else {
- //new authentication method (J2.5.18/3.2.2 and greater)
- // Get a database object
- $db = JFactory::getDbo();
- $query = $db->getQuery(TRUE);
-
- $query->select('id, password');
- $query->from('#__users');
- $query->where('username='.$db->quote($name));
-
- $db->setQuery( $query );
- $result = $db->loadObject();
-
- if ($result) {
- $match = JUserHelper::verifyPassword($password, $result->password, $result->id);
-
- if ($match === TRUE) {
- $jUser = JUser::getInstance($result->id); // Bring this in line with the rest of the system
- $dbId = $row['id'] = $result->id;
- $dbEmail = $row['email'] = $jUser->email;
- }
+ else {
+ if (!JUserHelper::verifyPassword($password, $dbPassword, $dbId)) return FALSE;
}
- }
- if (!empty($row)) {
- CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $dbId, $dbEmail, 'Joomla');
+ CRM_Core_BAO_UFMatch::synchronizeUFMatch($row, $dbId, $dbEmail, 'Joomla');
$contactID = CRM_Core_BAO_UFMatch::getContactId($dbId);
if (!$contactID) {
return FALSE;
}
return array($contactID, $dbId, mt_rand());
}
+
return FALSE;
}