widget only

This commit is contained in:
afornerot 2019-12-18 14:54:21 +01:00
parent 4d7d0fd82b
commit 1d0628ea03
4 changed files with 88 additions and 63 deletions

View File

@ -501,6 +501,13 @@ class GroupController extends Controller
if($group->getFgAll()||$group->getFgtemplate()) if($group->getFgAll()||$group->getFgtemplate())
throw $this->createNotFoundException('Permission denied'); throw $this->createNotFoundException('Permission denied');
$usergroup = $em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(array("user"=>$userid,"group"=>$groupid));
if($usergroup) {
$response = new Response(json_encode($output));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
$key = Uuid::uuid4(); $key = Uuid::uuid4();
$usergroup=new Usergroup; $usergroup=new Usergroup;
$user=$em->getRepository("CadolesCoreBundle:User")->find($userid); $user=$em->getRepository("CadolesCoreBundle:User")->find($userid);

View File

@ -2129,15 +2129,18 @@ class PagewidgetController extends Controller
if(!$cansee) throw $this->createNotFoundException('Permission denied'); if(!$cansee) throw $this->createNotFoundException('Permission denied');
} }
$onlyservice = $this->container->get('cadoles.portal.service.only'); $onlyservice = $this->container->get('cadoles.portal.service.only');
$files=$onlyservice->getDocument($group, $folders, $firstfolder); $files=$onlyservice->getDocument($group, $folders, $firstfolder, $tasks);
$idonly=$em->getRepository("CadolesCoreBundle:Group")->find($group)->getIdOnlyoffice();
// Render // Render
return $this->render($this->labelentity.':viewonlydoc.html.twig', [ return $this->render($this->labelentity.':viewonlydoc.html.twig', [
'entity' => $entity, 'entity' => $entity,
'canadd' => $canupdate, 'canadd' => $cansee,
'canupdate' => $canupdate, 'canupdate' => $cansee,
'firstfolder' => $firstfolder, 'firstfolder' => $firstfolder,
'folders' => $folders, 'folders' => $folders,
'tasks' => $tasks,
'urlonly' => $this->getParameter("widonlyoffice_url")."/products/projects/projects.aspx?prjID=".$idonly,
'files' => $files, 'files' => $files,
'access' => $access, 'access' => $access,
]); ]);

View File

