From ed1b32e48149f22058a61f4c31999d1f4aed442c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 18 Sep 2020 15:09:03 +0200 Subject: [PATCH] gestion repertoire only --- .../CoreBundle/Controller/FileController.php | 1 + .../Controller/PagewidgetController.php | 25 +++++- .../PortalBundle/Resources/config/routing.yml | 10 +++ .../views/Pagewidget/viewfile.html.twig | 4 - .../views/Pagewidget/viewonlydoc.html.twig | 86 ++----------------- .../PortalBundle/Service/onlyService.php | 55 ++++++------ 6 files changed, 71 insertions(+), 110 deletions(-) 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 43773ba4..7db90415 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php @@ -48,6 +48,7 @@ class FileController extends Controller // Récupérer en session le mode de visualisation $sessionviewdirectory = $this->get('session')->get('sessionviewdirectory'); if(!is_array($sessionviewdirectory)) $sessionviewdirectory=[$directory=>$defaultview]; + if(!array_key_exists($directory,$sessionviewdirectory)) $sessionviewdirectory[$directory]=$defaultview; if($view) $sessionviewdirectory[$directory] = $view; $this->get('session')->set('sessionviewdirectory',$sessionviewdirectory); 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 49c28fc1..5878dcbd 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -2388,22 +2388,32 @@ class PagewidgetController extends Controller } + /* $onlyservice = $this->container->get('cadoles.portal.service.only'); - $files=$onlyservice->getDocument($group, $folders, $firstfolder, $tasks); + $firstfolder=null; + $files=$onlyservice->getDocument($group, $firstfolder, $tasks); + $grp=null; if($group) $grp=$em->getRepository("CadolesCoreBundle:Group")->find($group); if($grp) $idonly= $grp->getIdOnlyoffice(); else $idonly=0; + */ // Récupération des paramétres du widget $apponly=0; + $view="small"; foreach($entity->getParameter()["fields"] as $parameter) { switch($parameter["id"]) { case "apponly": $apponly=$parameter["value"]; - break; + break; + case "modelist": + $view=($parameter["value"]==0?"small":"list"); + break; } } + + /* // Render return $this->render($this->labelentity.':viewonlydoc.html.twig', [ @@ -2411,13 +2421,22 @@ class PagewidgetController extends Controller 'canadd' => $cansee, 'canupdate' => $cansee, 'firstfolder' => $firstfolder, - 'folders' => $folders, 'tasks' => $tasks, 'urlonly' => $this->getParameter("widonlyoffice_url")."/products/projects/projects.aspx?prjID=".$idonly, 'apponly' => $apponly, 'files' => $files, 'access' => $access, ]); + */ + + return $this->render($this->labelentity.':viewonlydoc.html.twig', [ + 'entity' => $entity, + 'canadd' => $canupdate, + 'canupdate' => $canupdate, + 'access' => $access, + 'directory' => $id, + 'view' => $view, + ]); } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml index c98eacc8..eafa3dc3 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml @@ -1152,3 +1152,13 @@ cadoles_portal_user_panelwidget_view_onlydoc: path: /pagewidget/view/onlydoc/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewonlydoc, access: user } + +#== FRAME ========================================================================================================================================== + +cadoles_portal_config_frame_only: + path: /config/frame/only/{directory} + defaults: { _controller: CadolesPortalBundle:Frame:only, access: config } + +cadoles_portal_user_frame_only: + path: /pagewidget/frame/only/{directory} + defaults: { _controller: CadolesPortalBundle:Frame:only, access: user } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewfile.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewfile.html.twig index a13eaf62..cd4df4fb 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewfile.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewfile.html.twig @@ -36,10 +36,6 @@ {% endif %} - - {% if canadd %} - - {% endif %} {% endif %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewonlydoc.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewonlydoc.html.twig index 245c853c..d987708d 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewonlydoc.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewonlydoc.html.twig @@ -10,6 +10,7 @@ {% set stylewidgetheader = constants.mystylewidgetheader(entity) %} {% set stylewidgetbody = constants.mystylewidgetbody(entity) %} {% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %} +{% set stylewidgetbodyframe = constants.mystylewidgetbodyframe(entity) %} {% set color = app.session.get('color') %} @@ -20,9 +21,13 @@ {% set colorbodyfont = entity.colorbodyfont %} -{% if colorbodyfont is null %} +{% if entity.border and colorbodyfont is null %} {% set colorbodyfont = color['fontcolorhover'] %} {% endif %} +{% if colorbodyfont is null %} + {% set colorbodyfont = color['main'] %} +{% endif %} +
{% if canupdate or canadd %} @@ -31,10 +36,6 @@ {% endif %} - - {% if canadd %} - - {% endif %}
{% endif %} @@ -48,82 +49,11 @@ {{ entity.name }} - {% if files|length >= 1 or canupdate %} -
- {% if apponly==0 %} -
-

