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 preparing for archive only |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
Method to determine if client login credentials are present | Method to determine if client login credentials are present | ||
<! removed transcluded page call, red link never existed > | |||
===Syntax=== | ===Syntax=== | ||
| Line 83: | Line 81: | ||
</source> | </source> | ||
<! removed transcluded page call, red link never existed > | |||
< | |||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=hasCredentials | category=hasCredentials | ||
category=JClientHelper | category=JClientHelper | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
[[Category:Archived pages API16]] | |||
Latest revision as of 01:24, 25 March 2017
Description
Method to determine if client login credentials are present
<! 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 transcluded page call, red link never existed >
Examples
Code Examples