From 065f64bd478b0e8bfced770ebe25f578623a8998 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Mon, 9 Feb 2015 13:42:26 +0100 Subject: [PATCH] Report previous patches --- bin/console | 3 -- composer.json | 3 +- lib/Alchemy/Phrasea/Controller/Api/V1.php | 30 +++++++++++++++++-- .../Phrasea/Model/Manager/UserManager.php | 15 ++++++++++ .../Repositories/ApiAccountRepository.php | 9 ++++++ .../Phrasea/TaskManager/Job/BridgeJob.php | 1 + lib/classes/patch/320alpha4b.php | 1 - 7 files changed, 55 insertions(+), 7 deletions(-) diff --git a/bin/console b/bin/console index b537608c86..d47a71301e 100755 --- a/bin/console +++ b/bin/console @@ -11,14 +11,11 @@ namespace KonsoleKommander; - use Alchemy\Phrasea\Command\BuildSubdefs; use Alchemy\Phrasea\Command\Plugin\ListPlugin; use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper; use Alchemy\Phrasea\Command\Setup\H264MappingGenerator; use Alchemy\Phrasea\Command\Setup\StaticConfigurationDumper; -use Alchemy\Phrasea\Command\SearchEngine\IndexFull; -use Alchemy\Phrasea\Command\WebsocketServer; use Alchemy\Phrasea\Core\Version; use Alchemy\Phrasea\Command\BuildMissingSubdefs; use Alchemy\Phrasea\Command\CreateCollection; diff --git a/composer.json b/composer.json index 59c74d4322..f145b508b5 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,8 @@ "alchemy/geonames-api-consumer" : "~0.1.0", "goodby/csv" : "~1.0", "guzzle/guzzle" : "~3.0", - "imagine/imagine" : "dev-alchemy-0.6.2 as 0.6.2","igorw/get-in" : "~1.0", + "imagine/imagine" : "dev-alchemy-0.6.2 as 0.6.2", + "igorw/get-in" : "~1.0", "ircmaxell/random-lib" : "~1.0", "jms/serializer" : "~0.10", "jms/translation-bundle" : "~1.1", diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php index 6478ac8d1b..e110843190 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php @@ -555,7 +555,8 @@ class V1 implements ControllerProviderInterface return $this->getBadRequest($app, $request, sprintf('Invalid forceBehavior value `%s`', $request->get('forceBehavior'))); } - $app['border-manager']->process($session, $Package, $callback, $behavior); + $nosubdef = $request->get('nosubdefs')==='' || \p4field::isyes($request->get('nosubdefs')); + $app['border-manager']->process($session, $Package, $callback, $behavior, $nosubdef); $ret = ['entity' => null,]; @@ -1325,13 +1326,38 @@ class V1 implements ControllerProviderInterface } } + if($media->get_name() != 'document') { + $databox = $record->get_databox(); + try { + $subDefDefinition = $databox->get_subdef_structure()->get_subdef($record->get_type(), $media->get_name()); + } catch (\Exception_Databox_SubdefNotFound $e) { + return null; + } + } + + if ($media->get_name() != 'document' && false === $subDefDefinition->is_downloadable()) { + return null; + } + if ($media->get_permalink() instanceof \media_Permalink_Adapter) { $permalink = $this->list_permalink($media->get_permalink()); } else { $permalink = null; } - return ['name' => $media->get_name(), 'permalink' => $permalink, 'height' => $media->get_height(), 'width' => $media->get_width(), 'filesize' => $media->get_size(), 'devices' => $media->getDevices(), 'player_type' => $media->get_type(), 'mime_type' => $media->get_mime(),]; + return [ + 'name' => $media->get_name(), + 'permalink' => $permalink, + 'height' => $media->get_height(), + 'width' => $media->get_width(), + 'filesize' => $media->get_size(), + 'devices' => $media->getDevices(), + 'player_type' => $media->get_type(), + 'mime_type' => $media->get_mime(), + 'substituted' => $media->is_substituted(), + 'created_on' => $media->get_creation_date()->format(DATE_ATOM), + 'updated_on' => $media->get_modification_date()->format(DATE_ATOM), + ]; } /** diff --git a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php index 731ac865a3..eb44ee1349 100644 --- a/lib/Alchemy/Phrasea/Model/Manager/UserManager.php +++ b/lib/Alchemy/Phrasea/Model/Manager/UserManager.php @@ -217,6 +217,7 @@ class UserManager $this->cleanFtpExports($user); $this->cleanAuthProvider($user); $this->cleanUserSessions($user); + $this->cleanOauthApplication($user); } /** @@ -235,4 +236,18 @@ class UserManager $stmt->closeCursor(); } } + private function cleanOauthApplication(User $user) + { + $accounts = $this->objectManager->getRepository('Phraseanet:ApiAccount')->findByUser($user); + + foreach ($accounts as $account) { + $this->objectManager->remove($account); + } + + $apps = $this->objectManager->getRepository('Phraseanet:ApiApplication')->findByCreator($user); + + foreach ($apps as $app) { + $this->objectManager->remove($app); + } + } } diff --git a/lib/Alchemy/Phrasea/Model/Repositories/ApiAccountRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/ApiAccountRepository.php index 2bc3036d1b..99e22e0ed9 100644 --- a/lib/Alchemy/Phrasea/Model/Repositories/ApiAccountRepository.php +++ b/lib/Alchemy/Phrasea/Model/Repositories/ApiAccountRepository.php @@ -24,4 +24,13 @@ class ApiAccountRepository extends EntityRepository return $qb->getQuery()->getOneOrNullResult(); } + + public function findByUser(User $user) + { + $qb = $this->createQueryBuilder('acc'); + $qb->where($qb->expr()->eq('acc.user', ':user')); + $qb->setParameter(':user', $user); + + return $qb->getQuery()->getResult(); + } } diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php index 1f0fefcc14..dfc60cc1c1 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php +++ b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php @@ -118,6 +118,7 @@ class BridgeJob extends AbstractJob try { $dist_id = $account->get_api()->upload($element->get_record(), $element->get_datas()); $element->set_uploaded_on(new \DateTime()); + $element->set_status(\Bridge_Element::STATUS_DONE); } catch (\Exception $e) { $this->log('debug', 'Error while uploading : ' . $e->getMessage()); $element->set_status(\Bridge_Element::STATUS_ERROR); diff --git a/lib/classes/patch/320alpha4b.php b/lib/classes/patch/320alpha4b.php index e728cda731..1758b0a9c8 100644 --- a/lib/classes/patch/320alpha4b.php +++ b/lib/classes/patch/320alpha4b.php @@ -89,7 +89,6 @@ class patch_320alpha4b extends patchAbstract if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) { continue; } - $feed = $this->get_feed($appbox, $user, $row['pub_restrict'], $row['homelink'], $app); $feed = $this->get_feed($app, $appbox, $user, $row['pub_restrict'], $row['homelink']);