JClientHelper/hasCredentials
From Joomla! Documentation
< API16:JClientHelper
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Method to determine if client login credentials are present
Template:Description:JClientHelper/hasCredentials
Syntax[edit]
hasCredentials($client)
Parameter Name | Default Value | Description |
---|---|---|
$client | Client name, currently only 'ftp' is supported |
Returns[edit]
boolean True if login credentials are available
Defined in[edit]
libraries/joomla/client/helper.php
Importing[edit]
jimport( 'joomla.client.helper' );
Source Body[edit]
function hasCredentials($client)
{
$return = false;
$client = strtolower($client);
// Get (unmodified) credentials for this client
switch ($client)
{
case 'ftp':
$config = &JFactory::getConfig();
$options = array(
'enabled' => $config->getValue('config.ftp_enable'),
'user' => $config->getValue('config.ftp_user'),
'pass' => $config->getValue('config.ftp_pass')
);
break;
default:
$options = array(
'enabled' => false,
'user' => '',
'pass' => ''
);
break;
}
if ($options['enabled'] == false)
{
// The client is disabled in global config, so let's pretend we are OK
$return = true;
}
else if ($options['user'] != '' && $options['pass'] != '')
{
// Login credentials are available in global config
$return = true;
}
else
{
// Check if login credentials are available in the session
$session = &JFactory::getSession();
$user = $session->get($client.'.user', null, 'JClientHelper');
$pass = $session->get($client.'.pass', null, 'JClientHelper');
if ($user != '' && $pass != '') {
$return = true;
}
}
return $return;
}
[Edit See Also] Template:SeeAlso:JClientHelper/hasCredentials
Examples[edit]
<CodeExamplesForm />