mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Cleanup controllers
This commit is contained in:
@@ -31,71 +31,71 @@ class Datafiles extends AbstractDelivery
|
|||||||
|
|
||||||
$controllers->get('/{sbas_id}/{record_id}/{subdef}/', function($sbas_id, $record_id, $subdef, PhraseaApplication $app) use ($that) {
|
$controllers->get('/{sbas_id}/{record_id}/{subdef}/', function($sbas_id, $record_id, $subdef, PhraseaApplication $app) use ($that) {
|
||||||
|
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$record = new \record_adapter($app, $sbas_id, $record_id);
|
$record = new \record_adapter($app, $sbas_id, $record_id);
|
||||||
|
|
||||||
if (!$app->isAuthenticated()) {
|
if (!$app->isAuthenticated()) {
|
||||||
throw new \Exception_Session_NotAuthenticated();
|
throw new \Exception_Session_NotAuthenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
$all_access = false;
|
$all_access = false;
|
||||||
$subdefStruct = $databox->get_subdef_structure();
|
$subdefStruct = $databox->get_subdef_structure();
|
||||||
|
|
||||||
if ($subdefStruct->getSubdefGroup($record->get_type())) {
|
if ($subdefStruct->getSubdefGroup($record->get_type())) {
|
||||||
foreach ($subdefStruct->getSubdefGroup($record->get_type()) as $subdefObj) {
|
foreach ($subdefStruct->getSubdefGroup($record->get_type()) as $subdefObj) {
|
||||||
if ($subdefObj->get_name() == $subdef) {
|
if ($subdefObj->get_name() == $subdef) {
|
||||||
if ($subdefObj->get_class() == 'thumbnail') {
|
if ($subdefObj->get_class() == 'thumbnail') {
|
||||||
$all_access = true;
|
$all_access = true;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$user = $app['phraseanet.user'];
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
if (!$record->has_subdef($subdef) || !$record->get_subdef($subdef)->is_physically_present()) {
|
if (!$record->has_subdef($subdef) || !$record->get_subdef($subdef)->is_physically_present()) {
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$user->ACL()->has_access_to_subdef($record, $subdef)) {
|
||||||
|
throw new \Exception_UnauthorizedAction(sprintf('User has not access to subdef %s', $subdef));
|
||||||
|
}
|
||||||
|
|
||||||
|
$stamp = false;
|
||||||
|
$watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
||||||
|
|
||||||
|
if ($watermark && !$all_access) {
|
||||||
|
$subdef_class = $databox
|
||||||
|
->get_subdef_structure()
|
||||||
|
->get_subdef($record->get_type(), $subdef)
|
||||||
|
->get_class();
|
||||||
|
|
||||||
|
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record)) {
|
||||||
|
$watermark = false;
|
||||||
|
} elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record)) {
|
||||||
|
$watermark = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$user->ACL()->has_access_to_subdef($record, $subdef)) {
|
if ($watermark && !$all_access) {
|
||||||
throw new \Exception_UnauthorizedAction(sprintf('User has not access to subdef %s', $subdef));
|
|
||||||
|
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
||||||
|
|
||||||
|
/* @var $repository \Repositories\BasketElementRepository */
|
||||||
|
|
||||||
|
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $user);
|
||||||
|
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $user);
|
||||||
|
|
||||||
|
if ($ValidationByRecord && count($ValidationByRecord) > 0) {
|
||||||
|
$watermark = false;
|
||||||
|
} elseif ($ReceptionByRecord && count($ReceptionByRecord) > 0) {
|
||||||
|
$watermark = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$stamp = false;
|
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||||
$watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
if ($watermark && !$all_access) {
|
|
||||||
$subdef_class = $databox
|
|
||||||
->get_subdef_structure()
|
|
||||||
->get_subdef($record->get_type(), $subdef)
|
|
||||||
->get_class();
|
|
||||||
|
|
||||||
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $user->ACL()->has_preview_grant($record)) {
|
|
||||||
$watermark = false;
|
|
||||||
} elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $user->ACL()->has_hd_grant($record)) {
|
|
||||||
$watermark = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($watermark && !$all_access) {
|
|
||||||
|
|
||||||
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketElementRepository */
|
|
||||||
|
|
||||||
$ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $user);
|
|
||||||
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $user);
|
|
||||||
|
|
||||||
if ($ValidationByRecord && count($ValidationByRecord) > 0) {
|
|
||||||
$watermark = false;
|
|
||||||
} elseif ($ReceptionByRecord && count($ReceptionByRecord) > 0) {
|
|
||||||
$watermark = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
|
||||||
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
|
@@ -29,75 +29,72 @@ class Permalink extends AbstractDelivery
|
|||||||
|
|
||||||
$that = $this;
|
$that = $this;
|
||||||
|
|
||||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/'
|
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/view/', function($label, $sbas_id, $record_id, $key, $subdef, PhraseaApplication $app) {
|
||||||
, function($label, $sbas_id, $record_id, $key, $subdef, PhraseaApplication $app) {
|
|
||||||
|
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
|
|
||||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
||||||
|
|
||||||
if (!$record instanceof \record_adapter) {
|
if (!$record instanceof \record_adapter) {
|
||||||
throw new \Exception_NotFound('bad luck');
|
throw new \Exception_NotFound('bad luck');
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'subdef_name' => $subdef
|
'subdef_name' => $subdef
|
||||||
, 'module_name' => 'overview'
|
, 'module_name' => 'overview'
|
||||||
, 'module' => 'overview'
|
, 'module' => 'overview'
|
||||||
, 'view' => 'overview'
|
, 'view' => 'overview'
|
||||||
, 'record' => $record
|
, 'record' => $record
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('overview.html.twig', $params));
|
return $app['twig']->render('overview.html.twig', $params);
|
||||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(Application $app, $label, $sbas_id, $record_id, $key, $subdef) use ($that) {
|
$controllers->get('/v1/{label}/{sbas_id}/{record_id}/{key}/{subdef}/', function(Application $app, $label, $sbas_id, $record_id, $key, $subdef) use ($that) {
|
||||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $key, $record_id, $subdef);
|
||||||
|
|
||||||
if (!($record instanceof \record_adapter)) {
|
if (!($record instanceof \record_adapter)) {
|
||||||
throw new \Exception_NotFound('bad luck');
|
throw new \Exception_NotFound('bad luck');
|
||||||
|
}
|
||||||
|
|
||||||
|
$watermark = $stamp = false;
|
||||||
|
|
||||||
|
if ($app->isAuthenticated()) {
|
||||||
|
$user = \User_Adapter::getInstance($app['phraseanet.user']->get_id(), $app);
|
||||||
|
|
||||||
|
$watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
||||||
|
|
||||||
|
if ($watermark) {
|
||||||
|
|
||||||
|
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
||||||
|
|
||||||
|
if (count($repository->findReceivedValidationElementsByRecord($record, $user)) > 0) {
|
||||||
|
$watermark = false;
|
||||||
|
} elseif (count($repository->findReceivedElementsByRecord($record, $user)) > 0) {
|
||||||
|
$watermark = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$watermark = $stamp = false;
|
|
||||||
|
|
||||||
if ($app->isAuthenticated()) {
|
|
||||||
$user = \User_Adapter::getInstance($app['phraseanet.user']->get_id(), $app);
|
|
||||||
|
|
||||||
$watermark = !$user->ACL()->has_right_on_base($record->get_base_id(), 'nowatermark');
|
|
||||||
|
|
||||||
if ($watermark) {
|
|
||||||
|
|
||||||
$repository = $app['EM']->getRepository('\Entities\BasketElement');
|
|
||||||
|
|
||||||
if (count($repository->findReceivedValidationElementsByRecord($record, $user)) > 0) {
|
|
||||||
$watermark = false;
|
|
||||||
} elseif (count($repository->findReceivedElementsByRecord($record, $user)) > 0) {
|
|
||||||
$watermark = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
|
||||||
} else {
|
|
||||||
$collection = \collection::get_from_base_id($app, $record->get_base_id());
|
|
||||||
switch ($collection->get_pub_wm()) {
|
|
||||||
default:
|
|
||||||
case 'none':
|
|
||||||
$watermark = false;
|
|
||||||
break;
|
|
||||||
case 'stamp':
|
|
||||||
$stamp = true;
|
|
||||||
break;
|
|
||||||
case 'wm':
|
|
||||||
$watermark = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||||
|
} else {
|
||||||
|
$collection = \collection::get_from_base_id($app, $record->get_base_id());
|
||||||
|
switch ($collection->get_pub_wm()) {
|
||||||
|
default:
|
||||||
|
case 'none':
|
||||||
|
$watermark = false;
|
||||||
|
break;
|
||||||
|
case 'stamp':
|
||||||
|
$stamp = true;
|
||||||
|
break;
|
||||||
|
case 'wm':
|
||||||
|
$watermark = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $that->deliverContent($app['request'], $record, $subdef, $watermark, $stamp, $app);
|
||||||
|
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -208,8 +208,7 @@ class RecordsRequest extends ArrayCollection
|
|||||||
$repository = $app['EM']->getRepository('\Entities\StoryWZ');
|
$repository = $app['EM']->getRepository('\Entities\StoryWZ');
|
||||||
|
|
||||||
$storyWZ = $repository->findByUserAndId(
|
$storyWZ = $repository->findByUserAndId(
|
||||||
$app,
|
$app, $app['phraseanet.user']
|
||||||
$app['phraseanet.user']
|
|
||||||
, $request->get('story')
|
, $request->get('story')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ class Account implements ControllerProviderInterface
|
|||||||
$controllers->before(function() use ($app) {
|
$controllers->before(function() use ($app) {
|
||||||
$response = $app['firewall']->requireAuthentication();
|
$response = $app['firewall']->requireAuthentication();
|
||||||
|
|
||||||
if($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -248,9 +248,9 @@ class Account implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($app['twig']->render('account/reset-password.html.twig', array(
|
return $app['twig']->render('account/reset-password.html.twig', array(
|
||||||
'passwordMsg' => $passwordMsg
|
'passwordMsg' => $passwordMsg
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -291,21 +291,17 @@ class Account implements ControllerProviderInterface
|
|||||||
$auth = new \Session_Authentication_Native($app, $user->get_login(), $password);
|
$auth = new \Session_Authentication_Native($app, $user->get_login(), $password);
|
||||||
$auth->challenge_password();
|
$auth->challenge_password();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-email/?notice=bad-password');
|
return $app->redirect('/account/reset-email/?notice=bad-password');
|
||||||
}
|
}
|
||||||
if ( ! \PHPMailer::ValidateAddress($email)) {
|
if (!\PHPMailer::ValidateAddress($email)) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-email/?notice=mail-invalid');
|
return $app->redirect('/account/reset-email/?notice=mail-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($email !== $emailConfirm) {
|
if ($email !== $emailConfirm) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-email/?notice=mail-match');
|
return $app->redirect('/account/reset-email/?notice=mail-match');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! \mail::reset_email($app, $email, $user->get_id()) === true) {
|
if (!\mail::reset_email($app, $email, $user->get_id()) === true) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-email/?notice=mail-server');
|
return $app->redirect('/account/reset-email/?notice=mail-server');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,10 +348,10 @@ class Account implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($app['twig']->render('account/reset-email.html.twig', array(
|
return $app['twig']->render('account/reset-email.html.twig', array(
|
||||||
'noticeMsg' => $noticeMsg,
|
'noticeMsg' => $noticeMsg,
|
||||||
'updateMsg' => $updateMsg,
|
'updateMsg' => $updateMsg,
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,13 +367,10 @@ class Account implements ControllerProviderInterface
|
|||||||
|
|
||||||
if ((null !== $password = $request->request->get('form_password')) && (null !== $passwordConfirm = $request->request->get('form_password_confirm'))) {
|
if ((null !== $password = $request->request->get('form_password')) && (null !== $passwordConfirm = $request->request->get('form_password_confirm'))) {
|
||||||
if ($password !== $passwordConfirm) {
|
if ($password !== $passwordConfirm) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-password/?pass-error=pass-match');
|
return $app->redirect('/account/reset-password/?pass-error=pass-match');
|
||||||
} elseif (strlen(trim($password)) < 5) {
|
} elseif (strlen(trim($password)) < 5) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-password/?pass-error=pass-short');
|
return $app->redirect('/account/reset-password/?pass-error=pass-short');
|
||||||
} elseif (trim($password) != str_replace(array("\r\n", "\n", "\r", "\t", " "), "_", $password)) {
|
} elseif (trim($password) != str_replace(array("\r\n", "\n", "\r", "\t", " "), "_", $password)) {
|
||||||
|
|
||||||
return $app->redirect('/account/reset-password/?pass-error=pass-invalid');
|
return $app->redirect('/account/reset-password/?pass-error=pass-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +398,7 @@ class Account implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function grantAccess(Application $app, Request $request, $application_id)
|
public function grantAccess(Application $app, Request $request, $application_id)
|
||||||
{
|
{
|
||||||
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +417,7 @@ class Account implements ControllerProviderInterface
|
|||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array('success' => ! $error));
|
return $app->json(array('success' => !$error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -438,9 +431,9 @@ class Account implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
require_once $app['phraseanet.registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php';
|
require_once $app['phraseanet.registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php';
|
||||||
|
|
||||||
return new Response($app['twig']->render('account/access.html.twig', array(
|
return $app['twig']->render('account/access.html.twig', array(
|
||||||
'inscriptions' => giveMeBases($app, $app['phraseanet.user']->get_id())
|
'inscriptions' => giveMeBases($app, $app['phraseanet.user']->get_id())
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -453,8 +446,8 @@ class Account implements ControllerProviderInterface
|
|||||||
public function accountAuthorizedApps(Application $app, Request $request)
|
public function accountAuthorizedApps(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
return $app['twig']->render('account/authorized_apps.html.twig', array(
|
return $app['twig']->render('account/authorized_apps.html.twig', array(
|
||||||
"applications" => \API_OAuth2_Application::load_app_by_user($app, $app['phraseanet.user']),
|
"applications" => \API_OAuth2_Application::load_app_by_user($app, $app['phraseanet.user']),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -466,46 +459,15 @@ class Account implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function accountSessionsAccess(Application $app, Request $request)
|
public function accountSessionsAccess(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
|
$dql = 'SELECT s FROM Entities\Session s
|
||||||
|
WHERE s.usr_id = :usr_id
|
||||||
|
ORDER BY s.created DESC';
|
||||||
|
|
||||||
$dql = 'SELECT s FROM Entities\Session s
|
$query = $app['EM']->createQuery($dql);
|
||||||
WHERE s.usr_id = :usr_id
|
$query->setParameters(array('usr_id' => $app['session']->get('usr_id')));
|
||||||
ORDER BY s.created DESC';
|
$sessions = $query->getResult();
|
||||||
|
|
||||||
$query = $app['EM']->createQuery($dql);
|
return $app['twig']->render('account/sessions.html.twig', array('sessions' => $sessions));
|
||||||
$query->setParameters(array('usr_id'=>$app['session']->get('usr_id')));
|
|
||||||
$sessions = $query->getResult();
|
|
||||||
|
|
||||||
// $sql = 'SELECT session_id, lastaccess, ip, platform, browser, screen
|
|
||||||
// , created_on, browser_version, token
|
|
||||||
// FROM cache WHERE usr_id = :usr_id';
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
|
||||||
// $stmt->execute(array(':usr_id' => $this->get_usr_id()));
|
|
||||||
// $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
// $stmt->closeCursor();
|
|
||||||
//
|
|
||||||
// $geonames = new geonames();
|
|
||||||
//
|
|
||||||
// foreach ($rs as $k => $row) {
|
|
||||||
// $datas = $geonames->find_geoname_from_ip($row['ip'], $this->app);
|
|
||||||
//
|
|
||||||
// if ($datas['city']) {
|
|
||||||
// $infos = $datas['city'] . ' (' . $datas['country'] . ')';
|
|
||||||
// } elseif ($datas['fips']) {
|
|
||||||
// $infos = $datas['fips'] . ' (' . $datas['country'] . ')';
|
|
||||||
// } elseif ($datas['country']) {
|
|
||||||
// $infos = $datas['country'];
|
|
||||||
// } else {
|
|
||||||
// $infos = '';
|
|
||||||
// }
|
|
||||||
// $rs[$k]['session_id'] = (int) $rs[$k]['session_id'];
|
|
||||||
// $rs[$k]['ip_infos'] = $infos;
|
|
||||||
// $rs[$k]['created_on'] = new \DateTime($row['created_on']);;
|
|
||||||
// $rs[$k]['lastaccess'] = new \DateTime($row['lastaccess']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return new Response($app['twig']->render('account/sessions.html.twig', array('sessions'=>$sessions)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -539,12 +501,12 @@ class Account implements ControllerProviderInterface
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($app['twig']->render('account/account.html.twig', array(
|
return $app['twig']->render('account/account.html.twig', array(
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'notice' => $notice,
|
'notice' => $notice,
|
||||||
'evt_mngr' => $evtMngr,
|
'evt_mngr' => $evtMngr,
|
||||||
'notifications' => $evtMngr->list_notifications_available($user->get_id()),
|
'notifications' => $evtMngr->list_notifications_available($user->get_id()),
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -31,8 +31,8 @@ class Developers implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function() use ($app) {
|
$controllers->before(function() use ($app) {
|
||||||
$app['firewall']->requireAuthentication($app);
|
$app['firewall']->requireAuthentication($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of apps created by the user
|
* List of apps created by the user
|
||||||
@@ -184,7 +184,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function deleteApp(Application $app, Request $request, $id)
|
public function deleteApp(Application $app, Request $request, $id)
|
||||||
{
|
{
|
||||||
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array('success' => ! $error));
|
return $app->json(array('success' => !$error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +210,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function renewAppCallback(Application $app, Request $request, $id)
|
public function renewAppCallback(Application $app, Request $request, $id)
|
||||||
{
|
{
|
||||||
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array('success' => ! $error));
|
return $app->json(array('success' => !$error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -241,7 +241,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function renewAccessToken(Application $app, Request $request, $id)
|
public function renewAccessToken(Application $app, Request $request, $id)
|
||||||
{
|
{
|
||||||
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array('success' => ! $error, 'token' => $accessToken));
|
return $app->json(array('success' => !$error, 'token' => $accessToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,7 +279,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function authorizeGrantpassword(Application $app, Request $request, $id)
|
public function authorizeGrantpassword(Application $app, Request $request, $id)
|
||||||
{
|
{
|
||||||
if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ class Developers implements ControllerProviderInterface
|
|||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->json(array('success' => ! $error));
|
return $app->json(array('success' => !$error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,9 +341,8 @@ class Developers implements ControllerProviderInterface
|
|||||||
public function listApps(Application $app, Request $request)
|
public function listApps(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
return $app['twig']->render('developers/applications.html.twig', array(
|
return $app['twig']->render('developers/applications.html.twig', array(
|
||||||
"applications" => \API_OAuth2_Application::load_dev_app_by_user(
|
"applications" => \API_OAuth2_Application::load_dev_app_by_user($app, $app['phraseanet.user'])
|
||||||
$app, $app['phraseanet.user']
|
));
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -356,10 +355,10 @@ class Developers implements ControllerProviderInterface
|
|||||||
public function displayFormApp(Application $app, Request $request)
|
public function displayFormApp(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
return $app['twig']->render('developers/application_form.html.twig', array(
|
return $app['twig']->render('developers/application_form.html.twig', array(
|
||||||
"violations" => null,
|
"violations" => null,
|
||||||
'form' => null,
|
'form' => null,
|
||||||
'request' => $request
|
'request' => $request
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,10 +382,10 @@ class Developers implements ControllerProviderInterface
|
|||||||
$token = $client->get_user_account($user)->get_token()->get_value();
|
$token = $client->get_user_account($user)->get_token()->get_value();
|
||||||
|
|
||||||
return $app['twig']->render('developers/application.html.twig', array(
|
return $app['twig']->render('developers/application.html.twig', array(
|
||||||
"application" => $client,
|
"application" => $client,
|
||||||
"user" => $user,
|
"user" => $user,
|
||||||
"token" => $token
|
"token" => $token
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -31,10 +31,10 @@ class Login implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
if ($app['phraseanet.registry']->get('GV_maintenance')) {
|
if ($app['phraseanet.registry']->get('GV_maintenance')) {
|
||||||
return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=maintenance");
|
return $app->redirect("/login/?redirect=" . $request->request->get('redirect') . "&error=maintenance");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -418,12 +418,12 @@ class Login implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response($app['twig']->render('login/forgot-password.html.twig', array(
|
return $app['twig']->render('login/forgot-password.html.twig', array(
|
||||||
'tokenize' => $tokenize,
|
'tokenize' => $tokenize,
|
||||||
'passwordMsg' => $passwordMsg,
|
'passwordMsg' => $passwordMsg,
|
||||||
'errorMsg' => $errorMsg,
|
'errorMsg' => $errorMsg,
|
||||||
'sentMsg' => $sentMsg
|
'sentMsg' => $sentMsg
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,14 +476,14 @@ class Login implements ControllerProviderInterface
|
|||||||
|
|
||||||
$arrayVerif = $this->getRegisterFieldConfiguration($app);
|
$arrayVerif = $this->getRegisterFieldConfiguration($app);
|
||||||
|
|
||||||
return new Response($app['twig']->render('login/register.html.twig', array(
|
return $app['twig']->render('login/register.html.twig', array(
|
||||||
'inscriptions' => giveMeBases($app),
|
'inscriptions' => giveMeBases($app),
|
||||||
'parms' => $request->query->all(),
|
'parms' => $request->query->all(),
|
||||||
'needed' => $needed,
|
'needed' => $needed,
|
||||||
'arrayVerif' => $arrayVerif,
|
'arrayVerif' => $arrayVerif,
|
||||||
'demandes' => $request->query->get('demand', array()),
|
'demandes' => $request->query->get('demand', array()),
|
||||||
'lng' => $app['locale']
|
'lng' => $app['locale']
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,116 +28,116 @@ class RSSFeeds implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$display_feed = function(Application $app, $feed, $format, $page, $user = null) {
|
$display_feed = function(Application $app, $feed, $format, $page, $user = null) {
|
||||||
$total = $feed->get_count_total_entries();
|
$total = $feed->get_count_total_entries();
|
||||||
$perPage = 5;
|
$perPage = 5;
|
||||||
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
$entries = $feed->get_entries((($page - 1) * $perPage), $perPage);
|
||||||
|
|
||||||
$registry = $app['phraseanet.registry'];
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
if ($format == \Feed_Adapter::FORMAT_RSS) {
|
if ($format == \Feed_Adapter::FORMAT_RSS) {
|
||||||
$content = new \Feed_XML_RSS();
|
$content = new \Feed_XML_RSS();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == \Feed_Adapter::FORMAT_ATOM) {
|
if ($format == \Feed_Adapter::FORMAT_ATOM) {
|
||||||
$content = new \Feed_XML_Atom();
|
$content = new \Feed_XML_Atom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($format == \Feed_Adapter::FORMAT_COOLIRIS) {
|
if ($format == \Feed_Adapter::FORMAT_COOLIRIS) {
|
||||||
$content = new \Feed_XML_Cooliris();
|
$content = new \Feed_XML_Cooliris();
|
||||||
}
|
}
|
||||||
|
|
||||||
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)));
|
||||||
if ($total > ($page * $perPage))
|
if ($total > ($page * $perPage))
|
||||||
$content->set_next_page($feed->get_user_link($registry, $user, $format, ($page + 1)));
|
$content->set_next_page($feed->get_user_link($registry, $user, $format, ($page + 1)));
|
||||||
} else {
|
} else {
|
||||||
if ($page > 1)
|
if ($page > 1)
|
||||||
$content->set_previous_page($feed->get_homepage_link($registry, $format, ($page - 1)));
|
$content->set_previous_page($feed->get_homepage_link($registry, $format, ($page - 1)));
|
||||||
if ($total > ($page * $perPage))
|
if ($total > ($page * $perPage))
|
||||||
$content->set_next_page($feed->get_homepage_link($registry, $format, ($page + 1)));
|
$content->set_next_page($feed->get_homepage_link($registry, $format, ($page + 1)));
|
||||||
}
|
}
|
||||||
foreach ($entries->get_entries() as $entry)
|
foreach ($entries->get_entries() as $entry)
|
||||||
$content->set_item($entry);
|
$content->set_item($entry);
|
||||||
|
|
||||||
$render = $content->render();
|
$render = $content->render();
|
||||||
$response = new Response($render, 200, array('Content-Type' => $content->get_mimetype()));
|
$response = new Response($render, 200, array('Content-Type' => $content->get_mimetype()));
|
||||||
$response->setCharset('UTF-8');
|
$response->setCharset('UTF-8');
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
};
|
};
|
||||||
|
|
||||||
$controllers->get('/feed/{id}/{format}/', function(Application $app, $id, $format) use ($display_feed) {
|
$controllers->get('/feed/{id}/{format}/', function(Application $app, $id, $format) use ($display_feed) {
|
||||||
$feed = new \Feed_Adapter($app, $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
|
|
||||||
if (!$feed->is_public()) {
|
if (!$feed->is_public()) {
|
||||||
return new Response('Forbidden', 403);
|
return new Response('Forbidden', 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, $format, $page);
|
return $display_feed($app, $feed, $format, $page);
|
||||||
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/userfeed/{token}/{id}/{format}/', function(Application $app, $token, $id, $format) use ($display_feed) {
|
$controllers->get('/userfeed/{token}/{id}/{format}/', function(Application $app, $token, $id, $format) use ($display_feed) {
|
||||||
$token = new \Feed_Token($app, $token, $id);
|
$token = new \Feed_Token($app, $token, $id);
|
||||||
$feed = $token->get_feed();
|
$feed = $token->get_feed();
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, $format, $page, $token->get_user());
|
return $display_feed($app, $feed, $format, $page, $token->get_user());
|
||||||
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
})->assert('id', '\d+')->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/userfeed/aggregated/{token}/{format}/', function(Application $app, $token, $format) use ($display_feed) {
|
$controllers->get('/userfeed/aggregated/{token}/{format}/', function(Application $app, $token, $format) use ($display_feed) {
|
||||||
$token = new \Feed_TokenAggregate($app, $token);
|
$token = new \Feed_TokenAggregate($app, $token);
|
||||||
$feed = $token->get_feed();
|
$feed = $token->get_feed();
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, $format, $page, $token->get_user());
|
return $display_feed($app, $feed, $format, $page, $token->get_user());
|
||||||
})->assert('format', '(rss|atom)');
|
})->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/aggregated/{format}/', function(Application $app, $format) use ($display_feed) {
|
$controllers->get('/aggregated/{format}/', function(Application $app, $format) use ($display_feed) {
|
||||||
$feeds = \Feed_Collection::load_public_feeds($app);
|
$feeds = \Feed_Collection::load_public_feeds($app);
|
||||||
$feed = $feeds->get_aggregate();
|
$feed = $feeds->get_aggregate();
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, $format, $page);
|
return $display_feed($app, $feed, $format, $page);
|
||||||
})->assert('format', '(rss|atom)');
|
})->assert('format', '(rss|atom)');
|
||||||
|
|
||||||
$controllers->get('/cooliris/', function(Application $app) use ($display_feed) {
|
$controllers->get('/cooliris/', function(Application $app) use ($display_feed) {
|
||||||
$feeds = \Feed_Collection::load_public_feeds($app);
|
$feeds = \Feed_Collection::load_public_feeds($app);
|
||||||
$feed = $feeds->get_aggregate();
|
$feed = $feeds->get_aggregate();
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$page = (int) $request->query->get('page');
|
$page = (int) $request->query->get('page');
|
||||||
$page = $page < 1 ? 1 : $page;
|
$page = $page < 1 ? 1 : $page;
|
||||||
|
|
||||||
return $display_feed($app, $feed, \Feed_Adapter::FORMAT_COOLIRIS, $page);
|
return $display_feed($app, $feed, \Feed_Adapter::FORMAT_COOLIRIS, $page);
|
||||||
});
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -78,14 +78,14 @@ class Installer implements ControllerProviderInterface
|
|||||||
));
|
));
|
||||||
|
|
||||||
return $app['twig']->render(
|
return $app['twig']->render(
|
||||||
'/setup/index.html.twig'
|
'/setup/index.html.twig'
|
||||||
, array_merge($constraints_coll, array(
|
, array_merge($constraints_coll, array(
|
||||||
'locale' => $app['locale']
|
'locale' => $app['locale']
|
||||||
, 'available_locales' => $app->getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'version_number' => $app['phraseanet.version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,20 +131,19 @@ class Installer implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $twig->render(
|
return $twig->render(
|
||||||
'/setup/step2.html.twig'
|
'/setup/step2.html.twig'
|
||||||
, array(
|
, array(
|
||||||
'locale' => $app['locale']
|
'locale' => $app['locale']
|
||||||
, 'available_locales' => $app->getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'available_templates' => \appbox::list_databox_templates()
|
, 'available_templates' => \appbox::list_databox_templates()
|
||||||
, 'version_number' => $app['phraseanet.version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
, 'warnings' => $warnings
|
, 'warnings' => $warnings
|
||||||
, 'error' => $request->query->get('error')
|
, 'error' => $request->query->get('error')
|
||||||
, '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(__DIR__)))) . '/'
|
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doInstall(Application $app, Request $request)
|
public function doInstall(Application $app, Request $request)
|
||||||
|
@@ -27,43 +27,43 @@ class Upgrader implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->get('/', function() use ($app) {
|
$controllers->get('/', function() use ($app) {
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
$upgrade_status = \Setup_Upgrade::get_status();
|
$upgrade_status = \Setup_Upgrade::get_status();
|
||||||
|
|
||||||
return $app['twig']->render(
|
return $app['twig']->render(
|
||||||
'/setup/upgrader.html.twig'
|
'/setup/upgrader.html.twig'
|
||||||
, array(
|
, array(
|
||||||
'locale' => $app['locale']
|
'locale' => $app['locale']
|
||||||
, 'upgrade_status' => $upgrade_status
|
, 'upgrade_status' => $upgrade_status
|
||||||
, 'available_locales' => $app->getAvailableLanguages()
|
, 'available_locales' => $app->getAvailableLanguages()
|
||||||
, 'bad_users' => \User_Adapter::get_wrong_email_users($app)
|
, 'bad_users' => \User_Adapter::get_wrong_email_users($app)
|
||||||
, 'version_number' => $app['phraseanet.version']->getNumber()
|
, 'version_number' => $app['phraseanet.version']->getNumber()
|
||||||
, 'version_name' => $app['phraseanet.version']->getName()
|
, 'version_name' => $app['phraseanet.version']->getName()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/status/', function(Application $app) {
|
$controllers->get('/status/', function(Application $app) {
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
|
|
||||||
return $app->json(\Setup_Upgrade::get_status());
|
return $app->json(\Setup_Upgrade::get_status());
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->post('/execute/', function(Application $app) {
|
$controllers->post('/execute/', function(Application $app) {
|
||||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
session_write_close();
|
session_write_close();
|
||||||
ignore_user_abort(true);
|
ignore_user_abort(true);
|
||||||
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$upgrader = new \Setup_Upgrade($app);
|
$upgrader = new \Setup_Upgrade($app);
|
||||||
$appbox->forceUpgrade($upgrader, $app);
|
$appbox->forceUpgrade($upgrader, $app);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Show recomandation instead of redirect
|
* @todo Show recomandation instead of redirect
|
||||||
*/
|
*/
|
||||||
return $app->redirect('/');
|
return $app->redirect('/');
|
||||||
});
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -27,61 +27,61 @@ class ConnectionTest implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->get('/mysql/', function(Application $app) {
|
$controllers->get('/mysql/', function(Application $app) {
|
||||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||||
|
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$hostname = $request->query->get('hostname', '127.0.0.1');
|
$hostname = $request->query->get('hostname', '127.0.0.1');
|
||||||
$port = (int) $request->query->get('port', 3306);
|
$port = (int) $request->query->get('port', 3306);
|
||||||
$user = $request->query->get('user');
|
$user = $request->query->get('user');
|
||||||
$password = $request->query->get('password');
|
$password = $request->query->get('password');
|
||||||
$dbname = $request->query->get('dbname');
|
$dbname = $request->query->get('dbname');
|
||||||
|
|
||||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), $app['phraseanet.registry']);
|
||||||
|
$connection_ok = true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dbname && $connection_ok === true) {
|
||||||
try {
|
try {
|
||||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), $app['phraseanet.registry']);
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), $app['phraseanet.registry']);
|
||||||
$connection_ok = true;
|
$db_ok = true;
|
||||||
|
|
||||||
|
$sql = "SHOW TABLE STATUS";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$empty = $stmt->rowCount() === 0;
|
||||||
|
|
||||||
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($rs as $row) {
|
||||||
|
if ($row["Name"] === 'sitepreff') {
|
||||||
|
$is_appbox = true;
|
||||||
|
}
|
||||||
|
if ($row["Name"] === 'pref') {
|
||||||
|
$is_databox = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($dbname && $connection_ok === true) {
|
$datas = array(
|
||||||
try {
|
'connection' => $connection_ok
|
||||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), $app['phraseanet.registry']);
|
, 'database' => $db_ok
|
||||||
$db_ok = true;
|
, 'is_empty' => $empty
|
||||||
|
, 'is_appbox' => $is_appbox
|
||||||
|
, 'is_databox' => $is_databox
|
||||||
|
);
|
||||||
|
|
||||||
$sql = "SHOW TABLE STATUS";
|
return $app->json($datas);
|
||||||
$stmt = $conn->prepare($sql);
|
});
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
$empty = $stmt->rowCount() === 0;
|
|
||||||
|
|
||||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
if ($row["Name"] === 'sitepreff') {
|
|
||||||
$is_appbox = true;
|
|
||||||
}
|
|
||||||
if ($row["Name"] === 'pref') {
|
|
||||||
$is_databox = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$datas = array(
|
|
||||||
'connection' => $connection_ok
|
|
||||||
, 'database' => $db_ok
|
|
||||||
, 'is_empty' => $empty
|
|
||||||
, 'is_appbox' => $is_appbox
|
|
||||||
, 'is_databox' => $is_databox
|
|
||||||
);
|
|
||||||
|
|
||||||
return $app->json($datas);
|
|
||||||
});
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
@@ -28,21 +28,19 @@ class PathFileTest implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->get('/path/', function(Application $app, Request $request) {
|
$controllers->get('/path/', function(Application $app, Request $request) {
|
||||||
|
return $app->json(array(
|
||||||
return $app->json(array(
|
'exists' => file_exists($request->query->get('path'))
|
||||||
'exists' => file_exists($request->query->get('path'))
|
, 'file' => is_file($request->query->get('path'))
|
||||||
, 'file' => is_file($request->query->get('path'))
|
, 'dir' => is_dir($request->query->get('path'))
|
||||||
, 'dir' => is_dir($request->query->get('path'))
|
, 'readable' => is_readable($request->query->get('path'))
|
||||||
, 'readable' => is_readable($request->query->get('path'))
|
, 'writeable' => is_writable($request->query->get('path'))
|
||||||
, 'writeable' => is_writable($request->query->get('path'))
|
, 'executable' => is_executable($request->query->get('path'))
|
||||||
, 'executable' => is_executable($request->query->get('path'))
|
));
|
||||||
));
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$controllers->get('/url/', function(Application $app, Request $request) {
|
$controllers->get('/url/', function(Application $app, Request $request) {
|
||||||
|
return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->query->get('url'))));
|
||||||
return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->query->get('url'))));
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user