Difference between revisions of "JClientHelper/getCredentials"
From Joomla! Documentation
< API16:JClientHelper
(New page: ===Description===
Method to return the array of client layer configuration options
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JClientHelper/getC...) |
m (preparing for archive only) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
Method to return the array of client layer configuration options | Method to return the array of client layer configuration options | ||
− | |||
− | |||
− | |||
− | + | ||
+ | <! removed transcluded page call, red link never existed > | ||
===Syntax=== | ===Syntax=== | ||
Line 94: | Line 92: | ||
</source> | </source> | ||
− | + | ||
− | + | <! removed transcluded page call, red link never existed > | |
− | < | ||
− | |||
===Examples=== | ===Examples=== | ||
− | + | === Code Examples === | |
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=getCredentials | category=getCredentials | ||
category=JClientHelper | category=JClientHelper | ||
− | + | namespace=CodeExample | |
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Latest revision as of 20:24, 24 March 2017
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 return the array of client layer configuration options
<! 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)
{
// Initialise 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 transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]