Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAJ Ibexa 3.3.X (Branch created from tag v3.2.1) #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Changelog
=========

### 4.0

- Upgrade to eZ Ibexa 4

### 2.1
- activitieslog Interactive Login
- Total login number
Expand Down
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,33 @@
[![Downloads](https://img.shields.io/packagist/dt/arfaram/ezplatform-activities-log?style=flat-square&color=blue)](https://packagist.org/packages/arfaram/ezplatform-activities-log)
[![License](https://img.shields.io/packagist/l/arfaram/ezplatform-activities-log.svg?style=flat-square&color=blue)](https://github.com/arfaram/ezplatform-activities-log/blob/master/LICENSE)

# Available also in premium version with more set of features: [more infos](https://ramzi-arfaoui.de/ez-platform-ibexa-bundles/)

# eZ Platform / Ibexa ActivitiesLog Bundle (open source)
# eZ Platform ActivitiesLog Bundle

This bundle allows you to log user and system events from the UI or using API. See screenshots.

It is a lightweight implementation compared to [EdgarEzUIAuditBundle](https://github.com/noodle69/EdgarEzUIAuditBundle) (!only for eZ Platform /Ibexa 2.x) which provide more details.
It is a lightweight implementation compared to [EdgarEzUIAuditBundle](https://github.com/noodle69/EdgarEzUIAuditBundle) (!only for eZ Platform 2.x) which provide more details.

## Requirement

Ibexa **4.x +**

>Note that this bundle is also available for eZ Platform 3.2. You have to require `arfaram/ezplatform-activities-log:^3.2` and read the README file corresponding to version 3.2
Ibexa **3.3 +**

>Note that this bundle is also available for eZ Platform 3.0 and 3.1. You have to require `arfaram/ezplatform-activities-log:^2.1` and read the README file corresponding to version 2.x
>Please Note that this bundle is also available for Ibexa 3.0 and 3.1 then you have to use `arfaram/ezplatform-activities-log:^2.1` when using `composer require` and read the README file corresponding to version 2.x

>Note that this bundle is also available for eZ Platform 2.x. You have to require `arfaram/ezplatform-activities-log:^1.0` and read the README file corresponding to version 1.x
>Please Note that this bundle is also available for eZ Platform 2.x then you have to use `arfaram/ezplatform-activities-log:^1.0` when using `composer require` and read the README file corresponding to version 1.x

## Features

- Content activities based on ibexa AfterEvent (* See limitations)
- Current logged-in user activities
- Content ~~All user and system~~ activities based on ezplatform AfterEvent (* See limitations)
- Current logged in user activities
- Activities on user level
- Several policies to allow user the access to the activities panels
- User Login History, see CHANGELOG file for more details or see screeshots below
- New in 2.1: user Login History, see CHANGELOG file for more details or see screeshots below


## Limitations
(*) in eZ Platform 2.x it was possible to trigger all API events based on `MVCEvents::API_SIGNAL`. The Signal provides an object and it was easy to serialize it and save it in the DB. Ibexa 3 introduces `Before` and `After` Events which provide several objects like content, contentInfo, VersionInfo etc. So it is no longer possible to serialize these objects anymore. On one hand it is easy to gather a lot of information from the several Events but on the other hand it makes the EventSubscriber implementation very long.
(*) in eZ Platform 2.x it was possible to trigger all API events based on `MVCEvents::API_SIGNAL`. The Signal provides an object and it was easy to serialize it and save it in the DB. EZ Platform 3 introduces `Before` and `After` Events which provide several objects like content, contentInfo, VersionInfo etc. So it is no longer possible to serialize these objects anymore. On one hand it is easy to gather a lot of information from the several Events but on the other hand it makes the EventSubsriber implementation very long.

- This version supports:
- In this version I started only with content AfterEvents:
- HideContentEvent
- RevealContentEvent
- CopyContentEvent
Expand All @@ -42,7 +38,7 @@ Ibexa **4.x +**
- UpdateContentEvent
- PublishVersionEvent

Other `Events` will be added gradually :) Any contribution is welcome
Other `AfterEvents` will be added gradually :) best way to learn eZ Platform. Any contribution is welcome

## Installation

Expand All @@ -69,22 +65,17 @@ ez_platform_activities_log:
php bin/console doctrine:schema:validate
```

### Dump SQL
```
php bin/console doctrine:schema:update --dump-sql
```

### Create the database table

```
php bin/console doctrine:schema:update --dump-sql --force
php bin/console doctrine:schema:update --force
```

Note: use `doc/mysql.sql` to create the DB `activities_log` table if you got some doctrine issues

## Override pagination values

Add your pagination value to `.env` file:
Add you pagination value to `.env` file:

```
# Activities menus(all, me)
Expand All @@ -102,7 +93,7 @@ parameters:
env(ACTIVITIESLOG_USER_TAB_PAGINATION_LIMIT): XX
```

Default values are 15 for both.
Defaut values are 15 for both.

## Screenshots

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "arfaram/ezplatform-activities-log",
"type": "ezplatform-bundle",
"description": "UI Interface for several system activities and user history for eZ Platform Ibexa 4+",
"description": "UI Interface for several system activities and user history for eZ Platform 3+",
"keywords": [
"ezplatform",
"ibexa"
"ezplatform"
],
"homepage": "https://github.com/arfaram/ezplatform-activities-log",
"license": "GPL-2.0-only",
Expand All @@ -21,9 +20,9 @@
}
},
"require": {
"php": "^7.3",
"ibexa/core": "^4.0",
"ibexa/admin-ui": "^4.0",
"doctrine/orm": "^2.12"
"php": "^7.3 || ^8.1",
"ezsystems/ezplatform-kernel": "^1.3",
"ezsystems/ezplatform-admin-ui": "^2.0",
"doctrine/orm": "^2.6"
}
}
Binary file modified doc/all_activities_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/my_activities_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/user_activities_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 28 additions & 53 deletions src/bundle/Controller/ActivitiesLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,77 @@
namespace EzPlatform\ActivitiesLogBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use eZ\Publish\API\Repository\PermissionResolver;
use EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogInteractiveLoginService;
use EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogRepositoryService;
use EzPlatform\ActivitiesLog\Repository\User;
use EzPlatform\ActivitiesLogBundle\Entity\ActivitiesLog;
use Ibexa\Contracts\AdminUi\Controller\Controller as BaseController;
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller as BaseController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ActivitiesLogController extends BaseController
{
private const PAGINATION_PARAM_NAME = 'page';

/** @var \Doctrine\ORM\EntityManagerInterface */
private $entityManager;
private EntityManagerInterface $entityManager;
private ActivitiesLog $activitiesLog;
private PermissionResolver $permissionResolver;
private ActivitiesLogRepositoryService $activitiesLogRepositoryService;
private ActivitiesLogInteractiveLoginService $activitiesLogInteractiveLogin;
private int $activitiesLogUiPanelPaginationLimit;
private User $user;

/** @var \EzPlatform\ActivitiesLogBundle\Entity\ActivitiesLog */
private $activitiesLog;

/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
private $permissionResolver;

/** @var \EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogRepositoryService */
private $activitiesLogRepositoryService;

/** @var \EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogInteractiveLoginService */
private $activitiesLogInteractiveLogin;

/** @var int */
private $activitiesLogUiPanelPaginationLimit;

/** @var \EzPlatform\ActivitiesLog\Repository\User */
private $user;

/**
* ActivitiesLogController constructor.
* @param \Doctrine\ORM\EntityManagerInterface $entityManager
* @param \EzPlatform\ActivitiesLogBundle\Entity\ActivitiesLog $activitiesLog
* @param \Ibexa\Contracts\Core\Repository\PermissionResolver $permissionResolver
* @param \EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogRepositoryService $activitiesLogRepositoryService
* @param \EzPlatform\ActivitiesLog\Repository\Services\ActivitiesLogInteractiveLoginService $activitiesLogInteractiveLogin
* @param int $activitiesLogUiPanelPaginationLimit
* @param $user
*/
public function __construct(
EntityManagerInterface $entityManager,
ActivitiesLog $activitiesLog,
PermissionResolver $permissionResolver,
ActivitiesLogRepositoryService $activitiesLogRepositoryService,
ActivitiesLogInteractiveLoginService $activitiesLogInteractiveLogin,
$activitiesLogUiPanelPaginationLimit,
$user
int $activitiesLogUiPanelPaginationLimit,
User $user
) {
$this->entityManager = $entityManager;
$this->activitiesLog = $activitiesLog;
$this->permissionResolver = $permissionResolver;
$this->activitiesLogRepositoryService = $activitiesLogRepositoryService;
$this->activitiesLogInteractiveLogin = $activitiesLogInteractiveLogin;
$this->entityManager = $entityManager;
$this->activitiesLog = $activitiesLog;
$this->permissionResolver = $permissionResolver;
$this->activitiesLogRepositoryService = $activitiesLogRepositoryService;
$this->activitiesLogInteractiveLogin = $activitiesLogInteractiveLogin;
$this->activitiesLogUiPanelPaginationLimit = $activitiesLogUiPanelPaginationLimit;
$this->user = $user;
$this->user = $user;
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
public function allActivitiesAction(Request $request)
public function allActivitiesAction(Request $request): Response
{
if (!$this->permissionResolver->hasAccess('ezplatformactivitieslog', 'activitieslog_all')) {
return $this->render(
'@ibexadesign/activities/activitieslog_view.html.twig',
'@ezdesign/activities/activitieslog_view.html.twig',
[
'access_denied' => 'access_denied',
]
);
}
$page = $request->query->get(self::PAGINATION_PARAM_NAME, 1);
$page = $request->query->get(self::PAGINATION_PARAM_NAME, 1);
$pagerfanta = $this->activitiesLogRepositoryService->getPageResults($this->activitiesLogUiPanelPaginationLimit, $page);

return $this->render(
'@ibexadesign/activities/activitieslog_view.html.twig',
'@ezdesign/activities/activitieslog_view.html.twig',
[
'pagination' => $pagerfanta,
]
);
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
public function myActivitiesAction(Request $request)
public function myActivitiesAction(Request $request): Response
{
if (!$this->permissionResolver->hasAccess('ezplatformactivitieslog', 'activitieslog_my')) {
return $this->render(
'@ibexadesign/activities/activitieslog_view.html.twig',
'@ezdesign/activities/activitieslog_view.html.twig',
[
'access_denied' => 'access_denied',
]
Expand All @@ -116,7 +91,7 @@ public function myActivitiesAction(Request $request)
);

return $this->render(
'@ibexadesign/activities/activitieslog_view.html.twig',
'@ezdesign/activities/activitieslog_view.html.twig',
[
'pagination' => $pagerfanta,
'userInteractiveLoginData' => $this->activitiesLogInteractiveLogin->getInteractiveLoginData($userId),
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
return new TreeBuilder('ez_platform_activities_log');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace EzPlatform\ActivitiesLogBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration.
*
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
*/
class EzPlatformActivitiesLogExtension extends Extension
{
Expand All @@ -20,9 +20,9 @@ class EzPlatformActivitiesLogExtension extends Extension
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
$loader->load('tab.yaml');
$loader->load('events.yaml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

namespace EzPlatform\ActivitiesLogBundle\DependencyInjection\Security\PolicyProvider;

use Ibexa\Bundle\Core\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\YamlPolicyProvider;

class UIEzPlatformActivitiesLogPolicyProvider extends YamlPolicyProvider
{
/** @var string $path bundle path */
protected $path;
protected string $path;

/**
* UIEzPlatformActivitiesLogPolicyProvider constructor.
* @param string $path
*/
public function __construct(string $path)
{
$this->path = $path;
}

/**
* @return array
*/
public function getFiles()
public function getFiles(): array
{
return [$this->path . '/Resources/config/policies.yaml'];
return [$this->path.'/Resources/config/policies.yaml'];
}
}
Loading