JClientHelper/getCredentials
From Joomla! Documentation
< API15:JClientHelperRevision as of 08:52, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
Revision as of 08:52, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API15" 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 return the array of client layer configuration options
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
getCredentials($client, $force=false)
Parameter Name | Default Value | Description |
---|---|---|
$client | Client name, currently only 'ftp' is supported | |
$force | false | Forces re-creation of the login credentials. Set this to true if login credentials in the session storage have changed |
Returns[edit]
array Client layer configuration options, consisting of at least these fields: enabled, host, port, user, pass, root
Defined in[edit]
libraries/joomla/client/helper.php
Importing[edit]
jimport( 'joomla.client.helper' );
Source Body[edit]
function getCredentials($client, $force=false)
{
static $credentials = array();
$client = strtolower($client);
if (!isset($credentials[$client]) || $force)
{
// Initialize variables
$config =& JFactory::getConfig();
// Fetch the client layer configuration options for the specific client
switch ($client)
{
case 'ftp':
$options = array(
'enabled' => $config->getValue('config.ftp_enable'),
'host' => $config->getValue('config.ftp_host'),
'port' => $config->getValue('config.ftp_port'),
'user' => $config->getValue('config.ftp_user'),
'pass' => $config->getValue('config.ftp_pass'),
'root' => $config->getValue('config.ftp_root')
);
break;
default:
$options = array(
'enabled' => false,
'host' => '',
'port' => '',
'user' => '',
'pass' => '',
'root' => ''
);
break;
}
// If user and pass are not set in global config lets see if its in the session
if ($options['enabled'] == true && ($options['user'] == '' || $options['pass'] == ''))
{
$session =& JFactory::getSession();
$options['user'] = $session->get($client.'.user', null, 'JClientHelper');
$options['pass'] = $session->get($client.'.pass', null, 'JClientHelper');
}
// If user or pass are missing, disable this client
if ($options['user'] == '' || $options['pass'] == '') {
$options['enabled'] = false;
}
// Save the credentials for later use
$credentials[$client] = $options;
}
return $credentials[$client];
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />