diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php index a191f802..81126b09 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php @@ -29,7 +29,7 @@ class ScriptCommand extends Command $this ->setName('Core:Script') ->setDescription('Lauch Script') - ->setHelp('Execeute some script : visibletrue / ') + ->setHelp('Execeute some script : visibletrue / setusersniveau') ->addArgument('scriptname', InputArgument::OPTIONAL, 'scriptname') ; } @@ -51,6 +51,7 @@ class ScriptCommand extends Command switch($scriptname) { case "visibletrue": $this->visibletrue(); break; + case "setusersniveau": $this->setusersniveau(); break; } $this->writeln(''); @@ -70,6 +71,19 @@ class ScriptCommand extends Command } } + private function setusersniveau() { + $users = $this->em->getRepository('CadolesCoreBundle:User')->findAll(); + foreach($users as $user) { + $this->writeln($user->getUsername()); + + $user->setLabelniveau01($user->getNiveau01()->getLabel()); + $user->setLabelniveau02(($user->getNiveau02()?$user->getNiveau02()->getLabel():null)); + + $this->em->persist($user); + $this->em->flush(); + } + } + private function writelnred($string) { $this->output->writeln(''.$string.''); $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");