Преглед на файлове

[Technique] Mise en place AuthorizationChecker #1328

feature/souke
Guillaume Bourgeois преди 1 година
родител
ревизия
4842251273
променени са 32 файла, в които са добавени 109 реда и са изтрити 114 реда
  1. +3
    -1
      backend/controllers/DevelopmentController.php
  2. +3
    -4
      backend/views/layouts/header.php
  3. +48
    -45
      backend/views/layouts/left.php
  4. +4
    -2
      backend/views/user/index.php
  5. +3
    -0
      common/logic/AbstractSingleton.php
  6. +0
    -1
      common/logic/ModuleInterface.php
  7. +0
    -26
      common/logic/User/User/Service/UserSolver.php
  8. +0
    -5
      common/logic/User/User/Wrapper/UserContainer.php
  9. +0
    -5
      common/logic/User/User/Wrapper/UserModule.php
  10. +2
    -1
      common/versions/22.10.A.php
  11. +2
    -1
      common/versions/22.11.A.php
  12. +2
    -1
      common/versions/22.11.B.php
  13. +2
    -1
      common/versions/22.12.A.php
  14. +2
    -1
      common/versions/23.1.A.php
  15. +1
    -0
      common/versions/23.10.A.php
  16. +1
    -0
      common/versions/23.10.B.php
  17. +2
    -1
      common/versions/23.3.A.php
  18. +2
    -1
      common/versions/23.4.A.php
  19. +2
    -1
      common/versions/23.6.A.php
  20. +2
    -1
      common/versions/23.6.B.php
  21. +2
    -1
      common/versions/23.7.A.php
  22. +2
    -1
      common/versions/23.8.A.php
  23. +1
    -0
      common/versions/23.8.B.php
  24. +1
    -0
      common/versions/23.9.A.php
  25. +1
    -0
      common/versions/23.9.B.php
  26. +1
    -0
      common/versions/23.9.C.php
  27. +1
    -0
      common/versions/23.9.D.php
  28. +1
    -0
      common/versions/23.9.E.php
  29. +8
    -7
      common/versions/_macros.php
  30. +5
    -4
      common/views/nav_user_top.php
  31. +4
    -1
      frontend/views/layouts/main.php
  32. +1
    -2
      producer/views/layouts/main.php

+ 3
- 1
backend/controllers/DevelopmentController.php Целия файл

@@ -80,7 +80,9 @@ class DevelopmentController extends BackendController
foreach ($versionsArray as $version) {
$versionsRenderArray[$version] = [
'version' => $version,
'content' => $this->renderFile('@common/versions/' . $version . '.php')
'content' => $this->renderFile('@common/versions/' . $version . '.php', [
'userCurrent' => $this->getUserCurrent()
])
];
}


+ 3
- 4
backend/views/layouts/header.php Целия файл

@@ -48,13 +48,12 @@ use common\logic\Producer\Producer\Model\Producer;
$userModule = UserModule::getInstance();
$producerManager = ProducerManager::getInstance();
$producer = GlobalParam::getCurrentProducer();
$userCurrent = GlobalParam::getCurrentUser();

?>

<header class="main-header">

<!-- <?= Html::a('<span class="logo-mini"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span><span class="logo-lg"><img src="' . Yii::$app->urlManagerBackend->getBaseUrl() . '/img/logo-distrib.png" /></span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>-->

<?= Html::a('Opendistrib', Yii::$app->homeUrl, ['class' => 'logo']); ?>

<nav class="navbar navbar-static-top" role="navigation">
@@ -91,7 +90,7 @@ $producer = GlobalParam::getCurrentProducer();

<ul class="nav navbar-nav">

<?php if ($userModule->isCurrentAdmin()): ?>
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
<li class="dropdown producer-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-grain"></span>
@@ -268,7 +267,7 @@ $producer = GlobalParam::getCurrentProducer();
</ul>

</li>
<?php if ($userModule->isCurrentProducer() || $userModule->isCurrentAdmin()): ?>
<?php if ($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)): ?>
<li>
<a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => GlobalParam::getCurrentProducer()->slug]); ?>">
<span class="glyphicon glyphicon-eye-open"></span>

+ 48
- 45
backend/views/layouts/left.php Целия файл

@@ -37,15 +37,18 @@
*/

use common\helpers\GlobalParam;
use common\helpers\Opendistrib;
use yii\helpers\Html;
use common\logic\Ticket\Ticket\Wrapper\TicketManager;
use common\logic\User\User\Wrapper\UserModule;

