This commit is contained in:
afornerot 2019-06-27 16:55:26 +02:00
parent 8de5145700
commit 3d77248b3d
25 changed files with 730 additions and 1164 deletions

View File

@ -1,503 +0,0 @@
<?php
namespace Cadoles\CoreBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\KernelInterface;
use Doctrine\DBAL\Connection as DBALConnection;
use Doctrine\ORM\EntityManager;
use Cadoles\CoreBundle\Entity\User;
use Cadoles\CoreBundle\Entity\Niveau01;
use Cadoles\CoreBundle\Entity\Niveau02;
global $bdd01;
global $config;
class ImportCommand extends Command
{
protected function configure()
{
$this
// the name of the command (the part after "bin/console")
->setName('Core:Import')
// the short description shown while running "php bin/console list"
->setDescription("Importation Utilisateur à partir d'un fichier CSV Annuaire")
// the full command description shown when running the command with
// the "--help" option
->setHelp('This command Import for Core')
->addArgument('simulate', InputArgument::OPTIONAL, 'true to simulate / false to run')
;
}
protected function convert($filename, $delimiter = ',', $enclosure = '"')
{
if(!file_exists($filename) || !is_readable($filename)) {
return FALSE;
}
$header = NULL;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE) {
while (($row = fgetcsv($handle, 1000, $delimiter, $enclosure)) !== FALSE) {
if(!$header) {
$header = $row;
} else {
$data[] = array_combine($header, $row);
}
}
fclose($handle);
}
return $data;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$kernel = new \AppKernel('dev', true);
$kernel->boot();
$kernel->loadClassCache();
$em = $kernel->getContainer()->get('service_container')->get('doctrine.orm.default_entity_manager');
$simulate = $input->getArgument('simulate');
if($simulate=="") $simulate="true";
if($simulate!="true"&&$simulate!="false") {
$output->writeln('Paramétre incorrect');
return;
}
$simulate=($simulate=="true");
$output->writeln('');
if($simulate) $output->writeln('** SIMULATION');
else $output->writeln('** REEL');
$output->writeln('');
$output->writeln('=====================================================');
$output->writeln('== IMPORT USERS =====================================');
$output->writeln('=====================================================');
// Read CSV
$fileName = 'src/Cadoles/CoreBundle/Command/import.csv';
// Convert
$datas = $this->convert($fileName);
foreach($datas as $row) {
if($row["uid"]!="") {
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $row["uid"]));
if($data) {
$output->writeln(' - Existe déjà >> '.$row["uid"]);
}
else {
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('email' => $row["mail"]));
if($data) {
$output->writeln(' - Existe déjà >> '.$row["uid"]);
}
else {
$output->writeln(' - Création Utilisateur >> '.$row["uid"]);
if(!$simulate) {
$niveau01=$em->getRepository('CadolesCoreBundle:Niveau01')->findOneBy(array("id"=>-100));
$user = new User();
$user->setUsername($row["uid"]);
$user->setPasswordDirect($row["userpassword"]);
$user->setSalt("IMPORT-".$row["uid"]);
$user->setNiveau01($niveau01);
$user->setSiren($user->getNiveau01()->getSiren());
$user->setSiret($user->getNiveau02()!==null?$user->getNiveau02()->getSiret():"");
$user->setAvatar("noavatar.png");
$user->setVisible(true);
$user->setAuthlevel("simple");
$user->setRole("ROLE_USER");
$user->setFirstname($row["givenname"]);
$user->setLastname($row["sn"]);
$user->setEmail($row["mail"]);
$em->persist($user);
$em->flush();
}
}
}
}
}
return;
$ldap = $kernel->getContainer()->get('cadoles.core.service.ldap');
if($ldap->isEnabled()) {
$output->writeln('');
$output->writeln('=====================================================');
$output->writeln('== SYNCHONISATION BUNDLE TO LDAP ====================');
$output->writeln('=====================================================');
$output->writeln('');
$output->writeln('== NIVEAU01 =========================================');
$baseNiveau01 = $kernel->getContainer()->getParameter('ldap_baseniveau01');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau01','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$criteria = '(cn='.$data->getLabel().')';
$subbranch=$baseNiveau01;
$results = $ldap->search($criteria, array('cn'), $subbranch);
// Mise à jour si elle existe
if(count($results) > 0) {
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->modifyNiveau01($data,$data->getLabel());
}
// Sinon création de la fiche
else {
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->addNiveau01($data);
}
}
$output->writeln('');
$output->writeln('== NIVEAU02 =========================================');
$baseNiveau02 = $kernel->getContainer()->getParameter('ldap_baseniveau02');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau02','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$criteria = '(cn='.$data->getLabel().')';
$subbranch=$baseNiveau02;
$results = $ldap->search($criteria, array('cn'), $subbranch);
// Mise à jour si elle existe
if(count($results) > 0) {
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->modifyNiveau02($data,$data->getLabel());
}
// Sinon création de la fiche
else {
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->addNiveau02($data);
}
}
$output->writeln('');
$output->writeln('== GROUP ============================================');
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Group','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$criteria = '(cn='.$data->getLabel().')';
$subbranch=$baseGroup;
$results = $ldap->search($criteria, array('cn'), $subbranch);
// Mise à jour si elle existe
if(count($results) > 0) {
$output->writeln(' - Modification dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->modifyGroup($data,$data->getLabel());
}
// Sinon création de la fiche
else {
$output->writeln(' - Création dans annuaire >> '.$data->getLabel());
if(!$simulate) $ldap->addGroup($data);
}
}
$output->writeln('');
$output->writeln('== USER =============================================');
$baseUser = $kernel->getContainer()->getParameter('ldap_baseuser');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:User','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$criteria = '(uid='.$data->getUsername().')';
$subbranch=$baseUser;
$results = $ldap->search($criteria, array('uid'), $subbranch);
// S'assurer que SIREN correspond au Niveau01
if($data->getNiveau01()->getSiren()!=$data->getSiren()) {
$data->SetSiren($data->getNiveau01()->getSiren());
$data->flush();
}
// S'assurer que SIRET correspond au Niveau02
if($data->getNiveau02()!==null&&$data->getNiveau01()->getSiren()!=$data->getSiren()) {
$data->SetSiret($data->getNiveau02()->getSiret());
$data->flush();
}
// Mise à jour si elle existe
if(count($results) > 0) {
$output->writeln(' - Modification dans annuaire >> '.$data->getUsername());
if(!$simulate) $ldap->modifyUser($data);
}
// Sinon création de la fiche
else {
$output->writeln(' - Création dans annuaire >> '.$data->getUsername());
if(!$simulate) $ldap->addUser($data);
}
// Rattachement à Niveau01 et Niveau02
if(!$simulate) $ldap->addGroupUser($data);
}
$output->writeln('');
$output->writeln('== USER GROUP =======================================');
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Group','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$criteria = '(cn='.$data->getLabel().')';
$subbranch=$baseGroup;
$results = $ldap->search($criteria, array('cn'), $subbranch);
// Mise à jour des membres du groupes
if(count($results) > 0) {
$output->writeln(' - '.$data->getLabel());
$dn=$ldap->getGroupDN($data->getLabel());
$attrs["memberuid"]=array();
$attrs["cadolesMember"]=array();
foreach($data->getUsers() as $usergroupe) {
array_push($attrs["memberuid"],$usergroupe->getUser()->getUsername());
array_push($attrs["cadolesMember"],$ldap->getUserDN($usergroupe->getUser()));
$output->writeln(' > '.$usergroupe->getUser()->getUsername());
}
if(!$simulate) $ldap->ldapModify($dn, $attrs);
}
}
$output->writeln('');
$output->writeln('=====================================================');
$output->writeln('== SYNCHONISATION LDAP TO BUNDLE ====================');
$output->writeln('=====================================================');
$output->writeln('');
$output->writeln('== NIVEAU01 =========================================');
$baseNiveau01 = $kernel->getContainer()->getParameter('ldap_baseniveau01');
$criteria = '(cn=*)';
$subbranch=$baseNiveau01;
$results = $ldap->search($criteria, array('cn'), $subbranch);
foreach($results as $result) {
$data = $em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' => $result["cn"]));
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
else {
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
$dn=$ldap->getNiveau01DN($result["cn"]);
if(!$simulate) $ldap->deleteByDN($dn);
}
}
$output->writeln('');
$output->writeln('== NIVEAU02 =========================================');
$baseNiveau02 = $kernel->getContainer()->getParameter('ldap_baseniveau02');
$criteria = '(cn=*)';
$subbranch=$baseNiveau02;
$results = $ldap->search($criteria, array('cn'), $subbranch);
foreach($results as $result) {
$data = $em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' => $result["cn"]));
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
else {
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
$dn=$ldap->getNiveau02DN($result["cn"]);
if(!$simulate) $ldap->deleteByDN($dn);
}
}
$output->writeln('');
$output->writeln('== GROUP ============================================');
$baseGroup = $kernel->getContainer()->getParameter('ldap_basegroup');
$criteria = '(cn=*)';
$subbranch=$baseGroup;
$results = $ldap->search($criteria, array('cn'), $subbranch);
foreach($results as $result) {
$data = $em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' => $result["cn"]));
if($data) $output->writeln(' - Existe dans bundle >> '.$result["cn"]);
else {
$output->writeln(' - A supprimer dans annuaire >> '.$result["cn"]);
$dn=$ldap->getGroupDN($result["cn"]);
if(!$simulate) $ldap->deleteByDN($dn);
}
}
$output->writeln('');
$output->writeln('== USER =============================================');
$baseUser = $kernel->getContainer()->getParameter('ldap_baseuser');
$criteria = '(uid=*)';
$subbranch=$baseUser;
$results = $ldap->search($criteria, array('uid'), $subbranch);
foreach($results as $result) {
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('username' => $result["uid"]));
if($data) $output->writeln(' - Existe dans bundle >> '.$result["uid"]);
else {
$output->writeln(' - A supprimer dans annuaire >> '.$result["uid"]);
$dn='uid='.$result["uid"].','.$baseUser;
if(!$simulate) $ldap->deleteByDN($dn);
}
}
}
$output->writeln('');
$output->writeln('=====================================================');
$output->writeln('== SYNCHONISATION BUNDLE TO EPORTAIL ================');
$output->writeln('=====================================================');
$eportail = $kernel->getContainer()->get('cadoles.core.service.eportail');
if(!$eportail->isEnabled()) {
$output->writeln('');
$output->writeln(' Synchronisation ePortail désactivée');
}
else {
$output->writeln('');
$output->writeln('== NIVEAU01 =========================================');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau01','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncNiveau01($data,$data->getLabel());
}
$output->writeln('');
$output->writeln('== NIVEAU02 =========================================');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau02','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncNiveau02($data,$data->getLabel());
}
$output->writeln('');
$output->writeln('== GROUP ============================================');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Group','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$output->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncGroup($data,$data->getLabel());
}
$output->writeln('');
$output->writeln('== USER =============================================');
$datas = $em ->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:User','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$output->writeln(' - Synchronisation eportail >> '.$data->getUsername());
if(!$simulate) $eportail->syncUser($data);
}
$output->writeln('');
$output->writeln('=====================================================');
$output->writeln('== SYNCHONISATION EPORTAIL TO BUNDLE ================');
$output->writeln('=====================================================');
$dbeportail= $kernel->getContainer()->get('service_container')->get('doctrine.orm.eportail_entity_manager')->getConnection();
$output->writeln('');
$output->writeln('== GROUP ============================================');
$sql = "SELECT * FROM env_group WHERE group_id>0";
$query = $dbeportail->prepare($sql);
$query->execute();
while($row=$query->fetch()){
$fgOK=false;
if (strpos($row["group_name"], $labelniveau01.' = ') === 0) {
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
$data = $em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if (strpos($row["group_name"], $labelniveau02.' = ') === 0) {
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
$data = $em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if (strpos($row["group_name"], 'GROUPE = ') === 0) {
$tmp=str_replace("GROUPE = ","",$row["group_name"]);
$data = $em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$output->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if(!$fgOK) {
$output->writeln(' - A supprimer dans eportail >> '.$row["group_name"]);
if(!$simulate) delGroup($row["group_id"]);
}
}
$output->writeln('');
$output->writeln('== USER =============================================');
$sql = "SELECT * FROM env_user WHERE user_id>0";
$query = $dbeportail->prepare($sql);
$query->execute();
while($row=$query->fetch()){
$data = $em->getRepository('CadolesCoreBundle:User')->findBy(array('username' =>$row["user_login"]));
if($data) $output->writeln(' - Existe dans bundle >> '.$row["user_login"]);
else {
$output->writeln(' - A supprimer dans eportail >> '.$row["user_login"]);
if(!$simulate) delUser($row["user_id"]);
}
}
}
$output->writeln('');
$output->writeln('');
}
protected static function determineKernelRootDir(Event $event) {
$extra = $event->getComposer()->getPackage()->getExtra();
$rootdir = rtrim(getcwd(), '/');
return $rootdir . '/' . trim($extra['symfony-app-dir'], '/');
}
}

