Difference between revisions of "Plugin/Events/User/nl"

From Joomla! Documentation

< Plugin‎ | Events
(Created page with "===Gebruikt in bestand===")
(Updating to match new version of source page)
 
(24 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
In een standaard Joomla installatie hebben we een aantal vooraf gedefineerde gebruiker gebeurtenissen die, wanneer geactiveerd, functies oproepen in de bijbehorende plugins.
 
In een standaard Joomla installatie hebben we een aantal vooraf gedefineerde gebruiker gebeurtenissen die, wanneer geactiveerd, functies oproepen in de bijbehorende plugins.
  
==onUserLogin==
+
==onUserAuthorisation==
 +
<div class="mw-translate-fuzzy">
 
===Beschrijving===
 
===Beschrijving===
 
Deze gebeurtenis wordt geactiveerd nadat de gebruiker is geverifieerd in het Joomla! gebruikersbestand.
 
Deze gebeurtenis wordt geactiveerd nadat de gebruiker is geverifieerd in het Joomla! gebruikersbestand.
 +
</div>
  
Als het nodig is om de login-procedure (verificatie) af te breken, dan zult u de [[#onUserAuthenticate|onUserAuthenticate]] in plaats daarvan moeten gebruiken.
+
<div class="mw-translate-fuzzy">
 
 
 
===Parameters===
 
===Parameters===
* '''$user''' - een associatirve array van het [http://api.joomla.org/cms-3/classes/JAuthenticationResponse.html JAuthenticateResponse] type (zie link voor array keys)
+
* '''$user''' - een associatieve array van het [http://api.joomla.org/cms-3/classes/JAuthenticationResponse.html JAuthenticateResponse] type (zie link voor array keys)
 
* '''$options''' - een associatieve array die de volgende sleutels bevat: ["remember"] => bool, ["return"] => string, ["entry_url"] => string
 
* '''$options''' - een associatieve array die de volgende sleutels bevat: ["remember"] => bool, ["return"] => string, ["entry_url"] => string
 +
</div>
  
 +
<div class="mw-translate-fuzzy">
 
===Return waarde===
 
===Return waarde===
 
Boolean
 
Boolean
 +
</div>
  
 
===Gebruikt in bestanden===
 
===Gebruikt in bestanden===
 +
*<tt>libraries/joomla/user/authentication.php</tt>
 +
 +
===Voorbeeld===
 +
*<tt>[https://github.com/ITPrism/Plugin-User-FaceControl/blob/master/facecontrol.php Plugin User - Face Control]</tt>
 +
 +
==onUserAuthorisationFailure==
 +
===Description===
 +
The system triggers this event when the user has been authenticated but he has not been authorised to login. You should only use this event in '''User''' plugins.
 +
 +
===Parameters===
 +
* '''$user''' - an object [http://api.joomla.org/cms-3/classes/JAuthenticationResponse.html JAuthenticationResponse]
 +
 +
===Return Value===
 +
void (it does not return any value or object)
 +
 +
===Used in files===
 +
*<tt>libraries/cms/application/cms.php</tt>
 +
 +
==onUserLogin==
 +
===Description===
 +
This event is triggered after the user is authenticated against the Joomla! user-base.
 +
 +
<div class="mw-translate-fuzzy">
 +
Als het nodig is om de login-procedure (verificatie) af te breken, dan zult u de [[#onUserAuthenticate|onUserAuthenticate]] in plaats daarvan moeten gebruiken.
 +
</div>
 +
 +
===Parameters===
 +
* '''$user''' - an associative array of [http://api.joomla.org/cms-3/classes/JAuthenticationResponse.html JAuthenticationResponse] type (see link for array keys)
 +
* '''$options''' - an associative array containing these keys: ["remember"] => bool, ["return"] => string, ["entry_url"] => string
 +
 +
===Return Value===
 +
Boolean
 +
 +
===Used in files===
 
*<tt>libraries/joomla/application/application.php</tt>
 
*<tt>libraries/joomla/application/application.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
  
===Voorbeeld===
+
===Example===  
 
*<tt>plugins/user/example.php</tt>
 
*<tt>plugins/user/example.php</tt>
  
Line 33: Line 71:
  
 
===Parameters===
 
===Parameters===
* '''$credentials''' - an associative array containing these keys: ["username"] => string, ["id"] => int
+
* '''$credentials''' - een associatieve array die de volgende sleutels bevat: ["username"] => string, ["id"] => int
* '''$options''' - an associative array containing this key: ["clientid"] => int
+
* '''$options''' - een associatieve array die de volgende sleutels bevat: ["clientid"] => int
  
 
===Return waarde===
 
===Return waarde===
 
Boolean
 
Boolean
  
===Used in files===
+
===Gebruikt in bestanden===
 
*<tt>libraries/cms/application/cms.php</tt>
 
*<tt>libraries/cms/application/cms.php</tt>
 
*<tt>plugins/user/joomla/joomla.php</tt>
 
*<tt>plugins/user/joomla/joomla.php</tt>
Line 47: Line 85:
 
===Voorbeeld===
 
===Voorbeeld===
 
*<tt>plugins/user/example.php</tt>
 
*<tt>plugins/user/example.php</tt>
 
==onUserAuthenticate==
 
 
===Description===
 
This event is triggered to verify that a set of login credentials is valid.
 
 
===Parameters===
 
Array of credentials. Structure:\\
 
['username']\\
 
['password']\\
 
Alternative authentication mechanisms can supply additional credentials.
 
 
===Return Value===
 
An array of JAuthenticateResponse objects detailing the results of each called plugin, including success or failure.
 
 
===Gebruikt in bestanden===
 
*<tt>libraries/joomla/user/authentication.php</tt>
 
*<tt>plugins/authentication/gmail.php</tt>
 
*<tt>plugins/authentication/joomla.php</tt>
 
*<tt>plugins/authentication/ldap.php</tt>
 
 
===Voorbeeld===
 
*<tt>plugins/authentication/example.php</tt>
 
  
 
==onUserLoginFailure==
 
==onUserLoginFailure==
Line 77: Line 92:
  
 
===Parameters===
 
===Parameters===
Two parameters. The credentials array for the user (see onAuthenticate), and the JAuthenticateResponse that caused the failure.
+
Two parameters. The credentials array for the user (see onAuthenticate), and the JAuthenticationResponse that caused the failure.
  
 
===Return Value===
 
===Return Value===
Line 91: Line 106:
  
 
===Parameters===
 
===Parameters===
Options is array with:
+
Opties is een array met:
 
* remember
 
* remember
 
* return
 
* return
Line 144: Line 159:
 
Note: The old values that were just updated are not available here or afterwards. In case you need the old values, use onBeforeStoreUser().
 
Note: The old values that were just updated are not available here or afterwards. In case you need the old values, use onBeforeStoreUser().
  
===Return Value===
+
===Retourwaarde===
None
+
Geen
  
===Used in file===
+
===Gebruikt in bestand===
 
*<tt>libraries/joomla/user/user.php</tt>
 
*<tt>libraries/joomla/user/user.php</tt>
  
Line 155: Line 170:
 
==onUserBeforeDelete==
 
==onUserBeforeDelete==
  
===Description===
+
===Beschrijving===
The event is triggered when a user is about to be deleted from the system.
+
De gebeurtenis wordt geactiveerd wanneer een gebruiker wordt verwijderd uit het systeem.
  
 
===Parameters===
 
===Parameters===
* '''$user''' - An associative array of the columns in the user table.
+
* '''$user''' - Een associatieve array van de kolommen in de user tabel.
  
===Return Value===
+
<div class="mw-translate-fuzzy">
None.
+
===Retourwaarde===
 +
Geen.
 +
</div>
  
===Used in files===
+
===Gebruikt in bestanden===
 
*<tt>libraries/joomla/user/user.php</tt>
 
*<tt>libraries/joomla/user/user.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
Line 173: Line 190:
 
==onUserAfterDelete==
 
==onUserAfterDelete==
  
===Description===
+
===Beschrijving===
The event is triggered after a user has been deleted from the system.
+
De gebeurtenis wordt geactiveerd wanneer een gebruiker verwijderd is uit het systeem.
  
 
===Parameters===
 
===Parameters===
Line 181: Line 198:
 
* '''$msg''' - Error message if delete failed ([http://api.joomla.org/cms-3/classes/JError.html JError] object detailing the error, if any)
 
* '''$msg''' - Error message if delete failed ([http://api.joomla.org/cms-3/classes/JError.html JError] object detailing the error, if any)
  
===Return Value===
+
===Retourwaarde===
None.
+
Geen.
  
===Used in files===
+
===Gebruikt in bestanden===
 
*<tt>libraries/joomla/user/user.php</tt>
 
*<tt>libraries/joomla/user/user.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
 
*<tt>plugins/user/joomla.php</tt>
Line 190: Line 207:
 
===Voorbeeld===
 
===Voorbeeld===
 
*<tt>plugins/user/example.php</tt>
 
*<tt>plugins/user/example.php</tt>
 +
 +
===Volgorde van uitvoering===
 +
 +
To modify Joomla! login process upon your needs (e.g. creating AJAX output for login), it may be useful to know the order of the events to be fired.
 +
 +
{| class="wikitable"
 +
|-
 +
! Foutieve referenties !! CORRECT CREDENTIALS and the user is not blocked (is activated) !! CORRECT CREDENTIALS and the user is blocked (is not activated)
 +
|-
 +
| <pre>
 +
onUserAuthenticate
 +
returns
 +
TRUE or FALSE
 +
|
 +
|
 +
\ /
 +
onUserLoginFailure</pre> || <pre>
 +
onUserAuthenticate
 +
returns
 +
TRUE or FALSE
 +
|
 +
|
 +
\ /
 +
onUserLogin returns FALSE -> END
 +
returns TRUE
 +
|
 +
|
 +
\ /
 +
onUserAfterLogin</pre> || <pre>
 +
onUserAuthenticate
 +
returns
 +
TRUE or FALSE
 +
|
 +
|
 +
\ /
 +
onUserLogin
 +
returns
 +
TRUE or FALSE
 +
|
 +
|
 +
\ /
 +
END</pre>
 +
|}
 +
 +
'''Example idea'''
 +
Let's assume you want to preform Ajax login. You have already overriden a mod_login form so it's posted to Joomla! via an AJAX call. You added a field named '''ajax''' to the form.
 +
So when the form is posted and authentication is failed, your custom plugin must return some JSON data.
 +
 +
<source lang="php">
 +
public function onUserLoginFailure($response)
 +
{
 +
$input  = JFactory::getApplication()->input;
 +
 +
// If a non-ajax form was posted, we do not modify the behavior
 +
if (!$input->post->get('ajax', false))
 +
{
 +
return;
 +
}
 +
 +
$app = JFactory::getApplication();
 +
$task_failed = false;
 +
 +
// Fill this array with the data you want to return, e.g. $response['status'] may be useful
 +
// Check libraries/joomla/user/authentication.php for available status codes
 +
$data = array('status' => $response['status']);
 +
       
 +
        // At least here in the plugin it's a must to send proper headers
 +
        JFactory::getApplication()->setHeader('Content-Type', 'application/json', true)->sendHeaders();
 +
echo new JResponseJson($data, $response['error_message'], $task_failed);
 +
 +
// Closing app is a must here to return JSON immediately
 +
$app->close();
 +
}
 +
</source>
  
 
<noinclude>
 
<noinclude>
[[Category:Plugin Development]]
+
[[Category:Plugin Development{{#translation:}}]]
[[Category:Specifications]]
+
[[Category:Specifications{{#translation:}}]]
 
</noinclude>
 
</noinclude>

Latest revision as of 06:25, 1 July 2018

Other languages:
English • ‎Nederlands • ‎español • ‎français

In een standaard Joomla installatie hebben we een aantal vooraf gedefineerde gebruiker gebeurtenissen die, wanneer geactiveerd, functies oproepen in de bijbehorende plugins.

onUserAuthorisation

Beschrijving

Deze gebeurtenis wordt geactiveerd nadat de gebruiker is geverifieerd in het Joomla! gebruikersbestand.

Parameters

  • $user - een associatieve array van het JAuthenticateResponse type (zie link voor array keys)
  • $options - een associatieve array die de volgende sleutels bevat: ["remember"] => bool, ["return"] => string, ["entry_url"] => string

Return waarde

Boolean

Gebruikt in bestanden

  • libraries/joomla/user/authentication.php

Voorbeeld

onUserAuthorisationFailure

Description

The system triggers this event when the user has been authenticated but he has not been authorised to login. You should only use this event in User plugins.

Parameters

Return Value

void (it does not return any value or object)

Used in files

  • libraries/cms/application/cms.php

onUserLogin

Description

This event is triggered after the user is authenticated against the Joomla! user-base.

Als het nodig is om de login-procedure (verificatie) af te breken, dan zult u de onUserAuthenticate in plaats daarvan moeten gebruiken.

Parameters

  • $user - an associative array of JAuthenticationResponse type (see link for array keys)
  • $options - an associative array containing these keys: ["remember"] => bool, ["return"] => string, ["entry_url"] => string

Return Value

Boolean

Used in files

  • libraries/joomla/application/application.php
  • plugins/user/joomla.php

Example

  • plugins/user/example.php

onUserLogout

Beschrijving

Dit evenement wordt gestart vóór de gebruiker is afgemeld van het systeem.

Als een plugin false retourneert zal het algemene uitloggen mislukken en de onUserLogoutFailure event wordt geactiveerd; als dit lukt zal het onUserAfterLogout event worden geactiveerd.

NOTE: as of 3.3.6, returning false does not work correctly, because stock components perform their logout operation during the onUserLogout event. So even if your plugin returns false, the stock ones have already run anyway. Thus, the user will be "mostly" logged out even if you return false. There is no actual way to cleanly abort logout.

Parameters

  • $credentials - een associatieve array die de volgende sleutels bevat: ["username"] => string, ["id"] => int
  • $options - een associatieve array die de volgende sleutels bevat: ["clientid"] => int

Return waarde

Boolean

Gebruikt in bestanden

  • libraries/cms/application/cms.php
  • plugins/user/joomla/joomla.php
  • plugins/system/logout.php
  • plugins/system/remember/remember.php

Voorbeeld

  • plugins/user/example.php

onUserLoginFailure

Beschrijving

Deze gebeurtenis wordt geactiveerd wanneer een gebruiker authenticatie-aanvraag is mislukt door een plugin.

Parameters

Two parameters. The credentials array for the user (see onAuthenticate), and the JAuthenticationResponse that caused the failure.

Return Value

Unknown. The return value appears to be ignored in any case.

Gebruikt in bestand

  • libraries/joomla/application/user/authentication.php

onUserAfterLogin

Beschrijving

Deze gebeurtenis wordt geactiveerd wanneer een gebruiker succesvol is ingelogd.

Parameters

Opties is een array met:

  • remember
  • return
  • entry_url
  • action
  • user - JUser Object
  • responseType

Retourwaarde

Boolean

Gebruikt in bestanden

  • libraries/legacy/application/application.php
  • libraries/cms/application/cms.php
  • plugins/authentication/cookie/cookie.php

onUserBeforeSave

Description

This event is triggered before an update of a user record.

De oude en de nieuwe gebruiker parameters worden aangeboden; veel gebruikte leden zijn: gebruikersnaam, naam, e-mailadres, wachtwoord, wachtwoord_wissen.

The password array entry is the hashed password value. If the user has just changed the password, you may retrieve the cleartext password from $newUser['password_clear']. (It will be set to "" if the password has not been changed.)

Parameters

  • $oldUser - An associative array of the columns in the user table (current values).
  • $isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)
  • $newUser - An associative array of the columns in the user table (new values).

Return Value

Boolean. Whether the user-save should proceed or not. Any plugin that returns false aborts the save.

Gebruikt in bestand

  • libraries/joomla/user/user.php

Voorbeeld

  • plugins/user/example.php

onUserAfterSave

Description

This event is triggered after an update of a user record, or when a new user has been stored in the database.

Password in $user array is already hashed at this point. You may retrieve the cleartext password using $_POST['password'].

Parameters

  • $user - An associative array of the columns in the user table.
  • $isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)
  • $success - Boolean to identify if the store was successful
  • $msg - Error message if store failed

Note: The old values that were just updated are not available here or afterwards. In case you need the old values, use onBeforeStoreUser().

Retourwaarde

Geen

Gebruikt in bestand

  • libraries/joomla/user/user.php

Voorbeeld

  • plugins/user/example.php

onUserBeforeDelete

Beschrijving

De gebeurtenis wordt geactiveerd wanneer een gebruiker wordt verwijderd uit het systeem.

Parameters

  • $user - Een associatieve array van de kolommen in de user tabel.

Retourwaarde

Geen.

Gebruikt in bestanden

  • libraries/joomla/user/user.php
  • plugins/user/joomla.php

Voorbeeld

  • plugins/user/example.php

onUserAfterDelete

Beschrijving

De gebeurtenis wordt geactiveerd wanneer een gebruiker verwijderd is uit het systeem.

Parameters

  • $user - An associative array of the columns in the user table.
  • $succes - Boolean to identify if the deletion was successful
  • $msg - Error message if delete failed (JError object detailing the error, if any)

Retourwaarde

Geen.

Gebruikt in bestanden

  • libraries/joomla/user/user.php
  • plugins/user/joomla.php

Voorbeeld

  • plugins/user/example.php

Volgorde van uitvoering

To modify Joomla! login process upon your needs (e.g. creating AJAX output for login), it may be useful to know the order of the events to be fired.

Foutieve referenties CORRECT CREDENTIALS and the user is not blocked (is activated) CORRECT CREDENTIALS and the user is blocked (is not activated)
onUserAuthenticate
returns
TRUE or FALSE
	 |
	 |
	\ /
onUserLoginFailure
onUserAuthenticate
returns
TRUE or FALSE
	 |
	 |
	\ /
onUserLogin	returns FALSE -> END
returns TRUE
	 |
	 |
	\ /
onUserAfterLogin
onUserAuthenticate
returns
TRUE or FALSE
	 |
	 |
	\ /
onUserLogin
returns
TRUE or FALSE
	 |
	 |
	\ /
	END

Example idea Let's assume you want to preform Ajax login. You have already overriden a mod_login form so it's posted to Joomla! via an AJAX call. You added a field named ajax to the form. So when the form is posted and authentication is failed, your custom plugin must return some JSON data.

public function onUserLoginFailure($response)
{
	$input  = JFactory::getApplication()->input;

	// If a non-ajax form was posted, we do not modify the behavior
	if (!$input->post->get('ajax', false))
	{
		return;
	}

	$app = JFactory::getApplication();
	$task_failed = false; 

	// Fill this array with the data you want to return, e.g. $response['status'] may be useful
	// Check libraries/joomla/user/authentication.php for available status codes 
	$data = array('status' => $response['status']);
        
        // At least here in the plugin it's a must to send proper headers
        JFactory::getApplication()->setHeader('Content-Type', 'application/json', true)->sendHeaders();
	echo new JResponseJson($data, $response['error_message'], $task_failed);

	// Closing app is a must here to return JSON immediately
	$app->close();
}