gestion repertoire only

This commit is contained in:
root 2020-09-18 15:09:03 +02:00
parent e92e972c5a
commit ed1b32e481
6 changed files with 71 additions and 110 deletions

View File

@ -48,6 +48,7 @@ class FileController extends Controller
// Récupérer en session le mode de visualisation // Récupérer en session le mode de visualisation
$sessionviewdirectory = $this->get('session')->get('sessionviewdirectory'); $sessionviewdirectory = $this->get('session')->get('sessionviewdirectory');
if(!is_array($sessionviewdirectory)) $sessionviewdirectory=[$directory=>$defaultview]; if(!is_array($sessionviewdirectory)) $sessionviewdirectory=[$directory=>$defaultview];
if(!array_key_exists($directory,$sessionviewdirectory)) $sessionviewdirectory[$directory]=$defaultview;
if($view) if($view)
$sessionviewdirectory[$directory] = $view; $sessionviewdirectory[$directory] = $view;
$this->get('session')->set('sessionviewdirectory',$sessionviewdirectory); $this->get('session')->set('sessionviewdirectory',$sessionviewdirectory);

View File

@ -2388,36 +2388,55 @@ class PagewidgetController extends Controller
} }
/*
$onlyservice = $this->container->get('cadoles.portal.service.only'); $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; $grp=null;
if($group) $grp=$em->getRepository("CadolesCoreBundle:Group")->find($group); if($group) $grp=$em->getRepository("CadolesCoreBundle:Group")->find($group);
if($grp) $idonly= $grp->getIdOnlyoffice(); if($grp) $idonly= $grp->getIdOnlyoffice();
else $idonly=0; else $idonly=0;
*/
// Récupération des paramétres du widget // Récupération des paramétres du widget
$apponly=0; $apponly=0;
$view="small";
foreach($entity->getParameter()["fields"] as $parameter) { foreach($entity->getParameter()["fields"] as $parameter) {
switch($parameter["id"]) { switch($parameter["id"]) {
case "apponly": case "apponly":
$apponly=$parameter["value"]; $apponly=$parameter["value"];
break; break;
case "modelist":
$view=($parameter["value"]==0?"small":"list");
break;
} }
} }
/*
// Render // Render
return $this->render($this->labelentity.':viewonlydoc.html.twig', [ return $this->render($this->labelentity.':viewonlydoc.html.twig', [
'entity' => $entity, 'entity' => $entity,
'canadd' => $cansee, 'canadd' => $cansee,
'canupdate' => $cansee, 'canupdate' => $cansee,
'firstfolder' => $firstfolder, 'firstfolder' => $firstfolder,
'folders' => $folders,
'tasks' => $tasks, 'tasks' => $tasks,
'urlonly' => $this->getParameter("widonlyoffice_url")."/products/projects/projects.aspx?prjID=".$idonly, 'urlonly' => $this->getParameter("widonlyoffice_url")."/products/projects/projects.aspx?prjID=".$idonly,
'apponly' => $apponly, 'apponly' => $apponly,
'files' => $files, 'files' => $files,
'access' => $access, 'access' => $access,
]); ]);
*/
return $this->render($this->labelentity.':viewonlydoc.html.twig', [
'entity' => $entity,
'canadd' => $canupdate,
'canupdate' => $canupdate,
'access' => $access,
'directory' => $id,
'view' => $view,
]);
} }
} }

View File

@ -1152,3 +1152,13 @@ cadoles_portal_user_panelwidget_view_onlydoc:
path: /pagewidget/view/onlydoc/{id} path: /pagewidget/view/onlydoc/{id}
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewonlydoc, access: user } 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 }

View File

@ -36,10 +36,6 @@
<i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i> <i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
<i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i> <i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
{% endif %} {% endif %}
{% if canadd %}
<!-- <a style="{{ stylewidgetmenu }}" data-toggle="modal" data-target="#mymodal" onClick="ModalLoad('mymodal','Fichiers','{{ path('cadoles_core_'~access~'_file_upload',{'id': 'widget-'~entity.id,'type':'all'}) }}');" title='Ajouter des Fichiers'><i class="fa fa-plus fa-fw"></i></a> -->
{% endif %}
</div> </div>
{% endif %} {% endif %}

View File

