Actions

API15

JClientHelper/hasCredentials

From Joomla! Documentation

< API15:JClientHelper
Revision as of 08:52, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
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

[<! 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 />