mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Merged with 3.5.1
This commit is contained in:
@@ -9,24 +9,26 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Silex\Application;
|
||||||
|
use Alchemy\Phrasea\Controller\Admin as Controller;
|
||||||
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Silex\Application;
|
|
||||||
|
|
||||||
return call_user_func(
|
return call_user_func(
|
||||||
function()
|
function()
|
||||||
{
|
{
|
||||||
$app = new Application();
|
$app = new Application();
|
||||||
|
|
||||||
$app->mount('/publications', new Controller_Admin_Publications());
|
$app->mount('/publications', new Controller\Publications());
|
||||||
$app->mount('/users', new Controller_Admin_Users());
|
$app->mount('/users', new Controller\Users());
|
||||||
$app->mount('/fields', new Controller_Admin_Fields());
|
$app->mount('/fields', new Controller\Fields());
|
||||||
$app->mount('/tests/connection', new Controller_Utils_ConnectionTest());
|
$app->mount('/tests/connection', new ControllerUtils\ConnectionTest());
|
||||||
$app->mount('/tests/pathurl', new Controller_Utils_PathFileTest());
|
$app->mount('/tests/pathurl', new ControllerUtils\PathFileTest());
|
||||||
|
|
||||||
$app->error(function(\Exception $e)
|
$app->error(function(\Exception $e)
|
||||||
{
|
{
|
738
lib/Alchemy/Phrasea/Application/Api.php
Normal file
738
lib/Alchemy/Phrasea/Application/Api.php
Normal file
@@ -0,0 +1,738 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../../../../lib/classes/API/OAuth2/Autoloader.class.php";
|
||||||
|
require_once __DIR__ . "/../../../../lib/bootstrap.php";
|
||||||
|
|
||||||
|
bootstrap::register_autoloads();
|
||||||
|
API_OAuth2_Autoloader::register();
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package APIv1
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
return call_user_func(function()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$app = new Silex\Application();
|
||||||
|
|
||||||
|
$app["appbox"] = appbox::get_instance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associated user to related token
|
||||||
|
* @var User_Adapter
|
||||||
|
*/
|
||||||
|
$app['p4user'] = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var API_OAuth2_Token
|
||||||
|
*/
|
||||||
|
$app['token'] = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Protected Closure
|
||||||
|
* @var Closure
|
||||||
|
* @return Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
$app['response'] = $app->protect(function ($result)
|
||||||
|
{
|
||||||
|
$response = new Response(
|
||||||
|
$result->format()
|
||||||
|
, $result->get_http_code()
|
||||||
|
, array('Content-Type' => $result->get_content_type())
|
||||||
|
);
|
||||||
|
$response->setCharset('UTF-8');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api Service
|
||||||
|
* @var Closure
|
||||||
|
*/
|
||||||
|
$app['api'] = function () use ($app)
|
||||||
|
{
|
||||||
|
return new API_V1_adapter(false, $app["appbox"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$parseRoute = function ($route, Response $response)
|
||||||
|
{
|
||||||
|
$ressource = $general = $aspect = $action = null;
|
||||||
|
$exploded_route = explode('/', p4string::delFirstSlash((p4string::delEndSlash($route))));
|
||||||
|
if (sizeof($exploded_route) > 0 && $response->isOk())
|
||||||
|
{
|
||||||
|
$ressource = $exploded_route[0];
|
||||||
|
|
||||||
|
if (sizeof($exploded_route) == 2 && (int) $exploded_route[1] == 0)
|
||||||
|
{
|
||||||
|
$general = $exploded_route[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch ($ressource)
|
||||||
|
{
|
||||||
|
case API_V1_Log::DATABOXES_RESSOURCE :
|
||||||
|
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
||||||
|
$aspect = $exploded_route[2];
|
||||||
|
break;
|
||||||
|
case API_V1_Log::RECORDS_RESSOURCE :
|
||||||
|
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 4)
|
||||||
|
{
|
||||||
|
if (!isset($exploded_route[3]))
|
||||||
|
$aspect = "record";
|
||||||
|
elseif (preg_match("/^set/", $exploded_route[3]))
|
||||||
|
$action = $exploded_route[3];
|
||||||
|
else
|
||||||
|
$aspect = $exploded_route[3];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case API_V1_Log::BASKETS_RESSOURCE :
|
||||||
|
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
||||||
|
{
|
||||||
|
if (preg_match("/^set/", $exploded_route[2]) || preg_match("/^delete/", $exploded_route[2]))
|
||||||
|
$action = $exploded_route[2];
|
||||||
|
else
|
||||||
|
$aspect = $exploded_route[2];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case API_V1_Log::FEEDS_RESSOURCE :
|
||||||
|
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
||||||
|
$aspect = $exploded_route[2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oAuth verification process
|
||||||
|
*/
|
||||||
|
$app->before(function($request) use ($app)
|
||||||
|
{
|
||||||
|
$session = $app["appbox"]->get_session();
|
||||||
|
$oauth2_adapter = new API_OAuth2_Adapter($app["appbox"]);
|
||||||
|
$oauth2_adapter->verifyAccessToken();
|
||||||
|
|
||||||
|
$app['p4user'] = User_Adapter::getInstance($oauth2_adapter->get_usr_id(), $app["appbox"]);
|
||||||
|
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
|
||||||
|
|
||||||
|
if ($session->is_authenticated())
|
||||||
|
return;
|
||||||
|
if ($oauth2_adapter->has_ses_id())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$session->restore($app['p4user'], $oauth2_adapter->get_ses_id());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$auth = new Session_Authentication_None($app['p4user']);
|
||||||
|
$session->authenticate($auth);
|
||||||
|
$oauth2_adapter->remember_this_ses_id($session->get_ses_id());
|
||||||
|
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oAUth log process
|
||||||
|
*/
|
||||||
|
$app->after(function (Request $request, Response $response) use ($app, $parseRoute)
|
||||||
|
{
|
||||||
|
$account = $app['token']->get_account();
|
||||||
|
$pathInfo = $request->getPathInfo();
|
||||||
|
$route = $parseRoute($pathInfo, $response);
|
||||||
|
$log = API_V1_Log::create(
|
||||||
|
$app["appbox"], $account, $request->getMethod() . " " . $pathInfo, $response->getStatusCode(), $response->headers->get('content-type'), $route['ressource'], $route['general'], $route['aspect'], $route['action']);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method Not Allowed Closure
|
||||||
|
*/
|
||||||
|
$bad_request_exception = function()
|
||||||
|
{
|
||||||
|
throw new API_V1_exception_badrequest();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *******************************************************************
|
||||||
|
* Route : /databoxes/list/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/databoxes/list/';
|
||||||
|
$app->get(
|
||||||
|
$route, function() use ($app)
|
||||||
|
{
|
||||||
|
return $app['response']($app['api']->get_databoxes($app['request']));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *******************************************************************
|
||||||
|
*
|
||||||
|
* Route /databoxes/DATABOX_ID/collections/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters ;
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
*/
|
||||||
|
$route = '/databoxes/{databox_id}/collections/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_databox_collections($app['request'], $databox_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/databoxes/{any_id}/collections/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *******************************************************************
|
||||||
|
* Route /databoxes/DATABOX_ID/status/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters ;
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/databoxes/{databox_id}/status/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_databox_status($app['request'], $databox_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/databoxes/{any_id}/status/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route /databoxes/DATABOX_ID/metadatas/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters ;
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
*/
|
||||||
|
$route = '/databoxes/{databox_id}/metadatas/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_databox_metadatas($app['request'], $databox_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/databoxes/{any_id}/metadatas/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route /databoxes/DATABOX_ID/termsOfUse/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters ;
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
*/
|
||||||
|
$route = '/databoxes/{databox_id}/termsOfUse/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_databox_terms($app['request'], $databox_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/databoxes/{any_id}/termsOfUse/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/search/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET or POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* bases[] : array
|
||||||
|
* status[] : array
|
||||||
|
* fields[] : array
|
||||||
|
* record_type : boolean
|
||||||
|
* media_type : string
|
||||||
|
*
|
||||||
|
* Response :
|
||||||
|
* Array of record objects
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/search/';
|
||||||
|
$app->post(
|
||||||
|
$route, function() use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->search_records($app['request']);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/metadatas/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_record_metadatas($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/metadatas/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/status/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/status/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_record_status($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/status/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/related/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/related/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_record_related($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/related/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/embed/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/embed/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_record_embed($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/embed/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/setmetadatas/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/setmetadatas/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->set_record_metadatas($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->post('/records/{any_id}/{anyother_id}/setmetadatas/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/setstatus/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/setstatus/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->set_record_status($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->post('/records/{any_id}/{anyother_id}/setstatus/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /records/DATABOX_ID/RECORD_ID/setcollection/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* DATABOX_ID : required INT
|
||||||
|
* RECORD_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/records/{databox_id}/{record_id}/setcollection/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->set_record_collection($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
$app->post('/records/{wrong_databox_id}/{wrong_record_id}/setcollection/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
$route = '/records/{databox_id}/{record_id}/';
|
||||||
|
$app->get($route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_record($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/list/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/list/';
|
||||||
|
$app->get(
|
||||||
|
$route, function() use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->search_baskets($app['request']);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/add/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/add/';
|
||||||
|
$app->post(
|
||||||
|
$route, function() use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->create_basket($app['request']);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/BASKET_ID/content/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* BASKET_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/{basket_id}/content/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($basket_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_basket($app['request'], $basket_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('basket_id', '\d+');
|
||||||
|
$app->get('/baskets/{wrong_basket_id}/content/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/BASKET_ID/settitle/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* BASKET_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/{basket_id}/setname/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($basket_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->set_basket_title($app['request'], $basket_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('basket_id', '\d+');
|
||||||
|
$app->post('/baskets/{wrong_basket_id}/setname/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/BASKET_ID/setdescription/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* BASKET_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/{basket_id}/setdescription/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($basket_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->set_basket_description($app['request'], $basket_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('basket_id', '\d+');
|
||||||
|
$app->post('/baskets/{wrong_basket_id}/setdescription/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /baskets/BASKET_ID/delete/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* BASKET_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$route = '/baskets/{basket_id}/delete/';
|
||||||
|
$app->post(
|
||||||
|
$route, function($basket_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->delete_basket($app['request'], $basket_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('basket_id', '\d+');
|
||||||
|
$app->post('/baskets/{wrong_basket_id}/delete/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /feeds/list/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : POST
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// public function search_publications(\Symfony\Component\HttpFoundation\Request $app['request']);
|
||||||
|
|
||||||
|
|
||||||
|
$route = '/feeds/list/';
|
||||||
|
$app->get(
|
||||||
|
$route, function() use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->search_publications($app['request'], $app['p4user']);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route : /feeds/PUBLICATION_ID/content/FORMAT/
|
||||||
|
*
|
||||||
|
* Method : GET
|
||||||
|
*
|
||||||
|
* Parameters :
|
||||||
|
* PUBLICATION_ID : required INT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// public function get_publication(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
|
||||||
|
|
||||||
|
$route = '/feeds/{feed_id}/content/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($feed_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->get_publication($app['request'], $feed_id, $app['p4user']);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('feed_id', '\d+');
|
||||||
|
$app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* *******************************************************************
|
||||||
|
*
|
||||||
|
* Route Errors
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$app->error(function (\Exception $e) use ($app)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($e instanceof API_V1_exception_methodnotallowed)
|
||||||
|
$code = API_V1_result::ERROR_METHODNOTALLOWED;
|
||||||
|
elseif ($e instanceof Exception\MethodNotAllowedHttpException)
|
||||||
|
$code = API_V1_result::ERROR_METHODNOTALLOWED;
|
||||||
|
elseif ($e instanceof API_V1_exception_badrequest)
|
||||||
|
$code = API_V1_result::ERROR_BAD_REQUEST;
|
||||||
|
elseif ($e instanceof API_V1_exception_forbidden)
|
||||||
|
$code = API_V1_result::ERROR_FORBIDDEN;
|
||||||
|
elseif ($e instanceof API_V1_exception_unauthorized)
|
||||||
|
$code = API_V1_result::ERROR_UNAUTHORIZED;
|
||||||
|
elseif ($e instanceof API_V1_exception_internalservererror)
|
||||||
|
$code = API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||||
|
// elseif ($e instanceof API_V1_exception_notfound)
|
||||||
|
// $code = API_V1_result::ERROR_NOTFOUND;
|
||||||
|
elseif ($e instanceof Exception_NotFound)
|
||||||
|
$code = API_V1_result::ERROR_NOTFOUND;
|
||||||
|
elseif ($e instanceof Exception\NotFoundHttpException)
|
||||||
|
$code = API_V1_result::ERROR_NOTFOUND;
|
||||||
|
else
|
||||||
|
$code = API_V1_result::ERROR_INTERNALSERVERERROR;
|
||||||
|
|
||||||
|
$result = $app['api']->get_error_message($app['request'], $code);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
});
|
||||||
|
//// public function get_version();
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// /**
|
||||||
|
//// * Route : /records/DATABOX_ID/RECORD_ID/addtobasket/FORMAT/
|
||||||
|
//// *
|
||||||
|
//// * Method : POST
|
||||||
|
//// *
|
||||||
|
//// * Parameters :
|
||||||
|
//// * DATABOX_ID : required INT
|
||||||
|
//// * RECORD_ID : required INT
|
||||||
|
//// *
|
||||||
|
//// */
|
||||||
|
//// public function add_record_tobasket(\Symfony\Component\HttpFoundation\Request $app['request'], $databox_id, $record_id);
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// /**
|
||||||
|
//// * Route : /feeds/PUBLICATION_ID/remove/FORMAT/
|
||||||
|
//// *
|
||||||
|
//// * Method : GET
|
||||||
|
//// *
|
||||||
|
//// * Parameters :
|
||||||
|
//// * PUBLICATION_ID : required INT
|
||||||
|
//// *
|
||||||
|
//// */
|
||||||
|
//// public function remove_publications(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
|
||||||
|
////
|
||||||
|
////
|
||||||
|
//// /**
|
||||||
|
//// * Route : /users/search/FORMAT/
|
||||||
|
//// *
|
||||||
|
//// * Method : POST-GET
|
||||||
|
//// *
|
||||||
|
//// * Parameters :
|
||||||
|
//// *
|
||||||
|
//// */
|
||||||
|
//// public function search_users(\Symfony\Component\HttpFoundation\Request $app['request']);
|
||||||
|
////
|
||||||
|
//// /**
|
||||||
|
//// * Route : /users/USER_ID/access/FORMAT/
|
||||||
|
//// *
|
||||||
|
//// * Method : GET
|
||||||
|
//// *
|
||||||
|
//// * Parameters :
|
||||||
|
//// * USER_ID : required INT
|
||||||
|
//// *
|
||||||
|
//// */
|
||||||
|
//// public function get_user_acces(\Symfony\Component\HttpFoundation\Request $app['request'], $usr_id);
|
||||||
|
////
|
||||||
|
//// /**
|
||||||
|
//// * Route : /users/add/FORMAT/
|
||||||
|
//// *
|
||||||
|
//// * Method : POST
|
||||||
|
//// *
|
||||||
|
//// * Parameters :
|
||||||
|
//// *
|
||||||
|
//// */
|
||||||
|
//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
|
||||||
|
return $app;
|
||||||
|
});
|
@@ -9,16 +9,17 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
|
|
||||||
return call_user_func(
|
return call_user_func(
|
||||||
function()
|
function()
|
||||||
@@ -361,6 +362,7 @@ return call_user_func(
|
|||||||
'releasable' => false,
|
'releasable' => false,
|
||||||
'datas' => _('Erreur lors de la mise a jour des donnes ')
|
'datas' => _('Erreur lors de la mise a jour des donnes ')
|
||||||
);
|
);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
@@ -9,6 +9,15 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../../../../lib/bootstrap.php";
|
||||||
|
require_once __DIR__ . "/../../../../lib/classes/API/OAuth2/Autoloader.class.php";
|
||||||
|
bootstrap::register_autoloads();
|
||||||
|
API_OAuth2_Autoloader::register();
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -20,14 +29,6 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
require_once dirname(__FILE__) . "/../../../../lib/bootstrap.php";
|
|
||||||
require_once dirname(__FILE__) . "/../../../../lib/classes/API/OAuth2/Autoloader.class.php";
|
|
||||||
bootstrap::register_autoloads();
|
|
||||||
API_OAuth2_Autoloader::register();
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
@@ -9,16 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
|
|
||||||
return call_user_func(
|
return call_user_func(
|
||||||
function()
|
function()
|
@@ -9,17 +9,17 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Silex\Application;
|
||||||
|
use Alchemy\Phrasea\Controller\Prod as Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Silex\Application;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Prod as Controller;
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
@@ -9,17 +9,19 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use Silex\Application;
|
||||||
|
use Alchemy\Phrasea\Controller\Root as Controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
||||||
use Silex\Application;
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
||||||
@@ -65,11 +67,8 @@ return call_user_func(function()
|
|||||||
return $response;
|
return $response;
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->mount('/feeds/', new Controller_RSSFeeds());
|
$app->mount('/feeds/', new Controller\RSSFeeds());
|
||||||
|
|
||||||
/**
|
|
||||||
* Mount all aps
|
|
||||||
*/
|
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
);
|
);
|
@@ -9,15 +9,18 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Silex\Application;
|
||||||
|
use Alchemy\Phrasea\Controller\Setup as Controller;
|
||||||
|
use Alchemy\Phrasea\Controller\Utils as ControllerUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Silex\Application;
|
|
||||||
|
|
||||||
return call_user_func(function()
|
return call_user_func(function()
|
||||||
{
|
{
|
||||||
@@ -55,10 +58,10 @@ return call_user_func(function()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$app->mount('/installer/', new Controller_Setup_Installer());
|
$app->mount('/installer/', new Controller\Installer());
|
||||||
$app->mount('/upgrader/', new Controller_Setup_Upgrader());
|
$app->mount('/upgrader/', new Controller\Upgrader());
|
||||||
$app->mount('/test', new Controller_Utils_PathFileTest());
|
$app->mount('/test', new ControllerUtils\PathFileTest());
|
||||||
$app->mount('/connection_test', new Controller_Utils_ConnectionTest());
|
$app->mount('/connection_test', new ControllerUtils\ConnectionTest());
|
||||||
|
|
||||||
$app->error(function($e) use ($app)
|
$app->error(function($e) use ($app)
|
||||||
{
|
{
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,12 +19,18 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_Admin_Fields implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Fields implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
// $session->close_storage();
|
// $session->close_storage();
|
||||||
|
|
||||||
@@ -40,14 +42,14 @@ class Controller_Admin_Fields implements ControllerProviderInterface
|
|||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$multi = ($request->get('multi') === 'true');
|
$multi = ($request->get('multi') === 'true');
|
||||||
|
|
||||||
$metadata = databox_field::load_class_from_xpath($request->get('source'));
|
$metadata = \databox_field::load_class_from_xpath($request->get('source'));
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'result' => ($multi === $metadata->is_multi())
|
'result' => ($multi === $metadata->is_multi())
|
||||||
, 'is_multi' => $metadata->is_multi()
|
, 'is_multi' => $metadata->is_multi()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(p4string::jsonencode($datas));
|
return new Response(\p4string::jsonencode($datas));
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/checkreadonly/', function() use ($app, $appbox)
|
$controllers->get('/checkreadonly/', function() use ($app, $appbox)
|
||||||
@@ -55,14 +57,14 @@ class Controller_Admin_Fields implements ControllerProviderInterface
|
|||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$readonly = ($request->get('readonly') === 'true');
|
$readonly = ($request->get('readonly') === 'true');
|
||||||
|
|
||||||
$metadata = databox_field::load_class_from_xpath($request->get('source'));
|
$metadata = \databox_field::load_class_from_xpath($request->get('source'));
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
'result' => ($readonly === $metadata->is_readonly())
|
'result' => ($readonly === $metadata->is_readonly())
|
||||||
, 'is_readonly' => $metadata->is_readonly()
|
, 'is_readonly' => $metadata->is_readonly()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(p4string::jsonencode($datas));
|
return new Response(\p4string::jsonencode($datas));
|
||||||
});
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,24 +19,30 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_Admin_Publications implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Publications implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
$controllers->get('/list/', function() use ($app, $appbox)
|
$controllers->get('/list/', function() use ($app, $appbox)
|
||||||
{
|
{
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
$feeds = Feed_Collection::load_all($appbox, $user);
|
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||||
|
|
||||||
$template = 'admin/publications/list.html';
|
$template = 'admin/publications/list.html';
|
||||||
|
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('formatdate' => 'phraseadate::getDate'));
|
$twig->addFilter(array('formatdate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
return $twig->render($template, array('feeds' => $feeds));
|
return $twig->render($template, array('feeds' => $feeds));
|
||||||
@@ -50,15 +52,15 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
$controllers->post('/create/', function() use ($app, $appbox)
|
$controllers->post('/create/', function() use ($app, $appbox)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$feed = Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle'));
|
$feed = \Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle'));
|
||||||
|
|
||||||
if($request->get('public') == '1')
|
if($request->get('public') == '1')
|
||||||
$feed->set_public (true);
|
$feed->set_public (true);
|
||||||
elseif ($request->get('base_id'))
|
elseif ($request->get('base_id'))
|
||||||
$feed->set_collection(collection::get_from_base_id($request->get('base_id')));
|
$feed->set_collection(\collection::get_from_base_id($request->get('base_id')));
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
||||||
});
|
});
|
||||||
@@ -66,11 +68,11 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox)
|
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
|
||||||
$template = 'admin/publications/fiche.html';
|
$template = 'admin/publications/fiche.html';
|
||||||
|
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(
|
$twig->addFilter(
|
||||||
array(
|
array(
|
||||||
'formatdate' => 'phraseadate::getDate'
|
'formatdate' => 'phraseadate::getDate'
|
||||||
@@ -89,8 +91,8 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
|
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if (!$feed->is_owner($user))
|
if (!$feed->is_owner($user))
|
||||||
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||||
@@ -99,9 +101,9 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$collection = collection::get_from_base_id($request->get('base_id'));
|
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$collection = null;
|
$collection = null;
|
||||||
}
|
}
|
||||||
@@ -117,8 +119,8 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
if (!$feed->is_owner($user))
|
if (!$feed->is_owner($user))
|
||||||
return new Response('ERROR:you are not allowed');
|
return new Response('ERROR:you are not allowed');
|
||||||
@@ -126,7 +128,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
if ($_FILES['Filedata']['error'] !== 0)
|
if ($_FILES['Filedata']['error'] !== 0)
|
||||||
return new Response('ERROR:error while upload');
|
return new Response('ERROR:error while upload');
|
||||||
|
|
||||||
$file = new system_file($_FILES['Filedata']['tmp_name']);
|
$file = new \system_file($_FILES['Filedata']['tmp_name']);
|
||||||
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
|
||||||
return new Response('ERROR:bad filetype');
|
return new Response('ERROR:bad filetype');
|
||||||
|
|
||||||
@@ -134,10 +136,10 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
return new Response('ERROR:file too large');
|
return new Response('ERROR:file too large');
|
||||||
|
|
||||||
$datas = $file->get_technical_datas();
|
$datas = $file->get_technical_datas();
|
||||||
if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT]))
|
if (!isset($datas[\system_file::TC_DATAS_WIDTH]) || !isset($datas[\system_file::TC_DATAS_HEIGHT]))
|
||||||
return new Response('ERROR:file is not square');
|
return new Response('ERROR:file is not square');
|
||||||
|
|
||||||
if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT])
|
if ($datas[\system_file::TC_DATAS_WIDTH] != $datas[\system_file::TC_DATAS_HEIGHT])
|
||||||
return new Response('ERROR:file is not square');
|
return new Response('ERROR:file is not square');
|
||||||
|
|
||||||
$feed->set_icon($file);
|
$feed->set_icon($file);
|
||||||
@@ -152,11 +154,11 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$user = User_Adapter::getInstance($request->get('usr_id'), $appbox);
|
$user = \User_Adapter::getInstance($request->get('usr_id'), $appbox);
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$feed->add_publisher($user);
|
$feed->add_publisher($user);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
}
|
}
|
||||||
@@ -171,13 +173,13 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$publisher = new Feed_Publisher_Adapter($appbox, $request->get('publisher_id'));
|
$publisher = new \Feed_Publisher_Adapter($appbox, $request->get('publisher_id'));
|
||||||
$user = $publisher->get_user();
|
$user = $publisher->get_user();
|
||||||
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
||||||
$publisher->delete();
|
$publisher->delete();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
}
|
}
|
||||||
@@ -187,7 +189,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
$controllers->post('/feed/{id}/delete/', function($id) use ($app, $appbox)
|
||||||
{
|
{
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
$feed->delete();
|
$feed->delete();
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
@@ -9,13 +9,15 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class Controller_Admin_Subdefs
|
class Subdefs
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,7 +32,7 @@ class Controller_Admin_Subdefs
|
|||||||
* @param databox $databox
|
* @param databox $databox
|
||||||
* @return controller_admin_subdefs
|
* @return controller_admin_subdefs
|
||||||
*/
|
*/
|
||||||
public function __construct(http_request $request, databox &$databox)
|
public function __construct(\http_request $request, \databox &$databox)
|
||||||
{
|
{
|
||||||
$this->databox = $databox;
|
$this->databox = $databox;
|
||||||
if ($request->has_post_datas())
|
if ($request->has_post_datas())
|
||||||
@@ -112,7 +114,7 @@ class Controller_Admin_Subdefs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return phrasea::redirect('/admin/subdefs.php?p0=' . $databox->get_sbas_id());
|
return \phrasea::redirect('/admin/subdefs.php?p0=' . $databox->get_sbas_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -22,13 +18,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
use Alchemy\Phrasea\RequestHandler\User as RequestHandler;
|
||||||
|
|
||||||
class Controller_Admin_Users implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Users implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
@@ -37,10 +40,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/', function() use ($app)
|
$controllers->post('/rights/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
$template = 'admin/editusers.twig';
|
$template = 'admin/editusers.twig';
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
@@ -53,10 +56,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->get('/rights/', function() use ($app)
|
$controllers->get('/rights/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
$template = 'admin/editusers.twig';
|
$template = 'admin/editusers.twig';
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
@@ -72,7 +75,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$module = new module_admin_route_users_edit($request);
|
$module = new RequestHandler\Edit($request);
|
||||||
$module->delete_users();
|
$module->delete_users();
|
||||||
|
|
||||||
return $app->redirect('/admin/users/search/');
|
return $app->redirect('/admin/users/search/');
|
||||||
@@ -86,19 +89,19 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
$rights->apply_rights();
|
$rights->apply_rights();
|
||||||
$rights->apply_infos();
|
$rights->apply_infos();
|
||||||
|
|
||||||
$datas = array('error' => false);
|
$datas = array('error' => false);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$datas['message'] = $e->getMessage();
|
$datas['message'] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
p4string::jsonencode($datas)
|
\p4string::jsonencode($datas)
|
||||||
, 200
|
, 200
|
||||||
, array('Content-Type' => 'application/json')
|
, array('Content-Type' => 'application/json')
|
||||||
);
|
);
|
||||||
@@ -108,10 +111,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/quotas/', function() use ($app)
|
$controllers->post('/rights/quotas/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
$template = 'admin/editusers_quotas.twig';
|
$template = 'admin/editusers_quotas.twig';
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
@@ -123,7 +126,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/quotas/apply/', function() use ($app)
|
$controllers->post('/rights/quotas/apply/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
$rights->apply_quotas();
|
$rights->apply_quotas();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -133,10 +136,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/time/', function() use ($app)
|
$controllers->post('/rights/time/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
$template = 'admin/editusers_timelimit.twig';
|
$template = 'admin/editusers_timelimit.twig';
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
@@ -148,7 +151,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/time/apply/', function() use ($app)
|
$controllers->post('/rights/time/apply/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
$rights->apply_time();
|
$rights->apply_time();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -158,10 +161,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/masks/', function() use ($app)
|
$controllers->post('/rights/masks/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
|
|
||||||
$template = 'admin/editusers_masks.twig';
|
$template = 'admin/editusers_masks.twig';
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
$twig->addFilter(array('bas_name' => 'phrasea::bas_names'));
|
||||||
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
$twig->addFilter(array('sbas_name' => 'phrasea::sbas_names'));
|
||||||
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
$twig->addFilter(array('sbasFromBas' => 'phrasea::sbasFromBas'));
|
||||||
@@ -173,7 +176,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/rights/masks/apply/', function() use ($app)
|
$controllers->post('/rights/masks/apply/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$rights = new module_admin_route_users_edit($request);
|
$rights = new RequestHandler\Edit($request);
|
||||||
$rights->apply_masks();
|
$rights->apply_masks();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -183,10 +186,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/search/', function() use ($app)
|
$controllers->post('/search/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$users = new module_admin_route_users($request);
|
$users = new RequestHandler\Manage($request);
|
||||||
$template = 'admin/users.html';
|
$template = 'admin/users.html';
|
||||||
|
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('floor' => 'floor'));
|
$twig->addFilter(array('floor' => 'floor'));
|
||||||
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
@@ -197,10 +200,10 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
$controllers->get('/search/', function() use ($app)
|
$controllers->get('/search/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$users = new module_admin_route_users($request);
|
$users = new RequestHandler\Manage($request);
|
||||||
$template = 'admin/users.html';
|
$template = 'admin/users.html';
|
||||||
|
|
||||||
$twig = new supertwig();
|
$twig = new \supertwig();
|
||||||
$twig->addFilter(array('floor' => 'floor'));
|
$twig->addFilter(array('floor' => 'floor'));
|
||||||
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
$twig->addFilter(array('getDate' => 'phraseadate::getDate'));
|
||||||
|
|
||||||
@@ -222,11 +225,11 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
|
|
||||||
$elligible_users = $user_query->on_sbas_where_i_am($user->ACL(), $rights)
|
$elligible_users = $user_query->on_sbas_where_i_am($user->ACL(), $rights)
|
||||||
->like(User_Query::LIKE_EMAIL, $like_value)
|
->like(\User_Query::LIKE_EMAIL, $like_value)
|
||||||
->like(User_Query::LIKE_FIRSTNAME, $like_value)
|
->like(\User_Query::LIKE_FIRSTNAME, $like_value)
|
||||||
->like(User_Query::LIKE_LASTNAME, $like_value)
|
->like(\User_Query::LIKE_LASTNAME, $like_value)
|
||||||
->like(User_Query::LIKE_LOGIN, $like_value)
|
->like(\User_Query::LIKE_LOGIN, $like_value)
|
||||||
->like_match(User_Query::LIKE_MATCH_OR)
|
->like_match(\User_Query::LIKE_MATCH_OR)
|
||||||
->who_have_right($have_right)
|
->who_have_right($have_right)
|
||||||
->who_have_not_right($have_not_right)
|
->who_have_not_right($have_not_right)
|
||||||
->on_base_ids($on_base)
|
->on_base_ids($on_base)
|
||||||
@@ -244,7 +247,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(p4string::jsonencode($datas), 200, array('Content-type' => 'application/json'));
|
return new Response(\p4string::jsonencode($datas), 200, array('Content-type' => 'application/json'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -255,7 +258,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$module = new module_admin_route_users($request);
|
$module = new RequestHandler\Manage($request);
|
||||||
if ($request->get('template') == '1')
|
if ($request->get('template') == '1')
|
||||||
{
|
{
|
||||||
$user = $module->create_template();
|
$user = $module->create_template();
|
||||||
@@ -264,27 +267,27 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$user = $module->create_newuser();
|
$user = $module->create_newuser();
|
||||||
}
|
}
|
||||||
if (!($user instanceof User_Adapter))
|
if (!($user instanceof \User_Adapter))
|
||||||
throw new Exception('Unknown error');
|
throw new \Exception('Unknown error');
|
||||||
|
|
||||||
$datas['data'] = $user->get_id();
|
$datas['data'] = $user->get_id();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$datas['error'] = true;
|
$datas['error'] = true;
|
||||||
$datas['message'] = $e->getMessage();
|
$datas['message'] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(p4string::jsonencode($datas));
|
return new Response(\p4string::jsonencode($datas));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/export/csv/', function() use ($appbox, $app)
|
$controllers->post('/export/csv/', function() use ($appbox, $app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$user_query = new User_Query($appbox);
|
$user_query = new \User_Query($appbox);
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
$like_value = $request->get('like_value');
|
$like_value = $request->get('like_value');
|
||||||
$like_field = $request->get('like_field');
|
$like_field = $request->get('like_field');
|
||||||
$on_base = $request->get('base_id') ? : null;
|
$on_base = $request->get('base_id') ? : null;
|
||||||
@@ -296,7 +299,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
->on_sbas_ids($on_sbas);
|
->on_sbas_ids($on_sbas);
|
||||||
|
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$geoname = new geonames();
|
$geoname = new \geonames();
|
||||||
$buffer = array();
|
$buffer = array();
|
||||||
|
|
||||||
$buffer[] = array(
|
$buffer[] = array(
|
||||||
@@ -332,8 +335,8 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
, $user->get_lastname()
|
, $user->get_lastname()
|
||||||
, $user->get_firstname()
|
, $user->get_firstname()
|
||||||
, $user->get_email()
|
, $user->get_email()
|
||||||
, phraseadate::format_mysql($user->get_creation_date())
|
, \phraseadate::format_mysql($user->get_creation_date())
|
||||||
, phraseadate::format_mysql($user->get_modification_date())
|
, \phraseadate::format_mysql($user->get_modification_date())
|
||||||
, $user->get_address()
|
, $user->get_address()
|
||||||
, $user->get_city()
|
, $user->get_city()
|
||||||
, $user->get_zipcode()
|
, $user->get_zipcode()
|
||||||
@@ -348,7 +351,7 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
while (count($results) > 0);
|
while (count($results) > 0);
|
||||||
|
|
||||||
$out = format::arr_to_csv($buffer);
|
$out = \format::arr_to_csv($buffer);
|
||||||
|
|
||||||
$headers = array(
|
$headers = array(
|
||||||
'Content-type' => 'text/csv'
|
'Content-type' => 'text/csv'
|
||||||
@@ -365,3 +368,4 @@ class Controller_Admin_Users implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Root;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,12 +19,20 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_RSSFeeds implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class RSSFeeds implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
|
|
||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
@@ -38,29 +42,29 @@ class Controller_RSSFeeds implements ControllerProviderInterface
|
|||||||
$perPage = 5;
|
$perPage = 5;
|
||||||
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = \registry::get_instance();
|
||||||
|
|
||||||
if ($format == 'rss')
|
if ($format == 'rss')
|
||||||
{
|
{
|
||||||
$content = new Feed_XML_RSS();
|
$content = new \Feed_XML_RSS();
|
||||||
}
|
}
|
||||||
if ($format == 'atom')
|
if ($format == 'atom')
|
||||||
{
|
{
|
||||||
$content = new Feed_XML_Atom();
|
$content = new \Feed_XML_Atom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user instanceof User_Adapter)
|
if ($user instanceof \User_Adapter)
|
||||||
$link = $feed->get_user_link($registry, $user, $format, $page);
|
$link = $feed->get_user_link($registry, $user, $format, $page);
|
||||||
else
|
else
|
||||||
$link = $feed->get_homepage_link($registry, $format, $page);
|
$link = $feed->get_homepage_link($registry, $format, $page);
|
||||||
|
|
||||||
$content->set_updated_on(new DateTime());
|
$content->set_updated_on(new \DateTime());
|
||||||
$content->set_title($feed->get_title());
|
$content->set_title($feed->get_title());
|
||||||
$content->set_subtitle($feed->get_subtitle());
|
$content->set_subtitle($feed->get_subtitle());
|
||||||
$content->set_generator('Phraseanet');
|
$content->set_generator('Phraseanet');
|
||||||
$content->set_link($link);
|
$content->set_link($link);
|
||||||
|
|
||||||
if ($user instanceof User_Adapter)
|
if ($user instanceof \User_Adapter)
|
||||||
{
|
{
|
||||||
if ($page > 1)
|
if ($page > 1)
|
||||||
$content->set_previous_page($feed->get_user_link($registry, $user, $format, ($page - 1)));
|
$content->set_previous_page($feed->get_user_link($registry, $user, $format, ($page - 1)));
|
||||||
@@ -88,7 +92,7 @@ class Controller_RSSFeeds implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed)
|
$controllers->get('/feed/{id}/{format}/', function($id, $format) use ($app, $appbox, $display_feed)
|
||||||
{
|
{
|
||||||
$feed = new Feed_Adapter($appbox, $id);
|
$feed = new \Feed_Adapter($appbox, $id);
|
||||||
|
|
||||||
if (!$feed->is_public())
|
if (!$feed->is_public())
|
||||||
{
|
{
|
||||||
@@ -109,10 +113,10 @@ class Controller_RSSFeeds implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$token = new Feed_Token($appbox, $token, $id);
|
$token = new \Feed_Token($appbox, $token, $id);
|
||||||
$feed = $token->get_feed();
|
$feed = $token->get_feed();
|
||||||
}
|
}
|
||||||
catch (Exception_FeedNotFound $e)
|
catch (\Exception_FeedNotFound $e)
|
||||||
{
|
{
|
||||||
return new Response('Not Found', 404);
|
return new Response('Not Found', 404);
|
||||||
}
|
}
|
||||||
@@ -130,10 +134,10 @@ class Controller_RSSFeeds implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$token = new Feed_TokenAggregate($appbox, $token);
|
$token = new \Feed_TokenAggregate($appbox, $token);
|
||||||
$feed = $token->get_feed();
|
$feed = $token->get_feed();
|
||||||
}
|
}
|
||||||
catch (Exception_FeedNotFound $e)
|
catch (\Exception_FeedNotFound $e)
|
||||||
{
|
{
|
||||||
return new Response('', 404);
|
return new Response('', 404);
|
||||||
}
|
}
|
||||||
@@ -150,7 +154,7 @@ class Controller_RSSFeeds implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
$controllers->get('/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
||||||
{
|
{
|
||||||
$feeds = Feed_Collection::load_public_feeds($appbox);
|
$feeds = \Feed_Collection::load_public_feeds($appbox);
|
||||||
$feed = $feeds->get_aggregate();
|
$feed = $feeds->get_aggregate();
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Setup;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -24,41 +20,44 @@ use Silex\ControllerProviderInterface;
|
|||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Berlin');
|
date_default_timezone_set('Europe/Berlin');
|
||||||
require_once dirname(__FILE__) . '/../../../version.inc';
|
require_once dirname(__FILE__) . '/../../../../version.inc';
|
||||||
require_once dirname(__FILE__) . '/../../phrasea.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/phrasea.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../bootstrap.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/bootstrap.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../cache/cacheableInterface.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/cache/cacheableInterface.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../cache/interface.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/cache/interface.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../cache/nocache.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/cache/nocache.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../cache/adapter.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/cache/adapter.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../User/Interface.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/User/Interface.class.php';
|
||||||
require_once dirname(__FILE__) . '/../../User/Adapter.class.php';
|
require_once dirname(__FILE__) . '/../../../../classes/User/Adapter.class.php';
|
||||||
|
|
||||||
bootstrap::register_autoloads();
|
/**
|
||||||
bootstrap::set_php_configuration();
|
*
|
||||||
|
* @package
|
||||||
class Controller_Setup_Installer implements ControllerProviderInterface
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class Installer implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
$app['available_languages'] = User_Adapter::detectLanguage(new Setup_Registry());
|
$app['available_languages'] = \User_Adapter::detectLanguage(new \Setup_Registry());
|
||||||
|
|
||||||
$controllers->get('/', function() use ($app)
|
$controllers->get('/', function() use ($app)
|
||||||
{
|
{
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
||||||
setup::write_config($servername);
|
\setup::write_config($servername);
|
||||||
|
|
||||||
|
|
||||||
$php_constraint = setup::check_php_version();
|
$php_constraint = \setup::check_php_version();
|
||||||
$writability_constraints = setup::check_writability(new Setup_Registry());
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
$extension_constraints = setup::check_php_extension();
|
$extension_constraints = \setup::check_php_extension();
|
||||||
$opcode_constraints = setup::check_cache_opcode();
|
$opcode_constraints = \setup::check_cache_opcode();
|
||||||
$php_conf_constraints = setup::check_php_configuration();
|
$php_conf_constraints = \setup::check_php_configuration();
|
||||||
$locales_constraints = setup::check_system_locales();
|
$locales_constraints = \setup::check_system_locales();
|
||||||
|
|
||||||
$constraints_coll = array(
|
$constraints_coll = array(
|
||||||
'php_constraint' => $php_constraint
|
'php_constraint' => $php_constraint
|
||||||
@@ -110,7 +109,7 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/step2/', function() use ($app)
|
$controllers->get('/step2/', function() use ($app)
|
||||||
{
|
{
|
||||||
phrasea::use_i18n(Session_Handler::get_locale());
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
|
|
||||||
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
|
$ld_path = array(dirname(__FILE__) . '/../../../../templates/web');
|
||||||
|
|
||||||
@@ -129,14 +128,14 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
$html = $twig->render(
|
$html = $twig->render(
|
||||||
'/setup/step2.twig'
|
'/setup/step2.twig'
|
||||||
, array(
|
, array(
|
||||||
'locale' => Session_Handler::get_locale()
|
'locale' => \Session_Handler::get_locale()
|
||||||
, 'available_locales' => $app['available_languages']
|
, 'available_locales' => $app['available_languages']
|
||||||
, 'available_templates' => appbox::list_databox_templates()
|
, 'available_templates' => \appbox::list_databox_templates()
|
||||||
, 'version_number' => GV_version
|
, 'version_number' => GV_version
|
||||||
, 'version_name' => GV_version_name
|
, 'version_name' => GV_version_name
|
||||||
, 'warnings' => $warnings
|
, 'warnings' => $warnings
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
, 'discovered_binaries' => setup::discover_binaries()
|
, 'discovered_binaries' => \setup::discover_binaries()
|
||||||
, 'rootpath' => dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/'
|
, 'rootpath' => dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -147,7 +146,7 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
$controllers->post('/install/', function() use ($app)
|
$controllers->post('/install/', function() use ($app)
|
||||||
{
|
{
|
||||||
set_time_limit(360);
|
set_time_limit(360);
|
||||||
phrasea::use_i18n(Session_Handler::get_locale());
|
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$conn = $connbas = null;
|
$conn = $connbas = null;
|
||||||
@@ -162,9 +161,9 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$conn = new connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name);
|
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
return $app->redirect('/setup/installer/step2/?error=' . _('Appbox is unreachable'));
|
||||||
}
|
}
|
||||||
@@ -173,28 +172,28 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
if ($databox_name)
|
if ($databox_name)
|
||||||
{
|
{
|
||||||
$connbas = new connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name);
|
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
|
||||||
}
|
}
|
||||||
setup::rollback($conn, $connbas);
|
\setup::rollback($conn, $connbas);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$appbox = appbox::create(new Setup_Registry(), $conn, $appbox_name, true);
|
$appbox = \appbox::create(new \Setup_Registry(), $conn, $appbox_name, true);
|
||||||
|
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = \registry::get_instance();
|
||||||
setup::create_global_values($registry);
|
\setup::create_global_values($registry);
|
||||||
|
|
||||||
$appbox->set_registry($registry);
|
$appbox->set_registry($registry);
|
||||||
|
|
||||||
$registry->set('GV_base_datapath_noweb', p4string::addEndSlash($request->get('datapath_noweb')));
|
$registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->get('datapath_noweb')));
|
||||||
$registry->set('GV_base_datapath_web', p4string::addEndSlash($request->get('datapath_web')));
|
$registry->set('GV_base_datapath_web', \p4string::addEndSlash($request->get('datapath_web')));
|
||||||
$registry->set('GV_base_dataurl', p4string::addEndSlash($request->get('mount_point_web')));
|
$registry->set('GV_base_dataurl', \p4string::addEndSlash($request->get('mount_point_web')));
|
||||||
|
|
||||||
$registry->set('GV_cli', $request->get('binary_php'));
|
$registry->set('GV_cli', $request->get('binary_php'));
|
||||||
$registry->set('GV_imagick', $request->get('binary_convert'));
|
$registry->set('GV_imagick', $request->get('binary_convert'));
|
||||||
@@ -209,15 +208,15 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
$registry->set('GV_mplayer', $request->get('binary_mplayer'));
|
$registry->set('GV_mplayer', $request->get('binary_mplayer'));
|
||||||
$registry->set('GV_pdftotext', $request->get('binary_xpdf'));
|
$registry->set('GV_pdftotext', $request->get('binary_xpdf'));
|
||||||
|
|
||||||
$user = User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
$user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true);
|
||||||
|
|
||||||
if (!p4string::hasAccent($databox_name))
|
if (!\p4string::hasAccent($databox_name))
|
||||||
{
|
{
|
||||||
if ($databox_name)
|
if ($databox_name)
|
||||||
{
|
{
|
||||||
|
|
||||||
$template = new system_file(dirname(__FILE__) . '/../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
$template = new \system_file(dirname(__FILE__) . '/../../../conf.d/data_templates/' . $request->get('db_template') . '.xml');
|
||||||
$databox = databox::create($appbox, $connbas, $template, $registry);
|
$databox = \databox::create($appbox, $connbas, $template, $registry);
|
||||||
$user->ACL()
|
$user->ACL()
|
||||||
->give_access_to_sbas(array($databox->get_sbas_id()))
|
->give_access_to_sbas(array($databox->get_sbas_id()))
|
||||||
->update_rights_to_sbas(
|
->update_rights_to_sbas(
|
||||||
@@ -227,7 +226,7 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$a = collection::create($databox, $appbox, 'test', $user);
|
$a = \collection::create($databox, $appbox, 'test', $user);
|
||||||
|
|
||||||
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
$user->ACL()->give_access_to_base(array($a->get_base_id()));
|
||||||
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
$user->ACL()->update_rights_to_base($a->get_base_id(), array(
|
||||||
@@ -272,7 +271,7 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
$settings = null;
|
$settings = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
task_abstract::create($appbox, $class_name, $settings);
|
\task_abstract::create($appbox, $class_name, $settings);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -281,9 +280,9 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phrasea::start();
|
\phrasea::start();
|
||||||
|
|
||||||
$auth = new Session_Authentication_None($user);
|
$auth = new \Session_Authentication_None($user);
|
||||||
|
|
||||||
$appbox->get_session()->authenticate($auth);
|
$appbox->get_session()->authenticate($auth);
|
||||||
|
|
||||||
@@ -291,9 +290,9 @@ class Controller_Setup_Installer implements ControllerProviderInterface
|
|||||||
|
|
||||||
return $app->redirect($redirection);
|
return $app->redirect($redirection);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
setup::rollback($conn, $connbas);
|
\setup::rollback($conn, $connbas);
|
||||||
exit($e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine());
|
exit($e->getMessage() . ' ' . $e->getFile() . ' ' . $e->getLine());
|
||||||
}
|
}
|
||||||
|
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Setup;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,33 +19,40 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_Setup_Upgrader implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Upgrader implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$controllers = new ControllerCollection();
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
$app['registry'] = new Setup_Registry();
|
$app['registry'] = new \Setup_Registry();
|
||||||
$app['available_languages'] = User_Adapter::detectLanguage($app['registry']);
|
$app['available_languages'] = \User_Adapter::detectLanguage($app['registry']);
|
||||||
$app['twig'] = function()
|
$app['twig'] = function()
|
||||||
{
|
{
|
||||||
return new supertwig();
|
return new \supertwig();
|
||||||
};
|
};
|
||||||
|
|
||||||
$controllers->get('/', function() use ($app)
|
$controllers->get('/', function() use ($app)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
$upgrade_status = Setup_Upgrade::get_status();
|
$upgrade_status = \Setup_Upgrade::get_status();
|
||||||
|
|
||||||
ini_set('display_errors', 'on');
|
ini_set('display_errors', 'on');
|
||||||
$html = $app['twig']->render(
|
$html = $app['twig']->render(
|
||||||
'/setup/upgrader.twig'
|
'/setup/upgrader.twig'
|
||||||
, array(
|
, array(
|
||||||
'locale' => Session_Handler::get_locale()
|
'locale' => \Session_Handler::get_locale()
|
||||||
, 'upgrade_status' => $upgrade_status
|
, 'upgrade_status' => $upgrade_status
|
||||||
, 'available_locales' => $app['available_languages']
|
, 'available_locales' => $app['available_languages']
|
||||||
, 'bad_users' => User_Adapter::get_wrong_email_users(appbox::get_instance())
|
, 'bad_users' => \User_Adapter::get_wrong_email_users(\appbox::get_instance())
|
||||||
, 'version_number' => GV_version
|
, 'version_number' => GV_version
|
||||||
, 'version_name' => GV_version_name)
|
, 'version_name' => GV_version_name)
|
||||||
);
|
);
|
||||||
@@ -60,24 +63,24 @@ class Controller_Setup_Upgrader implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/status/', function() use ($app)
|
$controllers->get('/status/', function() use ($app)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
ini_set('display_errors', 'on');
|
ini_set('display_errors', 'on');
|
||||||
|
|
||||||
$datas = Setup_Upgrade::get_status();
|
$datas = \Setup_Upgrade::get_status();
|
||||||
|
|
||||||
return new Response(p4string::jsonencode($datas), 200, array('Content-Type: application/json'));
|
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type: application/json'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/execute/', function() use ($app)
|
$controllers->post('/execute/', function() use ($app)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
ini_set('display_errors', 'on');
|
ini_set('display_errors', 'on');
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
session_write_close();
|
session_write_close();
|
||||||
ignore_user_abort(true);
|
ignore_user_abort(true);
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$upgrader = new Setup_Upgrade($appbox);
|
$upgrader = new \Setup_Upgrade($appbox);
|
||||||
$appbox->forceUpgrade($upgrader);
|
$appbox->forceUpgrade($upgrader);
|
||||||
|
|
||||||
return;
|
return;
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Utils;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,7 +19,14 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConnectionTest implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
@@ -32,7 +35,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/mysql/', function() use ($app)
|
$controllers->get('/mysql/', function() use ($app)
|
||||||
{
|
{
|
||||||
require_once dirname(__FILE__) . '/../../connection/pdo.class.php';
|
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$hostname = $request->get('hostname', '127.0.0.1');
|
$hostname = $request->get('hostname', '127.0.0.1');
|
||||||
@@ -45,10 +48,10 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$conn = new connection_pdo('test', $hostname, $port, $user, $password);
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password);
|
||||||
$connection_ok = true;
|
$connection_ok = true;
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,7 +60,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$conn = new connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
||||||
$db_ok = true;
|
$db_ok = true;
|
||||||
|
|
||||||
$sql = "SHOW TABLE STATUS";
|
$sql = "SHOW TABLE STATUS";
|
||||||
@@ -66,7 +69,7 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
|||||||
|
|
||||||
$empty = $stmt->rowCount() === 0;
|
$empty = $stmt->rowCount() === 0;
|
||||||
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
@@ -81,13 +84,13 @@ class Controller_Utils_ConnectionTest implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(p4string::jsonencode(array(
|
return new Response(\p4string::jsonencode(array(
|
||||||
'connection' => $connection_ok
|
'connection' => $connection_ok
|
||||||
, 'database' => $db_ok
|
, 'database' => $db_ok
|
||||||
, 'is_empty' => $empty
|
, 'is_empty' => $empty
|
@@ -9,12 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace Alchemy\Phrasea\Controller\Utils;
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
@@ -23,7 +19,13 @@ use Silex\Application;
|
|||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Silex\ControllerCollection;
|
use Silex\ControllerCollection;
|
||||||
|
|
||||||
class Controller_Utils_PathFileTest implements ControllerProviderInterface
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class PathFileTest implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
@@ -34,7 +36,7 @@ class Controller_Utils_PathFileTest implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$path = $app['request']->get('path');
|
$path = $app['request']->get('path');
|
||||||
|
|
||||||
return new Response(p4string::jsonencode(array(
|
return new Response(\p4string::jsonencode(array(
|
||||||
'exists' => file_exists($path)
|
'exists' => file_exists($path)
|
||||||
, 'file' => is_file($path)
|
, 'file' => is_file($path)
|
||||||
, 'dir' => is_dir($path)
|
, 'dir' => is_dir($path)
|
||||||
@@ -48,8 +50,8 @@ class Controller_Utils_PathFileTest implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$url = $app['request']->get('url');
|
$url = $app['request']->get('url');
|
||||||
|
|
||||||
return new Response(p4string::jsonencode(array(
|
return new Response(\p4string::jsonencode(array(
|
||||||
'code' => http_query::getHttpCodeFromUrl($url)
|
'code' => \http_query::getHttpCodeFromUrl($url)
|
||||||
)), 200, array('application/json'));
|
)), 200, array('application/json'));
|
||||||
});
|
});
|
||||||
|
|
@@ -9,13 +9,17 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\RequestHandler\User;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class module_admin_route_users_edit
|
class Edit
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $request;
|
protected $request;
|
||||||
@@ -43,12 +47,12 @@ class module_admin_route_users_edit
|
|||||||
* @param Symfony\Component\HttpFoundation\Request $request
|
* @param Symfony\Component\HttpFoundation\Request $request
|
||||||
* @return module_admin_route_users_edit
|
* @return module_admin_route_users_edit
|
||||||
*/
|
*/
|
||||||
public function __construct(Symfony\Component\HttpFoundation\Request $request)
|
public function __construct(Request $request)
|
||||||
{
|
{
|
||||||
$this->users = explode(';', $request->get('users'));
|
$this->users = explode(';', $request->get('users'));
|
||||||
|
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
@@ -67,22 +71,22 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
public function delete_users()
|
public function delete_users()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
foreach ($this->users as $usr_id)
|
foreach ($this->users as $usr_id)
|
||||||
{
|
{
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
||||||
$this->delete_user($user);
|
$this->delete_user($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function delete_user(User_Adapter $user)
|
protected function delete_user(\User_Adapter $user)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$list = array_keys(User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin')));
|
$list = array_keys(\User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin')));
|
||||||
|
|
||||||
$user->ACL()->revoke_access_from_bases($list);
|
$user->ACL()->revoke_access_from_bases($list);
|
||||||
if ($user->ACL()->is_phantom())
|
if ($user->ACL()->is_phantom())
|
||||||
@@ -93,9 +97,9 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
public function get_users_rights()
|
public function get_users_rights()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$list = array_keys(User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin')));
|
$list = array_keys(\User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL()->get_granted_base(array('canadmin')));
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
b.sbas_id,
|
b.sbas_id,
|
||||||
@@ -150,7 +154,7 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = 'SELECT base_id, sum(1) as access FROM basusr
|
$sql = 'SELECT base_id, sum(1) as access FROM basusr
|
||||||
@@ -159,7 +163,7 @@ class module_admin_route_users_edit
|
|||||||
GROUP BY base_id';
|
GROUP BY base_id';
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$access = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$access = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$base_ids = array();
|
$base_ids = array();
|
||||||
@@ -191,7 +195,7 @@ class module_admin_route_users_edit
|
|||||||
if (count($this->users) == 1)
|
if (count($this->users) == 1)
|
||||||
{
|
{
|
||||||
$usr_id = array_pop($this->users);
|
$usr_id = array_pop($this->users);
|
||||||
$out['main_user'] = User_Adapter::getInstance($usr_id, $appbox);
|
$out['main_user'] = \User_Adapter::getInstance($usr_id, $appbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
@@ -208,10 +212,10 @@ class module_admin_route_users_edit
|
|||||||
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
||||||
AND bu.base_id = :base_id";
|
AND bu.base_id = :base_id";
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = \connection::getPDOConnection();
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':base_id' => $this->base_id));
|
$stmt->execute(array(':base_id' => $this->base_id));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->users_datas = $rs;
|
$this->users_datas = $rs;
|
||||||
@@ -233,10 +237,10 @@ class module_admin_route_users_edit
|
|||||||
WHERE usr_id IN (" . implode(',', $this->users) . ")
|
WHERE usr_id IN (" . implode(',', $this->users) . ")
|
||||||
AND base_id = :base_id";
|
AND base_id = :base_id";
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = \connection::getPDOConnection();
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':base_id' => $this->base_id));
|
$stmt->execute(array(':base_id' => $this->base_id));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
|
||||||
@@ -266,8 +270,8 @@ class module_admin_route_users_edit
|
|||||||
$tbits_left = array();
|
$tbits_left = array();
|
||||||
$tbits_right = array();
|
$tbits_right = array();
|
||||||
|
|
||||||
$sbas_id = phrasea::sbasFromBas($this->base_id);
|
$sbas_id = \phrasea::sbasFromBas($this->base_id);
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = \databox::get_instance($sbas_id);
|
||||||
$status = $databox->get_statusbits();
|
$status = $databox->get_statusbits();
|
||||||
|
|
||||||
foreach ($status as $bit => $datas)
|
foreach ($status as $bit => $datas)
|
||||||
@@ -337,10 +341,10 @@ class module_admin_route_users_edit
|
|||||||
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
||||||
AND bu.base_id = :base_id";
|
AND bu.base_id = :base_id";
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
$conn = \connection::getPDOConnection();
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':base_id' => $this->base_id));
|
$stmt->execute(array(':base_id' => $this->base_id));
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$time_limited = -1;
|
$time_limited = -1;
|
||||||
@@ -365,12 +369,12 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
if ($limited_from)
|
if ($limited_from)
|
||||||
{
|
{
|
||||||
$date_obj_from = new DateTime($limited_from);
|
$date_obj_from = new \DateTime($limited_from);
|
||||||
$limited_from = $date_obj_from->format('Y-m-d');
|
$limited_from = $date_obj_from->format('Y-m-d');
|
||||||
}
|
}
|
||||||
if ($limited_to)
|
if ($limited_to)
|
||||||
{
|
{
|
||||||
$date_obj_to = new DateTime($limited_to);
|
$date_obj_to = new \DateTime($limited_to);
|
||||||
$limited_to = $date_obj_to->format('Y-m-d');
|
$limited_to = $date_obj_to->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,10 +392,10 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
public function apply_rights()
|
public function apply_rights()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$request = http_request::getInstance();
|
$request = \http_request::getInstance();
|
||||||
$ACL = User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL();
|
$ACL = \User_Adapter::getInstance($session->get_usr_id(), $appbox)->ACL();
|
||||||
$base_ids = array_keys($ACL->get_granted_base(array('canadmin')));
|
$base_ids = array_keys($ACL->get_granted_base(array('canadmin')));
|
||||||
|
|
||||||
$update = $create = $delete = $create_sbas = $update_sbas = array();
|
$update = $create = $delete = $create_sbas = $update_sbas = array();
|
||||||
@@ -443,7 +447,7 @@ class module_admin_route_users_edit
|
|||||||
{
|
{
|
||||||
if ($v === '1')
|
if ($v === '1')
|
||||||
{
|
{
|
||||||
$create_sbas[phrasea::sbasFromBas($base_id)] = phrasea::sbasFromBas($base_id);
|
$create_sbas[\phrasea::sbasFromBas($base_id)] = \phrasea::sbasFromBas($base_id);
|
||||||
$create[] = $base_id;
|
$create[] = $base_id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -451,7 +455,7 @@ class module_admin_route_users_edit
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$create_sbas[phrasea::sbasFromBas($base_id)] = phrasea::sbasFromBas($base_id);
|
$create_sbas[\phrasea::sbasFromBas($base_id)] = \phrasea::sbasFromBas($base_id);
|
||||||
$update[$base_id][$p] = $v;
|
$update[$base_id][$p] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,7 +503,7 @@ class module_admin_route_users_edit
|
|||||||
{
|
{
|
||||||
$appbox->get_connection()->beginTransaction();
|
$appbox->get_connection()->beginTransaction();
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
||||||
$user->ACL()->revoke_access_from_bases($delete)
|
$user->ACL()->revoke_access_from_bases($delete)
|
||||||
->give_access_to_base($create)
|
->give_access_to_base($create)
|
||||||
->give_access_to_sbas($create_sbas);
|
->give_access_to_sbas($create_sbas);
|
||||||
@@ -520,7 +524,7 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
unset($user);
|
unset($user);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$appbox->get_connection()->rollBack();
|
$appbox->get_connection()->rollBack();
|
||||||
}
|
}
|
||||||
@@ -536,9 +540,9 @@ class module_admin_route_users_edit
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$request = http_request::getInstance();
|
$request = \http_request::getInstance();
|
||||||
|
|
||||||
$infos = array(
|
$infos = array(
|
||||||
'gender'
|
'gender'
|
||||||
@@ -560,8 +564,8 @@ class module_admin_route_users_edit
|
|||||||
foreach ($this->users as $usr_id)
|
foreach ($this->users as $usr_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!mail::validateEmail($parm['email']))
|
if (!\mail::validateEmail($parm['email']))
|
||||||
throw new Exception_InvalidArgument(_('Email addess is not valid'));
|
throw new \Exception_InvalidArgument(_('Email addess is not valid'));
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = User_Adapter::getInstance($usr_id, $appbox);
|
||||||
$user->set_firstname($parm['first_name'])
|
$user->set_firstname($parm['first_name'])
|
||||||
@@ -586,7 +590,7 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
foreach ($this->users as $usr_id)
|
foreach ($this->users as $usr_id)
|
||||||
{
|
{
|
||||||
$user = User_Adapter::getInstance($usr_id, appbox::get_instance());
|
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance());
|
||||||
if ($this->request->get('quota'))
|
if ($this->request->get('quota'))
|
||||||
$user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes'));
|
$user->ACL()->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes'));
|
||||||
else
|
else
|
||||||
@@ -609,7 +613,7 @@ class module_admin_route_users_edit
|
|||||||
{
|
{
|
||||||
foreach ($this->users as $usr_id)
|
foreach ($this->users as $usr_id)
|
||||||
{
|
{
|
||||||
$user = User_Adapter::getInstance($usr_id, appbox::get_instance());
|
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance());
|
||||||
|
|
||||||
$user->ACL()->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or);
|
$user->ACL()->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or);
|
||||||
}
|
}
|
||||||
@@ -623,14 +627,14 @@ class module_admin_route_users_edit
|
|||||||
|
|
||||||
$this->base_id = (int) $this->request->get('base_id');
|
$this->base_id = (int) $this->request->get('base_id');
|
||||||
|
|
||||||
$dmin = $this->request->get('dmin') ? new DateTime($this->request->get('dmin')) : null;
|
$dmin = $this->request->get('dmin') ? new \DateTime($this->request->get('dmin')) : null;
|
||||||
$dmax = $this->request->get('dmax') ? new DateTime($this->request->get('dmax')) : null;
|
$dmax = $this->request->get('dmax') ? new \DateTime($this->request->get('dmax')) : null;
|
||||||
|
|
||||||
$activate = $this->request->get('limit');
|
$activate = $this->request->get('limit');
|
||||||
|
|
||||||
foreach ($this->users as $usr_id)
|
foreach ($this->users as $usr_id)
|
||||||
{
|
{
|
||||||
$user = User_Adapter::getInstance($usr_id, appbox::get_instance());
|
$user = \User_Adapter::getInstance($usr_id, \appbox::get_instance());
|
||||||
|
|
||||||
$user->ACL()->set_limits($this->base_id, $activate, $dmin, $dmax);
|
$user->ACL()->set_limits($this->base_id, $activate, $dmin, $dmax);
|
||||||
}
|
}
|
@@ -9,13 +9,17 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\RequestHandler\User;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package
|
* @package
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class module_admin_route_users
|
class Manage
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $request;
|
protected $request;
|
||||||
@@ -35,7 +39,7 @@ class module_admin_route_users
|
|||||||
*/
|
*/
|
||||||
protected $usr_id;
|
protected $usr_id;
|
||||||
|
|
||||||
public function __construct(Symfony\Component\HttpFoundation\Request $request)
|
public function __construct(Request $request)
|
||||||
{
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
@@ -43,9 +47,9 @@ class module_admin_route_users
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search(Symfony\Component\HttpFoundation\Request $request)
|
public function search(Request $request)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$offset_start = (int) $request->get('offset_start');
|
$offset_start = (int) $request->get('offset_start');
|
||||||
@@ -65,8 +69,8 @@ class module_admin_route_users
|
|||||||
, 'offset_start' => $offset_start
|
, 'offset_start' => $offset_start
|
||||||
);
|
);
|
||||||
|
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
$query = new User_Query($appbox);
|
$query = new \User_Query($appbox);
|
||||||
|
|
||||||
if (is_array($request->get('base_id')))
|
if (is_array($request->get('base_id')))
|
||||||
$query->on_base_ids($request->get('base_id'));
|
$query->on_base_ids($request->get('base_id'));
|
||||||
@@ -83,22 +87,22 @@ class module_admin_route_users
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$invite_id = User_Adapter::get_usr_id_from_login('invite');
|
$invite_id = \User_Adapter::get_usr_id_from_login('invite');
|
||||||
$invite = User_Adapter::getInstance($invite_id, $appbox);
|
$invite = \User_Adapter::getInstance($invite_id, $appbox);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$invite = User_Adapter::create($appbox, 'invite', 'invite', '', false);
|
$invite = \User_Adapter::create($appbox, 'invite', 'invite', '', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$autoregister_id = User_Adapter::get_usr_id_from_login('autoregister');
|
$autoregister_id = \User_Adapter::get_usr_id_from_login('autoregister');
|
||||||
$autoregister = User_Adapter::getInstance($autoregister_id, $appbox);
|
$autoregister = \User_Adapter::getInstance($autoregister_id, $appbox);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$autoregister = User_Adapter::create($appbox, 'autoregister', 'autoregister', '', false);
|
$autoregister = \User_Adapter::create($appbox, 'autoregister', 'autoregister', '', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->query_parms as $k => $v)
|
foreach ($this->query_parms as $k => $v)
|
||||||
@@ -119,12 +123,12 @@ class module_admin_route_users
|
|||||||
{
|
{
|
||||||
$email = $this->request->get('value');
|
$email = $this->request->get('value');
|
||||||
|
|
||||||
if(!mail::validateEmail($email))
|
if(!\mail::validateEmail($email))
|
||||||
{
|
{
|
||||||
throw new Exception_InvalidArgument(_('Invalid mail address'));
|
throw new \Exception_InvalidArgument(_('Invalid mail address'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
|
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
$sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email';
|
$sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email';
|
||||||
@@ -135,13 +139,13 @@ class module_admin_route_users
|
|||||||
|
|
||||||
if (!is_array($row) || $count == 0)
|
if (!is_array($row) || $count == 0)
|
||||||
{
|
{
|
||||||
$created_user = User_Adapter::create($appbox, $email, random::generatePassword(16), $email, false, false);
|
$created_user = \User_Adapter::create($appbox, $email, \random::generatePassword(16), $email, false, false);
|
||||||
$this->usr_id = $created_user->get_id();
|
$this->usr_id = $created_user->get_id();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->usr_id = $row['usr_id'];
|
$this->usr_id = $row['usr_id'];
|
||||||
$created_user = User_Adapter::getInstance($this->usr_id, $appbox);
|
$created_user = \User_Adapter::getInstance($this->usr_id, $appbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $created_user;
|
return $created_user;
|
||||||
@@ -153,13 +157,13 @@ class module_admin_route_users
|
|||||||
|
|
||||||
if(trim($name) === '')
|
if(trim($name) === '')
|
||||||
{
|
{
|
||||||
throw new Exception_InvalidArgument(_('Invalid template name'));
|
throw new \Exception_InvalidArgument(_('Invalid template name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = \appbox::get_instance();
|
||||||
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||||
|
|
||||||
$created_user = User_Adapter::create($appbox, $name, random::generatePassword(16), null, false, false);
|
$created_user = \User_Adapter::create($appbox, $name, \random::generatePassword(16), null, false, false);
|
||||||
$created_user->set_template($user);
|
$created_user->set_template($user);
|
||||||
$this->usr_id = $user->get_id();
|
$this->usr_id = $user->get_id();
|
||||||
|
|
@@ -1,748 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package APIv1
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Application Routage for API v1
|
|
||||||
*/
|
|
||||||
require_once dirname(__FILE__) . "/../../../../lib/classes/API/OAuth2/Autoloader.class.php";
|
|
||||||
require_once dirname(__FILE__) . "/../../../../lib/bootstrap.php";
|
|
||||||
|
|
||||||
bootstrap::register_autoloads();
|
|
||||||
API_OAuth2_Autoloader::register();
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpKernel\Exception;
|
|
||||||
|
|
||||||
return call_user_func(function(){
|
|
||||||
|
|
||||||
|
|
||||||
$app = new Silex\Application();
|
|
||||||
|
|
||||||
$app["appbox"] = appbox::get_instance();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Associated user to related token
|
|
||||||
* @var User_Adapter
|
|
||||||
*/
|
|
||||||
$app['p4user'] = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var API_OAuth2_Token
|
|
||||||
*/
|
|
||||||
$app['token'] = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Protected Closure
|
|
||||||
* @var Closure
|
|
||||||
* @return Symfony\Component\HttpFoundation\Response
|
|
||||||
*/
|
|
||||||
$app['response'] = $app->protect(function ($result)
|
|
||||||
{
|
|
||||||
$response = new Response(
|
|
||||||
$result->format()
|
|
||||||
, $result->get_http_code()
|
|
||||||
, array('Content-Type' => $result->get_content_type())
|
|
||||||
);
|
|
||||||
$response->setCharset('UTF-8');
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Api Service
|
|
||||||
* @var Closure
|
|
||||||
*/
|
|
||||||
$app['api'] = function () use ($app)
|
|
||||||
{
|
|
||||||
return new API_V1_adapter(false, $app["appbox"]);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$parseRoute = function ($route, Response $response)
|
|
||||||
{
|
|
||||||
$ressource = $general = $aspect = $action = null;
|
|
||||||
$exploded_route = explode('/', p4string::delFirstSlash((p4string::delEndSlash($route))));
|
|
||||||
if (sizeof($exploded_route) > 0 && $response->isOk())
|
|
||||||
{
|
|
||||||
$ressource = $exploded_route[0];
|
|
||||||
|
|
||||||
if (sizeof($exploded_route) == 2 && (int) $exploded_route[1] == 0)
|
|
||||||
{
|
|
||||||
$general = $exploded_route[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch ($ressource)
|
|
||||||
{
|
|
||||||
case API_V1_Log::DATABOXES_RESSOURCE :
|
|
||||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
|
||||||
$aspect = $exploded_route[2];
|
|
||||||
break;
|
|
||||||
case API_V1_Log::RECORDS_RESSOURCE :
|
|
||||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 4)
|
|
||||||
{
|
|
||||||
if (!isset($exploded_route[3]))
|
|
||||||
$aspect = "record";
|
|
||||||
elseif (preg_match("/^set/", $exploded_route[3]))
|
|
||||||
$action = $exploded_route[3];
|
|
||||||
else
|
|
||||||
$aspect = $exploded_route[3];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case API_V1_Log::BASKETS_RESSOURCE :
|
|
||||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
|
||||||
{
|
|
||||||
if (preg_match("/^set/", $exploded_route[2]) || preg_match("/^delete/", $exploded_route[2]))
|
|
||||||
$action = $exploded_route[2];
|
|
||||||
else
|
|
||||||
$aspect = $exploded_route[2];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case API_V1_Log::FEEDS_RESSOURCE :
|
|
||||||
if ((int) $exploded_route[1] > 0 && sizeof($exploded_route) == 3)
|
|
||||||
$aspect = $exploded_route[2];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* oAuth verification process
|
|
||||||
*/
|
|
||||||
$app->before(function($request) use ($app)
|
|
||||||
{
|
|
||||||
$session = $app["appbox"]->get_session();
|
|
||||||
$oauth2_adapter = new API_OAuth2_Adapter($app["appbox"]);
|
|
||||||
$oauth2_adapter->verifyAccessToken();
|
|
||||||
|
|
||||||
$app['p4user'] = User_Adapter::getInstance($oauth2_adapter->get_usr_id(), $app["appbox"]);
|
|
||||||
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
|
|
||||||
|
|
||||||
if ($session->is_authenticated())
|
|
||||||
return;
|
|
||||||
if ($oauth2_adapter->has_ses_id())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$session->restore($app['p4user'], $oauth2_adapter->get_ses_id());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$auth = new Session_Authentication_None($app['p4user']);
|
|
||||||
$session->authenticate($auth);
|
|
||||||
$oauth2_adapter->remember_this_ses_id($session->get_ses_id());
|
|
||||||
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* oAUth log process
|
|
||||||
*/
|
|
||||||
$app->after(function (Request $request, Response $response) use ($app, $parseRoute)
|
|
||||||
{
|
|
||||||
$account = $app['token']->get_account();
|
|
||||||
$pathInfo = $request->getPathInfo();
|
|
||||||
$route = $parseRoute($pathInfo, $response);
|
|
||||||
$log = API_V1_Log::create(
|
|
||||||
$app["appbox"],
|
|
||||||
$account,
|
|
||||||
$request->getMethod() . " " . $pathInfo,
|
|
||||||
$response->getStatusCode(),
|
|
||||||
$response->headers->get('content-type'),
|
|
||||||
$route['ressource'],
|
|
||||||
$route['general'],
|
|
||||||
$route['aspect'],
|
|
||||||
$route['action']);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method Not Allowed Closure
|
|
||||||
*/
|
|
||||||
$bad_request_exception = function()
|
|
||||||
{
|
|
||||||
throw new API_V1_exception_badrequest();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* *******************************************************************
|
|
||||||
* Route : /databoxes/list/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/databoxes/list/';
|
|
||||||
$app->get(
|
|
||||||
$route, function() use ($app)
|
|
||||||
{
|
|
||||||
return $app['response']($app['api']->get_databoxes($app['request']));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* *******************************************************************
|
|
||||||
*
|
|
||||||
* Route /databoxes/DATABOX_ID/collections/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters ;
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
*/
|
|
||||||
$route = '/databoxes/{databox_id}/collections/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_databox_collections($app['request'], $databox_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/databoxes/{any_id}/collections/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* *******************************************************************
|
|
||||||
* Route /databoxes/DATABOX_ID/status/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters ;
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/databoxes/{databox_id}/status/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_databox_status($app['request'], $databox_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/databoxes/{any_id}/status/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route /databoxes/DATABOX_ID/metadatas/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters ;
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
*/
|
|
||||||
$route = '/databoxes/{databox_id}/metadatas/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_databox_metadatas($app['request'], $databox_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/databoxes/{any_id}/metadatas/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route /databoxes/DATABOX_ID/termsOfUse/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters ;
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
*/
|
|
||||||
$route = '/databoxes/{databox_id}/termsOfUse/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_databox_terms($app['request'], $databox_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/databoxes/{any_id}/termsOfUse/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/search/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET or POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* bases[] : array
|
|
||||||
* status[] : array
|
|
||||||
* fields[] : array
|
|
||||||
* record_type : boolean
|
|
||||||
* media_type : string
|
|
||||||
*
|
|
||||||
* Response :
|
|
||||||
* Array of record objects
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/search/';
|
|
||||||
$app->post(
|
|
||||||
$route, function() use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->search_records($app['request']);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/metadatas/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_record_metadatas($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/records/{any_id}/{anyother_id}/metadatas/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/status/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/status/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_record_status($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/records/{any_id}/{anyother_id}/status/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/related/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/related/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_record_related($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/records/{any_id}/{anyother_id}/related/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/embed/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/embed/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_record_embed($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->get('/records/{any_id}/{anyother_id}/embed/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/setmetadatas/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/setmetadatas/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->set_record_metadatas($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->post('/records/{any_id}/{anyother_id}/setmetadatas/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/setstatus/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/setstatus/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->set_record_status($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
$app->post('/records/{any_id}/{anyother_id}/setstatus/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/setcollection/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* DATABOX_ID : required INT
|
|
||||||
* RECORD_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/records/{databox_id}/{record_id}/setcollection/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->set_record_collection($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
$app->post('/records/{wrong_databox_id}/{wrong_record_id}/setcollection/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
$route = '/records/{databox_id}/{record_id}/';
|
|
||||||
$app->get($route, function($databox_id, $record_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_record($app['request'], $databox_id, $record_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
})->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
$app->get('/records/{any_id}/{anyother_id}/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/list/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/list/';
|
|
||||||
$app->get(
|
|
||||||
$route, function() use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->search_baskets($app['request']);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/add/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/add/';
|
|
||||||
$app->post(
|
|
||||||
$route, function() use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->create_basket($app['request']);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/BASKET_ID/content/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* BASKET_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/{basket_id}/content/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($basket_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_basket($app['request'], $basket_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('basket_id', '\d+');
|
|
||||||
$app->get('/baskets/{wrong_basket_id}/content/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/BASKET_ID/settitle/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* BASKET_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/{basket_id}/setname/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($basket_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->set_basket_title($app['request'], $basket_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('basket_id', '\d+');
|
|
||||||
$app->post('/baskets/{wrong_basket_id}/setname/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/BASKET_ID/setdescription/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* BASKET_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/{basket_id}/setdescription/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($basket_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->set_basket_description($app['request'], $basket_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('basket_id', '\d+');
|
|
||||||
$app->post('/baskets/{wrong_basket_id}/setdescription/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /baskets/BASKET_ID/delete/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* BASKET_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$route = '/baskets/{basket_id}/delete/';
|
|
||||||
$app->post(
|
|
||||||
$route, function($basket_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->delete_basket($app['request'], $basket_id);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('basket_id', '\d+');
|
|
||||||
$app->post('/baskets/{wrong_basket_id}/delete/', $bad_request_exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /feeds/list/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : POST
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// public function search_publications(\Symfony\Component\HttpFoundation\Request $app['request']);
|
|
||||||
|
|
||||||
|
|
||||||
$route = '/feeds/list/';
|
|
||||||
$app->get(
|
|
||||||
$route, function() use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->search_publications($app['request'], $app['p4user']);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Route : /feeds/PUBLICATION_ID/content/FORMAT/
|
|
||||||
*
|
|
||||||
* Method : GET
|
|
||||||
*
|
|
||||||
* Parameters :
|
|
||||||
* PUBLICATION_ID : required INT
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// public function get_publication(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
|
|
||||||
|
|
||||||
$route = '/feeds/{feed_id}/content/';
|
|
||||||
$app->get(
|
|
||||||
$route, function($feed_id) use ($app)
|
|
||||||
{
|
|
||||||
$result = $app['api']->get_publication($app['request'], $feed_id, $app['p4user']);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
}
|
|
||||||
)->assert('feed_id', '\d+');
|
|
||||||
$app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* *******************************************************************
|
|
||||||
*
|
|
||||||
* Route Errors
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
$app->error(function (\Exception $e) use ($app)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ($e instanceof API_V1_exception_methodnotallowed)
|
|
||||||
$code = API_V1_result::ERROR_METHODNOTALLOWED;
|
|
||||||
elseif ($e instanceof Exception\MethodNotAllowedHttpException)
|
|
||||||
$code = API_V1_result::ERROR_METHODNOTALLOWED;
|
|
||||||
elseif ($e instanceof API_V1_exception_badrequest)
|
|
||||||
$code = API_V1_result::ERROR_BAD_REQUEST;
|
|
||||||
elseif ($e instanceof API_V1_exception_forbidden)
|
|
||||||
$code = API_V1_result::ERROR_FORBIDDEN;
|
|
||||||
elseif ($e instanceof API_V1_exception_unauthorized)
|
|
||||||
$code = API_V1_result::ERROR_UNAUTHORIZED;
|
|
||||||
elseif ($e instanceof API_V1_exception_internalservererror)
|
|
||||||
$code = API_V1_result::ERROR_INTERNALSERVERERROR;
|
|
||||||
// elseif ($e instanceof API_V1_exception_notfound)
|
|
||||||
// $code = API_V1_result::ERROR_NOTFOUND;
|
|
||||||
elseif ($e instanceof Exception_NotFound)
|
|
||||||
$code = API_V1_result::ERROR_NOTFOUND;
|
|
||||||
elseif ($e instanceof Exception\NotFoundHttpException)
|
|
||||||
$code = API_V1_result::ERROR_NOTFOUND;
|
|
||||||
else
|
|
||||||
$code = API_V1_result::ERROR_INTERNALSERVERERROR;
|
|
||||||
|
|
||||||
$result = $app['api']->get_error_message($app['request'], $code);
|
|
||||||
|
|
||||||
return $app['response']($result);
|
|
||||||
});
|
|
||||||
//// public function get_version();
|
|
||||||
////
|
|
||||||
////
|
|
||||||
//// /**
|
|
||||||
//// * Route : /records/DATABOX_ID/RECORD_ID/addtobasket/FORMAT/
|
|
||||||
//// *
|
|
||||||
//// * Method : POST
|
|
||||||
//// *
|
|
||||||
//// * Parameters :
|
|
||||||
//// * DATABOX_ID : required INT
|
|
||||||
//// * RECORD_ID : required INT
|
|
||||||
//// *
|
|
||||||
//// */
|
|
||||||
//// public function add_record_tobasket(\Symfony\Component\HttpFoundation\Request $app['request'], $databox_id, $record_id);
|
|
||||||
////
|
|
||||||
////
|
|
||||||
//// /**
|
|
||||||
//// * Route : /feeds/PUBLICATION_ID/remove/FORMAT/
|
|
||||||
//// *
|
|
||||||
//// * Method : GET
|
|
||||||
//// *
|
|
||||||
//// * Parameters :
|
|
||||||
//// * PUBLICATION_ID : required INT
|
|
||||||
//// *
|
|
||||||
//// */
|
|
||||||
//// public function remove_publications(\Symfony\Component\HttpFoundation\Request $app['request'], $publication_id);
|
|
||||||
////
|
|
||||||
////
|
|
||||||
//// /**
|
|
||||||
//// * Route : /users/search/FORMAT/
|
|
||||||
//// *
|
|
||||||
//// * Method : POST-GET
|
|
||||||
//// *
|
|
||||||
//// * Parameters :
|
|
||||||
//// *
|
|
||||||
//// */
|
|
||||||
//// public function search_users(\Symfony\Component\HttpFoundation\Request $app['request']);
|
|
||||||
////
|
|
||||||
//// /**
|
|
||||||
//// * Route : /users/USER_ID/access/FORMAT/
|
|
||||||
//// *
|
|
||||||
//// * Method : GET
|
|
||||||
//// *
|
|
||||||
//// * Parameters :
|
|
||||||
//// * USER_ID : required INT
|
|
||||||
//// *
|
|
||||||
//// */
|
|
||||||
//// public function get_user_acces(\Symfony\Component\HttpFoundation\Request $app['request'], $usr_id);
|
|
||||||
////
|
|
||||||
//// /**
|
|
||||||
//// * Route : /users/add/FORMAT/
|
|
||||||
//// *
|
|
||||||
//// * Method : POST
|
|
||||||
//// *
|
|
||||||
//// * Parameters :
|
|
||||||
//// *
|
|
||||||
//// */
|
|
||||||
//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
|
|
||||||
return $app;
|
|
||||||
|
|
||||||
});
|
|
@@ -57,7 +57,7 @@ class Bridge_Application extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
$app = require __DIR__ . '/../../classes/module/Prod.php';
|
$app = require __DIR__ . '/../../Alchemy/Phrasea/Application/Prod.php';
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
@@ -165,7 +165,7 @@ class Feed_rssfeedsTest extends PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../../lib/classes/module/Root.php';
|
return require dirname(__FILE__) . '/../../../lib/Alchemy/Phrasea/Application/Root.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
//$app->get('/feeds/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
//$app->get('/feeds/aggregated/{format}/', function($format) use ($app, $appbox, $display_feed)
|
||||||
|
@@ -150,7 +150,7 @@ class oauthv2_application_test extends PhraseanetWebTestCaseAuthenticatedAbstrac
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require __DIR__ . '/../../../../lib/classes/module/api/OAuthv2.php';
|
return require __DIR__ . '/../../../../lib/Alchemy/Phrasea/Application/OAuth2.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAuthorizeRedirect()
|
public function testAuthorizeRedirect()
|
||||||
|
@@ -41,7 +41,7 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../../../lib/classes/module/api/V1.php';
|
return require dirname(__FILE__) . '/../../../../lib/Alchemy/Phrasea/Application/Api.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRouteNotFound()
|
public function testRouteNotFound()
|
||||||
|
@@ -50,7 +50,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../../../lib/classes/module/api/V1.php';
|
return require dirname(__FILE__) . '/../../../../lib/Alchemy/Phrasea/Application/Api.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRouteNotFound()
|
public function testRouteNotFound()
|
||||||
|
@@ -35,7 +35,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
$app = require dirname(__FILE__) . '/../../../../classes/module/Admin.php';
|
$app = require dirname(__FILE__) . '/../../../../Alchemy/Phrasea/Application/Admin.php';
|
||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ class Module_LightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../classes/module/Lightbox.php';
|
return require dirname(__FILE__) . '/../../Alchemy/Phrasea/Application/Lightbox.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -45,7 +45,7 @@ class Feed_overviewTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../../../lib/classes/module/Overview.php';
|
return require dirname(__FILE__) . '/../../../../lib/Alchemy/Phrasea/Application/Overview.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
//$deliver_content = function(session $session, record_adapter $record, $subdef, $watermark, $stamp, $app)
|
//$deliver_content = function(session $session, record_adapter $record, $subdef, $watermark, $stamp, $app)
|
||||||
|
@@ -63,7 +63,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
$app = require __DIR__ . '/../../../../../classes/module/Prod.php';
|
$app = require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Prod.php';
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ class Module_Prod_Route_TooltipTest extends PhraseanetWebTestCaseAuthenticatedAb
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../../../classes/module/Prod.php';
|
return require dirname(__FILE__) . '/../../../../Alchemy/Phrasea/Application/Prod.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRouteBasket()
|
public function testRouteBasket()
|
||||||
|
@@ -42,7 +42,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
return require dirname(__FILE__) . '/../../classes/module/Root.php';
|
return require dirname(__FILE__) . '/../../Alchemy/Phrasea/Application/Root.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAggregatedRss()
|
public function testAggregatedRss()
|
||||||
|
@@ -26,7 +26,7 @@ if ($parm["session"])
|
|||||||
session_id($parm["session"]);
|
session_id($parm["session"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$app = require __DIR__ . "/../../lib/classes/module/Admin.php";
|
$app = require __DIR__ . "/../../lib/Alchemy/Application/Admin.php";
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$app = require dirname(__FILE__).'/../../../lib/classes/module/api/OAuthv2.php';
|
$app = require __DIR__ . '/../../../lib/Alchemy/Phrasea/Application/OAuth2.php';
|
||||||
$app->run();
|
$app->run();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
|
@@ -16,9 +16,6 @@
|
|||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//require_once dirname(__FILE__) . "/../../../lib/vendor/Silex/autoload.php";
|
$app = require __DIR__ . '/../../../lib/Alchemy/Phrasea/Application/Api.php';
|
||||||
//use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
$app = require __DIR__ . '/../../../lib/classes/module/api/V1.php';
|
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
@@ -15,10 +15,10 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
require_once dirname(__FILE__) . "/../../lib/bootstrap.php";
|
require_once __DIR__ . "/../../lib/bootstrap.php";
|
||||||
bootstrap::register_autoloads();
|
bootstrap::register_autoloads();
|
||||||
|
|
||||||
$app = require dirname(__FILE__).'/../../lib/classes/module/Overview.php';
|
$app = require __DIR__ .'/../../lib/Alchemy/Phrasea/Application/Overview.php';
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
|
||||||
|
@@ -20,6 +20,6 @@
|
|||||||
require_once __DIR__ . "/../lib/classes/bootstrap.class.php";
|
require_once __DIR__ . "/../lib/classes/bootstrap.class.php";
|
||||||
bootstrap::register_autoloads();
|
bootstrap::register_autoloads();
|
||||||
|
|
||||||
$app = require __DIR__ . '/../lib/classes/module/Root.php';
|
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php';
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once dirname(__FILE__) . "/../../lib/bootstrap.php";
|
require_once __DIR__ . "/../../lib/bootstrap.php";
|
||||||
bootstrap::register_autoloads();
|
bootstrap::register_autoloads();
|
||||||
|
|
||||||
$app = require dirname(__FILE__) . '/../../lib/classes/module/Lightbox.php';
|
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Lightbox.php';
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
require_once __DIR__ . "/../../lib/bootstrap.php";
|
require_once __DIR__ . "/../../lib/bootstrap.php";
|
||||||
bootstrap::register_autoloads();
|
bootstrap::register_autoloads();
|
||||||
|
|
||||||
$app = require __DIR__ . "/../../lib/classes/module/Prod.php";
|
$app = require __DIR__ . "/../../lib/Alchemy/Phrasea/Application/Prod.php";
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ require_once dirname(__FILE__) . '/../../lib/classes/bootstrap.class.php';
|
|||||||
bootstrap::register_autoloads();
|
bootstrap::register_autoloads();
|
||||||
bootstrap::set_php_configuration();
|
bootstrap::set_php_configuration();
|
||||||
|
|
||||||
$app = require __DIR__ . '/../../lib/classes/module/Setup.php';
|
ini_set("display_errors", 1);
|
||||||
|
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Setup.php';
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
Reference in New Issue
Block a user