Actions

JClientHelper/setCredentialsFromRequest

From Joomla! Documentation

Revision as of 14:11, 10 August 2009 by Batch1211 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This method checks if valid credentials have been passed through the request. If so, they are set as the new credentials for the client. Since this method is used to determine, if the input fields for the client settings need to be shown, this method returns FALSE if the credentials passed by the request could be successfully stored OR the credentials have been stored via the Global Configurations. Otherwise this method reurns TRUE.

Contents

Syntax

boolean setCredentials ($client, $user, $pass)

Argument Data type Description Default
$client string Client name, currently only 'ftp' is supported

Request Parameters

The method checks for the following two request parameters, that shall be used to set the credentials for the given client.

  • username
  • password

Returns

Returns FALSE if:

  • Parameters 'username' and 'password' that are passed via the request are not empty AND are valid (See JClientHelper/setCredentials). OR:
  • The credentials for the given client are set in the Global Configurations.

Example

In this example, we want to find out, if we need to show the login form for the FTP client:

jimport('joomla.client.helper');
 
if(JClientHelper::setCredentialsFromRequest('ftp'){
   // show login form
}
// continue with code

This code checks if the credentials for the FTP client are passed via the request, or are already stored via the Global Configurations. If this is the case, the code continues without the login form beeing displayed. Otherwise, the login form is displayed.

See also