@ -33,7 +33,7 @@
{% endif %} {% endif %}
{% if canadd %} {% 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> <a style="{{ stylewidgetmenu }}" href="{{urlonly}}" target="_blank" title='Plus de fonctionnalités'><i class="fa fa-plus fa-fw"></i></a>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
@ -51,42 +51,24 @@
{% if files|length >= 1 or canupdate %} {% if files|length >= 1 or canupdate %}
<div class="widgetbody" style="{{ stylewidgetbody }}"> <div class="widgetbody" style="{{ stylewidgetbody }}">
<div class="grid clearfix"> <div class="grid clearfix">
{% if canupdate %}
<div class="grid-sizer grid-small"></div> <div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div> <div class="grid-gutter-sizer"></div>
{% endif %}
{% for file in files|sort %}
{% if loop.index==1 and not canupdate%}
<div class="grid-sizer grid-small"></div>
<div class="grid-gutter-sizer"></div>
{% endif %}
{% for file in files %}
<div class="grid-item grid-small"> <div class="grid-item grid-small">
<div class="grid-item-content"> <div class="grid-item-content">
{% if canadd %} <a href="{{ file.webUrl }}" target="_blank">
<a style="color:#{{colorbodyfont}}; cursor:pointer" onClick="delFile('widget-{{ entity.id}}','{{file.name }}')" class="item-delete">
<i style="color:#{{colorbodyfont}}" class="fa fa-trash" title="Supprimer le fichier"></i>
</a>
{% endif %}
{% if file.minefamily=="text" or file.minefamily=="image" or file.minetype == "application/pdf" %}
<a style="cursor:pointer" onClick="showFrameitem('file-{{entity.id}}-{{loop.index}}','{{ path('cadoles_core_'~access~'_file_view',{'directory':'widget-'~entity.id,'filename':file.name }) }}')">
{% else %}
<a style="cursor:pointer" href="{{ path('cadoles_core_'~access~'_file_download',{'directory':'widget-'~entity.id,'filename':file.name }) }}">
{% endif %}
<div class="item-link clearfix"> <div class="item-link clearfix">
<div class="grid-item-logo"> <div class="grid-item-logo">
{% if file.thumb is not empty %} {% 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.thumb }}"> <img class="grid-item-img" height="110" src="{{file.viewUrl}}">
{% else %} {% else %}
<img class="grid-item-img" height="110" src="/{{ alias }}/bundles/cadolescore/images/files/{{ file.fileExst | replace({".":""})}}.png">
<img class="grid-item-img" height="110" src="/{{ alias }}/bundles/cadolescore/images/files/_blank.png">
{% endif %} {% endif %}
</div> </div>
<div class="grid-item-title"> <div class="grid-item-title">
<h2 style="color:#{{colorbodyfont}}">{{ file.name }}</h2> <h2 style="color:#{{colorbodyfont}}">{{ file.title }}</h2>
</div> </div>
</div> </div>
</a> </a>
@ -96,19 +78,37 @@
{% if canadd %} {% if canadd %}
<div class="grid-item grid-small"> <div class="grid-item grid-small">
<div 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' class="grid-item-content" style="background-color: #{{color['main']}};cursor:pointer;"> <div class="grid-item-content">
<a href="{{urlonly}}" target="_blank" title='Plus de fonctionnalités'>
<div class="item-link clearfix"> <div class="item-link clearfix">
<div class="grid-item-logo"> <div class="grid-item-logo">
<img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_add.png"> <img class="grid-item-img" height="110" src="/{{ alias }}/uploads/icon/icon_add.png">
</div> </div>
<div class="grid-item-title"> <div class="grid-item-title">
<h2>Ajouter un fichier</h2> <h2>Plus</h2>
</div> </div>
</div> </div>
</a>
</div> </div>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% if not tasks is empty %}
<div style='width:90%; margin:auto;'>
<h4 style='margin-bottom:5px;border-bottom:1px solid;'>Tâches</h4>
{% 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 %}
</div>
{% endif %}
</div> </div>
{% endif %} {% endif %}
</div> </div>

View File

@ -4,6 +4,7 @@ namespace Cadoles\PortalBundle\Service;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
class onlyService class onlyService
@ -35,18 +36,21 @@ class onlyService
} }
} }
public function getDocument($idproject,&$folders,&$firstfolder) { public function getDocument($idgroup,&$folders,&$firstfolder,&$tasks) {
$files=[]; $files=[];
$folders=[]; $folders=[];
$tasks=[];
$group=$this->em->getRepository("CadolesCoreBundle:Group")->find($idgroup);
if($group&&$group->getIdonlyoffice()) {
if($this->only_activate) { if($this->only_activate) {
if($this->authOnly()) { if($this->authOnly()) {
$response = \Unirest\Request::get($this->only_url.'/project/'.$idproject,$this->headers); $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers);
if($this->koresponse($response)) return false; if(!$this->koresponse($response)) {
$firstfolder=$response->body->response->projectFolder;; $firstfolder=$response->body->response->projectFolder;;
$response = \Unirest\Request::get($this->only_url.'/project/'.$idproject.'/files',$this->headers); $response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/files',$this->headers);
if($this->koresponse($response)) return 0; if(!$this->koresponse($response)) {
foreach($response->body->response->files as $fileonly) { foreach($response->body->response->files as $fileonly) {
array_push($files,$fileonly); array_push($files,$fileonly);
} }
@ -57,6 +61,13 @@ class onlyService
array_push($files,$file); array_push($files,$file);
} }
} }
$response = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/task/open',$this->headers);
error_log($this->only_url.'/project/'.$group->getIdonlyoffice().'/tasks/open');
if(!$this->koresponse($response)) $tasks=$response->body->response;
}
}
}
} }
} }
@ -103,6 +114,10 @@ class onlyService
return false; return false;
} }
private function mydebug($texte) {
if($this->debug) error_log($texte);
}
private function scanfolder($folderid,&$folders,$headers) { private function scanfolder($folderid,&$folders,$headers) {
$files=[]; $files=[];
$response = \Unirest\Request::get($this->only_url.'/files/'.$folderid,$headers); $response = \Unirest\Request::get($this->only_url.'/files/'.$folderid,$headers);