View File

@ -608,133 +608,6 @@ class SynchroCommand extends Command
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled()) {
$this->writeln('');
$this->writeln('=====================================================');
$this->writeln('== SYNCHONISATION BUNDLE TO EPORTAIL ================');
$this->writeln('=====================================================');
$this->writeln('');
$this->writeln('== NIVEAU01 =========================================');
$datas = $this->em
->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau01','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncNiveau01($data,$data->getLabel());
}
$this->writeln('');
$this->writeln('== NIVEAU02 =========================================');
$datas = $this->em
->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Niveau02','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncNiveau02($data,$data->getLabel());
}
$this->writeln('');
$this->writeln('== GROUP ============================================');
$datas = $this->em
->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:Group','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$this->writeln(' - Synchronisation eportail >> '.$data->getLabel());
if(!$simulate) $eportail->syncGroup($data,$data->getLabel());
}
$this->writeln('');
$this->writeln('== USER =============================================');
$datas = $this->em
->createQueryBuilder()
->select('table')
->from('CadolesCoreBundle:User','table')
->getQuery()
->getResult();
foreach($datas as $data) {
$this->writeln(' - Synchronisation eportail >> '.$data->getUsername());
if(!$simulate) $eportail->syncUser($data);
}
$this->writeln('');
$this->writeln('=====================================================');
$this->writeln('== SYNCHONISATION EPORTAIL TO BUNDLE ================');
$this->writeln('=====================================================');
$dbeportail= $this->container->get('service_container')->get('doctrine.orm.eportail_entity_manager')->getConnection();
$this->writeln('');
$this->writeln('== GROUP ============================================');
$sql = "SELECT * FROM env_group WHERE group_id>0";
$query = $dbeportail->prepare($sql);
$query->execute();
while($row=$query->fetch()){
$fgOK=false;
if (strpos($row["group_name"], $labelniveau01.' = ') === 0) {
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
$data = $this->em->getRepository('CadolesCoreBundle:Niveau01')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if (strpos($row["group_name"], $labelniveau02.' = ') === 0) {
$tmp=str_replace("$labelniveau01 = ","",$row["group_name"]);
$data = $this->em->getRepository('CadolesCoreBundle:Niveau02')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if (strpos($row["group_name"], 'GROUPE = ') === 0) {
$tmp=str_replace("GROUPE = ","",$row["group_name"]);
$data = $this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('label' =>$tmp));
if($data) {
$fgOK=true;
$this->writeln(' - Existe dans bundle >> '.$row["group_name"]);
}
}
if(!$fgOK) {
$this->writeln(' - A supprimer dans eportail >> '.$row["group_name"]);
if(!$simulate) delGroup($row["group_id"]);
}
}
$this->writeln('');
$this->writeln('== USER =============================================');
$sql = "SELECT * FROM env_user WHERE user_id>0";
$query = $dbeportail->prepare($sql);
$query->execute();
while($row=$query->fetch()){
$data = $this->em->getRepository('CadolesCoreBundle:User')->findBy(array('username' =>$row["user_login"]));
if($data) $this->writeln(' - Existe dans bundle >> '.$row["user_login"]);
else {
$this->writeln(' - A supprimer dans eportail >> '.$row["user_login"]);
if(!$simulate) delUser($row["user_id"]);
}
}
}
$this->writeln(''); $this->writeln('');
return 1; return 1;
} }

View File

