mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2012 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Controller\Prod;
|
|
|
|
use Silex\Application;
|
|
use Silex\ControllerProviderInterface;
|
|
use Silex\ControllerCollection;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
|
|
|
/**
|
|
*
|
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
* @link www.phraseanet.com
|
|
*/
|
|
class MoveCollection implements ControllerProviderInterface
|
|
{
|
|
|
|
public function connect(Application $app)
|
|
{
|
|
$controllers = $app['controllers_factory'];
|
|
|
|
$controllers->post('/', function(Application $app, Request $request) {
|
|
$request = $app['request'];
|
|
$move = new RecordHelper\MoveCollection($app['phraseanet.core'], $app['request']);
|
|
$move->propose();
|
|
|
|
return $app['twig']->render('prod/actions/collection_default.html.twig', array('action' => $move, 'message' => ''));
|
|
}
|
|
);
|
|
|
|
$controllers->post('/apply/', function(Application $app, Request $request) {
|
|
$move = new RecordHelper\MoveCollection($app['phraseanet.core'], $request);
|
|
$success = false;
|
|
|
|
try {
|
|
$move->execute();
|
|
$success = true;
|
|
$msg = _('Records have been successfuly moved');
|
|
} catch (\Exception_Unauthorized $e) {
|
|
$msg = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination()));
|
|
} catch (\Exception $e) {
|
|
$msg = _('An error occured');
|
|
}
|
|
|
|
$datas = array(
|
|
'success' => $success,
|
|
'message' => $msg
|
|
);
|
|
|
|
return new JsonResponse($datas);
|
|
});
|
|
|
|
return $controllers;
|
|
}
|
|
}
|