Skip to content

Commit

Permalink
removes obsolete composer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Dec 17, 2020
1 parent 3e73d75 commit 7b1b832
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 217 deletions.
19 changes: 8 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "claroline/distribution",
"description": "Claroline distribution",
"keywords": ["Claroline", "Distribution"],
"name": "claroline/Claroline",
"description": "Claroline Learning Management System",
"keywords": ["Claroline", "LMS"],
"homepage": "http://www.claroline.net",
"type": "claroline-core",
"license": "GPL-3.0-or-later",
"authors": [{
"name": "Claroline development team",
Expand Down Expand Up @@ -36,7 +35,8 @@
"jdorn/sql-formatter": "1.2.17",
"lightsaml/sp-bundle": "1.2.1",
"lightsaml/lightsaml-logout": "1.0.0",
"meyfa/php-svg": "0.8.0",
"php-http/httplug-bundle": "*",
"php-http/guzzle6-adapter":"*",
"postal/postal": "1.0",
"psr/log": "1.0.2",
"ramsey/uuid": "3.7.3",
Expand All @@ -59,9 +59,11 @@
"symfony/filesystem": "4.4.*",
"symfony/finder": "4.4.*",
"symfony/framework-bundle": "4.4.*",
"symfony/google-mailer": "4.4.*",
"symfony/http-client": "4.4.*",
"symfony/inflector": "4.4.*",
"symfony/intl": "4.4.*",
"symfony/mailer": "4.4.*",
"symfony/monolog-bridge": "4.4.*",
"symfony/process": "4.4.*",
"symfony/routing": "4.4.*",
Expand All @@ -77,12 +79,7 @@
"symfony/web-profiler-bundle": "4.4.*",
"symfony/yaml": "4.4.*",
"twig/twig": "^2.14",
"u01jmg3/ics-parser": "2.1.3",
"willdurand/js-translation-bundle": "3.0.*",
"php-http/httplug-bundle": "*",
"php-http/guzzle6-adapter":"*",
"symfony/google-mailer": "4.4.*",
"symfony/mailer": "4.4.*"
"willdurand/js-translation-bundle": "3.0.*"
},
"require-dev": {
"symfony/dom-crawler": "4.4.*",
Expand Down
50 changes: 0 additions & 50 deletions src/plugin/agenda/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,56 +142,6 @@ public function markTodoAction(Request $request)
}, $tasks));
}

/**
* @Route("/download", name="apiv2_download_agenda", methods={"GET"})
*
* @return StreamedResponse
*/
public function exportAction(Request $request)
{
$id = $request->query->get('workspace');
$file = $this->manager->export($id);

$response = new StreamedResponse();

$response->setCallBack(
function () use ($file) {
readfile($file);
}
);

$workspace = $this->om->getRepository(Workspace::class)->find($id);
$name = $workspace ? $workspace->getName() : 'desktop';
$response->headers->set('Content-Transfer-Encoding', 'octet-stream');
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-Disposition', 'attachment; filename='.$name.'.ics');
$response->headers->set('Content-Type', ' text/calendar');
$response->headers->set('Connection', 'close');

return $response;
}

/**
* @Route("/import", name="apiv2_event_import", methods={"POST"})
*
* @return JsonResponse
*/
public function importAction(Request $request)
{
$data = json_decode($request->getContent(), true);
$file = $data['file'];
$workspace = $data['workspace'];
$workspace = $workspace['id'] ? $this->om->getObject($workspace, Workspace::class) : null;
$fileEntity = $this->om->getObject($file, PublicFile::class) ?? new PublicFile();
$file = $this->serializer->deserialize($file, $fileEntity);
$fileData = $this->fileUtils->getContents($file);
$events = $this->manager->import($fileData, $workspace);

return new JsonResponse(array_map(function (Event $event) {
return $this->serializer->serialize($event);
}, $events));
}