$producerManager = $this->getProducerManager();
$userModule = $this->getUserModule();
$userModule = UserModule::getInstance();
$userProducerManager = $this->getUserProducerManager();
$ticketManager = $this->getTicketManager();

$producer = GlobalParam::getCurrentProducer();
$userCurrent = GlobalParam::getCurrentUser();
$isUserCurrentGrantedAsAdministrator = $userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent);
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);


?>

@@ -61,13 +64,13 @@ $producer = GlobalParam::getCurrentProducer();

$countTicketsProducerUnreadLabel = '';
$countTicketsProducerUnread = $ticketManager->countTicketsUnreadByUser($this->getUserCurrent());
if($countTicketsProducerUnread && !$userModule->isCurrentAdmin()) {
if($countTicketsProducerUnread && !$isUserCurrentGrantedAsAdministrator) {
$countTicketsProducerUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsProducerUnread.'</small></span>';
}

$countTicketsAdminUnreadLabel = '';
$countTicketsAdminUnread = $ticketManager->countTicketsAdminUnreadByUser($this->getUserCurrent());
if($countTicketsAdminUnread && $userModule->isCurrentAdmin()) {
if($countTicketsAdminUnread && $isUserCurrentGrantedAsAdministrator) {
$countTicketsAdminUnreadLabel = '<span class="pull-right-container"><small class="label pull-right bg-green">'.$countTicketsAdminUnread.'</small></span>';
}

@@ -81,56 +84,56 @@ $producer = GlobalParam::getCurrentProducer();
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget' => 'tree'],
'items' => [
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()],
['label' => "Besoin d'aide ?", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Support',
'icon' => 'comments',
'url' => ['support/index'],
'visible' => $userModule->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsProducerUnreadLabel . '</a>'
],
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => $producer->name, 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Tableau de bord', 'icon' => 'dashboard', 'url' => ['/dashboard/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Distributions', 'icon' => 'calendar', 'url' => ['/distribution/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Produits',
'icon' => 'clone',
'url' => ['/product/index'],
'visible' => $userModule->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'active' => Yii::$app->controller->id == 'product',
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/product/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Catégories', 'icon' => 'book', 'url' => ['/product-category/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Import prix', 'icon' => 'upload', 'url' => ['/product/price-import'], 'visible' => $isUserCurrentGrantedAsProducer],
]
],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'point-sale'],
['label' => 'Points de vente', 'icon' => 'map-marker', 'url' => ['/point-sale/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'point-sale'],
[
'label' => 'Utilisateurs',
'icon' => 'users',
'url' => ['/user/index'],
'items' => [
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Liste', 'icon' => 'th-list', 'url' => ['/user/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Crédit',
'icon' => 'euro',
'url' => ['/credit/index'],
'template' => '<a href="{url}">{icon} {label}' . $sumUserProducerCreditsLabel . '</a>',
'visible' => $userModule->isCurrentProducer() && $producerManager->getConfig('credit')
'visible' => $isUserCurrentGrantedAsProducer && $producerManager->getConfig('credit')
],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Groupes', 'icon' => 'users', 'url' => ['/user-group/index'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $userModule->isCurrentProducer(), 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Abonnements', 'icon' => 'repeat', 'url' => ['/subscription/index'], 'visible' => $isUserCurrentGrantedAsProducer, 'active' => Yii::$app->controller->id == 'subscription'],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate/index'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Documents',
'icon' => 'clone',
'url' => ['/delivery-note/index'],
'items' => [
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Bons de livraison', 'icon' => 'sticky-note-o', 'url' => ['/delivery-note/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Factures', 'icon' => 'sticky-note-o', 'url' => ['/invoice/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Devis', 'icon' => 'sticky-note-o', 'url' => ['/quotation/index'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
[
@@ -138,52 +141,52 @@ $producer = GlobalParam::getCurrentProducer();
'icon' => 'line-chart',
'url' => ['/stats/index'],
'items' => [
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Rapports', 'icon' => 'pencil-square-o', 'url' => ['/report/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Produits', 'icon' => 'table', 'url' => ['/stats/products'], 'visible' => $isUserCurrentGrantedAsProducer],
],
],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $userModule->isCurrentProducer()],
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Paramètres', 'icon' => 'cog', 'url' => ['/producer/update'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => 'Accès', 'icon' => 'lock', 'url' => ['/access/index'], 'visible' => $isUserCurrentGrantedAsProducer],
['label' => "Opendistrib", 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsProducer],
[
'label' => 'Développement',
'icon' => 'code',
'url' => ['/development/index'],
'visible' => $userModule->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'active' => Yii::$app->controller->id == 'development',
'template' => '<a href="{url}">{icon} {label}' . $newVersionOpendistribLabel . '</a>'
],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $userModule->isCurrentProducer()],
['label' => 'Tarifs', 'icon' => 'euro', 'url' => ['/producer/billing'], 'visible' => $isUserCurrentGrantedAsProducer],

['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Tickets',
'icon' => 'comments',
'url' => ['support-admin/index'],
'visible' => $userModule->isCurrentAdmin(),
'visible' => $isUserCurrentGrantedAsAdministrator,
'template' => '<a href="{url}">{icon} {label}' . $countTicketsAdminUnreadLabel . '</a>'
],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Producteurs', 'icon' => 'th-list', 'url' => ['/producer-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
[
'label' => 'Statistiques',
'icon' => 'line-chart',
'url' => ['/stats-admin/matomo'],
'visible' => $userModule->isCurrentAdmin(),
'visible' => $isUserCurrentGrantedAsAdministrator,
'items' => [
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Matomo', 'icon' => 'line-chart', 'url' => ['/stats-admin/matomo'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Chiffre d\'affaire', 'icon' => 'line-chart', 'url' => ['/stats-admin/turnover'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Commandes clients', 'icon' => 'calendar', 'url' => ['/stats-admin/customer-orders'], 'visible' => $isUserCurrentGrantedAsAdministrator],
],
],

['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $userModule->isCurrentAdmin()],
['label' => 'Tranches de prix', 'icon' => 'eur', 'url' => ['/producer-price-range-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Taxes', 'icon' => 'eur', 'url' => ['/tax-rate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Communiquer', 'icon' => 'bullhorn', 'url' => ['/communicate-admin/index'], 'visible' => $isUserCurrentGrantedAsAdministrator],

//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $userModule->isCurrentAdmin()],
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $userModule->isCurrentAdmin()],
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $userModule->isCurrentAdmin()],
//['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => $isUserCurrentGrantedAsAdministrator],
//['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug'], 'visible' => $isUserCurrentGrantedAsAdministrator],
['label' => 'Login', 'url' => ['site/login'], 'visible' => !$userModule->isCurrentConnected()],
],
]

+ 4
- 2
backend/views/user/index.php Целия файл

@@ -36,6 +36,7 @@
* termes.
*/

use common\helpers\GlobalParam;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use yii\helpers\Html;
use yii\grid\GridView;
@@ -45,6 +46,7 @@ use common\logic\User\UserProducer\Model\UserProducer;

$userModule = UserModule::getInstance();
$producerManager = ProducerManager::getInstance();
$userCurrent = GlobalParam::getCurrentUser();

$this->setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle());
@@ -203,8 +205,8 @@ $this->render('_menu', [
'class' => 'btn btn-default btn-confirm-delete'
]);
},
'switch' => function($url, $model) use ($userModule) {
if($userModule->isCurrentAdmin()) {
'switch' => function($url, $model) use ($userModule, $userCurrent) {
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) {
return Html::a('<span class="glyphicon glyphicon-user"></span>',
Yii::$app->urlManager->createUrl(['user/switch-identity', 'id' => $model->id]),
[

+ 3
- 0
common/logic/AbstractSingleton.php Целия файл

@@ -15,6 +15,9 @@ abstract class AbstractSingleton
trigger_error("Le clonage n'est pas autorisé.", E_USER_ERROR);
}*/

/**
* @return $this
*/
final public static function getInstance(): self
{
$c = get_called_class();

+ 0
- 1
common/logic/ModuleInterface.php Целия файл

@@ -5,5 +5,4 @@ namespace common\logic;
interface ModuleInterface
{
public function getContainerFqcn(): string;
public function getServices(): ContainerInterface;
}

+ 0
- 26
common/logic/User/User/Service/UserSolver.php Целия файл

@@ -182,32 +182,6 @@ class UserSolver extends AbstractService implements SolverInterface
return !\Yii::$app->user->isGuest;
}

/**
* Retourne si l'utilisateur courant est un producteur ou non.
*
*/
public function isCurrentProducer(): bool
{
$user = $this->getCurrent();
if ($user) {
return $this->isProducer($user);
}
return false;
}

/**
* Retourne si l'utilisateur courant est un admin ou non.
*
*/
public function isCurrentAdmin(): bool
{
$user = $this->getCurrent();
if ($user) {
return $this->isAdmin($user);
}
return false;
}

/**
* Retourne l'ID de l'utilisateur courant connecté.
*

+ 0
- 5
common/logic/User/User/Wrapper/UserContainer.php Целия файл

@@ -59,9 +59,4 @@ class UserContainer extends AbstractContainer
{
return NewsletterManager::getInstance();
}

public function getAuthorizationChecker(): AuthorizationChecker
{
return AuthorizationChecker::getInstance();
}
}

+ 0
- 5
common/logic/User/User/Wrapper/UserModule.php Целия файл

@@ -29,11 +29,6 @@ class UserModule extends AbstractModule
return UserContainer::class;
}

public function getServices(): UserContainer
{
return $this->container;
}

public function getAuthorizationChecker(): AuthorizationChecker
{
return AuthorizationChecker::getInstance();

+ 2
- 1
common/versions/22.10.A.php Целия файл

@@ -30,7 +30,8 @@ version(
"[Backend] Facture > créer : tri des utilisateurs par ordre alphabétique",
"Correctif connexion personnes morales"
]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/22.11.A.php Целия файл

@@ -13,7 +13,8 @@ version(
"[Administration] Abonnements : suppression des commandes après la date de fin lors de l'arrêt d'un abonnement",
"[Administration] Distributions > calendrier : amélioration chargement automatique des distributions (affichage pastilles vertes)"
]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/22.11.B.php Целия файл

@@ -13,7 +13,8 @@ version(
"[Administration] Développement : mise en avant des nouvelles versions et des informations de contact"
],
[]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/22.12.A.php Целия файл

@@ -10,7 +10,8 @@ version(
"[Administration] Abonnements : comportement paiement automatique (déduit, oui, non)"
],
[]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.1.A.php Целия файл

@@ -12,7 +12,8 @@ version(
"[Administration] Documents > listes : optimisation chargement",
"[Espace producteur] Commander : ajustement ordre des points de vente"
]
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.10.A.php Целия файл

@@ -22,6 +22,7 @@ version(
"[Administration] Correctif problème upload images webp"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.10.B.php Целия файл

@@ -26,6 +26,7 @@ version(
],
[]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.3.A.php Целия файл

@@ -13,7 +13,8 @@ version(
"[Administration] Export vers le logiciel Evoliz : ajout de la TVA + code classification vente"
],
[]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.4.A.php Целия файл

@@ -12,7 +12,8 @@ version(
[
"Logiciel de caisse Tiller : synchronisation des commandes partiellement payées"
]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.6.A.php Целия файл

@@ -14,7 +14,8 @@ version(
"[Espace producteur] Produits : mise en évidence des noms de produit",
"[Site] Profil utilisateur : permettre édition adresse email"
],
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.6.B.php Целия файл

@@ -21,7 +21,8 @@ version(
"[Espace producteur] Abonnements : correctif disponibilité produits par point de vente",
"Abonnements > ajout/modification : prise en compte des contraintes de délai et d'heure limite de commande dans la génération des commandes des distributions à venir"
]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.7.A.php Целия файл

@@ -11,7 +11,8 @@ version(
'[Administration] Distributions > Produits : possibilité de définir une quantité maximum à 0',
'[Technique] Réécriture requêtes bases de données'
]
]
],
$userCurrent
);

?>

+ 2
- 1
common/versions/23.8.A.php Целия файл

@@ -12,7 +12,8 @@ version(
'[Site & espace producteur] Barre de navigation en haut du site'
],
[]
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.8.B.php Целия файл

@@ -16,6 +16,7 @@ version(
"[Administration et espace producteur] Produits : optimisation de l'affichage des images"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.9.A.php Целия файл

@@ -22,6 +22,7 @@ version(
"[Technique] ParameterBag : service dédié à la récupération des paramètres système"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.9.B.php Целия файл

@@ -28,6 +28,7 @@ version(
"[Administration] Tickets admin : flag pour savoir si un ticket a été lu par le producteur"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.9.C.php Целия файл

@@ -21,6 +21,7 @@ version(
"[Technique] Mise en place Twig"
]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.9.D.php Целия файл

@@ -17,6 +17,7 @@ version(
[],
[]
],
$userCurrent
);

?>

+ 1
- 0
common/versions/23.9.E.php Целия файл

@@ -21,6 +21,7 @@ version(
[],
[]
],
$userCurrent
);

?>

+ 8
- 7
common/versions/_macros.php Целия файл

@@ -1,11 +1,12 @@
<?php

use common\logic\User\User\Model\User;
use common\logic\User\User\Wrapper\UserModule;

function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = []) {
function version(string $date, array $featuresMaintenanceArray, array $featuresMaintenanceAdminArray = [], User $userCurrent) {
release_date($date);
features($featuresMaintenanceArray[0] ?? [], $featuresMaintenanceAdminArray[0] ?? []);
maintenance($featuresMaintenanceArray[1] ?? [], $featuresMaintenanceAdminArray[1] ?? []);
features($featuresMaintenanceArray[0] ?? [], $featuresMaintenanceAdminArray[0] ?? [], $userCurrent);
maintenance($featuresMaintenanceArray[1] ?? [], $featuresMaintenanceAdminArray[1] ?? [], $userCurrent);
}

function release_date(string $date) {
@@ -16,7 +17,7 @@ function release_date(string $date) {
echo $html;
}

function features(array $featuresArray, array $featuresAdminArray) {
function features(array $featuresArray, array $featuresAdminArray, User $userCurrent) {
$userModule = UserModule::getInstance();
if(count($featuresArray) > 0 || count($featuresAdminArray) > 0) {
$html = '<div class="block block-features">';
@@ -25,7 +26,7 @@ function features(array $featuresArray, array $featuresAdminArray) {
foreach($featuresArray as $feature) {
$html .= '<li>'.$feature.'</li>';
}
if($userModule->isCurrentAdmin()) {
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) {
foreach($featuresAdminArray as $feature) {
$html .= '<li class="admin">'.$feature.'</li>';
}
@@ -36,7 +37,7 @@ function features(array $featuresArray, array $featuresAdminArray) {
}
}

function maintenance(array $maintenanceArray, array $maintenanceAdminArray) {
function maintenance(array $maintenanceArray, array $maintenanceAdminArray, User $userCurrent) {
$userModule = UserModule::getInstance();
if(count($maintenanceArray) > 0 || count($maintenanceAdminArray) > 0) {
$html = '<div class="block block-maintenance">';
@@ -45,7 +46,7 @@ function maintenance(array $maintenanceArray, array $maintenanceAdminArray) {
foreach($maintenanceArray as $maintenance) {
$html .= '<li>'.$maintenance.'</li>';
}
if($userModule->isCurrentAdmin()) {
if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)) {
foreach ($maintenanceAdminArray as $maintenance) {
$html .= '<li class="admin">' . $maintenance . '</li>';
}

+ 5
- 4
common/views/nav_user_top.php Целия файл

@@ -7,9 +7,10 @@ use yii\bootstrap\Nav;
use yii\helpers\Html;

$userModule = UserModule::getInstance();

$userCurrent = GlobalParam::getCurrentUser();
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
$producer = null;
if ($userModule->isCurrentProducer()) {
if ($isUserCurrentGrantedAsProducer) {
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
}

@@ -59,13 +60,13 @@ if ($userModule->isCurrentProducer()) {
$itemAdministration = [
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>',
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['dashboard/index']),
'visible' => $userModule->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'linkOptions' => ['class' => 'btn btn-default navbar-btn']
];
$itemProducerSpace = [
'label' => '<span class="glyphicon glyphicon-eye-open"></span> <span class="link-text">Mon espace producteur</span>',
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']),
'visible' => $userModule->isCurrentProducer(),
'visible' => $isUserCurrentGrantedAsProducer,
'linkOptions' => ['class' => 'btn btn-default navbar-btn']
];
$itemProducers = [

+ 4
- 1
frontend/views/layouts/main.php Целия файл

@@ -36,6 +36,7 @@
* termes.
*/

use common\helpers\GlobalParam;
use common\logic\User\User\Wrapper\UserModule;
use yii\helpers\Html;
use yii\bootstrap\Nav;
@@ -45,9 +46,11 @@ use common\logic\Producer\Producer\Model\Producer;
\frontend\assets\AppAsset::register($this);

$userModule = UserModule::getInstance();
$userCurrent = GlobalParam::getCurrentUser();
$isUserCurrentGrantedAsProducer = $userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent);
$isHome = (Yii::$app->controller->id == 'site' && \Yii::$app->controller->action->id == 'index');
$producer = null;
if ($userModule->isCurrentProducer()) {
if ($isUserCurrentGrantedAsProducer) {
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
}


+ 1
- 2
producer/views/layouts/main.php Целия файл

@@ -37,7 +37,6 @@
*/

use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Wrapper\UserModule;
use common\logic\User\UserProducer\Model\UserProducer;
@@ -52,7 +51,7 @@ $userModule = UserModule::getInstance();
$userCurrent = GlobalParam::getCurrentUser();
$producerManager = ProducerManager::getInstance();
$producerUser = null;
if($userModule->isCurrentProducer()) {
if($userModule->getAuthorizationChecker()->isGrantedAsProducer($userCurrent)) {
$producerUser = $producerManager->findOneProducerById($userCurrent->id_producer);
}
$producer = $this->context->getProducerCurrent();

Loading…
Отказ
Запис