Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JClientHelper

Liste de tous les membres

Fonctions membres publiques statiques

static getCredentials ($client, $force=false)
static setCredentials ($client, $user, $pass)
static hasCredentials ($client)
static setCredentialsFromRequest ($client)

Description détaillée

Définition à la ligne 19 du fichier helper.php.


Documentation des fonctions membres

static JClientHelper::getCredentials (   $client,
  $force = false 
)
static

Method to return the array of client layer configuration options

Paramètres:
string$clientClient name, currently only 'ftp' is supported
boolean$forceForces re-creation of the login credentials. Set this to true if login credentials in the session storage have changed
Renvoie:
array Client layer configuration options, consisting of at least these fields: enabled, host, port, user, pass, root
Depuis:
11.1

Définition à la ligne 33 du fichier helper.php.

Références JFactory\getConfig(), et JFactory\getSession().

Référencé par JFolder\copy(), JFile\copy(), JFolder\create(), JFile\delete(), JFolder\delete(), JFactory\getStream(), JFile\move(), JFolder\move(), JFile\upload(), et JFile\write().

{
static $credentials = array();
$client = strtolower($client);
if (!isset($credentials[$client]) || $force)
{
$config = JFactory::getConfig();
// Fetch the client layer configuration options for the specific client
switch ($client)
{
case 'ftp':
$options = array(
'enabled' => $config->get('ftp_enable'),
'host' => $config->get('ftp_host'),
'port' => $config->get('ftp_port'),
'user' => $config->get('ftp_user'),
'pass' => $config->get('ftp_pass'),
'root' => $config->get('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 they are 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];
}

+ Voici le graphe d'appel pour cette fonction :

+ Voici le graphe des appelants de cette fonction :

static JClientHelper::hasCredentials (   $client)
static

Method to determine if client login credentials are present

Paramètres:
string$clientClient name, currently only 'ftp' is supported
Renvoie:
boolean True if login credentials are available
Depuis:
11.1

Définition à la ligne 148 du fichier helper.php.

Références JFactory\getConfig(), et JFactory\getSession().

{
$return = false;
$client = strtolower($client);
// Get (unmodified) credentials for this client
switch ($client)
{
case 'ftp':
$config = JFactory::getConfig();
$options = array('enabled' => $config->get('ftp_enable'), 'user' => $config->get('ftp_user'), 'pass' => $config->get('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;
}
elseif ($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;
}

+ Voici le graphe d'appel pour cette fonction :

static JClientHelper::setCredentials (   $client,
  $user,
  $pass 
)
static

Method to set client login credentials

Paramètres:
string$clientClient name, currently only 'ftp' is supported
string$userUsername
string$passPassword
Renvoie:
boolean True if the given login credentials have been set and are valid
Depuis:
11.1

Définition à la ligne 93 du fichier helper.php.

Références JFactory\getConfig(), JClientFtp\getInstance(), et JFactory\getSession().

{
$return = false;
$client = strtolower($client);
// Test if the given credentials are valid
switch ($client)
{
case 'ftp':
$config = JFactory::getConfig();
$options = array('enabled' => $config->get('ftp_enable'), 'host' => $config->get('ftp_host'), 'port' => $config->get('ftp_port'));
if ($options['enabled'])
{
$ftp = JClientFtp::getInstance($options['host'], $options['port']);
// Test the connection and try to log in
if ($ftp->isConnected())
{
if ($ftp->login($user, $pass))
{
$return = true;
}
$ftp->quit();
}
}
break;
default:
break;
}
if ($return)
{
// Save valid credentials to the session
$session = JFactory::getSession();
$session->set($client . '.user', $user, 'JClientHelper');
$session->set($client . '.pass', $pass, 'JClientHelper');
// Force re-creation of the data saved within JClientHelper::getCredentials()
self::getCredentials($client, true);
}
return $return;
}

+ Voici le graphe d'appel pour cette fonction :

static JClientHelper::setCredentialsFromRequest (   $client)
static

Determine whether input fields for client settings need to be shown

If valid credentials were passed along with the request, they are saved to the session. This functions returns an exception if invalid credentials have been given or if the connection to the server failed for some other reason.

Paramètres:
string$clientThe name of the client.
Renvoie:
mixed True, if FTP settings; JError if using legacy tree.
Depuis:
11.1
Exceptions:
InvalidArgumentExceptionif credentials invalid

Définition à la ligne 206 du fichier helper.php.

Références JText\_(), JFactory\getApplication(), et JError\raiseWarning().

{
// Determine whether FTP credentials have been passed along with the current request
$input = JFactory::getApplication()->input;
$user = $input->post->getString('username', null);
$pass = $input->post->getString('password', null);
if ($user != '' && $pass != '')
{
// Add credentials to the session
if (self::setCredentials($client, $user, $pass))
{
$return = false;
}
else
{
if (class_exists('JError'))
{
$return = JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED'));
}
else
{
throw new InvalidArgumentException('Invalid user credentials');
}
}
}
else
{
// Just determine if the FTP input fields need to be shown
$return = !self::hasCredentials('ftp');
}
return $return;
}

+ Voici le graphe d'appel pour cette fonction :


La documentation de cette classe a été générée à partir du fichier suivant :