extranet/library/Scores/Menu.php

922 lines
23 KiB
PHP
Raw Normal View History

2011-01-05 10:59:49 +01:00
<?php
class Menu
{
2011-01-05 16:14:23 +01:00
protected $menu = null;
2011-04-15 11:05:30 +02:00
protected $siret = null;
protected $id = 0;
protected $lienref = null;
/**
* Définition du menu avec ces groupes et pages
* Groupes
* => label : titre du menu
* => check : nom du controller
* => permission : code de la permission nécessaire pour l'affichage
* activateMenu : Définir controller/action pour activer le menu
* => controller : nom du controller
* => action : nom de l'action
* Pages
* => label : titre de la page
* => title : titre de l'infobulle
* => controller : nom du controller
* => action : nom de l'action
* => permission : code de la permission nécessaire pour l'affichage
* => forceVisible : boolean, affiche le menu en grisé même si l'utilisateur n'a pas la permission
* @var array
*/
2011-01-05 10:59:49 +01:00
protected $defineMenu = array(
array(
'label' => 'RECHERCHES',
'activateMenu' => array(
array('controller'=>'recherche', 'action'=>'liste'),
array('controller'=>'recherche', 'action'=>'list'),
2011-09-20 09:26:03 +02:00
array('controller'=>'recherche', 'action'=>'annonceliste'),
array('controller'=>'recherche', 'action'=>'enquete'),
2011-12-09 16:27:22 +01:00
array('controller'=>'recherche', 'action'=>'refclientliste'),
array('controller'=>'giant', 'action'=>'search'),
array('controller'=>'giant', 'action'=>'identite'),
array('controller'=>'giant', 'action'=>'commandes'),
array('controller'=>'giant', 'action'=>'rapport'),
),
2011-01-05 10:59:49 +01:00
'pages' => array(
array(
'label' => "Rechercher une entreprise",
2011-01-06 09:37:20 +01:00
'title' => "Rechercher une entreprise",
'controller' => 'recherche',
'action' => 'entreprise',
'forceVisible' => true,
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Rechercher par dirigeant",
2011-01-06 09:37:20 +01:00
'controller' => 'recherche',
'action' => 'dirigeant',
'forceVisible' => true,
'permission' => 'SEARCHDIR',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Recherche Internationale",
'controller' => '',
'action' => '',
2011-04-15 12:25:46 +02:00
'permission' => 'INTERNATIONAL'
2011-01-05 10:59:49 +01:00
),
2012-05-20 18:31:28 +02:00
array( // idClient = 1 && idClient =
2011-01-05 10:59:49 +01:00
'label' => "Rechercher une annonce",
'controller' => 'recherche',
'action' => 'annonce',
'permission' => 'HISTOBODACC',
2011-01-05 10:59:49 +01:00
),
2012-05-20 18:31:28 +02:00
array(
2011-11-23 14:06:55 +01:00
'label' => "Rechercher par actionnaire",
'controller' => 'recherche',
'action' => 'actionnaire',
'forceVisible' => true,
'permission' => 'SEARCHACT',
2011-04-15 11:05:30 +02:00
),
array(
2011-01-05 10:59:49 +01:00
'label' => "Dernière recherche",
2011-01-06 09:37:20 +01:00
'controller' => 'recherche',
'action' => 'last',
2011-01-05 10:59:49 +01:00
),
array(
2011-01-05 10:59:49 +01:00
'label' => "Liste des dernières recherches",
2011-01-06 09:37:20 +01:00
'controller' => 'recherche',
'action' => 'list',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Centrale IparI",
2011-04-15 11:05:30 +02:00
'controller' => 'recherche',
'action' => 'ipari',
'permission' => 'IPARI',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'IDENTITE',
'pages' => array(
2011-05-03 17:58:48 +02:00
array(
2011-01-05 10:59:49 +01:00
'label' => "Fiche d'identité",
2011-04-15 11:05:30 +02:00
'controller' => 'identite',
'action' => 'fiche',
2011-05-09 10:47:50 +02:00
'forceVisible' => true,
'permission' => 'IDENTITE',
2011-01-05 10:59:49 +01:00
),
2011-05-03 17:58:48 +02:00
array(
2011-01-05 10:59:49 +01:00
'label' => "Fiche Procédure Collective",
2011-04-15 11:05:30 +02:00
'controller' => 'identite',
'action' => 'fichepc',
'permission' => 'IDPROCOL'
2011-01-05 10:59:49 +01:00
),
2011-05-03 17:58:48 +02:00
array(
2011-01-05 10:59:49 +01:00
'label' => "Liste des établissements",
2011-04-15 11:05:30 +02:00
'controller' => 'identite',
'action' => 'etablissements',
2011-05-09 10:47:50 +02:00
'forceVisible' => true,
'permission' => 'ETABLISSEMENTS',
2011-01-05 10:59:49 +01:00
),
2011-05-03 17:58:48 +02:00
array(
2012-12-03 22:01:11 +01:00
'label' => "Liens inter-entreprises",
'controller' => 'identite',
'action' => 'liens',
2011-05-09 10:47:50 +02:00
'forceVisible' => true,
'permission' => 'LIENS',
2011-01-05 10:59:49 +01:00
),
array(
2012-03-30 09:47:35 +02:00
'label' => "Informations Groupe",
'controller' => 'identite',
'action' => 'groupe',
'permission' => 'GROUPE'
2012-05-20 18:31:28 +02:00
),
2011-01-05 10:59:49 +01:00
array(
'label' => "Modifications Insee",
'controller' => 'identite',
2011-04-22 17:10:03 +02:00
'action' => 'evenements',
2011-08-29 12:07:19 +02:00
'permission' => 'eveninsee',
2011-08-29 16:24:02 +02:00
'forceVisible' => true,
'permission' => 'EVENINSEE',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'DIRIGEANTS',
2012-02-29 10:14:53 +01:00
'activateMenu' => array(
array('controller'=>'dirigeants', 'action'=>'op'),
),
2011-01-05 10:59:49 +01:00
'pages' => array(
2011-05-03 17:58:48 +02:00
array(
2011-01-05 10:59:49 +01:00
'label' => "Liste des dirigeants",
2011-04-19 08:23:20 +02:00
'controller' => 'dirigeant',
'action' => 'liste',
2011-05-09 10:47:50 +02:00
'forceVisible' => true,
'permission' => 'DIRIGEANTS',
2011-01-05 10:59:49 +01:00
),
2011-05-03 17:58:48 +02:00
array(
2011-01-05 10:59:49 +01:00
'label' => "Historique des dirigeants",
2011-04-19 08:23:20 +02:00
'controller' => 'dirigeant',
'action' => 'histo',
2011-05-09 10:47:50 +02:00
'forceVisible' => true,
'permission' => 'DIRIGEANTS',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'ELEMENTS FINANCIERS',
'pages' => array(
array(
'label' => "Synthèse",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'synthese',
'forceVisible' => true,
'permission' => 'SYNTHESE',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Bilans, Compte de résultat",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'bilan',
'forceVisible' => true,
'permission' => 'RATIOS',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Ratios",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'ratios',
'forceVisible' => true,
'permission' => 'RATIOS',
2011-01-05 10:59:49 +01:00
),
2012-04-05 11:14:03 +02:00
array(
'label' => "Flux de trésorerie",
'controller' => 'finance',
'action' => 'flux',
'forceVisible' => true,
'permission' => 'FLUX',
2012-04-05 11:14:03 +02:00
),
2011-01-05 10:59:49 +01:00
array(
'label' => "Liasse fiscale",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'liasse',
'forceVisible' => true,
'permission' => 'LIASSE',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Bourse & Cotations",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'bourse',
'forceVisible' => true,
'permission' => 'BOURSE',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Relations bancaires",
2011-04-19 09:21:06 +02:00
'controller' => 'finance',
'action' => 'banque',
'forceVisible' => true,
'permission' => 'BANQUE',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'ELEMENTS JURIDIQUES',
'pages' => array(
array(
'label' => "Annonces Légales",
2011-04-20 09:25:37 +02:00
'controller' => 'juridique',
'action' => 'annonces',
'forceVisible' => true,
'permission' => 'ANNONCES',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Information Réglementée",
2011-04-20 09:25:37 +02:00
'controller' => 'juridique',
'action' => 'infosreg',
'forceVisible' => true,
'permission' => 'INFOSREG',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Compétences Territoriales",
2011-04-20 09:25:37 +02:00
'controller' => 'juridique',
'action' => 'competences',
'forceVisible' => true,
'permission' => 'COMPETENCES',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Conventions collectives",
2011-04-20 09:25:37 +02:00
'controller' => 'juridique',
'action' => 'conventions',
'forceVisible' => true,
'permission' => 'CONVENTIONS',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Marques déposées",
2011-04-20 09:25:37 +02:00
'controller' => 'juridique',
2011-05-02 15:38:52 +02:00
'action' => 'marques',
'permission' => 'MARQUES',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'BANQUE DE FRANCE',
2011-01-05 16:14:23 +01:00
'permission' => 'BDF',
2012-06-15 16:30:30 +02:00
'activateMenu' => array(
array('controller'=>'bdf', 'action'=>'module'),
),
2011-01-05 10:59:49 +01:00
'pages' => array(
array(
'label' => "27. Panorama",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'module27',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "28. Concours Bancaires",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'module28',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "29. Impayés",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'module29',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "40. Relations Bancaires",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'module40',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "51. Dirigeants",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'module51',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Autres",
2011-04-20 09:25:37 +02:00
'controller' => 'bdf',
2012-06-15 16:30:30 +02:00
'action' => 'index',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'EVALUATION',
'activateMenu' => array(
array('controller'=>'evaluation', 'action'=> 'scoringcommande'),
array('controller'=>'evaluation', 'action'=> 'aviscredit'),
2012-05-20 18:31:28 +02:00
),
2011-01-05 10:59:49 +01:00
'pages' => array(
array(
'label' => "IndiScore",
2011-04-20 09:25:37 +02:00
'controller' => 'evaluation',
'action' => 'indiscore',
2011-08-29 12:07:19 +02:00
'permission' => array('indiscore', 'indiscorep'),
'pref' => array('demanderef'),
'forceVisible' => true,
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Rapport de synthèse",
2011-04-20 09:25:37 +02:00
'controller' => 'evaluation',
'action' => 'indiscore2',
'permission' => array('INDISCORE2', 'INDISCORE2P'),
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Rapport complet",
2011-04-20 09:25:37 +02:00
'controller' => 'evaluation',
2011-06-03 10:53:22 +02:00
'action' => 'indiscore3',
'permission' => array('INDISCORE3', 'INDISCORE3P'),
'pref' => array('demanderef'),
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Scoring Credit Safe",
2011-04-20 09:25:37 +02:00
'controller' => 'evaluation',
'action' => 'scoring',
'permission' => 'SCORECSF',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Enquête commerciale",
2011-04-20 09:25:37 +02:00
'controller' => 'evaluation',
'action' => 'enquetec',
'permission' => 'ENQUETEC',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'PIECES OFFICIELLES',
'activateMenu' => array(
array('controller'=> 'pieces', 'action'=>'cmdassociation'),
array('controller'=> 'pieces', 'action'=>'associationactes'),
array('controller'=> 'pieces', 'action'=>'associationbilans'),
array('controller'=> 'pieces', 'action'=>'cmdcourrier'),
array('controller'=> 'pieces', 'action'=>'kbis'),
2012-03-09 16:17:31 +01:00
array('controller'=> 'pieces', 'action'=>'kbispasserelle'),
),
2011-01-05 10:59:49 +01:00
'pages' => array(
array(
'label' => "Commande de Pièces",
2011-04-20 09:25:37 +02:00
'controller' => 'pieces',
'action' => 'commande',
'permission' => array('KBIS', 'PRIVILEGES'),
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Comptes annuels",
2011-04-20 09:25:37 +02:00
'controller' => 'pieces',
'action' => 'bilans',
'forceVisible' => true,
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Actes & Statuts",
2011-04-20 09:25:37 +02:00
'controller' => 'pieces',
'action' => 'actes',
'forceVisible' => true,
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Suivi Privilèges",
2011-04-20 09:25:37 +02:00
'controller' => 'pieces',
'action' => 'privileges',
'permission' => 'SURVPRIV',
2011-01-05 10:59:49 +01:00
),
),
),
array(
'label' => 'OPTIONS',
'pages' => array(
array(
'label' => 'Nouveautés',
'controller' => 'aide',
'action' => 'newliste',
),
2011-01-05 10:59:49 +01:00
array(
'label' => "Mes options",
2011-01-07 18:16:07 +01:00
'controller' => 'user',
'action' => 'index',
'permission' => 'MONPROFIL'
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Mes surveillances",
2011-04-20 09:25:37 +02:00
'controller' => 'surveillance',
'action' => 'liste',
'permission' => 'SURVLISTE'
2011-01-05 10:59:49 +01:00
),
2011-05-24 08:25:58 +02:00
array(
'label' => "Surveillances fichier",
'controller' => 'surveillance',
'action' => 'fichier',
),
2011-01-05 10:59:49 +01:00
array(
'label' => "Mon portefeuille",
2011-04-20 09:25:37 +02:00
'controller' => 'surveillance',
'action' => 'portefeuille',
'permission' => 'PORTEFEUILLE',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Administration",
2011-05-03 17:58:48 +02:00
'controller' => 'user',
'action' => 'liste',
2011-01-05 10:59:49 +01:00
),
array(
'label' => "Surveillances",
'controller' => '',
'action' => '',
),
array(
'label' => "Se déconnecter",
'controller' => 'user',
'action' => 'logout',
),
),
),
array(
'label' => 'GESTION S&D',
'check' => 'dashboard',
2011-12-09 16:27:22 +01:00
'activateMenu' => array(
array('controller'=>'dashboard', 'action'=>'clients'),
array('controller'=>'dashboard', 'action'=>'client'),
array('controller'=>'dashboard', 'action'=>'users'),
array('controller'=>'dashboard', 'action'=>'user'),
2011-12-09 16:27:22 +01:00
array('controller'=>'dashboard', 'action'=>'commandes'),
2012-09-25 16:59:49 +02:00
array('controller'=>'dashboard', 'action'=>'prestations'),
array('controller'=>'dashboard', 'action'=>'prestation'),
array('controller'=>'dashboard', 'action'=>'services'),
array('controller'=>'dashboard', 'action'=>'service'),
array('controller'=>'dashboard', 'action'=>'tarifs'),
array('controller'=>'dashboard', 'action'=>'tarif'),
2011-12-09 16:27:22 +01:00
),
'pages' => array(
array(
'label' => "Gestion",
'controller' => 'dashboard',
'action' => 'index',
),
2011-11-28 14:05:41 +01:00
array(
'label' => "Saisie / Edition",
'controller' => 'saisie',
'action' => 'fiche',
),
array(
'label' => "Saisie Fiche Etrangère",
'controller' => 'saisie',
'action' => 'lienetranger',
),
),
),
2011-01-05 10:59:49 +01:00
);
2012-05-20 18:31:28 +02:00
/**
* Construit le menu en fonction des paramètres de l'URL
* @param array $parameters
*/
public function __construct($parameters)
{
require_once 'Scores/SessionEntreprise.php';
//Special case, edit foreign company
if (array_key_exists('lienref', $parameters)) {
$this->lienref = $parameters['lienref'];
} else {
//French Company
if (array_key_exists('siret', $parameters)) {
$this->siret = $parameters['siret'];
}
if (array_key_exists('id', $parameters)) {
$this->id = $parameters['id'];
}
if (empty($this->siret) && empty($this->id)) {
$session = new SessionEntreprise(null);
$this->siret = $session->getSiret();
$this->id = $session->getId();
}
}
//Compute Menu
2011-01-05 16:14:23 +01:00
$this->menu = new Zend_Navigation();
2011-01-05 10:59:49 +01:00
$this->computeMenu();
}
2012-05-20 18:31:28 +02:00
/**
* Retourne le menu généré
*/
public function getMenu()
{
2011-01-05 10:59:49 +01:00
return $this->menu;
}
2012-05-20 18:31:28 +02:00
/**
* Retourne la permission associés à une page
* @param string $controller
* @param string $action
* @return string
*/
public function getPagePermission($controller, $action)
{
$permission = null;
foreach ( $this->defineMenu as $menu )
{
foreach ( $menu['pages'] as $item ) {
if ( $controller == $item['controller']
&& $action == $item['action']
&& array_key_exists('permission', $item) ) {
$permission = $item['permission'];
break;
}
}
}
return $permission;
}
/**
* Retourne la position du groupe à activé
* @param string $controller
* @param string $action
*/
public function getIdMenu($controller, $action)
{
$i = 0;
2011-08-23 11:14:06 +02:00
$stop = false;
foreach($this->defineMenu as $menu){
$perm = true;
if (array_key_exists('permission', $menu)){
$perm = $this->checkPermission($menu['permission']);
}
$visible = true;
if (array_key_exists('check', $menu)){
$visible = $this->checkMenu($menu['check']);
}
foreach($menu['pages'] as $item){
if($controller == $item['controller'] && $action == $item['action']){
$stop = true;
2012-05-20 18:31:28 +02:00
break;
}
2011-08-23 11:14:06 +02:00
}
if (array_key_exists('activateMenu', $menu)){
foreach($menu['activateMenu'] as $item){
if($controller == $item['controller'] && $action == $item['action']){
$stop = true;
break;
}
}
2012-05-20 18:31:28 +02:00
}
2011-08-23 11:14:06 +02:00
if ($stop === true) break;
if ($perm && $visible){
$i++;
}
}
return $i;
}
2012-05-20 18:31:28 +02:00
/**
* Parcours la définition du menu en gérant les permissions et autres
* particularités
*/
protected function computeMenu()
{
2011-01-05 10:59:49 +01:00
foreach($this->defineMenu as $element){
$perm = true;
2011-01-05 16:14:23 +01:00
if (array_key_exists('permission', $element)){
$perm = $this->checkPermission($element['permission']);
2011-01-05 10:59:49 +01:00
}
$visible = true;
if (array_key_exists('check', $element)){
$visible = $this->checkMenu($element['check']);
}
if ($perm && $visible){
2011-01-05 10:59:49 +01:00
$menu = array();
$menu['label'] = $element['label'];
2011-01-05 16:14:23 +01:00
$menu['uri'] = '#';
2011-04-01 14:14:40 +02:00
$menu['class'] = 'header';
2011-01-05 10:59:49 +01:00
if (array_key_exists('pages', $element)){
2011-01-05 16:14:23 +01:00
$menu['pages'] = $this->computePage($element['pages']);
2011-01-05 10:59:49 +01:00
}
2011-01-05 16:14:23 +01:00
$this->menu->addPage($menu);
2011-01-05 10:59:49 +01:00
}
}
}
2012-05-20 18:31:28 +02:00
/**
* Parcours les pages d'un groupe du menu pour vérifier les permissions
* et autres particularités
* @param array $pages
*/
protected function computePage($pages)
{
2011-01-05 16:14:23 +01:00
$computePages = array();
foreach($pages as $page){
$visible = false;
2011-05-03 17:58:48 +02:00
if (array_key_exists('forceVisible', $page)){
$visible = $page['forceVisible'];
2011-01-05 16:14:23 +01:00
}
2011-01-05 10:59:49 +01:00
$perm = true;
2011-01-05 16:14:23 +01:00
if (array_key_exists('permission', $page)){
$perm = $this->checkPermission($page['permission']);
2011-01-05 10:59:49 +01:00
}
2012-01-24 17:05:50 +01:00
2011-04-21 15:57:47 +02:00
if (!$perm && $visible){
2011-01-05 16:14:23 +01:00
$computePage = array();
$computePage['label'] = $page['label'];
2011-04-21 15:57:47 +02:00
$computePage['class'] = 'inactif';
2011-01-05 16:14:23 +01:00
$computePage['uri'] = '#';
$computePages[] = $computePage;
2011-04-21 15:57:47 +02:00
} elseif ($perm){
if ($this->checkParams($page['controller'], $page['action'])){
$computePage = array();
$computePage = $page;
$computePage['params'] = $this->setParams($page['controller'], $page['action']);
2012-05-20 18:31:28 +02:00
2012-02-13 13:55:50 +01:00
if (array_key_exists('pref', $page)){
if ($this->hasPref('demanderef') && in_array('demanderef', $page['pref']) ){ // @todo: Erreur data
$computePage['class'] = 'demanderef';
}
}
2012-05-20 18:31:28 +02:00
2011-04-21 15:57:47 +02:00
$computePages[] = $computePage;
2011-05-03 17:58:48 +02:00
} elseif ($visible) {
2011-04-21 15:57:47 +02:00
$computePage = array();
$computePage['label'] = $page['label'];
$computePage['class'] = 'inactif';
$computePage['uri'] = '#';
$computePages[] = $computePage;
}
2011-01-05 10:59:49 +01:00
}
}
2011-01-05 16:14:23 +01:00
return $computePages;
2011-01-05 10:59:49 +01:00
}
2012-05-20 18:31:28 +02:00
/**
* Vérifie les permissions de l'utilisateur
* @param mixed $perm
*/
protected function checkPermission($perm)
{
2011-01-05 10:59:49 +01:00
$hasPerm = false;
2011-01-05 16:14:23 +01:00
if (is_array($perm)){
$list = $perm;
} else if (is_string($perm)){
$list = (array)$perm;
}
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
2011-01-05 16:14:23 +01:00
foreach($list as $permission){
2011-08-23 17:12:53 +02:00
if ($user->checkPerm($permission)){
2011-01-05 16:14:23 +01:00
$hasPerm = true;
break;
2011-01-05 10:59:49 +01:00
}
}
return $hasPerm;
}
2012-05-20 18:31:28 +02:00
/**
* Vérifie préférence utilisateur
* @param string $pref
*/
public function hasPref($pref)
{
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
if ($user->checkPref($pref)){
2012-05-20 18:31:28 +02:00
return true;
}
return false;
}
2012-05-20 18:31:28 +02:00
/**
* Permet d'effectuer une vérification pour la visibilité d'un menu (Groupe)
* @param string $controller
*/
protected function checkMenu($controller)
{
switch($controller) {
case 'dashboard':
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
if ($user->checkModeEdition() && $user->getIdClient()==1){
return true;
}
return false;
2012-05-20 18:31:28 +02:00
break;
}
2011-04-15 11:05:30 +02:00
}
2012-05-20 18:31:28 +02:00
/**
* Vérifie les paramètres pour un controller et/ou une action
* @param string $controller
* @param string $action
*/
protected function checkParams($controller, $action = '')
2011-04-21 15:57:47 +02:00
{
switch($controller) {
case 'bdf':
return true;
break;
case 'dashboard':
return true;
2011-05-03 17:58:48 +02:00
break;
case 'recherche':
switch($action) {
case 'last':
case 'list':
//Vérifier la présence d'au moins une recherche
require_once 'Scores/RechercheHistorique.php';
$recherches = new RechercheHistorique();
if (count($recherches->liste()>0)){
return true;
2012-05-20 18:31:28 +02:00
}
return false;
break;
case 'annonce':
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
if($user->checkPerm('histobodacc')){
return true;
}
return false;
break;
2012-05-20 18:31:28 +02:00
}
return true;
break;
case 'user':
switch($action){
case 'liste':
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
if ($user->isAdmin() || $user->isSuperAdmin()){
return true;
2012-05-20 18:31:28 +02:00
}
return false;
2012-05-20 18:31:28 +02:00
break;
}
return true;
break;
case 'surveillance':
2011-05-24 08:25:58 +02:00
switch($action) {
case 'fichier':
2012-05-20 18:31:28 +02:00
$user = new Scores_Utilisateur();
if (substr($user->getLogin(),0,6)=='cnasea'
|| strtolower($user->getLogin())=='omni04'
|| strtolower($user->getLogin())=='bodacca3m'
|| strtolower($user->getLogin())=='bodaccomni'
|| strtolower($user->getLogin())=='bodacccrr'
2012-02-13 12:04:44 +01:00
|| strtolower($user->getLogin())=='cpcambr13'
|| strtolower($user->getLogin())=='cpcambr14'
|| strtolower($user->getLogin())=='frbsurveillance'
2012-05-20 18:31:28 +02:00
|| $user->getIdClient()==32
2011-08-23 17:16:01 +02:00
|| $user->getIdClient()==82 ) {
2011-08-09 17:48:43 +02:00
return true;
} else {
return false;
2011-08-09 17:48:43 +02:00
}
2011-05-24 08:25:58 +02:00
break;
}
return true;
break;
2011-04-21 15:57:47 +02:00
case 'identite':
switch($action) {
case 'fiche':
case 'fichepc':
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
}
if ( !empty($this->id) && intval($this->id)!=0 ){
return true;
}
2011-10-25 11:48:08 +02:00
return false;
break;
2012-05-20 18:31:28 +02:00
case 'groupe':
case 'etablissements':
case 'evenements':
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
}
return false;
break;
case 'liens':
if ( !empty($this->lienref) ){
return true;
}
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
}
return false;
break;
}
break;
2011-04-21 15:57:47 +02:00
case 'dirigeant':
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
}
return false;
break;
2011-04-21 15:57:47 +02:00
case 'finance':
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
}
return false;
break;
case 'juridique':
2011-10-25 11:48:08 +02:00
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
2011-08-20 15:17:03 +02:00
}
2011-10-25 11:48:08 +02:00
switch($action){
case 'annonces':
if ( !empty($this->id) && intval($this->id)!=0 ){
return true;
}
break;
}
return false;
break;
case 'evaluation':
switch($action){
2012-05-20 18:31:28 +02:00
case 'indiscore':
2011-10-26 14:18:25 +02:00
$siretSiege = substr($this->siret, 0,9);
2011-08-31 15:07:03 +02:00
if (!empty($siretSiege) && intval($siretSiege)!=0 ){
return true;
}
return false;
break;
}
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
2011-08-20 15:17:03 +02:00
}
return false;
2011-04-21 15:57:47 +02:00
break;
case 'pieces':
if ( !empty($this->siret) && intval($this->siret)!=0 ){
return true;
2012-05-20 18:31:28 +02:00
}
return false;
break;
2011-11-28 14:05:41 +01:00
case 'saisie':
switch($action){
case 'fiche':
if ( !empty($this->id) && intval($this->id)!=0 ){
return true;
}
break;
case 'lienetranger':
return true;
break;
2011-11-28 14:05:41 +01:00
}
2012-05-20 18:31:28 +02:00
return false;
2011-11-28 14:05:41 +01:00
break;
case 'aide':
return true;
break;
2011-04-21 15:57:47 +02:00
}
}
2012-05-20 18:31:28 +02:00
/**
* Définit les paramètres nécessaire pour les liens des pages
* @param string $controller
* @param string $action
*/
protected function setParams($controller, $action)
{
2011-04-15 11:05:30 +02:00
$params = array();
/**
* Réinitialiser la route pour avoir toujours les liens du menu propre
*/
2012-05-20 18:31:28 +02:00
$params['route'] = null;
switch($controller)
{
2011-04-15 12:25:46 +02:00
case 'recherche':
2012-04-12 15:08:16 +02:00
switch($action){
case 'ipari':
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
2012-05-20 18:31:28 +02:00
break;
}
break;
2011-05-20 10:25:05 +02:00
case 'evaluation':
if (!empty($this->siret)) { $params['siret'] = substr($this->siret,0,9); }
2011-10-26 14:18:25 +02:00
if (!empty($this->id)) { $params['id'] = $this->id; }
break;
2011-04-15 11:05:30 +02:00
case 'identite':
switch($action){
case 'liens':
if (!empty($this->lienref)) { $params['lienref'] = $this->lienref; }
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
break;
default:
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
break;
}
break;
case 'pieces':
2011-05-02 09:20:13 +02:00
case 'finance':
2011-04-19 08:23:20 +02:00
case 'dirigeant':
2011-04-19 09:21:06 +02:00
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
break;
case 'juridique':
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
2011-11-28 14:05:41 +01:00
break;
case 'saisie':
switch($action){
case 'fiche':
if (!empty($this->siret)) { $params['siret'] = $this->siret; }
if (!empty($this->id)) { $params['id'] = $this->id; }
2012-05-20 18:31:28 +02:00
break;
}
2012-05-20 18:31:28 +02:00
break;
2012-06-15 16:30:30 +02:00
case 'bdf':
if (!empty($this->siret)) {
$params['siret'] = $this->siret;
}
break;
2011-04-15 11:05:30 +02:00
}
return $params;
}
}