@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
(-100, 'DRAAF', '130007107'); (-100, 'DRAAF', '130007107');
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Zk1FeGDztzYdA2Q2EhJOmEuDHs7uyXI2 (-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}KYFkIhUXbGQ8luMLxpsdl5OtVq4aZ/GN
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple'); ', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
@ -20,6 +20,7 @@ INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `f
(1020, 1000, 1020, 'Thème', 'cadoles_core_config_theme', 'fa-paint-brush', 'ROLE_ADMIN,ROLE_MODO', ''), (1020, 1000, 1020, 'Thème', 'cadoles_core_config_theme', 'fa-paint-brush', 'ROLE_ADMIN,ROLE_MODO', ''),
(1030, 1000, 1030, 'Modération', 'cadoles_core_config_permmodo', 'fa-balance-scale', 'ROLE_ADMIN', ''), (1030, 1000, 1030, 'Modération', 'cadoles_core_config_permmodo', 'fa-balance-scale', 'ROLE_ADMIN', ''),
(1040, 1000, 1040, 'Fiche Utilisateur', 'cadoles_core_config_datauser', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''), (1040, 1000, 1040, 'Fiche Utilisateur', 'cadoles_core_config_datauser', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''),
(1050, 1000, 1050, 'Liste Utilisateurs', 'cadoles_core_config_datausers', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''),
(1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''), (1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''),
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN,ROLE_MODO', ''), (1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN,ROLE_MODO', ''),
@ -71,6 +72,7 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type
('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'), ('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'),
('005', 0, 1, 0, 'theme', 'theme', '', '', 'Le theme de votre site'), ('005', 0, 1, 0, 'theme', 'theme', '', '', 'Le theme de votre site'),
('006', 0, 1, 0, 'datauser', 'datauser', '', '', 'Parametrage des champs utilisateurs : obligatoire / facultatif / caché'), ('006', 0, 1, 0, 'datauser', 'datauser', '', '', 'Parametrage des champs utilisateurs : obligatoire / facultatif / caché'),
('007', 0, 1, 0, 'datausers', 'datausers', '', '', 'Parametrage des colonnes visible dans la liste des utilisateurs'),
('010', 1, 1, 1, 'boolean', 'fgforceconnect', '0', '', 'Forcer la connection afin de rendre votre site privé'), ('010', 1, 1, 1, 'boolean', 'fgforceconnect', '0', '', 'Forcer la connection afin de rendre votre site privé'),
@ -93,6 +95,7 @@ INSERT IGNORE permmodo (`route`, `visible`) VALUES
('cadoles_core_config_commun',0), ('cadoles_core_config_commun',0),
('cadoles_core_config_theme',0), ('cadoles_core_config_theme',0),
('cadoles_core_config_datauser',0), ('cadoles_core_config_datauser',0),
('cadoles_core_config_datausers',0),
('cadoles_core_config_whitelist',0), ('cadoles_core_config_whitelist',0),
('cadoles_core_config_niveau01',0), ('cadoles_core_config_niveau01',0),
('cadoles_core_config_niveau02',1), ('cadoles_core_config_niveau02',1),

View File

@ -5,6 +5,7 @@ namespace Cadoles\CoreBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Form\FormError;
use Cadoles\CoreBundle\Entity\Config; use Cadoles\CoreBundle\Entity\Config;
use Cadoles\CoreBundle\Form\ConfigType; use Cadoles\CoreBundle\Form\ConfigType;
@ -242,8 +243,18 @@ class ConfigController extends Controller
else { else {
$fields=json_decode($fields, true); $fields=json_decode($fields, true);
} }
if($session->get('viewniveau02')&&!array_key_exists("niveau02",$fields))
$fields["niveau02"]["perm"]=1;
elseif(!$session->get('viewniveau02'))
unset($fields["niveau02"]);
if(array_key_exists("niveau02",$fields))
$fields["niveau02"]["label"]=$session->get('labelniveau02');
$form = $this->createForm(DatauserType::class,$config,array("fields" => $fields));
$form = $this->createForm(DatauserType::class,$config,array("mode"=>"datauser","fields" => $fields));
// Récupération des data du formulaire // Récupération des data du formulaire
$form->handleRequest($request); $form->handleRequest($request);
@ -266,7 +277,107 @@ class ConfigController extends Controller
'useheader' => true, 'useheader' => true,
'usemenu' => false, 'usemenu' => false,
'usesidebar' => true, 'usesidebar' => true,
'form' => $form->createView() 'form' => $form->createView(),
'mode' => "datauser"
]);
}
public function datausersAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$session=$this->get('session');
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers");
$fields=$config->getValue();
if($fields=="") {
// Valeur par défaut 0=caché / 3=visible
$fields["avatar"]["perm"]=1;
$fields["avatar"]["label"]="Avatar";
$fields["login"]["perm"]=1;
$fields["login"]["label"]="Login";
$fields["lastname"]["perm"]=1;
$fields["lastname"]["label"]="Nom";
$fields["firstname"]["perm"]=1;
$fields["firstname"]["label"]="Prenom";
$fields["email"]["perm"]=1;
$fields["email"]["label"]="Email";
$fields["niveau01"]["perm"]=1;
$fields["niveau01"]["label"]="Niveau 01";
$fields["niveau02"]["perm"]=1;
$fields["niveau02"]["label"]="Niveau 02";
$fields["group"]["perm"]=1;
$fields["group"]["label"]="Groupes";
$fields["role"]["perm"]=1;
$fields["role"]["label"]="Rôles";
}
else {
$fields=json_decode($fields, true);
}
$fields["niveau01"]["label"]=$session->get('labelniveau01');
if($session->get('viewniveau02')&&!array_key_exists("niveau02",$fields))
$fields["niveau02"]["perm"]=1;
elseif(!$session->get('viewniveau02'))
unset($fields["niveau02"]);
if(array_key_exists("niveau02",$fields))
$fields["niveau02"]["label"]=$session->get('labelniveau02');
$form = $this->createForm(DatauserType::class,$config,array("mode"=>"datausers","fields" => $fields));
// Récupération des data du formulaire
$form->handleRequest($request);
if ($form->get('submit')->isClicked()) {
$onevisible=false;
foreach($fields as $key => $value) {
$perm = $form->get($key)->getData();
$fields[$key]["perm"]=$perm;
if($perm==1) $onevisible=true;
}
if(!$onevisible)
$form->addError(new FormError('Au moins une colonne doit être visible'));
if ($form->get('submit')->isClicked() && !$form->isValid()) {
$this->get('session')->getFlashBag()->clear();
$validator = $this->get('validator');
$errors = $validator->validate($config);
foreach( $errors as $error ) {
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
}
$errors = $form->getErrors();
foreach( $errors as $error ) {
$request->getSession()->getFlashBag()->add("error", $error->getMessage());
}
}
}
if ($form->get('submit')->isClicked() && $form->isValid()) {
$json=json_encode($fields);
$config->setValue($json);
$em->persist($config);
$em->flush();
}
return $this->render('CadolesCoreBundle:Config:datauser.html.twig',[
'useheader' => true,
'usemenu' => false,
'usesidebar' => true,
'form' => $form->createView(),
'mode' => "datausers"
]); ]);
} }

View File

@ -13,22 +13,45 @@ class CoreController extends Controller
{ {
public function homeAction(Request $request) public function homeAction(Request $request)
{ {
$em = $this->getDoctrine()->getManager();
$user=$this->getUser();
$portal_activate=$this->getParameter("portal_activate"); $portal_activate=$this->getParameter("portal_activate");
if(!$portal_activate) { if(!$portal_activate) {
return $this->render('CadolesCoreBundle:Core:home.html.twig',[ $item_activate=$this->getParameter("item_activate");
'useheader' => true,
'usemenu' => false, $bookmarks=null;
'usesidebar' => false, $items=null;
]); $itemcategorys=null;
if($item_activate) {
$em->getRepository("CadolesPortalBundle:Item")->getUserItems($user,$bookmarks,$items,$itemcategorys);
return $this->render('CadolesPortalBundle:Page:noportal.html.twig',[
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
'item_activate' => $item_activate,
'bookmarks' => $bookmarks,
'items' => $items,
'itemcategorys' => $itemcategorys
]);
}
else {
return $this->render('CadolesCoreBundle:Core:home.html.twig',[
'useheader' => true,
'usemenu' => false,
'usesidebar' => false,
]);
}
} }
else { else {
$em = $this->getDoctrine()->getManager();
// Récupération de la page encours // Récupération de la page encours
$id = $request->query->get('id'); $id = $request->query->get('id');
// L'utilisateur en cours // L'utilisateur en cours
$user=$this->getUser();
// Chargement des chartes à signer // Chargement des chartes à signer
if($user) { if($user) {
@ -43,8 +66,45 @@ class CoreController extends Controller
'notices' => $notices 'notices' => $notices
]); ]);
} }
// On s'assure que l'ensemble des champs user obligatoire sont bien renseignés sinon bascule sur le profil
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser");
$fields=$config->getValue();
$fields=json_decode($fields,true);
$toprofil=false;
if($fields!="") {
foreach($fields as $key => $field) {
// Si champs obligatoire
if($field["perm"]==2) {
switch($key) {
case "firstname": if($user->getFirstname()=="") $toprofil=true; break;
case "visible": if($user->getVisible()=="") $toprofil=true; break;
case "authlevel": if($user->getAuthlevel()=="") $toprofil=true; break;
case "belongingpopulation": if($user->getBelongingpopulation()=="") $toprofil=true; break;
case "job": if($user->getJob()=="") $toprofil=true; break;
case "position": if($user->getPosition()=="") $toprofil=true; break;
case "niveau02": if($user->geNiveau02()=="") $toprofil=true; break;
case "usualname": if($user->getUsualname()=="") $toprofil=true; break;
case "gender": if($user->getGender()=="") $toprofil=true; break;
case "givensname": if($user->getGivensname()=="") $toprofil=true; break;
case "telephonenumber": if($user->getTelephonenumber()=="") $toprofil=true; break;
case "postaladress": if($user->getPostaladress()=="") $toprofil=true; break;
case "birthdate": if($user->getBirthdate()=="") $toprofil=true; break;
case "birthcountry": if($user->getBirthcountry()=="") $toprofil=true; break;
case "birthplace": if($user->getBirthplace()=="") $toprofil=true; break;
}
}
}
}
if($toprofil) {
return $this->redirect($this->generateUrl('cadoles_core_profil',array("info"=>"Merci de compléter votre profil")));
}
} }
// Calcul des pages de l'utilisateur // Calcul des pages de l'utilisateur
$this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->getPagesUser($user,$id,$entity,$pagesuser,$pagesadmin,$pagesshared); $this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->getPagesUser($user,$id,$entity,$pagesuser,$pagesadmin,$pagesshared);

View File

@ -35,11 +35,17 @@ class UserController extends Controller
public function listAction($access) public function listAction($access)
{ {
$em = $this->getDoctrine()->getManager();
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers");
$fields=$config->getValue();
$fields=json_decode($fields,true);
return $this->render('CadolesCoreBundle:User:list.html.twig',[ return $this->render('CadolesCoreBundle:User:list.html.twig',[
'useheader' => true, 'useheader' => true,
'usemenu' => false, 'usemenu' => false,
'usesidebar' => ($access=="config"), 'usesidebar' => ($access=="config"),
'access' => $access 'access' => $access,
'fields' => $fields
]); ]);
} }
@ -347,6 +353,7 @@ class UserController extends Controller
public function updateAction($id,$access,Request $request) public function updateAction($id,$access,Request $request)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
$info = $request->query->get('info');
// Récupération de l'enregistrement courant // Récupération de l'enregistrement courant
$data=$this->getData($id); $data=$this->getData($id);
@ -502,7 +509,8 @@ class UserController extends Controller
'access' => $access, 'access' => $access,
'listgroups' => $this->getListGroups($access), 'listgroups' => $this->getListGroups($access),
'listmodos' => $this->getListModos(), 'listmodos' => $this->getListModos(),
'form' => $form->createView() 'form' => $form->createView(),
'info' => $info,
]); ]);
} }

View File

@ -103,7 +103,7 @@
$viewniveau02 =$this->container->getParameter('viewniveau02'); $viewniveau02 =$this->container->getParameter('viewniveau02');
$iconniveau02 =$this->container->getParameter('iconniveau02'); $iconniveau02 =$this->container->getParameter('iconniveau02');
$labelsniveau02 =$this->container->getParameter('labelsniveau02'); $labelsniveau02 =$this->container->getParameter('labelsniveau02');
$labelniveau02 =$this->container->getParameter('labelsniveau02'); $labelniveau02 =$this->container->getParameter('labelniveau02');
$session->set('viewniveau02',$viewniveau02); $session->set('viewniveau02',$viewniveau02);
$session->set('labelniveau02',$labelniveau02); $session->set('labelniveau02',$labelniveau02);

View File

@ -84,11 +84,7 @@ class syncGroup implements EventSubscriber
if(count($results)) { if(count($results)) {
$ldap->deleteGroup($group); $ldap->deleteGroup($group);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->delGroup($group);
} }
public function upsertGroup($group, $force = false) public function upsertGroup($group, $force = false)
@ -113,11 +109,7 @@ class syncGroup implements EventSubscriber
else { else {
$ldap->addGroup($group); $ldap->addGroup($group);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->syncGroup($group,$this->oldid);
} }
public function getBaseGroup() { public function getBaseGroup() {

View File

@ -103,11 +103,7 @@ class syncNiveau01 implements EventSubscriber
if(count($results)) { if(count($results)) {
$ldap->deleteNiveau01($niveau01); $ldap->deleteNiveau01($niveau01);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->delNiveau01($niveau01);
} }
public function upsertNiveau01($niveau01, $force = false) public function upsertNiveau01($niveau01, $force = false)
@ -135,10 +131,6 @@ class syncNiveau01 implements EventSubscriber
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->syncNiveau01($niveau01,$this->oldid);
} }
public function getBaseNiveau01() { public function getBaseNiveau01() {

View File

@ -102,11 +102,7 @@ class syncNiveau02 implements EventSubscriber
if(count($results)) { if(count($results)) {
$ldap->deleteNiveau02($niveau02); $ldap->deleteNiveau02($niveau02);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->delNiveau02($niveau02);
} }
public function upsertNiveau02($niveau02, $force = false) public function upsertNiveau02($niveau02, $force = false)
@ -131,11 +127,7 @@ class syncNiveau02 implements EventSubscriber
else { else {
$ldap->addNiveau02($niveau02); $ldap->addNiveau02($niveau02);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->syncNiveau02($niveau02,$this->oldid);
} }
public function getBaseNiveau02() { public function getBaseNiveau02() {

View File

@ -113,11 +113,7 @@ class syncUser implements EventSubscriber
if(count($results)) { if(count($results)) {
$ldap->deleteUser($user); $ldap->deleteUser($user);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->delUser($user);
} }
public function upsertUser($user, $force = false) public function upsertUser($user, $force = false)
@ -142,10 +138,6 @@ class syncUser implements EventSubscriber
$ldap->addGroupUser($user); $ldap->addGroupUser($user);
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->syncUser($user);
// On ajoute l'utilisateur au groupe 'Tout le Monde' quoi qu'il arrive // On ajoute l'utilisateur au groupe 'Tout le Monde' quoi qu'il arrive
$fgall=$this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('fgall'=>true)); $fgall=$this->em->getRepository('CadolesCoreBundle:Group')->findBy(array('fgall'=>true));
if($fgall) { if($fgall) {

View File

@ -82,11 +82,7 @@ class syncUserGroup implements EventSubscriber
if(count($results)) { if(count($results)) {
$ldap->delUserGroup($group); $ldap->delUserGroup($group);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->delUserGroup($group);
} }
public function upsertGroup($group, $force = false) public function upsertGroup($group, $force = false)
@ -104,11 +100,7 @@ class syncUserGroup implements EventSubscriber
if(count($results) > 0) { if(count($results) > 0) {
$ldap->addUserGroup($group); $ldap->addUserGroup($group);
} }
} }
$eportail = $this->container->get('cadoles.core.service.eportail');
if($eportail->isEnabled())
$eportail->addUserGroup($group);
} }
public function getBaseGroup() { public function getBaseGroup() {

View File

@ -34,17 +34,25 @@ class DatauserType extends AbstractType
foreach($options["fields"] as $key => $field) { foreach($options["fields"] as $key => $field) {
if($key=="birthplace") if($options["mode"]=="datauser") {
$choices=array( if($key=="birthplace")
"Falcultatif" => 1, $choices=array(
"Caché" => 0, "Falcultatif" => 1,
); "Caché" => 0,
else );
$choices=array( else
"Obligatoire" => 2, $choices=array(
"Falcultatif" => 1, "Obligatoire" => 2,
"Caché" => 0, "Falcultatif" => 1,
); "Caché" => 0,
);
}
else {
$choices=array(
"Visible" => 1,
"Caché" => 0,
);
}
$builder->add($key, ChoiceType::class, $builder->add($key, ChoiceType::class,
array("label" => $field["label"], array("label" => $field["label"],
@ -63,8 +71,9 @@ class DatauserType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults(array( $resolver->setDefaults(array(
'data_class' => 'Cadoles\CoreBundle\Entity\Config', 'data_class' => 'Cadoles\CoreBundle\Entity\Config',
'fields' => "array", 'mode' => 'string',
'fields' => "array",
)); ));
} }
} }

View File

@ -161,6 +161,10 @@ cadoles_core_config_datauser:
path: /config/commun/datauser path: /config/commun/datauser
defaults: { _controller: CadolesCoreBundle:Config:datauser } defaults: { _controller: CadolesCoreBundle:Config:datauser }
cadoles_core_config_datausers:
path: /config/commun/datausers
defaults: { _controller: CadolesCoreBundle:Config:datausers }
#== Registration ========================================================================================================= #== Registration =========================================================================================================
#-- Access config #-- Access config
cadoles_core_config_registration: cadoles_core_config_registration:

View File

@ -1,23 +1,28 @@
services: services:
cadoles.core.session.listener: cadoles.core.session.listener:
public: true
class: Cadoles\CoreBundle\EventListener\sessionListener class: Cadoles\CoreBundle\EventListener\sessionListener
arguments: ['@service_container','@doctrine.orm.entity_manager',"@security.token_storage"] arguments: ['@service_container','@doctrine.orm.entity_manager',"@security.token_storage"]
tags: tags:
- { name: kernel.event_listener, event: kernel.request, method: onDomainParse } - { name: kernel.event_listener, event: kernel.request, method: onDomainParse }
cadoles.core.upload.listener: cadoles.core.upload.listener:
public: true
class: Cadoles\CoreBundle\EventListener\uploadListener class: Cadoles\CoreBundle\EventListener\uploadListener
arguments: ["@doctrine.orm.entity_manager","@security.token_storage","@session"] arguments: ["@doctrine.orm.entity_manager","@security.token_storage","@session"]
tags: tags:
- { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload } - { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload }
cadoles.core.upload.namer.same: cadoles.core.upload.namer.same:
public: true
class: Cadoles\CoreBundle\Service\uploadSameNamer class: Cadoles\CoreBundle\Service\uploadSameNamer
cadoles.core.password.encoder: cadoles.core.password.encoder:
public: true
class: Cadoles\CoreBundle\Service\passwordEncoder class: Cadoles\CoreBundle\Service\passwordEncoder
cadoles.core.sync.user: cadoles.core.sync.user:
public: true
class: Cadoles\CoreBundle\EventListener\syncUser class: Cadoles\CoreBundle\EventListener\syncUser
arguments: arguments:
- "@service_container" - "@service_container"
@ -28,6 +33,7 @@ services:
- [setBaseUser, ["%ldap_baseuser%"]] - [setBaseUser, ["%ldap_baseuser%"]]
cadoles.core.sync.niveau01: cadoles.core.sync.niveau01:
public: true
class: Cadoles\CoreBundle\EventListener\syncNiveau01 class: Cadoles\CoreBundle\EventListener\syncNiveau01
arguments: arguments:
- "@service_container" - "@service_container"
@ -38,6 +44,7 @@ services:
- [setBaseNiveau01, ["%ldap_baseNiveau01%"]] - [setBaseNiveau01, ["%ldap_baseNiveau01%"]]
cadoles.core.sync.niveau02: cadoles.core.sync.niveau02:
public: true
class: Cadoles\CoreBundle\EventListener\syncNiveau02 class: Cadoles\CoreBundle\EventListener\syncNiveau02
arguments: arguments:
- "@service_container" - "@service_container"
@ -48,6 +55,7 @@ services:
- [setBaseNiveau02, ["%ldap_baseniveau02%"]] - [setBaseNiveau02, ["%ldap_baseniveau02%"]]
cadoles.core.sync.group: cadoles.core.sync.group:
public: true
class: Cadoles\CoreBundle\EventListener\syncGroup class: Cadoles\CoreBundle\EventListener\syncGroup
arguments: arguments:
- "@service_container" - "@service_container"
@ -58,6 +66,7 @@ services:
- [setBaseGroup, ["%ldap_basegroup%"]] - [setBaseGroup, ["%ldap_basegroup%"]]
cadoles.core.sync.usergroup: cadoles.core.sync.usergroup:
public: true
class: Cadoles\CoreBundle\EventListener\syncUserGroup class: Cadoles\CoreBundle\EventListener\syncUserGroup
arguments: arguments:
- "@service_container" - "@service_container"
@ -68,6 +77,7 @@ services:
- [setBaseGroup, ["%ldap_basegroup%"]] - [setBaseGroup, ["%ldap_basegroup%"]]
cadoles.core.service.ldap: cadoles.core.service.ldap:
public: true
class: Cadoles\CoreBundle\Service\ldapService class: Cadoles\CoreBundle\Service\ldapService
arguments: arguments:
- %ldap_host% - %ldap_host%
@ -82,30 +92,25 @@ services:
- [setBaseGroup, ["%ldap_basegroup%"]] - [setBaseGroup, ["%ldap_basegroup%"]]
- [setLdapSync, ["%ldap_sync%","%masteridentity%"]] - [setLdapSync, ["%ldap_sync%","%masteridentity%"]]
cadoles.core.service.eportail:
class: Cadoles\CoreBundle\Service\eportailService
arguments:
- "@doctrine"
calls:
- [setEportailSync, ["%eportail_sync%","%masteridentity%"]]
- [setLabelniveau01, ["%labelniveau01%"]]
- [setLabelniveau02, ["%labelniveau02%"]]
cadoles.core.service.mail: cadoles.core.service.mail:
public: true
class: Cadoles\CoreBundle\Service\mailService class: Cadoles\CoreBundle\Service\mailService
arguments: ["@mailer", "@twig"] arguments: ["@mailer", "@twig"]
cadoles.core.service.color: cadoles.core.service.color:
public: true
class: Cadoles\CoreBundle\Service\colorService class: Cadoles\CoreBundle\Service\colorService
arguments: ['@service_container'] arguments: ['@service_container']
cadoles.core.icon_choice_type: cadoles.core.icon_choice_type:
public: true
class: Cadoles\CoreBundle\Form\IconChoiceType class: Cadoles\CoreBundle\Form\IconChoiceType
arguments: ["%kernel.root_dir%/../web/bundles/cadolescore/css/font-awesome.css"] arguments: ["%kernel.root_dir%/../web/bundles/cadolescore/css/font-awesome.css"]
tags: tags:
- { name: form.type } - { name: form.type }
cadoles.saml_user_mapper: cadoles.saml_user_mapper:
public: true
class: Cadoles\CoreBundle\Service\samlUserMapperService class: Cadoles\CoreBundle\Service\samlUserMapperService
arguments: arguments:
- "@=service('doctrine').getManager()" - "@=service('doctrine').getManager()"
@ -113,6 +118,7 @@ services:
- "@session" - "@session"
cadoles.saml_user_creator: cadoles.saml_user_creator:
public: true
class: Cadoles\CoreBundle\Service\samlUserCreatorService class: Cadoles\CoreBundle\Service\samlUserCreatorService
arguments: arguments:
- "@=service('doctrine').getManager()" - "@=service('doctrine').getManager()"
@ -120,4 +126,5 @@ services:
- "@session" - "@session"
cadoles.saml_attribute_mapper: cadoles.saml_attribute_mapper:
public: true
class: Cadoles\CoreBundle\Service\samlAttributeMapperService class: Cadoles\CoreBundle\Service\samlAttributeMapperService

View File

@ -3,7 +3,11 @@
{% block pagewrapper %} {% block pagewrapper %}
{{ form_start(form) }} {{ form_start(form) }}
<h1 class="page-header"> <h1 class="page-header">
Paramétrage de la Fiche Utilisateur {% if mode=="datauser" %}
Paramétrage de la Fiche Utilisateur
{% else %}
Paramétrage de la Listes des Utilisateurs
{% endif %}
</h1> </h1>
{{ form_widget(form.submit) }} {{ form_widget(form.submit) }}

View File

@ -30,6 +30,7 @@
{{ flashMessage }}<br> {{ flashMessage }}<br>
{% endfor %} {% endfor %}
</div> </div>
<br>
{% endif %} {% endif %}
{% if app.session.flashbag.has('notice') %} {% if app.session.flashbag.has('notice') %}
@ -39,8 +40,18 @@
{{ flashMessage }}<br> {{ flashMessage }}<br>
{% endfor %} {% endfor %}
</div> </div>
<br>
{% endif %} {% endif %}
{% if info %}
<div class='alert alert-info' style='margin: 5px 0px'>
<strong>Information</strong><br>
{{ info }}<br>
</div>
<br>
{% endif %}
<div class="row"> <div class="row">
<div style="width:90px; margin:auto;"> <div style="width:90px; margin:auto;">
<img id="user_avatar_img" src="/{{ alias }}/uploads/avatar/{{ user.avatar }}" class="avatar big" > <img id="user_avatar_img" src="/{{ alias }}/uploads/avatar/{{ user.avatar }}" class="avatar big" >

View File

@ -27,17 +27,17 @@
{% if access=="config" %} {% if access=="config" %}
<th width="90px" class="no-sort">Action</th> <th width="90px" class="no-sort">Action</th>
{% endif %} {% endif %}
<th width="70px" class="no-sort">Avatar</th> <th width="70px" class="no-sort {% if fields["avatar"].perm==0 %}no-visible{% endif %}">Avatar</th>
<th width="200px">Login</th> <th width="200px class=="{% if fields["login"].perm==0 %}no-visible{% endif %}">Login</th>
<th>Nom</th> <th class="{% if fields["lastname"].perm==0 %}no-visible{% endif %}">Nom</th>
<th>Prénom</th> <th class="{% if fields["firstname"].perm==0 %}no-visible{% endif %}">Prénom</th>
<th>Email</th> <th class="{% if fields["email"].perm==0 %}no-visible{% endif %}">Email</th>
<th>{{ labelniveau01 }}</th> <th class="{% if fields["niveau01"].perm==0 %}no-visible{% endif %}">{{ labelniveau01 }}</th>
{% if viewniveau02 %} {% if viewniveau02 %}
<th class="no-sort">{{ labelniveau02 }}</th> <th class="no-sort {% if fields["niveau02"].perm==0 %}no-visible{% endif %}">{{ labelniveau02 }}</th>
{% endif %} {% endif %}
<th class="no-sort">Groupes</th> <th class="no-sort {% if fields["group"].perm==0 %}no-visible{% endif %}">Groupes</th>
<th>Rôle</th> <th class="{% if fields["role"].perm==0 %}no-visible{% endif %}">Rôle</th>
</tr> </tr>
</thead> </thead>
</table> </table>
@ -58,7 +58,7 @@
{% endif %} {% endif %}
$('#dataTables').DataTable({ $('#dataTables').DataTable({
columnDefs: [ { "targets": 'no-sort', "orderable": false } ], columnDefs: [ { "targets": 'no-sort', "orderable": false },{ "targets": 'no-visible', "visible": false } ],
responsive: true, responsive: true,
iDisplayLength: 100, iDisplayLength: 100,
processing: true, processing: true,

View File

@ -1,439 +0,0 @@
<?php
namespace Cadoles\CoreBundle\Service;
use Cadoles\CoreBundle\Entity\User;
use Cadoles\CoreBundle\Entity\Niveau01;
use Cadoles\CoreBundle\Entity\Niveau02;
use Cadoles\CoreBundle\Entity\Group;
use Cadoles\CoreBundle\Entity\UserGroup;
use Doctrine\ORM\EntityManager;
if(file_exists("/var/www/html/eportail/include/delete.php")) {
include("/var/www/html/eportail/include/delete.php");
}
global $bdd01;
global $config;
class eportailService
{
protected $dbeportail;
protected $doctrine;
private $eportailSync = false;
private $labelniveau01 = "SERVICE";
private $labelniveau02 = "ETAB";
public function __construct($doctrine)
{
$this->doctrine=$doctrine;
}
public function isEnabled() {
return $this->eportailSync;
}
//==================================================================================================================================================================
//== Function User==================================================================================================================================================
//==================================================================================================================================================================
public function syncUser(User $user) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
$sql = "SELECT user_id FROM env_user WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($user->getUsername()));
// Correspondance profil core = profil eportail
switch($user->getRole()) {
case "ROLE_ADMIN":
$profil=1;
break;
case "ROLE_MODO":
$profil=2;
break;
case "ROLE_VALIDATOR":
$profil=50;
break;
case "ROLE_MANAGER":
$profil=50;
break;
case "ROLE_USER":
$profil=50;
break;
}
// Si existe modification
if($row=$query->fetch()){
echo "modif";
$sql="UPDATE env_user SET user_password=?, user_lastname=?, user_firstname=?, user_pseudo=?, user_email=?, user_avatar=?, user_profil=? WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array(
$user->getPassword(),
$user->getLastname(),
$user->getFirstname(),
$user->getFirstname()." ".$user->getLastname(),
$user->getEmail(),
$user->getAvatar(),
$profil,
$user->getUsername()
));
}
// Sinon création
else {
$sql="INSERT INTO env_user(user_login, user_password, user_lastname, user_firstname, user_pseudo, user_email, user_avatar, user_profil) VALUES(?,?,?,?,?,?,?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array(
$user->getUsername(),
$user->getPassword(),
$user->getLastname(),
$user->getFirstname(),
$user->getFirstname()." ".$user->getLastname(),
$user->getEmail(),
$user->getAvatar(),
$profil
));
}
// Ratacchement utilisateur group
$this->defineGroupUser($user);
return true;
}
public function delUser(User $user) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// On recherche l'utilisateur eportail
$sql = "SELECT user_id FROM env_user WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($user->getUsername()));
// Si existe suppression
if($row=$query->fetch()){
delUser($row["user_id"]);
}
return true;
}
//==================================================================================================================================================================
//== Function Niveau01==============================================================================================================================================
//==================================================================================================================================================================
public function syncNiveau01(Niveau01 $niveau01, $oldid) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Renommage du précédent groupe
if(isset($oldid)&&$oldid!=$niveau01->getLabel()) {
$sql="UPDATE env_group SET group_name=? WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array(
$this->labelniveau01." = ".$niveau01->getLabel(),
$this->labelniveau01." = ".$oldid));
}
// On recherche le groupe à insérer / modifier
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau01." = ".$niveau01->getLabel()));
// Si existe modification = rien à faire normalement
// Sinon création
if(!$row=$query->fetch()){
$sql="INSERT INTO env_group(group_name, group_type, group_user) VALUES(?,?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau01." = ".$niveau01->getLabel(),4,-1));
}
return true;
}
public function delNiveau01(Niveau01 $niveau01) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// On recherche le groupe eportail
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau01." = ".$niveau01->getLabel()));
// Si existe suppression
if($row=$query->fetch()){
delGroup($row["group_id"]);
}
return true;
}
//==================================================================================================================================================================
//== Function Niveau02==============================================================================================================================================
//==================================================================================================================================================================
public function syncNiveau02(Niveau02 $niveau02, $oldid) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Renommage du précédent groupe
if(isset($oldid)&&$oldid!=$niveau02->getLabel()) {
$sql="UPDATE env_group SET group_name=? WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array(
$this->labelniveau02." = ".$niveau02->getLabel(),
$this->labelniveau02." = ".$oldid));
}
// On recherche le groupe à insérer / modifier
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau02." = ".$niveau02->getLabel()));
// Si existe modification = rien à faire normalement
// Sinon création
if(!$row=$query->fetch()){
$sql="INSERT INTO env_group(group_name, group_type, group_user) VALUES(?,?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau02." = ".$niveau02->getLabel(),4,-1));
}
return true;
}
public function delNiveau02(Niveau02 $niveau02) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// On recherche le groupe eportail
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau02." = ".$niveau02->getLabel()));
// Si existe suppression
if($row=$query->fetch()){
delGroup($row["group_id"]);
}
return true;
}
//==================================================================================================================================================================
//== Function Groupe================================================================================================================================================
//==================================================================================================================================================================
public function syncGroup(Group $group, $oldid) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Renommage du précédent groupe
if(isset($oldid)&&$oldid!=$group->getLabel()) {
$sql="UPDATE env_group SET group_name=? WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array(
"GROUPE = ".$group->getLabel(),
"GROUPE = ".$oldid));
}
// On recherche le groupe à insérer / modifier
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$group->getLabel()));
// Si existe modification = rien à faire normalement
// Sinon création
if(!$row=$query->fetch()){
$sql="INSERT INTO env_group(group_name, group_type, group_user) VALUES(?,?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$group->getLabel(),4,-1));
}
return true;
}
public function delGroup(Group $group) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// On recherche le groupe eportail
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$group->getLabel()));
// Si existe suppression
if($row=$query->fetch()){
delGroup($row["group_id"]);
}
return true;
}
//==================================================================================================================================================================
//== Function GroupUser=============================================================================================================================================
//==================================================================================================================================================================
public function defineGroupUser(User $user) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Recherche de l'utilisateur
$sql = "SELECT user_id FROM env_user WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($user->getUsername()));
if($row=$query->fetch()){
$id=$row["user_id"];
// On supprime l'ensemble des liens utilisateur / groupe
$q="DELETE FROM env_group_user WHERE group_user_user=?";
$query=$this->dbeportail->prepare($q);
$query->execute(array($id));
// On regènere son rattachement niveau01
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau01." = ".$user->getNiveau01()->getLabel()));
if($row=$query->fetch()){
$sql="INSERT INTO env_group_user(group_user_group, group_user_user) VALUES(?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($row["group_id"],$id));
}
// On regènere son rattachement etablissement
if($user->getNiveau02()!==null) {
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($this->labelniveau02." = ".$user->getNiveau02()->getLabel()));
if($row=$query->fetch()){
$sql="INSERT INTO env_group_user(group_user_group, group_user_user) VALUES(?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($row["group_id"],$id));
}
}
// On regènere son rattachement aux groupes
$groups=$user->getGroups();
if($groups) {
foreach($groups as $usergroup) {
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$usergroup->getGroup()->getLabel()));
if($row=$query->fetch()){
$sql="INSERT INTO env_group_user(group_user_group, group_user_user) VALUES(?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($row["group_id"],$id));
}
}
}
}
}
public function delUserGroup(UserGroup $usergroup) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Recherche de l'utilisateur
$sql = "SELECT user_id FROM env_user WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($usergroup->getUser()->getUsername()));
if($row=$query->fetch()){
$iduser=$row["user_id"];
// Recherche du groupe
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$usergroup->getGroup()->getLabel()));
if($row=$query->fetch()){
$idgroup=$row["group_id"];
// Suppression du rattachement
$sql="DELETE FROM env_group_user WHERE group_user_group=? AND group_user_user=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($idgroup,$iduser));
}
}
}
public function addUserGroup(UserGroup $usergroup) {
global $bdd01;
global $config;
$bdd01=$this->dbeportail;
$config["dbprefixe"]="env_";
// Recherche de l'utilisateur
$sql = "SELECT user_id FROM env_user WHERE user_login=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($usergroup->getUser()->getUsername()));
if($row=$query->fetch()){
$iduser=$row["user_id"];
// Recherche du groupe
$sql = "SELECT group_id FROM env_group WHERE group_name=?";
$query = $this->dbeportail->prepare($sql);
$query->execute(array("GROUPE = ".$usergroup->getGroup()->getLabel()));
if($row=$query->fetch()){
$idgroup=$row["group_id"];
// Création du rattachement
$sql="INSERT INTO env_group_user(group_user_group, group_user_user) VALUES(?,?)";
$query = $this->dbeportail->prepare($sql);
$query->execute(array($idgroup,$iduser));
}
}
}
//==================================================================================================================================================================
//== Init du Service Synfony========================================================================================================================================
//==================================================================================================================================================================
public function setEportailSync($eportailSync,$masteridentity) {
$this->eportailSync = ($eportailSync&&($masteridentity=="SQL"));
if($eportailSync)
$this->dbeportail = $this->doctrine->getManager('eportail')->getConnection();
return $this;
}
public function setLabelniveau01($labelniveau01) {
setlocale( LC_CTYPE, 'fr_FR' );
$this->labelniveau01 = mb_strtoupper($labelniveau01);
return $this;
}
public function setLabelniveau02($labelniveau02) {
setlocale( LC_CTYPE, 'fr_FR' );
$this->labelniveau02 = mb_strtoupper($labelniveau02);
return $this;
}
}

View File

@ -1,4 +1,5 @@
services: services:
cadoles.cron.service.mail: cadoles.cron.service.mail:
public: true
class: Cadoles\CronBundle\Service\mailService class: Cadoles\CronBundle\Service\mailService
arguments: ["@mailer", "@twig"] arguments: ["@mailer", "@twig"]

View File

@ -12,6 +12,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity * @ORM\Entity
* @ORM\Table(name="item") * @ORM\Table(name="item")
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="Cadoles\PortalBundle\Repository\ItemRepository")
*/ */
class Item class Item
{ {

View File

@ -0,0 +1,118 @@
<?php
namespace Cadoles\PortalBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
class ItemRepository extends EntityRepository
{
public function getUserItems($user,&$bookmarks,&$itemsordered,&$itemcategorys,$iditemcategory=null,$withbookmark=1) {
// Profilage
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
$groups=($user?$user->getGroups():[]);
$niveau01=($user?$user->getNiveau01():[]);
// Bookmark de l'utilisateur
$bookmarks = array();
if($user)
$bookmarks=$this->getEntityManager()->getRepository("CadolesPortalBundle:Bookmark")->findBy(["user"=>$user]);
// Bookmark lié à un item
$bookmarksitems=new ArrayCollection();
foreach($bookmarks as $bookmark) {
if($bookmark->getItem()) $bookmarksitems->add($bookmark->getItem());
}
// Initialisation du calcul des items
$items=new ArrayCollection();
// Récupération des items par rôles
foreach($roles as $role) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where($qb->expr()->like('item.roles', $qb->expr()->literal("%$role%")));
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsroles=$qb->getQuery()->getResult();
foreach($itemsroles as $itemrole) {
if(!$bookmarksitems->contains($itemrole) && !$items->contains($itemrole)) $items->add($itemrole);
}
}
// Récupération des items par group
foreach($groups as $group) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where(":group MEMBER OF item.groups")
->setParameter("group",$group->getGroup());
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsgroups=$qb->getQuery()->getResult();
foreach($itemsgroups as $itemgroup) {
if(!$bookmarksitems->contains($itemgroup) && !$items->contains($itemgroup)) $items->add($itemgroup);
}
}
// Récupération des items par niveau01
if($niveau01) {
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where(":niveau01 MEMBER OF item.niveau01s")
->setParameter("niveau01",$niveau01);
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsniveau01s=$qb->getQuery()->getResult();
foreach($itemsniveau01s as $itemniveau01) {
if(!$bookmarksitems->contains($itemniveau01) && !$items->contains($itemniveau01)) $items->add($itemniveau01);
}
}
// Trie des items
$itemsordered = $items->getIterator();
$itemsordered->uasort(function ($first, $second) {
if((int) $first->getRowOrder() > (int) $second->getRowOrder())
$return=1;
elseif((int) $first->getRowOrder() == (int) $second->getRowOrder()) {
if($first->getTitle() > $second->getTitle())
$return=1;
else
$return=-1;
}
else
$return=-1;
return $return;
});
// Catégories affichées
$itemcategorys = $this->getEntityManager()->getRepository('CadolesPortalBundle:Itemcategory')->findBy([], ['rowOrder' => 'asc']);
if($iditemcategory && $itemcategoryfilter) $itemcategorys = $itemcategoryfilter;
switch($withbookmark) {
// items uniquement
case 1: $bookmarks=null; break;
// bookmarks uniquement
case 2: $itemsordered=null; break;
}
}
}

View File

@ -1,5 +1,6 @@
services: services:
Cadoles\PortalBundle\Form\PagewidgetType: Cadoles\PortalBundle\Form\PagewidgetType:
public: true
arguments: ['@service_container'] arguments: ['@service_container']
tags: tags:
- { name: form.type } - { name: form.type }

View File

@ -0,0 +1,334 @@
{% extends '@CadolesCore/base.html.twig' %}
{% set color = app.session.get('color') %}
{% set colormain = color['main'] %}
{% block pagewrapper %}
<div id="pagecontainer" style="margin: 0px -30px;"></div>
<div id="gridtemplate" style="max-width:1500px; margin:auto; margin-bottom:30px">
<div class="col-md-3">qsdfqsdfqsd</div>
<div class="col-md-9">
{% if bookmarks is not empty %}
<div class="bookmark-container">
{% if items is not empty %}
<h3 class="grid-title" data-idcategory="bookmark" style="{{ colorbodyfont }}">Favoris</h3>
{% else %}
<p></p>
{% endif %}
<div class="grid clearfix">
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
{% for bookmark in bookmarks %}
<div class="grid-item grid-small">
<div class="grid-item-content" style="background-color: {{ bookmark.color ? "#"~bookmark.color : '#'~colormain }};">
<a style="cursor:pointer" onClick="modBookmark({{ bookmark.id }})" class="item-update"><i style="color: #FFF" class="fa fa-file" title="Modifier le favori"></i></a>
{% if bookmark.target == 'frame' %}
<a class="linktosonde" data-sonde="{{ bookmark.title }}" style="cursor:pointer" onClick="showFrameitem('bookmark{{ bookmark.id }}','{{ bookmark.url }}')">
{% elseif bookmark.target == "_self" %}
<a class="linktosonde" data-sonde="{{ bookmark.title }}" href="{{ bookmark.url }}" target="{% if access=="user" %}_top{% else %}{{ bookmark.target }}{% endif %}">
{% else %}
<a class="linktosonde" data-sonde="{{ bookmark.title }}" href="{{ bookmark.url }}" target="{{ bookmark.target }}">
{% endif %}
<div class="item-link clearfix">
<div class="grid-item-logo">
{% if bookmark.icon %}
<img class="grid-item-img" height="110" src="/{{ alias }}/{{ bookmark.icon.label }}">
{% else %}
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_pin.png">
{% endif %}
</div>
<div class="grid-item-title">
<h2>{{ bookmark.title }}</h2>
<span>{{ bookmark.subtitle|nl2br }}</<span>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div class="bookmark-container" style="display:none">
<h3 class="grid-title" data-idcategory="bookmark"">Favoris</h3>
<div class="grid clearfix">
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
</div>
</div>
{% endif %}
{% set mycategs = [] %}
{% for itemcategory in itemcategorys %}
{% set haveitem=false %}
{% for item in items if item.itemcategory==itemcategory %}
{% if loop.index ==1 %}
{% set mycategs = mycategs|merge({ (loop.index) : itemcategory}) %}
{% endif %}
{% endfor %}
{% endfor %}
{% for itemcategory in mycategs %}
{% set haveitem=false %}
{% for item in items if item.itemcategory==itemcategory %}
{% if loop.index ==1 %}
{% set haveitem=true %}
{% if mycategs|length > 1 or bookmarks is not empty %}
<h3 class="grid-title" data-idcategory="{{ itemcategory.id }}">{{ itemcategory.label }}</h3>
{% else %}
<p></p>
{% endif %}
<div class="grid clearfix">
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
{% endif %}
<div class="grid-item grid-small" data-idcategory="{{ item.itemcategory.id }}" data-iditem="{{ item.id }}">
<div class="grid-item-content" style="background-color: {{ item.color ? "#"~item.color : '#'~colormain }};">
{% if item.content %}
<a style="cursor:pointer" class="item-preview"><i style="color: #FFF" class="fa fa-info" title="Informations sur ce service"></i></a>
{% endif %}
{% if item.protected and not app.user %}
{% if mode_auth == "SAML" %}
<a href="{{ path('lightsaml_sp.login') }}" {% if access=="user" %}target="_top"{% endif %}>
{% elseif mode_auth == "CAS" %}
<a href="{{ path('cas_sp.login') }}" {% if access=="user" %}target="_top"{% endif %}>
{% elseif mode_auth == "MYSQL" %}
<a href="{{ path('cnous_portal_user_login') }}" {% if access=="user" %}target="_top"{% endif %}>
{% endif %}
{% else %}
{% if item.target == 'frame' %}
<a class="linktosonde" data-sonde="{{ item.title }}" style="cursor:pointer" onClick="showFrameitem({{ item.id }},'{{ item.url }}')">
{% elseif item.target == "_self" %}
<a class="linktosonde" data-sonde="{{ item.title }}" href="{{ item.url }}" target="{% if access=="user" %}_top{% else %}{{ item.target }}{% endif %}">
{% else %}
<a class="linktosonde" data-sonde="{{ item.title }}" href="{{ item.url }}" target="{{ item.target }}">
{% endif %}
{% endif %}
<div class="item-link clearfix">
<div class="grid-item-logo">
{% if item.icon %}
<img class="grid-item-img" height="110" src="/{{ alias }}/{{ item.icon.label }}">
{% else %}
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_pin.png">
{% endif %}
</div>
<div class="grid-item-title">
<h2>{{ item.title }}</h2>
<span>{{ item.subtitle|nl2br }}</<span>
</div>
</div>
</a>
<div class="grid-item-body" style="display:none">
{{ item.content|raw }}
</div>
</div>
</div>
{% endfor %}
{% if haveitem %}
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}
{% block localjavascript %}
$('document').ready(function(){
// Ajustement des frames
$(window).resize(function() {
AjustFrame();
});
// Création des grilles d'items
var optiongrid={columnWidth: '.grid-sizer', itemSelector: '.grid-item', gutter: '.grid-gutter-sizer'};
$('body').imagesLoaded(function() {
var grid = $('.grid').masonry(optiongrid);
});
// Preview item de bureau
$( ".grid .item-preview" ).click(function() {
if($(this).parent().children(".grid-item-body").css('display') == 'none') {
$(this).html('<i style="color: #FFF" class="fa fa-minus" title="Informations sur ce service"></i>');
heightbody=$(this).parent().children(".grid-item-body").height()+30;
heightitem=$(this).parent().parent().height();
$(this).parent().children(".grid-item-body").show();
$(this).parent().parent().css("width","100%");
$(this).parent().parent().css("height",heightitem+heightbody);
$(this).parent().children(".grid-item-content").css("height",heightitem+heightbody);
$(this).parent().children(".item-preview").css("height",heightitem+heightbody);
var grid = $('.grid').masonry(optiongrid);
}
else {
$(this).html('<i style="color: #FFF" class="fa fa-plus" title="Informations sur ce service"></i>');
$(this).parent().children(".grid-item-body").hide();
$(this).parent().parent().css("width","");
$(this).parent().parent().css("height","");
$(this).parent().children(".grid-item-content").css("height","");
$(this).parent().children(".item-preview").css("height","");
var grid = $('.grid').masonry(optiongrid);
}
});
// Sur click item à sonder
{% if activate_widsonde %}
$( ".linktosonde" ).click(function() {
title=$(this).attr("data-sonde");
$.getScript( "{{ widsonde_url }}?appli="+title );
});
{% endif %}
});
// Ajout d'un bookmark
function addBookmark(idwidget,touser) {
var url="{{ path('cadoles_portal_user_bookmark_submit',{idpage:0,idwidget:'xx',touser:'yy'})}}";
url=url.replace('xx',idwidget);
url=url.replace('yy',touser);
$(location).attr('href', url);
}
// Modifciation d'un bookmark
function modBookmark(idbookmark) {
var url="{{ path('cadoles_portal_user_bookmark_update',{idpage:0,id:'xx'})}}";
url=url.replace('xx',idbookmark);
$(location).attr('href', url);
}
// Ajouter un item aux bookmark
function heartBookmark(iditem) {
var idbookmark;
$.ajax({
method: "POST",
url: "{{ path('cadoles_portal_user_bookmark_heart') }}",
data: {
iditem:iditem
},
success: function(idbookmark) {
location.reload();
}
});
}
// Supprimer un fichier
function delFile(directory,filename) {
var r = confirm("Confirmez-vous la suppression de ce fichier ?");
if (r == true) {
$.ajax({
method: "POST",
url: "{{ path('cadoles_core_user_file_delete') }}",
data: {
directory:directory,
filename:filename
},
success: function() {
location.reload();
}
});
}
}
// Ajustement des frames
function AjustFrame() {
$('.frameajust').iframeAutoHeight({
minHeight: 500, // Sets the iframe height to this value if the calculated value is less
heightOffset: 0, // Optionally add some buffer to the bottom
callback: function(callbackObject) { $(this).parent().css("height",callbackObject.newFrameHeight) ;}
});
if($(".frameitem").length>0) {
var heightbody = $('html').height();
var heightheader = $('.header').height();
if($('.pagemenu').css("display")=="none")
var heightmenu = 0;
else
var heightmenu = $('.pagemenu').height();
var heightframe = heightbody-heightheader-heightmenu;
$(".frameitem").height(heightframe);
}
}
// Affichage d'un Flux
function showFlux(idwidget, id) {
if(id=="all")
$(".widget[data-id="+idwidget+"]").find(".feed").show();
else {
$(".widget[data-id="+idwidget+"]").find(".feed").hide();
$(".widget[data-id="+idwidget+"]").find(".flux-"+id).show();
}
var optiongrid={columnWidth: '.grid-sizer',itemSelector: '.grid-item'};
var grid = $('.grid').masonry(optiongrid);
}
// Affichage des frames associés aux items de bureau
function resizeFrame() {
var iFrame = document.getElementById('frameContent');
var heightbody = $('html').height();
var heightheader = $('.header').height();
if($('#appmenu').css("display")=="none")
var heightmenu = 0;
else
var heightmenu = $('#appmenu').height();
var heightframe = heightbody-heightheader-heightmenu;
$(".pageframe").each(function( index ) {
$(this).height(heightframe);
});
}
function showFrameitem(id,url,forcereload) {
$(".pageframe").hide();
// Si force le rechargement et frame existante on la détruit
if(forcereload&&$("#frameitem-"+id).length)
$("#frameitem-"+id).remove();
// Si la frame en cours existe déjà on l'affiche
if($("#frameitem-"+id).length)
$("#frameitem-"+id).show();
// Sinon on la génère
else
$("#pagecontainer").append("<iframe id='frameitem-"+id+"' class='pageframe' src='"+url+"' style='border:none; width:100%'></iframe>");
resizeFrame();
}
{% endblock %}

View File

@ -29,6 +29,7 @@ INSERT IGNORE INTO `sidebar` (`id`, `parent_id`, `roworder`, `label`, `path`, `f
(1020, 1000, 1020, 'Thème', 'cadoles_core_config_theme', 'fa-paint-brush', 'ROLE_ADMIN,ROLE_MODO', ''), (1020, 1000, 1020, 'Thème', 'cadoles_core_config_theme', 'fa-paint-brush', 'ROLE_ADMIN,ROLE_MODO', ''),
(1030, 1000, 1030, 'Modération', 'cadoles_core_config_permmodo', 'fa-balance-scale', 'ROLE_ADMIN', ''), (1030, 1000, 1030, 'Modération', 'cadoles_core_config_permmodo', 'fa-balance-scale', 'ROLE_ADMIN', ''),
(1040, 1000, 1040, 'Fiche Utilisateur', 'cadoles_core_config_datauser', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''), (1040, 1000, 1040, 'Fiche Utilisateur', 'cadoles_core_config_datauser', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''),
(1050, 1000, 1050, 'Liste Utilisateurs', 'cadoles_core_config_datausers', 'fa-gear', 'ROLE_ADMIN,ROLE_MODO', ''),
(1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''), (1200, NULL, 1200, 'ORGANISATION', NULL, 'fa-sitemap', 'ROLE_ADMIN,ROLE_MODO', ''),
(1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN,ROLE_MODO', ''), (1210, 1200, 1210, 'Listes Blanche', 'cadoles_core_config_whitelist', 'fa-tasks', 'ROLE_ADMIN,ROLE_MODO', ''),
@ -82,6 +83,7 @@ INSERT IGNORE INTO `config` (`order`, `visible`, `changeable`, `required`, `type
('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'), ('004', 1, 1, 1, 'logo', 'logo', 'uploads/logo/logo.png', '', 'Le logo de votre site'),
('005', 0, 1, 0, 'theme', 'theme', '', '', 'Le theme de votre site'), ('005', 0, 1, 0, 'theme', 'theme', '', '', 'Le theme de votre site'),
('006', 0, 1, 0, 'datauser', 'datauser', '', '', 'Parametrage des champs utilisateurs : obligatoire / facultatif / caché'), ('006', 0, 1, 0, 'datauser', 'datauser', '', '', 'Parametrage des champs utilisateurs : obligatoire / facultatif / caché'),
('007', 0, 1, 0, 'datausers', 'datausers', '', '', 'Parametrage des colonnes visible dans la liste des utilisateurs'),
('010', 1, 1, 1, 'boolean', 'fgforceconnect', '0', '', 'Forcer la connection afin de rendre votre site privé'), ('010', 1, 1, 1, 'boolean', 'fgforceconnect', '0', '', 'Forcer la connection afin de rendre votre site privé'),
@ -110,6 +112,7 @@ INSERT IGNORE permmodo (`route`, `visible`) VALUES
('cadoles_core_config_commun',0), ('cadoles_core_config_commun',0),
('cadoles_core_config_theme',0), ('cadoles_core_config_theme',0),
('cadoles_core_config_datauser',0), ('cadoles_core_config_datauser',0),
('cadoles_core_config_datausers',0),
('cadoles_core_config_whitelist',0), ('cadoles_core_config_whitelist',0),
('cadoles_core_config_niveau01',0), ('cadoles_core_config_niveau01',0),
('cadoles_core_config_niveau02',1), ('cadoles_core_config_niveau02',1),