/**
* Method to determine if client login credentials are present
*
* @param string $client Client name, currently only 'ftp' is supported
*
* @return boolean True if login credentials are available
*
* @since 1.7.0
*/
public static function hasCredentials($client)
{
$return = false;
$client = strtolower($client);
// Get (unmodified) credentials for this client
switch ($client) {
case 'ftp':
$app = Factory::getApplication();
$options = array('enabled' => $app->get('ftp_enable'), 'user' => $app->get('ftp_user'), 'pass' => $app->get('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;
} elseif ($options['user'] != '' && $options['pass'] != '') {
// Login credentials are available in global config
$return = true;
} else {
// Check if login credentials are available in the session
$session = Factory::getSession();
$user = $session->get($client . '.user', null, 'JClientHelper');
$pass = $session->get($client . '.pass', null, 'JClientHelper');
if ($user != '' && $pass != '') {
$return = true;
}
}
return $return;
}