Documents

-
- {% endif %} +
- {% if apponly==0 or apponly==1 %} - - {%endif%} - - {% if not tasks is empty %} -
- {% if apponly==0 %} -

Tâches

- {%endif%} - - {% if apponly==0 or apponly==2 %} - {% for task in tasks %} -
  • {{ task.title }}
  • - {% if not task.subtasks is empty %} -
      - {% for subtask in task.subtasks %} -
    • {{ subtask.title }}
    • - {% endfor %} -
    - {% endif %} - {% endfor %} - {%endif%} -
    - {% endif %}
    - {% endif %}
    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 b2dd1451..98d2b547 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Service/onlyService.php @@ -36,9 +36,9 @@ class onlyService } } - public function getDocument($idgroup,&$folders,&$firstfolder,&$tasks) { + public function getDocument($idgroup,&$firstfolder,&$parents,&$tasks) { $files=[]; - $folders=[]; + $parents=[]; $tasks=[]; if(!is_null($idgroup)) { @@ -48,24 +48,29 @@ class onlyService if($this->authOnly()) { $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers); if(!$this->koresponse($response)) { - $firstfolder=$response->body->response->projectFolder;; + $home=$response->body->response->projectFolder; + if(!$firstfolder) $firstfolder=$response->body->response->projectFolder; - $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/files',$this->headers); - if(!$this->koresponse($response)) { - foreach($response->body->response->files as $fileonly) { - array_push($files,$fileonly); - } - foreach($response->body->response->folders as $folderonly) { - $folders[$folderonly->id]=$folderonly; - $subfolder=$this->scanfolder($folderonly->id,$folders,$this->headers); - foreach($subfolder as $file) { - array_push($files,$file); - } - } + $files[$firstfolder] = $this->scanfolder($firstfolder,"",$this->headers); + + // Construction du tableau des parents + $currentchild=$firstfolder; + + while($currentchild!=$home) { + $response = \Unirest\Request::get($this->only_url.'/files/'.$currentchild,$this->headers); + if($this->koresponse($response)) return 0; + + // Récupérer les informations du folder + $tmp=["id"=>$response->body->response->current->id,"name"=>$response->body->response->current->title]; + array_push($parents,$tmp); + + // Aller sur le folder parent + $currentchild=$response->body->response->current->parentId; + } $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/task/open',$this->headers); - if(!$this->koresponse($response)) $tasks=$response->body->response; - } + if(!$this->koresponse($response)) $tasks=$response->body->response; + } } } @@ -75,6 +80,10 @@ class onlyService return $files; } + private function getFiles($idfolder) { + + return $files; + } private function authOnly() { // Only Office est-il dans le domaine if(stripos($this->only_url,"/")===0) @@ -119,19 +128,15 @@ class onlyService if($this->debug) error_log($texte); } - private function scanfolder($folderid,&$folders,$headers) { - $files=[]; + private function scanfolder($folderid,$folderonly,$headers) { + $files=["info"=>$folderonly,"files"=>[],"folders"=>[]]; $response = \Unirest\Request::get($this->only_url.'/files/'.$folderid,$headers); if($this->koresponse($response)) return 0; foreach($response->body->response->files as $fileonly) { - array_push($files,$fileonly); + array_push($files["files"],$fileonly); } foreach($response->body->response->folders as $folderonly) { - $folders['"'.$folderonly->id.'"']=$folderonly; - $subfolder=$this->scanfolder($folderonly->id,$folders,$headers); - foreach($subfolder as $file) { - array_push($files,$file); - } + $files["folders"][$folderonly->id] = $this->scanfolder($folderonly->id,$folderonly,$headers); } return $files;