diff --git a/src/ninegate-1.0/scripts/ninegate-postservice-01.sh b/src/ninegate-1.0/scripts/ninegate-postservice-01.sh index 6d156e6a..9a7b0c0a 100755 --- a/src/ninegate-1.0/scripts/ninegate-postservice-01.sh +++ b/src/ninegate-1.0/scripts/ninegate-postservice-01.sh @@ -49,6 +49,9 @@ php bin/console Core:InitData --env=prod php bin/console Cron:InitData --env=prod php bin/console Portal:InitData --env=prod +# Passage des scripts +php bin/console Core:Script --env=prod + # Generation des assets bin/console assetic:dump --env=prod diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php index b5a4c92c..1d8a5c25 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php @@ -59,7 +59,7 @@ class PurgeFileCommand extends Command if($fs->exists($directory)) { $finder = new Finder(); - $finder->in($directory)->directories()->exclude("thumb"); + $finder->in($directory)->directories()->exclude("thumb")->exclude("thumbmini"); foreach (iterator_to_array($finder) as $file) { $name = $file->getRelativePathname(); @@ -78,8 +78,6 @@ class PurgeFileCommand extends Command } break; } - - } } @@ -333,11 +331,11 @@ class PurgeFileCommand extends Command if($result) $find=true; } - // Si pas trouvé on la cherche dans les blogcommentaire + // Si pas trouvé on la cherche dans les blogcomment if(!$find) { $result = $this->em - ->getRepository("CadolesPortalBundle:Blogcommentaire")->createQueryBuilder('blogcommentaire') - ->where('blogarticle.description LIKE :tofind') + ->getRepository("CadolesPortalBundle:Blogcomment")->createQueryBuilder('blogcomment') + ->where('blogcomment.description LIKE :tofind') ->setParameter('tofind', '%'.$tofind.'%') ->getQuery()->getResult(); if($result) $find=true; 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 4f0f457b..402f030e 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/ScriptCommand.php @@ -11,6 +11,7 @@ use Symfony\Component\HttpKernel\KernelInterface; use Doctrine\DBAL\Connection as DBALConnection; use Doctrine\ORM\EntityManager; +use Cadoles\CoreBundle\Entity\Script; use Cadoles\CoreBundle\Entity\User; use Cadoles\PortalBundle\Entity\Project; @@ -30,8 +31,6 @@ class ScriptCommand extends Command $this ->setName('Core:Script') ->setDescription('Lauch Script') - ->setHelp('Execeute some script : visibletrue / setusersniveau') - ->addArgument('scriptname', InputArgument::OPTIONAL, 'scriptname') ; } @@ -43,18 +42,64 @@ class ScriptCommand extends Command $this->filesystem = new Filesystem(); $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/"; - $this->writelnred(''); - $this->writelnred('== Core:Script'); - $this->writelnred('=========================================================================================================='); + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"visibletrue"]); + if(!$script) { + $this->writelnred("== SCRIPT = visibletrue"); + $this->visibletrue(); - $scriptname = $input->getArgument('scriptname'); - $this->writeln($scriptname); + $script=new Script(); + $script->setName("visibletrue"); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); + } - switch($scriptname) { - case "visibletrue": $this->visibletrue(); break; - case "setusersniveau": $this->setusersniveau(); break; - case "setfgcancreateproject": $this->setfgcancreateproject(); break; - case "createproject": $this->createproject(); break; + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"setusersniveau"]); + if(!$script) { + $this->writelnred("== SCRIPT = setusersniveau"); + $this->setusersniveau(); + + $script=new Script(); + $script->setName("setusersniveau"); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); + } + + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"setfgcancreateproject"]); + if(!$script) { + $this->writelnred("== SCRIPT = setfgcancreateproject"); + $this->setfgcancreateproject(); + + $script=new Script(); + $script->setName("setfgcancreateproject"); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); + } + + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"createproject"]); + if(!$script) { + $this->writelnred("== SCRIPT = createproject"); + $this->createproject(); + + $script=new Script(); + $script->setName("createproject"); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); + } + + $script=$this->em->getRepository("CadolesCoreBundle:Script")->findOneBy(["name"=>"createthumbmini"]); + if(!$script) { + $this->writelnred("== SCRIPT = createthumbmini"); + $this->createthumbmini(); + + $script=new Script(); + $script->setName("createthumbmini"); + $this->em->persist($script); + $this->em->flush(); + $this->writeln(""); } $this->writeln(''); @@ -113,6 +158,51 @@ class ScriptCommand extends Command } } + private function createthumbmini() { + $directory=$this->container->get('kernel')->getRootDir()."/../uploads/file"; + $files=[]; + $fs = new Filesystem(); + + if($fs->exists($directory)) { + $finder = new Finder(); + $finder->in($directory)->directories()->exclude("thumb")->exclude("thumbmini"); + + foreach (iterator_to_array($finder) as $rep) { + $finder2 = new Finder(); + if($fs->exists($rep."/thumb")) { + $finder2->sortByName()->in($rep."/thumb"); + + foreach ($finder2 as $file) { + if(!$fs->exists($rep."/thumbmini/".$file->getRelativePathname())) { + $this->writeln($file->getRelativePathname()); + $fs->mkdir($rep."/thumbmini"); + $fs->copy($rep."/thumb/".$file->getRelativePathname(),$rep."/thumbmini/".$file->getRelativePathname()); + $max_width=60; + $width = $this->getWidth($rep."/thumbmini/".$file->getRelativePathname()); + $height = $this->getHeight($rep."/thumbmini/".$file->getRelativePathname()); + $scale = $max_width/$width; + $this->resizeImage($rep."/thumbmini/".$file->getRelativePathname(),$width,$height,$scale); + $fs->chown($rep."/thumbmini/".$file->getRelativePathname(), 'www-data'); + } + } + } + } + } + + } + + + + + + + + + + + + + private function writelnred($string) { $this->output->writeln(''.$string.''); $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); @@ -122,6 +212,63 @@ class ScriptCommand extends Command $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); } + protected function getHeight($image) { + $size = getimagesize($image); + $height = $size[1]; + return $height; + } + + // Cacul de la largeur + protected function getWidth($image) { + $size = getimagesize($image); + $width = $size[0]; + return $width; + } + + protected function resizeImage($image,$width,$height,$scale) { + list($imagewidth, $imageheight, $imageType) = getimagesize($image); + $imageType = image_type_to_mime_type($imageType); + $newImageWidth = ceil($width * $scale); + $newImageHeight = ceil($height * $scale); + $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); + switch($imageType) { + case "image/gif": + $source=imagecreatefromgif($image); + break; + case "image/pjpeg": + case "image/jpeg": + case "image/jpg": + $source=imagecreatefromjpeg($image); + break; + case "image/png": + case "image/x-png": + $source=imagecreatefrompng($image); + break; + } + + $newImage = imagecreatetruecolor( $newImageWidth, $newImageHeight ); + imagealphablending( $newImage, false ); + imagesavealpha( $newImage, true ); + imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height); + + switch($imageType) { + case "image/gif": + imagegif($newImage,$image); + break; + case "image/pjpeg": + case "image/jpeg": + case "image/jpg": + imagejpeg($newImage,$image,90); + break; + case "image/png": + case "image/x-png": + imagepng($newImage,$image); + break; + } + + chmod($image, 0640); + return $image; + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php index 0393ef4c..87190a93 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/CoreController.php @@ -49,6 +49,10 @@ class CoreController extends Controller // Récupération de la page encours $id = $request->query->get('id'); + + // Récupération redirection potentielle + $gotoroute = $request->query->get('gotoroute'); + $gotoid = $request->query->get('gotoid'); // L'utilisateur en cours @@ -116,7 +120,7 @@ class CoreController extends Controller return $this->render('CadolesPortalBundle:Page:default.html.twig',[ 'useheader' => true, 'usemenu' => false, - 'usesidebar' => false + 'usesidebar' => false ]); } @@ -131,7 +135,9 @@ class CoreController extends Controller 'groupsshared' => $groupsshared, 'canadd' => $this->get('session')->get('cancreatepage'), 'widgetsuser' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->getWidgetAccess("user"), - 'widgetsgroup' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->getWidgetAccess("group") + 'widgetsgroup' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Widget")->getWidgetAccess("group"), + 'gotoroute' => $gotoroute, + 'gotoid' => $gotoid, ]); } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php index afdb8086..aeb5b572 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php @@ -78,7 +78,7 @@ class FileController extends Controller if($fs->exists($dir)) { $finder = new Finder(); - $finder->sortByName()->in($dir)->exclude('thumb'); + $finder->sortByName()->in($dir)->exclude('thumb')->exclude("thumbmini"); $i=-1; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php index f9ff517c..3c438107 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/SecurityController.php @@ -192,4 +192,11 @@ class SecurityController extends Controller return new Response(); } + + public function redirectAction($route,$id,Request $request) { + if($route=="cadoles_core_home") + return $this->redirectToRoute($route,["id"=>$id]); + else + return $this->redirectToRoute("cadoles_core_home",["gotoroute"=>$route,"gotoid"=>$id]); + } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Script.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Script.php new file mode 100644 index 00000000..bebb4328 --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/Script.php @@ -0,0 +1,57 @@ +id; + } + + /** + * Set name + * + * @param string $name + * + * @return Script + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } +} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/uploadListener.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/uploadListener.php index 93a89dc3..c3377623 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/uploadListener.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/EventListener/uploadListener.php @@ -108,7 +108,7 @@ class uploadListener if (in_array(strtolower($file->GetExtension()), array('jpg', 'jpeg', 'jpe', 'png', 'gif', 'bmp'))) { $fs = new Filesystem(); $fs->copy($pathname."/".$directory."/".$filename,$pathname."/".$directory."/thumb/".$filename); - $max_width=350; + $max_width=300; $width = $this->getWidth($pathname."/".$directory."/thumb/".$filename); $height = $this->getHeight($pathname."/".$directory."/thumb/".$filename); $scale = $max_width/$width; @@ -118,7 +118,7 @@ class uploadListener if (in_array(strtolower($file->GetExtension()), array('pdf'))) { $im = new \Imagick(); - $im->setResolution(350, 350); + $im->setResolution(300, 300); $im->readImage($pathname."/".$directory."/".$filename."[0]"); $im->setImageBackgroundColor('#ffffff'); $im = $im->flattenImages(); @@ -128,6 +128,17 @@ class uploadListener $fs->rename($pathname."/".$directory."/thumb/".$filename.".jpg", $pathname."/".$directory."/thumb/".$filename); } + $fgexit=$fs->exists($pathname."/".$directory."/thumb/".$filename); + if($fgexit) { + $fs->mkdir($pathname."/".$directory."/thumbmini"); + $fs->copy($pathname."/".$directory."/thumb/".$filename,$pathname."/".$directory."/thumbmini/".$filename); + $max_width=60; + $width = $this->getWidth($pathname."/".$directory."/thumbmini/".$filename); + $height = $this->getHeight($pathname."/".$directory."/thumbmini/".$filename); + $scale = $max_width/$width; + $this->resizeImage($pathname."/".$directory."/thumbmini/".$filename,$width,$height,$scale); + } + if (strpos($directory, 'widget') === 0) { $tmp=explode("-",$directory); $widgetid=$tmp[1]; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 62ba36eb..f3078eaa 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -41,6 +41,9 @@ cadoles_core_ldap_login: path: /ldaplogin defaults: { _controller: CadolesCoreBundle:Security:login } +cadoles_core_redirect: + path: /user/redirect/{route}/{id} + defaults: { _controller: CadolesCoreBundle:Security:redirect } #== Crop Image =========================================================================================================== cadoles_core_crop01: diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php index 5a09780f..21933970 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PageController.php @@ -559,6 +559,7 @@ class PageController extends Controller 'group' => $groupid ]); } + // Type Widgets if($entity->getPageCategory()->getId()==2) { return $this->render($this->labelentity.':viewwidget.html.twig', [ diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php index 3c0ef6d0..14d187a0 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -1449,7 +1449,7 @@ class PagewidgetController extends Controller if($fs->exists($directory)) { $finder = new Finder(); - $finder->sortByName()->in($directory)->exclude('thumb'); + $finder->sortByName()->in($directory)->exclude('thumb')->exclude('thumbmini'); foreach ($finder as $file) { $tmp=[]; @@ -1460,7 +1460,25 @@ class PagewidgetController extends Controller $tmp["minefamily"]=explode("/",$tmp["minetype"])[0]; $tmp["thumb"]=""; - if($fs->exists($directory."/thumb/".$tmp["name"])) { + if($tmp["extension"]=="pdf") { + $tmp["thumb"]="/".$this->getParameter('alias')."/bundles/cadolescore/images/files/".$tmp["extension"].".png"; + + if($fs->exists($directory."/thumbmini/".$tmp["name"])) { + $data = file_get_contents($directory."/thumbmini/".$tmp["name"]); + $tmp["thumb"]="data:image/jpg;base64," . base64_encode($data); + } + elseif($fs->exists($directory."/thumb/".$tmp["name"])) { + $data = file_get_contents($directory."/thumb/".$tmp["name"]); + $tmp["thumb"]="data:image/jpg;base64," . base64_encode($data); + } + + + } + elseif($fs->exists($directory."/thumbmini/".$tmp["name"])) { + $data = file_get_contents($directory."/thumbmini/".$tmp["name"]); + $tmp["thumb"]=$data; + } + elseif($fs->exists($directory."/thumb/".$tmp["name"])) { $data = file_get_contents($directory."/thumb/".$tmp["name"]); $tmp["thumb"]="data:image/" . $tmp["extension"] . ";base64," . base64_encode($data); } @@ -1504,7 +1522,7 @@ class PagewidgetController extends Controller if($fs->exists($directory)) { $finder = new Finder(); - $finder->sortByName()->in($directory)->exclude('thumb'); + $finder->sortByName()->in($directory)->exclude('thumb')->exclude('thumbmini'); foreach ($finder as $file) { $tmp=[]; diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig index fcce6997..a2518162 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Page/pages.html.twig @@ -244,26 +244,30 @@ {% block localjavascript %} var idpage; $('document').ready(function(){ - {% for page in pagesadmin %} - {% if page.id==entity.id %} - showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','portal'); - {% endif %} - {% endfor %} - - {% for page in pagesuser %} - {% if page.id==entity.id %} - showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','user'); - {% endif %} - {% endfor %} - - {% for groupshared in groupsshared %} - {% for page in groupshared.pagesshared %} + {% if gotoroute is empty %} + {% for page in pagesadmin %} {% if page.id==entity.id %} - showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','group',true,{{groupshared.id}}); + showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','portal'); {% endif %} - {% endfor %} - {% endfor %} - + {% endfor %} + + {% for page in pagesuser %} + {% if page.id==entity.id %} + showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','user'); + {% endif %} + {% endfor %} + + {% for groupshared in groupsshared %} + {% for page in groupshared.pagesshared %} + {% if page.id==entity.id %} + showPage({{ page.id }}, {{ page.pagecategory.id }},'{{ page.canupdate }}','group',true,{{groupshared.id}}); + {% endif %} + {% endfor %} + {% endfor %} + {% else %} + var url="{{ path(gotoroute,{id:gotoid}) }}"; + showGoto(url); + {% endif %} // Rendre les pages user déplacable $("#pagesuser").sortable({ @@ -391,9 +395,7 @@ // Affichages des pages function showPage(id,catid,canupdate,usage,forcereload,groupid) { // Sauvegarder la page en cours - idpage=id; - - + idpage=id; // Cacher toutes les pages $(".pageframereload").remove(); @@ -455,11 +457,19 @@ } + // On resize les frame + resizeFrame(); + } + + // Affichages des pages + function showGoto(url) { + $("#pagecontainer").append(""); // On resize les frame resizeFrame(); } + function submitPage() { var url="{{ path('cadoles_portal_'~access~'_page_submit') }}"; $(location).attr('href',url); diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php index ca9bf072..f12ef1f2 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php @@ -41,6 +41,7 @@ class onlyService $folders=[]; $tasks=[]; + dump($idgroup); $group=$this->em->getRepository("CadolesCoreBundle:Group")->find($idgroup); if($group&&$group->getIdonlyoffice()) { if($this->only_activate) { diff --git a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Topic/WebsocketTopic.php b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Topic/WebsocketTopic.php index 51457972..6e9d62c3 100644 --- a/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Topic/WebsocketTopic.php +++ b/src/ninegate-1.0/src/Cadoles/WebsocketBundle/Topic/WebsocketTopic.php @@ -10,6 +10,7 @@ use Gos\Bundle\WebSocketBundle\Router\WampRequest; use Doctrine\ORM\EntityManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Gos\Bundle\WebSocketBundle\Client\ClientManipulatorInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Cadoles\WebsocketBundle\Entity\Message; @@ -112,11 +113,15 @@ class WebsocketTopic implements TopicInterface if(array_key_exists("mail",$event)) { $mail = $this->container->get('cadoles.core.service.mail'); if($mail) { - $cplt="

Attention ne répondez pas à ce mail : Pour répondre, rendez-vous dans ce groupe sur le portail et utilisez le fil de conversation (chat)
"; + $pages=$group->getPages(); + $pageid=$pages[0]->getId(); + $cplt="

Attention pour répondre à ce message : n’utilisez pas votre mail mais rendez vous dans ce groupe sur Transnum et utilisez le fil de conversation (chat)
"; + $url=$url = $this->container->get('router')->generate('cadoles_core_hone', ['id'=>$pageid], UrlGeneratorInterface::ABSOLUTE_URL); + $cplturl="
".$url.""; $mail_params=array( "subject" => $event["subject"], - "body_html"=>$event["message"].$cplt, - "body_text"=>strip_tags($event["message"].$cplt) + "body_html"=>$event["message"].$cplt.$cplturl, + "body_text"=>strip_tags($event["message"].$cplt.$url) ); // Transformer la liste des destinataires en tableau : [0] tjr vide on l'unset