widget only
This commit is contained in:
parent
e124f3617d
commit
4d7d0fd82b
|
@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
|
||||||
(-100, 'DRAAF', '130007107');
|
(-100, 'DRAAF', '130007107');
|
||||||
|
|
||||||
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
|
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
|
||||||
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}hTAPycxp8kXFhZIjteFA4fsB2CQcIenW
|
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}Kvz21GjhkryG4l7EKniMJzVfwDufa+eI
|
||||||
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
|
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ class InitDataCommand extends ContainerAwareCommand
|
||||||
$activate_widmindmaps = $this->getContainer()->getParameter('activate_widmindmaps');
|
$activate_widmindmaps = $this->getContainer()->getParameter('activate_widmindmaps');
|
||||||
$activate_widmoodle = $this->getContainer()->getParameter('activate_widmoodle');
|
$activate_widmoodle = $this->getContainer()->getParameter('activate_widmoodle');
|
||||||
$activate_widnextcloud = $this->getContainer()->getParameter('activate_widnextcloud');
|
$activate_widnextcloud = $this->getContainer()->getParameter('activate_widnextcloud');
|
||||||
|
$activate_widonlyoffice = $this->getContainer()->getParameter('activate_widonlyoffice');
|
||||||
$activate_widopensondage = $this->getContainer()->getParameter('activate_widopensondage');
|
$activate_widopensondage = $this->getContainer()->getParameter('activate_widopensondage');
|
||||||
$activate_widphpldapadmin = $this->getContainer()->getParameter('activate_widphpldapadmin');
|
$activate_widphpldapadmin = $this->getContainer()->getParameter('activate_widphpldapadmin');
|
||||||
$activate_widpiwik = $this->getContainer()->getParameter('activate_widpiwik');
|
$activate_widpiwik = $this->getContainer()->getParameter('activate_widpiwik');
|
||||||
|
@ -58,6 +59,8 @@ class InitDataCommand extends ContainerAwareCommand
|
||||||
$activate_widsacoche = $this->getContainer()->getParameter('activate_widsacoche');
|
$activate_widsacoche = $this->getContainer()->getParameter('activate_widsacoche');
|
||||||
$activate_widwordpress = $this->getContainer()->getParameter('activate_widwordpress');
|
$activate_widwordpress = $this->getContainer()->getParameter('activate_widwordpress');
|
||||||
$activate_websocket = $this->getContainer()->getParameter('websocket_activate');
|
$activate_websocket = $this->getContainer()->getParameter('websocket_activate');
|
||||||
|
|
||||||
|
$widonlyoffice_sync = $this->getContainer()->getParameter('widonlyoffice_sync');
|
||||||
|
|
||||||
$output->writeln('PORTAL = Default Data');
|
$output->writeln('PORTAL = Default Data');
|
||||||
|
|
||||||
|
@ -530,7 +533,29 @@ class InitDataCommand extends ContainerAwareCommand
|
||||||
$entityItem->setUrl($widnextcloud_url);
|
$entityItem->setUrl($widnextcloud_url);
|
||||||
$em->persist($entityItem);
|
$em->persist($entityItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Item Onlyoffice
|
||||||
|
if($activate_widonlyoffice) {
|
||||||
|
$widonlyoffice_url =$this->getContainer()->getParameter('widonlyoffice_url');
|
||||||
|
$entityItem = $em->getRepository('CadolesPortalBundle:Item')->find(-1000);
|
||||||
|
if(!$entityItem) {
|
||||||
|
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_onlyoffice.png"]);
|
||||||
|
|
||||||
|
$entityItem = new Item();
|
||||||
|
$entityItem->setId(-1000);
|
||||||
|
$entityItem->setRowOrder(0);
|
||||||
|
$entityItem->setTitle('Onlyoffice');
|
||||||
|
$entityItem->SetSubtitle("Application Bureautique");
|
||||||
|
$entityItem->setIcon($entityicon);
|
||||||
|
$entityItem->setTarget("_blank");
|
||||||
|
$entityItem->setItemcategory($entityItemcategoryapp);
|
||||||
|
$entityItem->setEssential(true);
|
||||||
|
$entityItem->addGroup($groupall);
|
||||||
|
}
|
||||||
|
$entityItem->setUrl($widonlyoffice_url);
|
||||||
|
$em->persist($entityItem);
|
||||||
|
}
|
||||||
|
|
||||||
// Item Opensondage
|
// Item Opensondage
|
||||||
if($activate_widopensondage) {
|
if($activate_widopensondage) {
|
||||||
$widopensondage_url =$this->getContainer()->getParameter('widopensondage_url');
|
$widopensondage_url =$this->getContainer()->getParameter('widopensondage_url');
|
||||||
|
@ -1059,6 +1084,30 @@ class InitDataCommand extends ContainerAwareCommand
|
||||||
$entityWidget->setParameter($parameter);
|
$entityWidget->setParameter($parameter);
|
||||||
$em->persist($entityWidget);
|
$em->persist($entityWidget);
|
||||||
|
|
||||||
|
// Onlyoffice document
|
||||||
|
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1810);
|
||||||
|
if($widonlyoffice_sync) {
|
||||||
|
if(!$entityWidget) $entityWidget = new Widget();
|
||||||
|
$entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_onlyoffice.png"]);
|
||||||
|
$entityWidget->setId(-1810);
|
||||||
|
$entityWidget->setRoworder(2);
|
||||||
|
$entityWidget->setIcon($entityicon);
|
||||||
|
$entityWidget->setName('Documents Onlyoffice');
|
||||||
|
$entityWidget->setDescription("Les documents associés à votre groupe");
|
||||||
|
$entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_onlydoc");
|
||||||
|
$entityWidget->setHeight("630");
|
||||||
|
$entityWidget->setAutoajust(true);
|
||||||
|
$entityWidget->setBorder(false);
|
||||||
|
$entityWidget->setOpened(true);
|
||||||
|
$entityWidget->setAccess(["config","group"]);
|
||||||
|
$parameter = json_decode('{"fields": []}');
|
||||||
|
$entityWidget->setParameter($parameter);
|
||||||
|
$em->persist($entityWidget);
|
||||||
|
}
|
||||||
|
elseif($entityWidget) {
|
||||||
|
$em->remove($entityWidget);
|
||||||
|
}
|
||||||
|
|
||||||
// Widget Séparateur
|
// Widget Séparateur
|
||||||
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1600);
|
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1600);
|
||||||
if(!$entityWidget) $entityWidget = new Widget();
|
if(!$entityWidget) $entityWidget = new Widget();
|
||||||
|
|
|
@ -2107,7 +2107,41 @@ class PagewidgetController extends Controller
|
||||||
'nbarticle' => $nbarticle,
|
'nbarticle' => $nbarticle,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function viewOnlydocAction(Request $request,$id,$access="config") {
|
||||||
|
$usage=$request->query->get('usage');
|
||||||
|
$group=$request->query->get('group');
|
||||||
|
$user=$this->getUser();
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||||
|
if (!$entity) throw $this->createNotFoundException('Unable to find entity.');
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
if($access=="config") {
|
||||||
|
$canupdate = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// On s'assure que l'utilisateur à la permission de voir
|
||||||
|
$page=$entity->getPage();
|
||||||
|
$em->getRepository("CadolesPortalBundle:Page")->getPermission($this->getUser(),$page,$cansee,$canupdate);
|
||||||
|
if(!$cansee) throw $this->createNotFoundException('Permission denied');
|
||||||
|
}
|
||||||
|
$onlyservice = $this->container->get('cadoles.portal.service.only');
|
||||||
|
$files=$onlyservice->getDocument($group, $folders, $firstfolder);
|
||||||
|
|
||||||
|
// Render
|
||||||
|
return $this->render($this->labelentity.':viewonlydoc.html.twig', [
|
||||||
|
'entity' => $entity,
|
||||||
|
'canadd' => $canupdate,
|
||||||
|
'canupdate' => $canupdate,
|
||||||
|
'firstfolder' => $firstfolder,
|
||||||
|
'folders' => $folders,
|
||||||
|
'files' => $files,
|
||||||
|
'access' => $access,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -795,6 +795,10 @@ cadoles_portal_config_panelwidget_view_groupmessage:
|
||||||
path: /config/pagewidget/view/groupmessage/{id}
|
path: /config/pagewidget/view/groupmessage/{id}
|
||||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroupmessage, access: config }
|
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroupmessage, access: config }
|
||||||
|
|
||||||
|
cadoles_portal_config_panelwidget_view_onlydoc:
|
||||||
|
path: /config/pagewidget/view/onlydoc/{id}
|
||||||
|
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewonlydoc, access: config }
|
||||||
|
|
||||||
#-- Access user
|
#-- Access user
|
||||||
cadoles_portal_user_pagewidget_widget_sumbit:
|
cadoles_portal_user_pagewidget_widget_sumbit:
|
||||||
path: /user/pagewidget/submit/{idpage}/{idwidgettype}
|
path: /user/pagewidget/submit/{idpage}/{idwidgettype}
|
||||||
|
@ -904,3 +908,7 @@ cadoles_portal_user_panelwidget_view_groupmessage:
|
||||||
path: /pagewidget/view/groupmessage/{id}
|
path: /pagewidget/view/groupmessage/{id}
|
||||||
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroupmessage, access: user }
|
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewgroupmessage, access: user }
|
||||||
|
|
||||||
|
cadoles_portal_user_panelwidget_view_onlydoc:
|
||||||
|
path: /pagewidget/view/onlydoc/{id}
|
||||||
|
defaults: { _controller: CadolesPortalBundle:Pagewidget:viewonlydoc, access: user }
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,8 @@ services:
|
||||||
arguments: ['@service_container']
|
arguments: ['@service_container']
|
||||||
tags:
|
tags:
|
||||||
- { name: form.type }
|
- { name: form.type }
|
||||||
|
|
||||||
|
cadoles.portal.service.only:
|
||||||
|
public: true
|
||||||
|
class: Cadoles\PortalBundle\Service\onlyService
|
||||||
|
arguments: ['@service_container','@doctrine.orm.entity_manager']
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
{% set theme = app.session.get('theme') %}
|
||||||
|
{% if theme is not empty %}
|
||||||
|
{{ include('@Theme/'~theme~'/function.html.twig') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% import "@CadolesPortal/Pagewidget/constants.twig" as constants %}
|
||||||
|
|
||||||
|
{% set stylewidget = constants.mystylewidget(entity) %}
|
||||||
|
{% set stylewidgetmenu = constants.mystylewidgetmenu(entity) %}
|
||||||
|
{% set stylewidgetheader = constants.mystylewidgetheader(entity) %}
|
||||||
|
{% set stylewidgetbody = constants.mystylewidgetbody(entity) %}
|
||||||
|
{% set stylewidgetbodyreverse = constants.mystylewidgetbodyreverse(entity) %}
|
||||||
|
|
||||||
|
{% set color = app.session.get('color') %}
|
||||||
|
|
||||||
|
{% set colorbodyback = entity.colorbodyback %}
|
||||||
|
{% if colorbodyback is null %}
|
||||||
|
{% set colorbodyback = color['main'] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% set colorbodyfont = entity.colorbodyfont %}
|
||||||
|
{% if colorbodyfont is null %}
|
||||||
|
{% set colorbodyfont = color['fontcolorhover'] %}
|
||||||
|
{% 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">
|
||||||
|
{% if canupdate or canadd %}
|
||||||
|
<div class="widgetmenu">
|
||||||
|
{% if canupdate %}
|
||||||
|
<i class="fa fa-trash fa-fw" onClick="delWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||||
|
<i class="fa fa-file fa-fw" onClick="modWidget({{ entity.id }})" style="{{ stylewidgetmenu }}"></i>
|
||||||
|
{% 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>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="widgetheader" style="{{ stylewidgetheader }}">
|
||||||
|
{% if entity.icon %}
|
||||||
|
<img src="/{{ alias }}/{{ entity.icon.label }}" class="logo"/>
|
||||||
|
{% else %}
|
||||||
|
<img src="/{{ alias }}/uploads/icon/icon_pin.png" class="logo"/>
|
||||||
|
{% endif %}
|
||||||
|
<span class="title">{{ entity.name }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if files|length >= 1 or canupdate %}
|
||||||
|
<div class="widgetbody" style="{{ stylewidgetbody }}">
|
||||||
|
<div class="grid clearfix">
|
||||||
|
{% if canupdate %}
|
||||||
|
<div class="grid-sizer grid-small"></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 %}
|
||||||
|
|
||||||
|
<div class="grid-item grid-small">
|
||||||
|
<div class="grid-item-content">
|
||||||
|
{% if canadd %}
|
||||||
|
<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="grid-item-logo">
|
||||||
|
{% if file.thumb is not empty %}
|
||||||
|
<img class="grid-item-img" height="110" src="{{ file.thumb }}">
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<img class="grid-item-img" height="110" src="/{{ alias }}/bundles/cadolescore/images/files/_blank.png">
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid-item-title">
|
||||||
|
<h2 style="color:#{{colorbodyfont}}">{{ file.name }}</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if canadd %}
|
||||||
|
<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="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>Ajouter un fichier</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Cadoles\PortalBundle\Service;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
|
class onlyService
|
||||||
|
{
|
||||||
|
protected $container;
|
||||||
|
protected $em;
|
||||||
|
protected $only_activate = false;
|
||||||
|
protected $only_url;
|
||||||
|
protected $only_host;
|
||||||
|
protected $only_user;
|
||||||
|
protected $only_password;
|
||||||
|
protected $debug = false;
|
||||||
|
protected $headers = [];
|
||||||
|
|
||||||
|
public function __construct($container, EntityManager $em)
|
||||||
|
{
|
||||||
|
$this->container = $container;
|
||||||
|
$this->em = $em;
|
||||||
|
|
||||||
|
$this->only_activate = $this->container->getParameter('activate_widonlyoffice');
|
||||||
|
if($this->only_activate) {
|
||||||
|
$this->only_activate=$this->container->getParameter('widonlyoffice_sync');
|
||||||
|
if($this->only_activate) {
|
||||||
|
$this->only_url = $this->container->getParameter('widonlyoffice_url')."/api/2.0/";
|
||||||
|
$this->only_user = $this->container->getParameter('widonlyoffice_user');
|
||||||
|
$this->only_password = $this->container->getParameter('widonlyoffice_password');
|
||||||
|
$this->only_host = str_replace("https://","",str_replace("http://","",$this->container->getParameter("widonlyoffice_url")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocument($idproject,&$folders,&$firstfolder) {
|
||||||
|
$files=[];
|
||||||
|
$folders=[];
|
||||||
|
|
||||||
|
if($this->only_activate) {
|
||||||
|
if($this->authOnly()) {
|
||||||
|
$response = \Unirest\Request::get($this->only_url.'/project/'.$idproject,$this->headers);
|
||||||
|
if($this->koresponse($response)) return false;
|
||||||
|
$firstfolder=$response->body->response->projectFolder;;
|
||||||
|
|
||||||
|
$response = \Unirest\Request::get($this->only_url.'/project/'.$idproject.'/files',$this->headers);
|
||||||
|
if($this->koresponse($response)) return 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function authOnly() {
|
||||||
|
// Only Office est-il dans le domaine
|
||||||
|
if(stripos($this->only_url,"/")===0)
|
||||||
|
$this->only_url="https://".$this->container->getParameter("weburl").$this->only_url;
|
||||||
|
$indomaine = (stripos($this->only_url,$this->container->getParameter("weburl"))!==false);
|
||||||
|
|
||||||
|
// Si hors domaine on utilise le proxy si proxy il y a
|
||||||
|
if(!$indomaine) {
|
||||||
|
$PROXYactivate = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYactivate")->getValue();
|
||||||
|
if($PROXYactivate) {
|
||||||
|
$PROXYserver = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYserver")->getValue();
|
||||||
|
$PROXYport = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYport")->getValue();
|
||||||
|
\Unirest\Request::proxy($PROXYserver, $PROXYport, CURLPROXY_HTTP, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
\Unirest\Request::verifyPeer(false);
|
||||||
|
\Unirest\Request::verifyHost(false);
|
||||||
|
\Unirest\Request::timeout(5);
|
||||||
|
$this->headers = ['Host' => $this->only_host, 'Accept' => 'application/json','Content-Type'=>'application/json','Retry-After'=>'5'];
|
||||||
|
$query = array('userName' => $this->only_user, 'password' => $this->only_password);
|
||||||
|
$body = \Unirest\Request\Body::json($query);
|
||||||
|
|
||||||
|
$response = \Unirest\Request::post($this->only_url.'/authentication',$this->headers,$body);
|
||||||
|
if($this->koresponse($response)) return false;
|
||||||
|
$token=$response->body->response->token;
|
||||||
|
$this->headers["Authorization"]=$token;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function koresponse($response) {
|
||||||
|
if($response->code>=Response::HTTP_BAD_REQUEST) {
|
||||||
|
$this->mydebug("ERREUR ".$response->code);
|
||||||
|
if(property_exists($response,"body") && property_exists($response->body,"error")) $this->mydebug("ERREUR ".$response->body->error->message);;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function scanfolder($folderid,&$folders,$headers) {
|
||||||
|
$files=[];
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 9.6 KiB |
Loading…
Reference in New Issue