Source for file gmail.php
Documentation is available at gmail.php
* @subpackage Authentication.gmail
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* GMail Authentication Plugin
* @subpackage Authentication.gmail
* This method should handle any authentication and report back to the subject
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object &$response Authentication response object
// Check if we have curl or not
// Check if we have a username and password
if (strlen($credentials['username']) &&
strlen($credentials['password']))
$blacklist =
explode(',', $this->params->get('user_blacklist', ''));
// Check if the username isn't blacklisted
if (!in_array($credentials['username'], $blacklist))
$suffix =
$this->params->get('suffix', '');
$applysuffix =
$this->params->get('applysuffix', 0);
$offset =
strpos($credentials['username'], '@');
// Check if we want to do suffix stuff, typically for Google Apps for Your Domain
if ($suffix &&
$applysuffix)
if ($applysuffix ==
1 &&
$offset ===
false)
// Apply suffix if missing
$credentials['username'] .=
'@' .
$suffix;
elseif ($applysuffix ==
2)
// If we already have an @, get rid of it and replace it
$credentials['username'] =
substr($credentials['username'], 0, $offset);
$credentials['username'] .=
'@' .
$suffix;
$curl =
curl_init('https://mail.google.com/mail/feed/atom');
//curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_USERPWD, $credentials['username'] .
':' .
$credentials['password']);
$message =
JText::_('JGLOBAL_AUTH_ACCESS_GRANTED');
$message =
JText::_('JGLOBAL_AUTH_ACCESS_DENIED');
$message =
JText::_('JGLOBAL_AUTH_UNKNOWN_ACCESS_DENIED');
// The username is black listed
$message =
JText::_('JGLOBAL_AUTH_USER_BLACKLISTED');
$message =
JText::_('JGLOBAL_AUTH_USER_BLACKLISTED');
$message =
JText::_('JGLOBAL_AUTH_CURL_NOT_INSTALLED');
$response->type =
'GMail';
$response->error_message =
'';
if (strpos($credentials['username'], '@') ===
false)
// If there is a suffix then we want to apply it
$response->email =
$credentials['username'] .
'@' .
$suffix;
// If there isn't a suffix just use the default gmail one
$response->email =
$credentials['username'] .
'@gmail.com';
// The username looks like an email address (probably is) so use that
$response->email =
$credentials['username'];
// Reset the username to what we ended up using
$response->username =
$credentials['username'];
$response->fullname =
$credentials['username'];
$response->error_message =
JText::sprintf('JGLOBAL_AUTH_FAILED', $message);
Documentation generated on Tue, 19 Nov 2013 15:04:01 +0100 by phpDocumentor 1.4.3