API16:JClientHelper/hasCredentials
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Method to determine if client login credentials are present
Description:JClientHelper/hasCredentials
Syntax
hasCredentials($client)
| Parameter Name | Default Value | Description |
|---|---|---|
| $client | Client name, currently only 'ftp' is supported |
Returns
boolean True if login credentials are available
Defined in
libraries/joomla/client/helper.php
Importing
jimport( 'joomla.client.helper' );
Source Body
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] SeeAlso:JClientHelper/hasCredentials
Examples
<CodeExamplesForm />
