mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Code cleanup
This commit is contained in:
@@ -36,10 +36,10 @@ class ConnectedUsers implements ControllerProviderInterface
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
|
||||
$app['Core']['Twig']->addFilter('AppName', new \Twig_Filter_Function(__CLASS__ . '::appName'));
|
||||
$app['phraseanet.core']['Twig']->addFilter('AppName', new \Twig_Filter_Function(__CLASS__ . '::appName'));
|
||||
|
||||
return new Response(
|
||||
$app['Core']['Twig']->render(
|
||||
$app['phraseanet.core']['Twig']->render(
|
||||
'admin/connected-users.html.twig', array('datas' => \Session_Handler::get_active_sessions()
|
||||
)
|
||||
)
|
||||
|
@@ -11,10 +11,11 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
|
||||
use PHPExiftool\Driver\TagProvider;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
|
||||
@@ -155,43 +156,33 @@ class Description implements ControllerProviderInterface
|
||||
return $app->json($res);
|
||||
});
|
||||
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, $sbas_id) {
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||
throw new \Exception_Forbidden('You are not allowed to access this zone');
|
||||
}
|
||||
$controllers->post('/{sbas_id}/', function(Application $app, Request $request, $sbas_id) {
|
||||
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$fields = $databox->get_meta_structure();
|
||||
$available_dc_fields = $databox->get_available_dcfields();
|
||||
|
||||
$databox->get_connection()->beginTransaction();
|
||||
$error = false;
|
||||
try {
|
||||
if (is_array($request->get('field_ids'))) {
|
||||
foreach ($request->get('field_ids') as $id) {
|
||||
try {
|
||||
$field = \databox_field::get_instance($databox, $id);
|
||||
$field->set_name($request->get('name_' . $id));
|
||||
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
|
||||
$field->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id)));
|
||||
$field->set_business($request->get('business_' . $id));
|
||||
$field->set_indexable($request->get('indexable_' . $id));
|
||||
$field->set_required($request->get('required_' . $id));
|
||||
$field->set_separator($request->get('separator_' . $id));
|
||||
$field->set_readonly($request->get('readonly_' . $id));
|
||||
$field->set_type($request->get('type_' . $id));
|
||||
$field->set_tbranch($request->get('tbranch_' . $id));
|
||||
$field->set_report($request->get('report_' . $id));
|
||||
|
||||
$field->setVocabularyControl(null);
|
||||
$field->setVocabularyRestricted(false);
|
||||
$field->set_name($request->get('name_' . $id))
|
||||
->set_thumbtitle($request->get('thumbtitle_' . $id))
|
||||
->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id)))
|
||||
->set_multi($request->get('multi_' . $id))
|
||||
->set_business($request->get('business_' . $id))
|
||||
->set_indexable($request->get('indexable_' . $id))
|
||||
->set_required($request->get('required_' . $id))
|
||||
->set_separator($request->get('separator_' . $id))
|
||||
->set_readonly($request->get('readonly_' . $id))
|
||||
->set_type($request->get('type_' . $id))
|
||||
->set_tbranch($request->get('tbranch_' . $id))
|
||||
->set_report($request->get('report_' . $id))
|
||||
->setVocabularyControl(null)
|
||||
->setVocabularyRestricted(false);
|
||||
|
||||
try {
|
||||
$vocabulary = \Alchemy\Phrasea\Vocabulary\Controller::get($request->get('vocabulary_' . $id));
|
||||
$vocabulary = VocabularyController::get($request->get('vocabulary_' . $id));
|
||||
$field->setVocabularyControl($vocabulary);
|
||||
$field->setVocabularyRestricted($request->get('vocabularyrestricted_' . $id));
|
||||
} catch (\Exception $e) {
|
||||
@@ -201,11 +192,11 @@ class Description implements ControllerProviderInterface
|
||||
$dces_element = null;
|
||||
|
||||
$class = 'databox_Field_DCES_' . $request->get('dces_' . $id);
|
||||
if (class_exists($class))
|
||||
if (class_exists($class)) {
|
||||
$dces_element = new $class();
|
||||
}
|
||||
|
||||
$field->set_dces_element($dces_element);
|
||||
$field->save();
|
||||
$field->set_dces_element($dces_element)->save();
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
@@ -226,41 +217,37 @@ class Description implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$databox->get_connection()->rollBack();
|
||||
} else {
|
||||
$databox->get_connection()->commit();
|
||||
} catch (\Exception $e) {
|
||||
$databox->get_connection()->rollBack();
|
||||
}
|
||||
|
||||
return $app->redirect('/admin/description/' . $sbas_id . '/');
|
||||
})->before(function(Request $request) use ($app) {
|
||||
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
|
||||
->has_right_on_sbas($request->get('sbas_id'), 'bas_modify_struct')) {
|
||||
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
||||
}
|
||||
})->assert('sbas_id', '\d+');
|
||||
|
||||
$controllers->get('/{sbas_id}/', function(Application $app, $sbas_id) {
|
||||
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
if ( ! $user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) {
|
||||
throw new \Exception_Forbidden('You are not allowed to access this zone');
|
||||
}
|
||||
|
||||
$databox = \databox::get_instance((int) $sbas_id);
|
||||
$fields = $databox->get_meta_structure();
|
||||
$available_dc_fields = $databox->get_available_dcfields();
|
||||
|
||||
$params = array(
|
||||
'databox' => $databox,
|
||||
'fields' => $fields,
|
||||
'available_dc_fields' => $available_dc_fields,
|
||||
'vocabularies' => \Alchemy\Phrasea\Vocabulary\Controller::getAvailable(),
|
||||
'fields' => $databox->get_meta_structure(),
|
||||
'available_dc_fields' => $databox->get_available_dcfields(),
|
||||
'vocabularies' => VocabularyController::getAvailable(),
|
||||
);
|
||||
|
||||
return new Response($app['phraseanet.core']->getTwig()->render('admin/databox/doc_structure.twig', $params));
|
||||
})->before(function(Request $request) use ($app) {
|
||||
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
|
||||
->has_right_on_sbas($request->get('sbas_id'), 'bas_modify_struct')) {
|
||||
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
||||
}
|
||||
})->assert('sbas_id', '\d+');
|
||||
|
||||
return $controllers;
|
||||
|
@@ -11,11 +11,10 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,12 +26,9 @@ class Fields implements ControllerProviderInterface
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/checkmulti/', function() use ($app, $appbox) {
|
||||
$request = $app['request'];
|
||||
$controllers->get('/checkmulti/', function(PhraseaApplication $app, Request $request) {
|
||||
|
||||
$multi = ($request->get('multi') === 'true');
|
||||
|
||||
@@ -43,17 +39,10 @@ class Fields implements ControllerProviderInterface
|
||||
'is_multi' => $tag->isMulti(),
|
||||
);
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
});
|
||||
|
||||
$controllers->get('/checkreadonly/', function() use ($app, $appbox) {
|
||||
$request = $app['request'];
|
||||
$controllers->get('/checkreadonly/', function(PhraseaApplication $app, Request $request) {
|
||||
$readonly = ($request->get('readonly') === 'true');
|
||||
|
||||
$tag = \databox_field::loadClassFromTagName($request->get('source'));
|
||||
@@ -63,13 +52,7 @@ class Fields implements ControllerProviderInterface
|
||||
'is_readonly' => ! $tag->isWritable(),
|
||||
);
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json'),
|
||||
200,
|
||||
array('Content-Type' => 'application/json')
|
||||
);
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -11,11 +11,11 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,61 +27,45 @@ class Publications implements ControllerProviderInterface
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$session = $appbox->get_session();
|
||||
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/list/', function() use ($app, $appbox) {
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$controllers->get('/list/', function(PhraseaApplication $app) {
|
||||
|
||||
$template = 'admin/publications/list.html';
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['phraseanet.core']->getTwig();
|
||||
$feeds = \Feed_Collection::load_all(
|
||||
$app['phraseanet.appbox'], $app['phraseanet.core']->getAuthenticatedUser()
|
||||
);
|
||||
|
||||
return $twig->render($template, array('feeds' => $feeds));
|
||||
return $app['phraseanet.core']->getTwig()
|
||||
->render('admin/publications/list.html', array('feeds' => $feeds));
|
||||
});
|
||||
|
||||
$controllers->post('/create/', function() use ($app, $appbox) {
|
||||
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
|
||||
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
$request = $app['request'];
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
|
||||
$feed = \Feed_Adapter::create($appbox, $user, $request->get('title'), $request->get('subtitle'));
|
||||
$feed = \Feed_Adapter::create(
|
||||
$app['phraseanet.appbox'], $user, $request->get('title'), $request->get('subtitle')
|
||||
);
|
||||
|
||||
if ($request->get('public') == '1')
|
||||
if ($request->get('public') == '1') {
|
||||
$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')));
|
||||
}
|
||||
|
||||
return $app->redirect('/admin/publications/list/');
|
||||
});
|
||||
|
||||
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox) {
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$controllers->get('/feed/{id}/', function(PhraseaApplication $app, Request $request, $id) {
|
||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['phraseanet.core']->getTwig();
|
||||
|
||||
return $twig->render('admin/publications/fiche.html.twig'
|
||||
, array(
|
||||
'feed' => $feed
|
||||
, 'error' => $app['request']->get('error')
|
||||
)
|
||||
);
|
||||
return $app['phraseanet.core']->getTwig()
|
||||
->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->get('error')));
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/feed/{id}/update/', function($id) use ($app, $appbox) {
|
||||
$controllers->post('/feed/{id}/update/', function(PhraseaApplication $app, Request $request, $id) {
|
||||
|
||||
$feed = new \Feed_Adapter($appbox, $id);
|
||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
$request = $app['request'];
|
||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
||||
|
||||
try {
|
||||
$collection = \collection::get_from_base_id($request->get('base_id'));
|
||||
@@ -95,10 +79,16 @@ class Publications implements ControllerProviderInterface
|
||||
$feed->set_public($request->get('public'));
|
||||
|
||||
return $app->redirect('/admin/publications/list/');
|
||||
})->assert('id', '\d+');
|
||||
})->before(function(Request $request) use ($app) {
|
||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $request->get('id'));
|
||||
|
||||
$controllers->post('/feed/{id}/iconupload/', function($id) use ($app, $appbox) {
|
||||
try {
|
||||
if ( ! $feed->is_owner($app['phraseanet.core']->getAuthenticatedUser())) {
|
||||
return $app->redirect('/admin/publications/feed/' . $request->get('id') . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||
}
|
||||
})
|
||||
->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/feed/{id}/iconupload/', function(PhraseaApplication $app, Request $request, $id) {
|
||||
$datas = array(
|
||||
'success' => false,
|
||||
'message' => '',
|
||||
@@ -114,6 +104,7 @@ class Publications implements ControllerProviderInterface
|
||||
throw new \Exception_Forbidden('ERROR:you are not allowed');
|
||||
}
|
||||
|
||||
try {
|
||||
if ( ! $request->files->get('files')) {
|
||||
throw new \Exception_BadRequest('Missing file parameter');
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -36,8 +35,8 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
|
||||
$Core = $app['Core'];
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$Core = $app['phraseanet.core'];
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$user = $Core->getAuthenticatedUser();
|
||||
|
||||
\User_Adapter::updateClientInfos(3);
|
||||
|
114
lib/Alchemy/Phrasea/Controller/Login/Authenticate.php
Normal file
114
lib/Alchemy/Phrasea/Controller/Login/Authenticate.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Login;
|
||||
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class Authenticate implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->post('/', __CLASS__ . '::authenticate')
|
||||
->before('Alchemy\Phrasea\Security\Firewall::requrieNotAuthenticated');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
public function authenticate(Application $app, Request $request)
|
||||
{
|
||||
/* @var $Core \Alchemy\Phrasea\Core */
|
||||
$Core = $app['phraseanet.core'];
|
||||
|
||||
$appbox = \appbox::get_instance($Core);
|
||||
$session = $appbox->get_session();
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
if ($registry->get('GV_captchas')
|
||||
&& trim($registry->get('GV_captcha_private_key')) !== ''
|
||||
&& trim($registry->get('GV_captcha_public_key')) !== '')
|
||||
include($registry->get('GV_RootPath') . 'lib/vendor/recaptcha/recaptchalib.php');
|
||||
|
||||
$is_guest = false;
|
||||
|
||||
if (null !== $request->get('nolog') && \phrasea::guest_allowed()) {
|
||||
$is_guest = true;
|
||||
}
|
||||
|
||||
if ((null !== $request->get('login') && null !== $request->get('pwd')) || $is_guest) {
|
||||
|
||||
/**
|
||||
* @todo dispatch an event that can be used to tweak the authentication
|
||||
* (LDAP....)
|
||||
*/
|
||||
// $app['dispatcher']->dispatch();
|
||||
|
||||
try {
|
||||
if ($is_guest) {
|
||||
$auth = new \Session_Authentication_Guest($appbox);
|
||||
} else {
|
||||
$captcha = false;
|
||||
|
||||
if ($registry->get('GV_captchas')
|
||||
&& trim($registry->get('GV_captcha_private_key')) !== ''
|
||||
&& trim($registry->get('GV_captcha_public_key')) !== ''
|
||||
&& ! is_null($request->get("recaptcha_challenge_field")
|
||||
&& ! is_null($request->get("recaptcha_response_field")))) {
|
||||
$checkCaptcha = recaptcha_check_answer($registry->get('GV_captcha_private_key'), $_SERVER["REMOTE_ADDR"], $request->get("recaptcha_challenge_field"), $request->get("recaptcha_response_field"));
|
||||
|
||||
if ($checkCaptcha->is_valid) {
|
||||
$captcha = true;
|
||||
}
|
||||
}
|
||||
|
||||
$auth = new \Session_Authentication_Native($appbox, $request->get('login'), $request->get('pwd'));
|
||||
$auth->set_captcha_challenge($captcha);
|
||||
}
|
||||
$session->authenticate($auth);
|
||||
} catch (\Exception_Session_StorageClosed $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
|
||||
} catch (\Exception_Session_RequireCaptcha $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=captcha");
|
||||
} catch (\Exception_Unauthorized $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=auth");
|
||||
} catch (\Exception_Session_MailLocked $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=mailNotConfirm&usr=" . $e->get_usr_id());
|
||||
} catch (\Exception_Session_WrongToken $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=token");
|
||||
} catch (\Exception_InternalServerError $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=session");
|
||||
} catch (\Exception_ServiceUnavailable $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=maintenance");
|
||||
} catch (\Exception_Session_BadSalinity $e) {
|
||||
$date = new \DateTime('5 minutes');
|
||||
$usr_id = \User_Adapter::get_usr_id_from_login($request->get('login'));
|
||||
$url = \random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $date);
|
||||
|
||||
$url = '/account/forgot-password/?token=' . $url . '&salt=1';
|
||||
|
||||
return $app->redirect($url);
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect("/login/?redirect=" . $request->get('redirect') . "&error=" . _('An error occured'));
|
||||
}
|
||||
|
||||
$browser = \Browser::getInstance();
|
||||
|
||||
if($browser->isMobile()) {
|
||||
return $app->redirect("/lightbox/");
|
||||
} elseif ($request->get('redirect')) {
|
||||
return $app->redirect($request->get('redirect'));
|
||||
} elseif (true !== $browser->isNewGeneration()) {
|
||||
return $app->redirect('/client/');
|
||||
} else {
|
||||
return $app->redirect('/prod/');
|
||||
}
|
||||
} else {
|
||||
return $app->redirect("/login/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,13 +46,10 @@ class Account implements ControllerProviderInterface
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/', $this->call('displayAccount'))
|
||||
->bind('get_account');
|
||||
$controllers->get('/', $this->call('displayAccount'))->bind('account');
|
||||
|
||||
/**
|
||||
* Create account route
|
||||
*
|
||||
* name : create_account
|
||||
* Update account route
|
||||
*
|
||||
* description : update your account informations
|
||||
*
|
||||
@@ -91,8 +88,7 @@ class Account implements ControllerProviderInterface
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->post('/', $this->call('updateAccount'))
|
||||
->bind('create_account');
|
||||
$controllers->post('/', $this->call('updateAccount'));
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,8 +104,8 @@ class Account implements ControllerProviderInterface
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/access/', $this->call('accountAccess'))
|
||||
->bind('account_access');
|
||||
$controllers->get('/forgot-password/', $this->call('displayForgotPasswordForm'))
|
||||
->bind('forgot_password');
|
||||
|
||||
/**
|
||||
* Get reset email
|
||||
@@ -140,90 +136,7 @@ class Account implements ControllerProviderInterface
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->post('/reset-email/', $this->call('resetEmail'))
|
||||
->bind('post_account_reset_email');
|
||||
|
||||
/**
|
||||
* Get reset password
|
||||
*
|
||||
* name : account_reset_password
|
||||
*
|
||||
* description : Display form to reset password
|
||||
*
|
||||
* method : GET
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/reset-password/', $this->call('resetPassword'))
|
||||
->bind('account_reset_password');
|
||||
|
||||
/**
|
||||
* Reset user password
|
||||
*
|
||||
* name : post_account_reset_password
|
||||
*
|
||||
* description : Reset user password
|
||||
*
|
||||
* method : POST
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->post('/reset-password/', $this->call('renewPassword'))
|
||||
->bind('post_account_reset_password');
|
||||
|
||||
/**
|
||||
* Get security session
|
||||
*
|
||||
* name : account_security_sessions
|
||||
*
|
||||
* description : Display user's open sessions
|
||||
*
|
||||
* method : GET
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/security/sessions/', $this->call('accountSessionsAccess'))
|
||||
->bind('account_security_sessions');
|
||||
|
||||
/**
|
||||
* Get authorized apps
|
||||
*
|
||||
* name : account_security_applications
|
||||
*
|
||||
* description : Give authorized applications that can access user informations
|
||||
*
|
||||
* method : GET
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/security/applications/', $this->call('accountAuthorizedApps'))
|
||||
->bind('account_security_applications');
|
||||
|
||||
/**
|
||||
* Grant access to an authorized app
|
||||
*
|
||||
* name : account_security_applications_grant
|
||||
*
|
||||
* description : Grant or revoke access to a client application
|
||||
*
|
||||
* method : POST
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : JSON Response
|
||||
*/
|
||||
$controllers->post('/security/application/{application_id}/grant/', $this->call('grantAccess'))
|
||||
->assert('application_id', '\d+')
|
||||
->bind('account_security_applications_grant');
|
||||
|
||||
$controllers->post('/forgot-password/', $this->call('renewPassword'));
|
||||
|
||||
/**
|
||||
* Give account access
|
||||
@@ -238,8 +151,52 @@ class Account implements ControllerProviderInterface
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/access/', $this->call('accountAccess'))
|
||||
->bind('account_access');
|
||||
$controllers->get('/access/', $this->call('accountAccess'))->bind('account_access');
|
||||
|
||||
// /**
|
||||
// * Give account open sessions
|
||||
// *
|
||||
// * name : register_account
|
||||
// *
|
||||
// * description : Display form to create a new account
|
||||
// *
|
||||
// * method : GET
|
||||
// *
|
||||
// * parameters : none
|
||||
// *
|
||||
// * return : HTML Response
|
||||
// */
|
||||
// $controllers->get('/register/', $this->call('registerAccount'))->bind('register_account');
|
||||
|
||||
/**
|
||||
* Give authorized applications that can access user informations
|
||||
*
|
||||
* name : reset_email
|
||||
*
|
||||
* description : Display form to create a new account
|
||||
*
|
||||
* method : GET
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/reset-email/', $this->call('resetEmail'))->bind('reset_email');
|
||||
|
||||
/**
|
||||
* Grant access to an authorized app
|
||||
*
|
||||
* name : reset_password
|
||||
*
|
||||
* description : Display form to create a new account
|
||||
*
|
||||
* method : GET
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/reset-password/', $this->call('resetPassword'))->bind('reset_password');
|
||||
|
||||
/**
|
||||
* Give account open sessions
|
||||
@@ -293,13 +250,11 @@ class Account implements ControllerProviderInterface
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to reset a password
|
||||
*
|
||||
* @param \Silex\Application $app
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
*/
|
||||
public function registerAccount(Application $app, Request $request)
|
||||
{
|
||||
return new Response($app['phraseanet.core']['Twig']->render('account/register.html.twig'));
|
||||
}
|
||||
|
||||
public function resetPassword(Application $app, Request $request)
|
||||
{
|
||||
if (null !== $passwordMsg = $request->get('pass-error')) {
|
||||
@@ -316,7 +271,7 @@ class Account implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
return new Response($app['Core']['Twig']->render('account/reset-password.html.twig', array(
|
||||
return new Response($app['phraseanet.core']['Twig']->render('account/reset-password.html.twig', array(
|
||||
'passwordMsg' => $passwordMsg
|
||||
)));
|
||||
}
|
||||
@@ -353,7 +308,7 @@ class Account implements ControllerProviderInterface
|
||||
$app->abort(400, _('Could not perform request, please contact an administrator.'));
|
||||
}
|
||||
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
|
||||
try {
|
||||
$auth = new \Session_Authentication_Native($appbox, $user->get_login(), $password);
|
||||
@@ -420,7 +375,7 @@ class Account implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
return new Response($app['Core']['Twig']->render('account/reset-email.html.twig', array(
|
||||
return new Response($app['phraseanet.core']['Twig']->render('account/reset-email.html.twig', array(
|
||||
'noticeMsg' => $noticeMsg,
|
||||
'updateMsg' => $updateMsg,
|
||||
)));
|
||||
@@ -435,7 +390,7 @@ class Account implements ControllerProviderInterface
|
||||
*/
|
||||
public function renewPassword(Application $app, Request $request)
|
||||
{
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$appbox = \appbox::get_instance($app['phraseanet.core']);
|
||||
|
||||
if ((null !== $password = $request->get('form_password')) && (null !== $passwordConfirm = $request->get('form_password_confirm'))) {
|
||||
if ($password !== $passwordConfirm) {
|
||||
@@ -450,7 +405,7 @@ class Account implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $app['Core']->getAuthenticatedUser();
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
|
||||
$auth = new \Session_Authentication_Native($appbox, $user->get_login(), $request->get('form_old_password', ''));
|
||||
$auth->challenge_password();
|
||||
@@ -478,14 +433,14 @@ class Account implements ControllerProviderInterface
|
||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||
}
|
||||
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$appbox = \appbox::get_instance($app['phraseanet.core']);
|
||||
$error = false;
|
||||
|
||||
try {
|
||||
$account = \API_OAuth2_Account::load_with_user(
|
||||
$appbox
|
||||
, new \API_OAuth2_Application($appbox, $application_id)
|
||||
, $app['Core']->getAuthenticatedUser()
|
||||
, $app['phraseanet.core']->getAuthenticatedUser()
|
||||
);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$error = true;
|
||||
@@ -496,8 +451,6 @@ class Account implements ControllerProviderInterface
|
||||
return new JsonResponse(array('success' => ! $error));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Display account base access
|
||||
*
|
||||
@@ -508,10 +461,10 @@ class Account implements ControllerProviderInterface
|
||||
*/
|
||||
public function accountAccess(Application $app, Request $request)
|
||||
{
|
||||
require_once $app['Core']['Registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php';
|
||||
require_once $app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php';
|
||||
|
||||
return new Response($app['Core']['Twig']->render('account/access.html.twig', array(
|
||||
'inscriptions' => giveMeBases($app['Core']->getAuthenticatedUser()->get_id())
|
||||
return new Response($app['phraseanet.core']['Twig']->render('account/access.html.twig', array(
|
||||
'inscriptions' => giveMeBases($app['phraseanet.core']->getAuthenticatedUser()->get_id())
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -525,9 +478,9 @@ class Account implements ControllerProviderInterface
|
||||
*/
|
||||
public function accountAuthorizedApps(Application $app, Request $request)
|
||||
{
|
||||
return $app['Core']['Twig']->render('account/authorized_apps.html.twig', array(
|
||||
"apps" => \API_OAuth2_Application::load_app_by_user(\appbox::get_instance($app['Core']), $user),
|
||||
'user' => $app['Core']->getAuthenticatedUser()
|
||||
return $app['phraseanet.core']['Twig']->render('account/authorized_apps.html.twig', array(
|
||||
"apps" => \API_OAuth2_Application::load_app_by_user(\appbox::get_instance($app['phraseanet.core']), $user),
|
||||
'user' => $app['phraseanet.core']->getAuthenticatedUser()
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -220,8 +220,8 @@ class Developers implements ControllerProviderInterface
|
||||
try {
|
||||
$clientApp = new \API_OAuth2_Application($app['phraseanet.appbox'], $id);
|
||||
|
||||
if ($callback = $request->get("callback")) {
|
||||
$clientApp->set_redirect_uri($callback);
|
||||
if (null !== $request->get("callback")) {
|
||||
$clientApp->set_redirect_uri($request->get("callback"));
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
@@ -28,6 +28,15 @@ class Login implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
|
||||
|
||||
$controllers->get('/', $this->call('login'))
|
||||
->before(function() use ($app) {
|
||||
return $app['phraseanet.core']['Firewall']->requireNotAuthenticated($app);
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Logout
|
||||
*
|
||||
@@ -136,7 +145,7 @@ class Login implements ControllerProviderInterface
|
||||
*/
|
||||
public function sendConfirmMail(Application $app, Request $request)
|
||||
{
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
|
||||
if (null === $usrId = $request->get('usr_id')) {
|
||||
$app->abort(400, sprintf(_('Request to send you the confirmation mail failed, please retry')));
|
||||
@@ -163,7 +172,7 @@ class Login implements ControllerProviderInterface
|
||||
*/
|
||||
public function registerConfirm(Application $app, Request $request)
|
||||
{
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
|
||||
if (null === $code = $request->get('code')) {
|
||||
return $app->redirect('/login/?redirect=/prod&error=code-not-found');
|
||||
@@ -224,7 +233,7 @@ class Login implements ControllerProviderInterface
|
||||
*/
|
||||
public function renewPassword(Application $app, Request $request)
|
||||
{
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
|
||||
if (null !== $mail = trim($request->get('mail'))) {
|
||||
if ( ! \PHPMailer::ValidateAddress($mail)) {
|
||||
@@ -240,7 +249,7 @@ class Login implements ControllerProviderInterface
|
||||
$token = \random::getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), new \DateTime('+1 day'));
|
||||
|
||||
if ($token) {
|
||||
$url = sprintf('%slogin/forgot-password/?token=%s', $app['Core']['Registry']->get('GV_ServerName'), $token);
|
||||
$url = sprintf('%slogin/forgot-password/?token=%s', $app['phraseanet.core']['Registry']->get('GV_ServerName'), $token);
|
||||
|
||||
if (\mail::forgot_passord($mail, $user->get_login(), $url)) {
|
||||
return $app->redirect('/login/forgot-password/?sent=ok');
|
||||
@@ -345,7 +354,7 @@ class Login implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
return new Response($app['Core']['Twig']->render('login/forgot-password.html.twig', array(
|
||||
return new Response($app['phraseanet.core']['Twig']->render('login/forgot-password.html.twig', array(
|
||||
'tokenize' => $tokenize,
|
||||
'passwordMsg' => $passwordMsg,
|
||||
'errorMsg' => $errorMsg,
|
||||
@@ -362,7 +371,7 @@ class Login implements ControllerProviderInterface
|
||||
*/
|
||||
public function displayRegisterForm(Application $app, Request $request)
|
||||
{
|
||||
return new Response($app['Core']['Twig']->render('login/register.html.twig'));
|
||||
return new Response($app['phraseanet.core']['Twig']->render('login/register.html.twig'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,19 +385,137 @@ class Login implements ControllerProviderInterface
|
||||
{
|
||||
$appRedirect = $request->get("app");
|
||||
|
||||
try {
|
||||
$appbox = \appbox::get_instance($app['Core']);
|
||||
$session = $appbox->get_session();
|
||||
// try {
|
||||
$session = $app['phraseanet.appbox']->get_session();
|
||||
|
||||
$session->logout();
|
||||
$session->remove_cookies();
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect("/" . ($appRedirect ? $appRedirect : 'prod'));
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// return $app->redirect("/" . ($appRedirect ? $appRedirect : 'prod'));
|
||||
// }
|
||||
|
||||
return $app->redirect("/login/?logged_out=user" . ($appRedirect ? sprintf("&redirect=/%s", $appRedirect) : ""));
|
||||
}
|
||||
|
||||
|
||||
public function login(Application $app, Request $request)
|
||||
{
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$session = $appbox->get_session();
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
require_once($registry->get('GV_RootPath') . 'lib/classes/deprecated/inscript.api.php');
|
||||
if ($registry->get('GV_captchas') && trim($registry->get('GV_captcha_private_key')) !== '' && trim($registry->get('GV_captcha_public_key')) !== '') {
|
||||
include($registry->get('GV_RootPath') . 'lib/vendor/recaptcha/recaptchalib.php');
|
||||
}
|
||||
|
||||
if ($request->get('postlog')) {
|
||||
$session->set_postlog(true);
|
||||
|
||||
return $app->redirect("/login/index.php?redirect=" . $request->get('redirect'));
|
||||
}
|
||||
|
||||
if ( ! $session->isset_postlog() && $session->is_authenticated() && $request->get('error') != 'no-connection') {
|
||||
return $app->redirect($request->get('redirect', '/prod/'));
|
||||
}
|
||||
|
||||
$noconn = false;
|
||||
try {
|
||||
$conn = $appbox->get_connection();
|
||||
} catch (Exception $e) {
|
||||
$noconn = true;
|
||||
}
|
||||
|
||||
$client = \Browser::getInstance();
|
||||
|
||||
$warning = $notice = '';
|
||||
$linkMailConfirm = false;
|
||||
|
||||
if (ctype_digit($request->get('usr'))) {
|
||||
$linkMailConfirm = true;
|
||||
$errorWarning .= '<div class="notice"><a href="/login/sendmail-confirm.php?usr_id=' . $request->get('usr') . '" target ="_self" style="color:black;text-decoration:none;">' . _('login:: Envoyer a nouveau le mail de confirmation') . '</a></div>';
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case $registry->get('GV_maintenance'):
|
||||
case $request->get('error') === 'maintenance':
|
||||
$warning = _('login::erreur: maintenance en cours, merci de nous excuser pour la gene occasionee');
|
||||
break;
|
||||
case $noconn:
|
||||
case $request->get('error') === 'no-connection':
|
||||
$warning = _('login::erreur: No available connection - Please contact sys-admin');
|
||||
break;
|
||||
case $request->get('error') === 'auth':
|
||||
$warning = _('login::erreur: Erreur d\'authentification');
|
||||
break;
|
||||
case $request->get('error') === 'captcha':
|
||||
$warning = _('login::erreur: Erreur de captcha');
|
||||
break;
|
||||
case $request->get('error') === 'mailNotConfirm' :
|
||||
$warning = _('login::erreur: Vous n\'avez pas confirme votre email');
|
||||
break;
|
||||
case $request->get('error') === 'no-base' :
|
||||
$warning = _('login::erreur: Aucune base n\'est actuellment accessible');
|
||||
break;
|
||||
}
|
||||
switch ($request->get('notice')) {
|
||||
case 'ok':
|
||||
$notice = _('login::register: sujet email : confirmation de votre adresse email') . '</div>';
|
||||
break;
|
||||
case 'already':
|
||||
$notice = _('login::notification: cette email est deja confirmee') . '</div>';
|
||||
break;
|
||||
case 'mail-sent':
|
||||
$notice = _('login::notification: demande de confirmation par mail envoyee') . '</div>';
|
||||
break;
|
||||
case 'register-ok':
|
||||
$notice = _('login::notification: votre email est desormais confirme') . '</div>';
|
||||
break;
|
||||
case 'register-ok-wait':
|
||||
$notice = _('Your email is now confirmed. You will be informed as soon as your pending request will be managed');
|
||||
break;
|
||||
case 'password-update-ok':
|
||||
$notice = _('login::notification: Mise a jour du mot de passe avec succes');
|
||||
break;
|
||||
}
|
||||
|
||||
$captchaSys = '';
|
||||
if ( ! $registry->get('GV_maintenance')
|
||||
&& $registry->get('GV_captchas')
|
||||
&& trim($registry->get('GV_captcha_private_key')) !== ''
|
||||
&& trim($registry->get('GV_captcha_public_key')) !== ''
|
||||
&& $request->get('error') == 'captcha') {
|
||||
$captchaSys = '<div style="margin:0;float: left;width:330px;"><div id="recaptcha_image" style="float: left;margin:10px 15px 5px"></div>
|
||||
<div style="text-align:center;float: left;margin:0 15px 5px;width:300px;">
|
||||
<a href="javascript:Recaptcha.reload()" class="link">' . _('login::captcha: obtenir une autre captcha') . '</a>
|
||||
</div>
|
||||
<div style="text-align:center;float: left;width:300px;margin:0 15px 0px;">
|
||||
<span class="recaptcha_only_if_image">' . _('login::captcha: recopier les mots ci dessous') . ' : </span>
|
||||
<input name="recaptcha_response_field" id="recaptcha_response_field" value="" type="text" style="width:180px;"/>
|
||||
</div>' . recaptcha_get_html($registry->get('GV_captcha_public_key')) . '</div>';
|
||||
}
|
||||
|
||||
$public_feeds = \Feed_Collection::load_public_feeds($appbox);
|
||||
$feeds = array_merge(array($public_feeds->get_aggregate()), $public_feeds->get_feeds());
|
||||
|
||||
//$twig = new supertwig(array('Escaper' => false));
|
||||
$core = \bootstrap::getCore();
|
||||
$twig = $core->getTwig();
|
||||
|
||||
return $twig->render('login/index.twig', array(
|
||||
'module_name' => _('Accueil'),
|
||||
'notice' => $notice,
|
||||
'warning' => $warning,
|
||||
'redirect' => $request->get('redirect'),
|
||||
'logged_out' => $request->get('logged_out'),
|
||||
'captcha_system' => $captchaSys,
|
||||
'login' => new \login(),
|
||||
'feeds' => $feeds,
|
||||
'display_layout' => $registry->get('GV_home_publi')
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix the method to call with the controller class name
|
||||
*
|
||||
|
@@ -11,11 +11,12 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Setup;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
use \Alchemy\Phrasea\Core\Service\Builder as ServiceBuilder;
|
||||
use Doctrine\ORM\Tools\SchemaTool;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,8 +30,7 @@ class Installer implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/', function() use ($app) {
|
||||
$request = $app['request'];
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
|
||||
$php_constraint = \setup::check_php_version();
|
||||
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||
@@ -68,7 +68,7 @@ class Installer implements ControllerProviderInterface
|
||||
$loader = new \Twig_Loader_Filesystem($ld_path);
|
||||
$twig = new \Twig_Environment($loader);
|
||||
|
||||
$html = $twig->render(
|
||||
return $twig->render(
|
||||
'/setup/index.html.twig'
|
||||
, array_merge($constraints_coll, array(
|
||||
'locale' => \Session_Handler::get_locale()
|
||||
@@ -78,11 +78,9 @@ class Installer implements ControllerProviderInterface
|
||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||
))
|
||||
);
|
||||
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->get('/step2/', function() use ($app) {
|
||||
$controllers->get('/step2/', function(Application $app, Request $request) {
|
||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||
|
||||
$ld_path = array(__DIR__ . '/../../../../../templates/web');
|
||||
@@ -91,8 +89,6 @@ class Installer implements ControllerProviderInterface
|
||||
$twig = new \Twig_Environment($loader);
|
||||
$twig->addExtension(new \Twig_Extensions_Extension_I18n());
|
||||
|
||||
$request = $app['request'];
|
||||
|
||||
$warnings = array();
|
||||
|
||||
$php_constraint = \setup::check_php_version();
|
||||
@@ -124,7 +120,7 @@ class Installer implements ControllerProviderInterface
|
||||
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
||||
}
|
||||
|
||||
$html = $twig->render(
|
||||
return $twig->render(
|
||||
'/setup/step2.html.twig'
|
||||
, array(
|
||||
'locale' => \Session_Handler::get_locale()
|
||||
@@ -139,20 +135,14 @@ class Installer implements ControllerProviderInterface
|
||||
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
||||
)
|
||||
);
|
||||
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->post('/install/', function() use ($app) {
|
||||
$controllers->post('/install/', function(Application $app, Request $request) {
|
||||
set_time_limit(360);
|
||||
\phrasea::use_i18n(\Session_Handler::get_locale());
|
||||
$request = $app['request'];
|
||||
|
||||
$servername = $request->getScheme() . '://' . $request->getHttpHost() . '/';
|
||||
|
||||
$setupRegistry = new \Setup_Registry();
|
||||
$setupRegistry->set('GV_ServerName', $servername, \registry::TYPE_STRING);
|
||||
|
||||
$conn = $connbas = null;
|
||||
|
||||
$hostname = $request->get('ab_hostname');
|
||||
@@ -183,13 +173,13 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$appbox = \appbox::create($app['phraseanet.core'], $setupRegistry, $conn, $appbox_name, true);
|
||||
|
||||
$configuration = \Alchemy\Phrasea\Core\Configuration::build();
|
||||
$configuration = Configuration::build();
|
||||
|
||||
if ($configuration->isInstalled()) {
|
||||
$serviceName = $configuration->getOrm();
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$ormService = \Alchemy\Phrasea\Core\Service\Builder::create(
|
||||
$ormService = ServiceBuilder::create(
|
||||
$app['phraseanet.core']
|
||||
, $confService
|
||||
);
|
||||
@@ -203,7 +193,7 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
if ( ! empty($metadatas)) {
|
||||
// Create SchemaTool
|
||||
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
||||
$tool = new SchemaTool($em);
|
||||
// Create schema
|
||||
$tool->dropSchema($metadatas);
|
||||
$tool->createSchema($metadatas);
|
||||
|
@@ -11,10 +11,8 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Setup;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,10 +30,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
$upgrade_status = \Setup_Upgrade::get_status();
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['phraseanet.core']->getTwig();
|
||||
|
||||
$html = $twig->render(
|
||||
return $app['phraseanet.core']->getTwig()->render(
|
||||
'/setup/upgrader.html.twig'
|
||||
, array(
|
||||
'locale' => \Session_Handler::get_locale()
|
||||
@@ -46,9 +41,6 @@ class Upgrader implements ControllerProviderInterface
|
||||
, 'version_name' => $app['phraseanet.core']['Version']->getName()
|
||||
)
|
||||
);
|
||||
ini_set('display_errors', 'on');
|
||||
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->get('/status/', function() use ($app) {
|
||||
@@ -56,13 +48,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
|
||||
$datas = \Setup_Upgrade::get_status();
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type: application/json')
|
||||
);
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
});
|
||||
|
||||
$controllers->post('/execute/', function() use ($app) {
|
||||
@@ -78,8 +64,7 @@ class Upgrader implements ControllerProviderInterface
|
||||
/**
|
||||
* @todo Show recomandation instead of redirect
|
||||
*/
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\RedirectResponse('/');
|
||||
return new $app->redirect('/');
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
|
@@ -11,11 +11,8 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Utils;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +26,7 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/mysql/', function() use ($app) {
|
||||
$controllers->get('/mysql/', function(Application $app) {
|
||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||
|
||||
$request = $app['request'];
|
||||
@@ -75,8 +72,6 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
$datas = array(
|
||||
'connection' => $connection_ok
|
||||
, 'database' => $db_ok
|
||||
@@ -85,14 +80,9 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
, 'is_databox' => $is_databox
|
||||
);
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('content-type' => 'application/json')
|
||||
);
|
||||
return $app->json($app['phraseanet.core']['Serializer']->serialize($datas, 'json'));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,10 +12,8 @@
|
||||
namespace Alchemy\Phrasea\Controller\Utils;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ControllerCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,13 +27,11 @@ class PathFileTest implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/path/', function() use ($app) {
|
||||
$path = $app['request']->get('path');
|
||||
$controllers->get('/path/', function( Request $request) {
|
||||
$path = $request->get('path');
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize(
|
||||
return $app->json(
|
||||
$app['phraseanet.core']['Serializer']->serialize(
|
||||
array(
|
||||
'exists' => file_exists($path)
|
||||
, 'file' => is_file($path)
|
||||
@@ -46,25 +42,17 @@ class PathFileTest implements ControllerProviderInterface
|
||||
)
|
||||
, 'json'
|
||||
)
|
||||
, 200
|
||||
, array('content-type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/url/', function() use ($app) {
|
||||
$url = $app['request']->get('url');
|
||||
$controllers->get('/url/', function( Request $request) {
|
||||
$url = $request->get('url');
|
||||
|
||||
$Serializer = $app['phraseanet.core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize(
|
||||
array(
|
||||
'code' => \http_query::getHttpCodeFromUrl($url)
|
||||
)
|
||||
return $app->json(
|
||||
$app['phraseanet.core']['Serializer']->serialize(
|
||||
array('code' => \http_query::getHttpCodeFromUrl($url))
|
||||
, 'json'
|
||||
)
|
||||
, 200
|
||||
, array('content-type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user