Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
592056f
ContentPrepareEvent
Fedik Jul 25, 2023
1995a33
AfterTitle, BeforeDisplay, AfterDisplay
Fedik Jul 25, 2023
ede41c3
Fix category params
Fedik Jul 25, 2023
36d8057
phpcs
Fedik Jul 25, 2023
276d860
PrepareForm
Fedik Jul 25, 2023
c070269
PrepareForm
Fedik Jul 25, 2023
7348762
PrepareForm
Fedik Jul 25, 2023
63f1b96
PrepareForm
Fedik Jul 25, 2023
416b885
ContentPrepareData
Fedik Jul 25, 2023
5acdf15
ContentNormaliseRequestData
Fedik Jul 25, 2023
ea220f3
Params b/c compatibility
Fedik Jul 26, 2023
876badf
ContentBeforeSaveEvent
Fedik Jul 26, 2023
fd7f9a9
ContentAfterSave
Fedik Jul 26, 2023
3d7bb4f
Fixes for ContentBeforeSave
Fedik Jul 26, 2023
8feb26f
ContentSaveEvent
Fedik Jul 26, 2023
93d6c61
ContentDeleteEvent
Fedik Jul 26, 2023
de10615
ChangeStateEvent
Fedik Jul 26, 2023
c888f2e
BeforeValidateData
Fedik Jul 26, 2023
e46283c
Fix Data referencing
Fedik Jul 26, 2023
8696272
Fix params
Fedik Jul 26, 2023
dcc7054
Re-arange
Fedik Jul 26, 2023
7b536b2
Re-arange
Fedik Jul 26, 2023
19f9a2b
Descriptions with example
Fedik Jul 26, 2023
c0596ab
Descriptions with example
Fedik Jul 26, 2023
4e67381
Plugin system/fields partial
Fedik Jul 26, 2023
aef153b
Proxy interface, ArrayProxy class
Fedik Jul 27, 2023
1e477e3
ObjectProxy class
Fedik Jul 27, 2023
1eecbc7
Iterating own iterator
Fedik Jul 27, 2023
e17e974
Cleanup
Fedik Jul 27, 2023
b317289
Proxy Test
Fedik Jul 27, 2023
3e18ca7
Merge branch '5.0-dev' into content-events
Fedik Jul 27, 2023
38af7d5
Merge branch 'proxy-class' into content-events
Fedik Jul 27, 2023
2d86862
Proxy event data
Fedik Jul 27, 2023
26eb8f2
Dates
Fedik Jul 27, 2023
0134790
testing test
Fedik Jul 28, 2023
6866d42
Revert "testing test"
Fedik Jul 28, 2023
ef10d2b
testing test
Fedik Jul 28, 2023
db0277e
testing test
Fedik Jul 28, 2023
f22221e
testing test
Fedik Jul 28, 2023
762baee
testing test
Fedik Jul 28, 2023
f4b2f18
testing test
Fedik Jul 28, 2023
25fee21
testing test
Fedik Jul 28, 2023
538565f
testing test
Fedik Jul 28, 2023
cf0be84
testing test
Fedik Jul 28, 2023
1769788
testing test
Fedik Jul 28, 2023
d41e53e
testing test
Fedik Jul 28, 2023
87b43a6
testing test
Fedik Jul 28, 2023
429774f
testing test
Fedik Jul 28, 2023
0b94fc5
testing test
Fedik Jul 28, 2023
fcaba73
testing test
Fedik Jul 28, 2023
fa12d96
testing test
Fedik Jul 28, 2023
01a0f96
testing test
Fedik Jul 28, 2023
1e6942f
testing test
Fedik Jul 28, 2023
48fc17f
testing test
Fedik Jul 28, 2023
9f9cb05
testing test
Fedik Jul 28, 2023
61c8d16
testing test
Fedik Jul 28, 2023
413f857
testing test
Fedik Jul 28, 2023
e05d81e
testing test
Fedik Jul 28, 2023
fea0f4f
testing test
Fedik Jul 28, 2023
c75a44d
testing test
Fedik Jul 28, 2023
e48e0c0
testing test drone system
Fedik Jul 28, 2023
a819701
Revert "testing test drone system"
Fedik Jul 28, 2023
bfa4525
testing test
Fedik Jul 29, 2023
95b1a96
testing test
Fedik Jul 29, 2023
de60af5
testing test
Fedik Jul 29, 2023
8878acf
testing test
Fedik Jul 29, 2023
4a6064f
testing test
Fedik Jul 29, 2023
47291f0
Revert "testing test"
Fedik Jul 29, 2023
8e530da
testing test
Fedik Jul 29, 2023
0e4ce93
Schemaorg plg
Fedik Jul 29, 2023
a03ff75
Fix mixed events
Fedik Jul 29, 2023
555a4e8
Fix mixed events
Fedik Jul 29, 2023
441c7e0
Better reshape
Fedik Jul 29, 2023
4b40348
fixes
Fedik Jul 31, 2023
6220e42
b/c for get/set arguments
Fedik Aug 1, 2023
0338038
AuthorisationEvent
Fedik Aug 3, 2023
9b3b770
AuthorisationEvent
Fedik Aug 3, 2023
0b5944a
AuthorisationFailureEvent
Fedik Aug 3, 2023
ba935ef
LoginEvents
Fedik Aug 4, 2023
9bd72c8
LogoutEvents
Fedik Aug 4, 2023
fef5e83
LoginButtonsEvents
Fedik Aug 4, 2023
0ae28a0
SaveUserEvents
Fedik Aug 4, 2023
181b31e
DeleteUserEvents
Fedik Aug 4, 2023
dbf811f
DeleteUserEvents
Fedik Aug 4, 2023
12d477a
User group events
Fedik Aug 4, 2023
3762b15
User AfterRemind events
Fedik Aug 4, 2023
d2dde35
User events examples
Fedik Aug 4, 2023
604ac18
phpcs
Fedik Aug 4, 2023
2f837a5
CategoryChangeState
Fedik Aug 5, 2023
8908052
Simplify
Fedik Aug 5, 2023
e591064
Merge branch '5.0-dev' into content-events
Fedik Aug 5, 2023
50cfe0b
Merge branch '5.0-dev' into content-events
Fedik Aug 5, 2023
f1b9bf3
Updates
Fedik Aug 5, 2023
6e481d0
Reorder
Fedik Aug 5, 2023
487194c
Merge branch 'content-events' into user-events2
Fedik Aug 5, 2023
9e69543
Handle result
Fedik Aug 6, 2023
fa2cebc
Merge branch '5.0-dev' into user-events2
HLeithner Aug 14, 2023
9d51815
Merge branch '5.0-dev' into content-events
HLeithner Aug 14, 2023
810c56f
phpcs
Fedik Aug 14, 2023
d786b07
Play safe, legacy extension may have not set the Dispatcher
Fedik Aug 14, 2023
c7586b1
Revert "Play safe, legacy extension may have not set the Dispatcher"
Fedik Aug 15, 2023
d4237cb
Merge branch '5.0-dev' into content-events
HLeithner Aug 16, 2023
6dae1eb
Update access to dispatcher
Fedik Aug 17, 2023
18e6396
Do not use deprecated method
Fedik Aug 17, 2023
270e501
AfterCleanCache Event
Fedik Aug 17, 2023
1e8b38b
reorder
Fedik Aug 17, 2023
e27121e
Merge branch '5.0-dev' into content-events-fix
Fedik Aug 21, 2023
f373c3b
Merge branch 'content-events' into user-events2
Fedik Aug 21, 2023
7079e2a
Merge branch '5.0-dev' into user-events2
Fedik Aug 21, 2023
c8f1bc3
Merge branch '5.0-dev' into user-events2
Fedik Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/com_users/src/Model/RemindModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Users\Site\Model;