private function checkPermission(Event $event)
{
if (false === $event->isEditable()) {
Expand Down
98 changes: 2 additions & 96 deletions src/plugin/agenda/Manager/AgendaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
use Claroline\CoreBundle\Entity\Workspace\Workspace;
use Claroline\CoreBundle\Event\SendMessageEvent;
use Claroline\CoreBundle\Manager\RoleManager;
use ICal\ICal;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class AgendaManager
{
Expand All @@ -39,7 +37,7 @@ class AgendaManager

public function __construct(
ObjectManager $om,
$projectDir,
string $projectDir,
TokenStorageInterface $tokenStorage,
AuthorizationCheckerInterface $authorization,
RoleManager $rm,
Expand Down Expand Up @@ -107,98 +105,6 @@ public function sendInvitation(Event $event, array $users = [])
$dispatcher->dispatch($message, 'claroline_message_sending_to_users');
}

/**
* @param $workspaceId
*
* @return list of Events
*/
public function export($workspaceId = null)
{
$repo = $this->om->getRepository('ClarolineAgendaBundle:Event');
$workspace = $this->om->getRepository('ClarolineCoreBundle:Workspace\Workspace')->find($workspaceId);

if ($workspace) {
$listEvents = $repo->findByWorkspaceId($workspaceId, false);
} else {
$usr = $this->tokenStorage->getToken()->getUser();
$listDesktop = $repo->findDesktop($usr, false);
$listEventsU = $repo->findByUser($usr, false);
$listEvents = array_merge($listEventsU, $listDesktop);
}

$calendar = $this->writeCalendar($listEvents);
$fileName = $this->writeToICS($calendar, $workspace);

return $fileName;
}

/**
* @param string $text it's the calendar text formatted in ics structure
* @param Workspace $workspace
*
* @return string $fileName path to the file in public/uploads folder
*/
public function writeToICS($text, $workspace)
{
$name = is_null($workspace) ? 'desktop' : $workspace->getName();
$fileName = $this->projectDir.'/public/uploads/'.$name.'.ics';
file_put_contents($fileName, $text);

return $fileName;
}

/**
* Imports ical files.
*
* @param UploadedFile $fileData
* @param Workspace $workspace
*
* @return Event[]
*/
public function import($fileData, $workspace = null)
{
$ical = new ICal($fileData);
$events = $ical->events();
$entities = [];

foreach ($events as $event) {
$e = new Event();
$e->setTitle($event->summary);
$e->setStart($ical->iCalDateToUnixTimestamp($event->dtstart));
$e->setEnd($ical->iCalDateToUnixTimestamp($event->dtend));
$e->setDescription($event->description);
if ($workspace) {
$e->setWorkspace($workspace);
}
$e->setUser($this->tokenStorage->getToken()->getUser());
$e->setPriority('#01A9DB');
$this->om->persist($e);

$entities[] = $e;
}

$this->om->flush();

return $entities;
}

/**
* @return string view in ics format
*/
private function writeCalendar(array $events)
{
$date = new \Datetime();
$tz = $date->getTimezone();

return $this->container->get('twig')->render(
'@ClarolineAgenda/ics_calendar.ics.twig',
[
'tzName' => $tz->getName(),
'events' => $events,
]
);
}

public function checkOpenAccess(Workspace $workspace)
{
if (!$this->authorization->isGranted('agenda', $workspace)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, {createElement} from 'react'
import {PropTypes as T} from 'prop-types'
import moment from 'moment'
import get from 'lodash/get'
import isEmpty from 'lodash/isEmpty'

import {trans} from '#/main/app/intl/translation'
import {Routes} from '#/main/app/router'
import {now} from '#/main/app/intl/date'
import {CALLBACK_BUTTON, LINK_BUTTON, MENU_BUTTON, MODAL_BUTTON, URL_BUTTON} from '#/main/app/buttons'
import {CALLBACK_BUTTON, LINK_BUTTON, MENU_BUTTON, MODAL_BUTTON} from '#/main/app/buttons'
import {ToolPage} from '#/main/core/tool/containers/page'

import {Event as EventTypes} from '#/plugin/agenda/event/prop-types'
Expand Down Expand Up @@ -78,22 +77,6 @@ const AgendaTool = (props) => {
modal: [MODAL_AGENDA_PARAMETERS],
group: trans('management'),
displayed: false // TODO : implement
}, {
name: 'import',
type: CALLBACK_BUTTON,
icon: 'fa fa-fw fa-upload',
label: trans('import', {}, 'actions'),
callback: () => props.import(null, props.contextData),
group: trans('transfer'),
displayed: false // TODO : implement
}, {
name: 'export',
type: URL_BUTTON,
icon: 'fa fa-fw fa-download',
label: trans('export', {}, 'actions'),
target: ['apiv2_download_agenda', {workspace: get(props.contextData, 'id')}],
group: trans('transfer'),
displayed: false // TODO : implement
}
]}
>
Expand Down Expand Up @@ -214,7 +197,6 @@ AgendaTool.propTypes = {
delete: T.func.isRequired,
markDone: T.func.isRequired,
markTodo: T.func.isRequired,
import: T.func.isRequired,

loadEvent: T.func.isRequired,
currentEvent: T.shape(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ const AgendaTool = withRouter(
},
markTodo(event) {
dispatch(actions.markTodo(event))
},
import(data, workspace = null) {
dispatch(actions.import(data, workspace))
}
})
)(AgendaToolComponent)
Expand Down
17 changes: 0 additions & 17 deletions src/plugin/agenda/Resources/modules/tools/agenda/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,3 @@ actions.markTodo = (event) => ({
success: (response, dispatch) => dispatch(actions.setLoaded(false))
}
})

actions.import = (data, workspace = null, calendarRef) => ({
[API_REQUEST]: {
url: ['apiv2_event_import'],
request: {
body :JSON.stringify({
file: { id: data.file.id },
workspace: { id: workspace.id || null }
}),
method: 'POST'
},
success: (events) => {
calendarRef.fullCalendar('addEventSource', events)
calendarRef.fullCalendar('refetchEvents')
}
}
})
21 changes: 0 additions & 21 deletions src/plugin/agenda/Resources/views/ics_calendar.ics.twig

This file was deleted.

0 comments on commit 7b1b832

Please # to comment.