@ -10,6 +10,7 @@
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %} {% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %} {% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
{% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %} {% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %}
{% set stylewidgetbodyframe = constants.mystylewidgetbodyframe(entity) %}
{% set color = app.session.get('color') %} {% set color = app.session.get('color') %}
@ -20,9 +21,13 @@
{% set colorbodyfont = entity.colorbodyfont %} {% set colorbodyfont = entity.colorbodyfont %}
{% if colorbodyfont is null %} {% if entity.border and colorbodyfont is null %}
{% set colorbodyfont = color['fontcolorhover'] %} {% set colorbodyfont = color['fontcolorhover'] %}
{% endif %} {% endif %}
{% if colorbodyfont is null %}
{% set colorbodyfont = color['main'] %}
{% endif %}
<div class="widget {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} widget-file" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px"> <div class="widget {%if entity.border %} widget-bordered {%else%} widget-notbordered {%endif%} widget-file" data-id="{{ entity.id }}" loc="{{ entity.loc }}" style="{{ stylewidget }}" height="{{ entity.height }}px">
{% if canupdate or canadd %} {% if canupdate or canadd %}
@ -31,10 +36,6 @@
<i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i> <i class="fa fa-trash fa-fw" title="Supprimer le Widget" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
<i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i> <i class="fa fa-file fa-fw" title="Modifier le Widget" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
{% endif %} {% endif %}
{% if canadd %}
<a style="{{ stylewidgetmenu }}" href="{{urlonly}}" target="_blank" title='Plus de fonctionnalités'><i class="fa fa-plus fa-fw"></i></a>
{% endif %}
</div> </div>
{% endif %} {% endif %}
@ -48,82 +49,11 @@
<span class="title">{{ entity.name }}</span> <span class="title">{{ entity.name }}</span>
</div> </div>
{% if files|length >= 1 or canupdate %} <div class="widgetbody" style="{{ stylewidgetbodyframe }}">
<div class="widgetbody" style="{{ stylewidgetbody }}">
{% if apponly==0 %}
<div style='width:90%; margin:auto;'>
<h4 style='margin-bottom:5px;border-bottom:1px solid;'>Documents</h4>
</div>
{% endif %}
{% if apponly==0 or apponly==1 %} <iframe id="frame-{{directory}}" src="{{ path("cadoles_portal_"~access~"_frame_only",{'directory':directory,'defaultview':view}) }}" data-color="#{{colorbodyfont}}" style="{{ stylewidgetbodyframe }}" class="{% if not entity.autoajust %}notframeajust {% endif %}"></iframe>
<div class="grid clearfix">
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
{% for file in files %}
<div class="grid-item grid-small">
<div class="grid-item-content">
<a href="{{ file.webUrl }}" target="_blank">
<div class="item-link clearfix">
<div class="grid-item-logo">
{% if file.fileExst ==".png" or file.fileExst ==".jpg" or file.fileExst ==".jpeg" or file.fileExst ==".svg" or file.fileExst ==".gif"%}
<img class="grid-item-img" height="110" src="{{file.viewUrl}}">
{% else %}
<img class="grid-item-img" height="110" src="/{{ alias }}/bundles/cadolescore/images/files/{{ file.fileExst | replace({".":""})}}.png">
{% endif %}
</div>
<div class="grid-item-title">
<h2 style="color:#{{colorbodyfont}}">{{ file.title }}</h2>
</div>
</div>
</a>
</div>
</div>
{% endfor %}
{% if canadd %}
<div class="grid-item grid-small">
<div class="grid-item-content">
<a href="{{urlonly}}" target="_blank" title='Plus de fonctionnalités'>
<div class="item-link clearfix">
<div class="grid-item-logo">
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_add.png">
</div>
<div class="grid-item-title">
<h2>Plus</h2>
</div>
</div>
</a>
</div>
</div>
{% endif %}
</div>
{%endif%}
{% if not tasks is empty %}
<div style='width:90%; margin:auto;'>
{% if apponly==0 %}
<h4 style='margin-bottom:5px;border-bottom:1px solid;'>Tâches</h4>
{%endif%}
{% if apponly==0 or apponly==2 %}
{% for task in tasks %}
<li>{{ task.title }}</li>
{% if not task.subtasks is empty %}
<ul>
{% for subtask in task.subtasks %}
<li>{{ subtask.title }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{%endif%}
</div>
{% endif %}
</div> </div>
{% endif %}
</div> </div>

View File

@ -36,9 +36,9 @@ class onlyService
} }
} }
public function getDocument($idgroup,&$folders,&$firstfolder,&$tasks) { public function getDocument($idgroup,&$firstfolder,&$parents,&$tasks) {
$files=[]; $files=[];
$folders=[]; $parents=[];
$tasks=[]; $tasks=[];
if(!is_null($idgroup)) { if(!is_null($idgroup)) {
@ -48,24 +48,29 @@ class onlyService
if($this->authOnly()) { if($this->authOnly()) {
$response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers); $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers);
if(!$this->koresponse($response)) { 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); $files[$firstfolder] = $this->scanfolder($firstfolder,"",$this->headers);
if(!$this->koresponse($response)) {
foreach($response->body->response->files as $fileonly) { // Construction du tableau des parents
array_push($files,$fileonly); $currentchild=$firstfolder;
}
foreach($response->body->response->folders as $folderonly) { while($currentchild!=$home) {
$folders[$folderonly->id]=$folderonly; $response = \Unirest\Request::get($this->only_url.'/files/'.$currentchild,$this->headers);
$subfolder=$this->scanfolder($folderonly->id,$folders,$this->headers); if($this->koresponse($response)) return 0;
foreach($subfolder as $file) {
array_push($files,$file); // 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); $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; return $files;
} }
private function getFiles($idfolder) {
return $files;
}
private function authOnly() { private function authOnly() {
// Only Office est-il dans le domaine // Only Office est-il dans le domaine
if(stripos($this->only_url,"/")===0) if(stripos($this->only_url,"/")===0)
@ -119,19 +128,15 @@ class onlyService
if($this->debug) error_log($texte); if($this->debug) error_log($texte);
} }
private function scanfolder($folderid,&$folders,$headers) { private function scanfolder($folderid,$folderonly,$headers) {
$files=[]; $files=["info"=>$folderonly,"files"=>[],"folders"=>[]];
$response = \Unirest\Request::get($this->only_url.'/files/'.$folderid,$headers); $response = \Unirest\Request::get($this->only_url.'/files/'.$folderid,$headers);
if($this->koresponse($response)) return 0; if($this->koresponse($response)) return 0;
foreach($response->body->response->files as $fileonly) { foreach($response->body->response->files as $fileonly) {
array_push($files,$fileonly); array_push($files["files"],$fileonly);
} }
foreach($response->body->response->folders as $folderonly) { foreach($response->body->response->folders as $folderonly) {
$folders['"'.$folderonly->id.'"']=$folderonly; $files["folders"][$folderonly->id] = $this->scanfolder($folderonly->id,$folderonly,$headers);
$subfolder=$this->scanfolder($folderonly->id,$folders,$headers);
foreach($subfolder as $file) {
array_push($files,$file);
}
} }
return $files; return $files;