use Joomla\CMS\Event\User\AfterRemindEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
Expand Down Expand Up @@ -201,7 +202,9 @@ public function processRemindRequest($data)
return false;
}

Factory::getApplication()->triggerEvent('onUserAfterRemind', [$user]);
$this->getDispatcher()->dispatch('onUserAfterRemind', new AfterRemindEvent('onUserAfterRemind', [
'subject' => $user,
]));

return true;
}
Expand Down
54 changes: 41 additions & 13 deletions libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
use Joomla\CMS\Event\Application\BeforeRenderEvent;
use Joomla\CMS\Event\Application\BeforeRespondEvent;
use Joomla\CMS\Event\ErrorEvent;
use Joomla\CMS\Event\User\AfterLoginEvent;
use Joomla\CMS\Event\User\AfterLogoutEvent;
use Joomla\CMS\Event\User\AuthorisationFailureEvent;
use Joomla\CMS\Event\User\LoginEvent;
use Joomla\CMS\Event\User\LoginFailureEvent;
use Joomla\CMS\Event\User\LogoutEvent;
use Joomla\CMS\Event\User\LogoutFailureEvent;
use Joomla\CMS\Exception\ExceptionHandler;
use Joomla\CMS\Extension\ExtensionManagerTrait;
use Joomla\CMS\Factory;
Expand Down Expand Up @@ -837,9 +844,10 @@ public function login($credentials, $options = [])
// Get the global Authentication object.
$authenticate = Authentication::getInstance($this->authenticationPluginType);
$response = $authenticate->authenticate($credentials, $options);
$dispatcher = $this->getDispatcher();

