JClientHelper/hasCredentials: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Method to determine if client login credentials are present
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JClientHelper/hasCreden... |
m removing red link to edit, no existant pages |
||
| Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 84: | Line 84: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
<nowiki>[< | <nowiki>[<! removed edit link to red link >]</nowiki> | ||
</span> | </span> | ||
<! removed transcluded page call, red link never existed > | |||
===Examples=== | ===Examples=== | ||
| Line 99: | Line 99: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API16]] | |||
Revision as of 02:55, 13 May 2013
Description
Method to determine if client login credentials are present
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
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;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />