mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Update Admin/Dashboard controller
This commit is contained in:
@@ -29,7 +29,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
|
||||
return $app['firewall']->requireAdmin($app);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$engine = new \searchEngine_adapter($app['phraseanet.core']['Registry']);
|
||||
$engine = new \searchEngine_adapter($app);
|
||||
$searchEngineStatus = $engine->get_status();
|
||||
} catch (\Exception $e) {
|
||||
$searchEngineStatus = null;
|
||||
@@ -146,8 +146,8 @@ class Dashboard implements ControllerProviderInterface
|
||||
'email_status' => $emailStatus,
|
||||
'search_engine_status' => $searchEngineStatus,
|
||||
'php_version_constraints' => \setup::check_php_version(),
|
||||
'writability_constraints' => \setup::check_writability($app['phraseanet.core']['Registry']),
|
||||
'binaries_constraints' => \setup::check_binaries($app['phraseanet.core']['Registry']),
|
||||
'writability_constraints' => \setup::check_writability($app['phraseanet.registry']),
|
||||
'binaries_constraints' => \setup::check_binaries($app['phraseanet.registry']),
|
||||
'php_extension_constraints' => \setup::check_php_extension(),
|
||||
'cache_constraints' => \setup::check_cache_server(),
|
||||
'phrasea_constraints' => \setup::check_phrasea(),
|
||||
@@ -155,7 +155,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
'php_configuration_constraints' => \setup::check_php_configuration(),
|
||||
);
|
||||
|
||||
return new Response($app['phraseanet.core']['Twig']->render('admin/dashboard.html.twig', $parameters));
|
||||
return new Response($app['twig']->render('admin/dashboard.html.twig', $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
*/
|
||||
public function flush(Application $app, Request $request)
|
||||
{
|
||||
if ($app['phraseanet.core']['CacheService']->flushAll()) {
|
||||
if ($app['phraseanet.cache-service']->flushAll()) {
|
||||
|
||||
return $app->redirect('/admin/dashboard/?flush_cache=ok');
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
$app->abort(400, 'Bad request missing email parameter');
|
||||
};
|
||||
|
||||
if (\mail::mail_test($mail)) {
|
||||
if (\mail::mail_test($app, $mail)) {
|
||||
|
||||
return $app->redirect('/admin/dashboard/?email=sent');
|
||||
}
|
||||
@@ -205,7 +205,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
*/
|
||||
public function resetAdminRights(Application $app, Request $request)
|
||||
{
|
||||
\User_Adapter::reset_sys_admins_rights();
|
||||
\User_Adapter::reset_sys_admins_rights($app);
|
||||
|
||||
return $app->redirect('/admin/dashboard/');
|
||||
}
|
||||
@@ -219,7 +219,7 @@ class Dashboard implements ControllerProviderInterface
|
||||
*/
|
||||
public function addAdmins(Application $app, Request $request)
|
||||
{
|
||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
if (count($admins = $request->request->get('admins', array())) > 0) {
|
||||
|
||||
@@ -228,8 +228,8 @@ class Dashboard implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if ($admins > 0) {
|
||||
\User_Adapter::set_sys_admins(array_filter($admins));
|
||||
\User_Adapter::reset_sys_admins_rights();
|
||||
\User_Adapter::set_sys_admins($app, array_filter($admins));
|
||||
\User_Adapter::reset_sys_admins_rights($app);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,16 +6,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
protected $client;
|
||||
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
||||
|
||||
$app['debug'] = true;
|
||||
unset($app['exception_handler']);
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::slash
|
||||
@@ -25,7 +15,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testRouteDashboardUnauthorized()
|
||||
{
|
||||
$this->setAdmin(false);
|
||||
$this->client->request('GET', '/dashboard/');
|
||||
$this->client->request('GET', '/admin/dashboard/');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +25,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->client->request('GET', '/dashboard/', array(
|
||||
$this->client->request('GET', '/admin/dashboard/', array(
|
||||
'flush_cache' => 'ok',
|
||||
'email' => 'sent'
|
||||
));
|
||||
@@ -50,7 +40,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->client->request('POST', '/dashboard/flush-cache/');
|
||||
$this->client->request('POST', '/admin/dashboard/flush-cache/');
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
$this->assertRegexp('/flush_cache=ok/', $this->client->getResponse()->headers->get('location'));
|
||||
@@ -63,7 +53,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->client->request('POST', '/dashboard/send-mail-test/', array(
|
||||
$this->client->request('POST', '/admin/dashboard/send-mail-test/', array(
|
||||
'email' => self::$user->get_email()
|
||||
));
|
||||
|
||||
@@ -79,7 +69,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->client->request('POST', '/dashboard/send-mail-test/');
|
||||
$this->client->request('POST', '/admin/dashboard/send-mail-test/');
|
||||
}
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::resetAdminRights
|
||||
@@ -88,7 +78,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(true);
|
||||
|
||||
$this->client->request('POST', '/dashboard/reset-admin-rights/');
|
||||
$this->client->request('POST', '/admin/dashboard/reset-admin-rights/');
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
}
|
||||
@@ -102,11 +92,11 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$admins = array_keys(\User_Adapter::get_sys_admins());
|
||||
|
||||
$user = \User_Adapter::create($this->app['phraseanet.appbox'], uniqid('unit_test_user'), uniqid('unit_test_user'), uniqid('unit_test_user') ."@email.com", false);
|
||||
$user = \User_Adapter::create($this->app, uniqid('unit_test_user'), uniqid('unit_test_user'), uniqid('unit_test_user') ."@email.com", false);
|
||||
|
||||
$admins[] = $user->get_id();
|
||||
|
||||
$this->client->request('POST', '/dashboard/add-admins/', array(
|
||||
$this->client->request('POST', '/admin/dashboard/add-admins/', array(
|
||||
'admins' => $admins
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user