// Import the user plugin group.
PluginHelper::importPlugin('user', null, true, $this->getDispatcher());
PluginHelper::importPlugin('user', null, true, $dispatcher);

if ($response->status === Authentication::STATUS_SUCCESS) {
/*
Expand All @@ -852,7 +860,10 @@ public function login($credentials, $options = [])
foreach ($authorisations as $authorisation) {
if ((int) $authorisation->status & $denied_states) {
// Trigger onUserAuthorisationFailure Event.
$this->triggerEvent('onUserAuthorisationFailure', [(array) $authorisation]);
$dispatcher->dispatch('onUserAuthorisationFailure', new AuthorisationFailureEvent('onUserAuthorisationFailure', [
'subject' => (array) $authorisation,
'options' => $options,
]));

// If silent is set, just return false.
if (isset($options['silent']) && $options['silent']) {
Expand All @@ -862,25 +873,27 @@ public function login($credentials, $options = [])
// Return the error.
switch ($authorisation->status) {
case Authentication::STATUS_EXPIRED:
Factory::getApplication()->enqueueMessage(Text::_('JLIB_LOGIN_EXPIRED'), 'error');
$this->enqueueMessage(Text::_('JLIB_LOGIN_EXPIRED'), 'error');

return false;

case Authentication::STATUS_DENIED:
Factory::getApplication()->enqueueMessage(Text::_('JLIB_LOGIN_DENIED'), 'error');
$this->enqueueMessage(Text::_('JLIB_LOGIN_DENIED'), 'error');

return false;

default:
Factory::getApplication()->enqueueMessage(Text::_('JLIB_LOGIN_AUTHORISATION'), 'error');
$this->enqueueMessage(Text::_('JLIB_LOGIN_AUTHORISATION'), 'error');

return false;
}
}
}

// OK, the credentials are authenticated and user is authorised. Let's fire the onLogin event.
$results = $this->triggerEvent('onUserLogin', [(array) $response, $options]);
$loginEvent = new LoginEvent('onUserLogin', ['subject' => (array) $response, 'options' => $options]);
$dispatcher->dispatch('onUserLogin', $loginEvent);
$results = $loginEvent['result'] ?? [];

/*
* If any of the user plugins did not successfully complete the login routine
Expand All @@ -900,14 +913,20 @@ public function login($credentials, $options = [])
$options['responseType'] = $response->type;

// The user is successfully logged in. Run the after login events
$this->triggerEvent('onUserAfterLogin', [$options]);
$dispatcher->dispatch('onUserAfterLogin', new AfterLoginEvent('onUserAfterLogin', [
'options' => $options,
'subject' => (array) $response,
]));

return true;
}
}

// Trigger onUserLoginFailure Event.
$this->triggerEvent('onUserLoginFailure', [(array) $response]);
$dispatcher->dispatch('onUserLoginFailure', new LoginFailureEvent('onUserLoginFailure', [
'subject' => (array) $response,
'options' => $options,
]));

// If silent is set, just return false.
if (isset($options['silent']) && $options['silent']) {
Expand Down Expand Up @@ -942,7 +961,8 @@ public function login($credentials, $options = [])
public function logout($userid = null, $options = [])
{
// Get a user object from the Application.
$user = Factory::getUser($userid);
$user = Factory::getUser($userid);
$dispatcher = $this->getDispatcher();

// Build the credentials array.
$parameters = [
Expand All @@ -956,21 +976,29 @@ public function logout($userid = null, $options = [])
}

// Import the user plugin group.
PluginHelper::importPlugin('user', null, true, $this->getDispatcher());
PluginHelper::importPlugin('user', null, true, $dispatcher);

// OK, the credentials are built. Lets fire the onLogout event.
$results = $this->triggerEvent('onUserLogout', [$parameters, $options]);
$logoutEvent = new LogoutEvent('onUserLogout', ['subject' => $parameters, 'options' => $options]);
$dispatcher->dispatch('onUserLogout', $logoutEvent);
$results = $logoutEvent['result'] ?? [];

// Check if any of the plugins failed. If none did, success.
if (!\in_array(false, $results, true)) {
$options['username'] = $user->get('username');
$this->triggerEvent('onUserAfterLogout', [$options]);
$dispatcher->dispatch('onUserAfterLogout', new AfterLogoutEvent('onUserAfterLogout', [
'options' => $options,
'subject' => $parameters,
]));

return true;
}

// Trigger onUserLogoutFailure Event.
$this->triggerEvent('onUserLogoutFailure', [$parameters]);
$dispatcher->dispatch('onUserLogoutFailure', new LogoutFailureEvent('onUserLogoutFailure', [
'subject' => $parameters,
'options' => $options,
]));

return false;
}
Expand Down
11 changes: 8 additions & 3 deletions libraries/src/Authentication/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Joomla\CMS\Authentication;

use Joomla\CMS\Event\User\AuthorisationEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
Expand Down Expand Up @@ -212,10 +213,14 @@ public function authenticate($credentials, $options = [])
*/
public function authorise($response, $options = [])
{
$dispatcher = $this->getDispatcher();

// Get plugins in case they haven't been imported already
PluginHelper::importPlugin('user');
$results = Factory::getApplication()->triggerEvent('onUserAuthorisation', [$response, $options]);
PluginHelper::importPlugin('user', null, true, $dispatcher);

$event = new AuthorisationEvent('onUserAuthorisation', ['subject' => $response, 'options' => $options]);
$dispatcher->dispatch('onUserAuthorisation', $event);

return $results;
return $event['result'] ?? [];
}
}
20 changes: 20 additions & 0 deletions libraries/src/Event/CoreEventAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ trait CoreEventAware
'onContentChangeState' => Model\AfterChangeStateEvent::class,
'onCategoryChangeState' => Model\AfterCategoryChangeStateEvent::class,
'onBeforeBatch' => Model\BeforeBatchEvent::class,
// User
'onUserAuthorisation' => User\AuthorisationEvent::class,
'onUserAuthorisationFailure' => User\AuthorisationFailureEvent::class,
'onUserLogin' => User\LoginEvent::class,
'onUserAfterLogin' => User\AfterLoginEvent::class,
'onUserLoginFailure' => User\LoginFailureEvent::class,
'onUserLogout' => User\LogoutEvent::class,
'onUserAfterLogout' => User\AfterLogoutEvent::class,
'onUserLogoutFailure' => User\LogoutFailureEvent::class,
'onUserLoginButtons' => User\LoginButtonsEvent::class,
'onUserBeforeSave' => User\BeforeSaveEvent::class,
'onUserAfterSave' => User\AfterSaveEvent::class,
'onUserBeforeDelete' => User\BeforeDeleteEvent::class,
'onUserAfterDelete' => User\AfterDeleteEvent::class,
'onUserAfterRemind' => User\AfterRemindEvent::class,
// User Group
'onUserBeforeSaveGroup' => Model\BeforeSaveEvent::class,
'onUserAfterSaveGroup' => Model\AfterSaveEvent::class,
'onUserBeforeDeleteGroup' => Model\BeforeDeleteEvent::class,
'onUserAfterDeleteGroup' => Model\AfterDeleteEvent::class,
// Modules
'onRenderModule' => Module\BeforeRenderModuleEvent::class,
'onAfterRenderModule' => Module\AfterRenderModuleEvent::class,
Expand Down
58 changes: 58 additions & 0 deletions libraries/src/Event/User/AbstractDeleteEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* Joomla! Content Management System
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Event\User;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Base class for User delete event
*
* @since __DEPLOY_VERSION__
*/
abstract class AbstractDeleteEvent extends UserEvent
{
/**
* The argument names, in order expected by legacy plugins.
*
* @var array
*
* @since __DEPLOY_VERSION__
* @deprecated 5.0 will be removed in 6.0
*/
protected $legacyArgumentsOrder = ['subject'];

/**
* Setter for the subject argument.
*
* @param array $value The value to set
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject(array $value): array
{
return $value;
}

/**
* Getter for the user.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function getUser(): array
{
return $this->arguments['subject'];
}
}
84 changes: 84 additions & 0 deletions libraries/src/Event/User/AbstractLoginEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

/**
* Joomla! Content Management System
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\CMS\Event\User;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Base class for User login event
*
* @since __DEPLOY_VERSION__
*/
abstract class AbstractLoginEvent extends UserEvent
{
/**
* The argument names, in order expected by legacy plugins.
*
* @var array
*
* @since __DEPLOY_VERSION__
* @deprecated 5.0 will be removed in 6.0
*/
protected $legacyArgumentsOrder = ['subject', 'options'];

/**
* Setter for the subject argument.
*
* @param array $value The value to set
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject(array $value): array
{
return $value;
}

/**
* Setter for the options argument.
*
* @param array $value The value to set
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
protected function setOptions(array $value): array
{
return $value;
}

/**
* Getter for the response.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function getAuthenticationResponse(): array
{
return $this->arguments['subject'];
}

/**
* Getter for the options.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
public function getOptions(): array
{
return $this->arguments['options'] ?? [];
}
}
Loading