mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Update admin controllers
This commit is contained in:
@@ -35,7 +35,7 @@ class Collection implements ControllerProviderInterface
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $app['phraseanet.user']->ACL()->has_right_on_base($app['request']->attributes->get('bas_id'), 'canadmin')) {
|
if (!$app['phraseanet.user']->ACL()->has_right_on_base($app['request']->attributes->get('bas_id'), 'canadmin')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -491,8 +491,8 @@ class Collection implements ControllerProviderInterface
|
|||||||
$success = false;
|
$success = false;
|
||||||
$msg = _('An error occurred');
|
$msg = _('An error occurred');
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
if ($collection->get_record_amount() <= 500) {
|
if ($collection->get_record_amount() <= 500) {
|
||||||
$collection->empty_collection(500);
|
$collection->empty_collection(500);
|
||||||
@@ -532,8 +532,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_PRESENTATION);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_PRESENTATION);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -564,8 +565,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_STAMP);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_STAMP);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -596,8 +598,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_WM);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_WM);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -628,8 +631,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->update_logo(null);
|
$collection->update_logo(null);
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_LOGO);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_LOGO);
|
||||||
$success = true;
|
$success = true;
|
||||||
@@ -668,14 +672,14 @@ class Collection implements ControllerProviderInterface
|
|||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
|
|
||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_PRESENTATION);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_PRESENTATION);
|
||||||
|
|
||||||
$app['filesystem']->remove($file->getPathname());
|
$app['filesystem']->remove($file->getPathname());
|
||||||
@@ -706,14 +710,14 @@ class Collection implements ControllerProviderInterface
|
|||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
|
|
||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_STAMP);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_STAMP);
|
||||||
|
|
||||||
$app['filesystem']->remove($file->getPathname());
|
$app['filesystem']->remove($file->getPathname());
|
||||||
@@ -744,14 +748,14 @@ class Collection implements ControllerProviderInterface
|
|||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
|
|
||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_WM);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_WM);
|
||||||
|
|
||||||
$app['filesystem']->remove($file->getPathname());
|
$app['filesystem']->remove($file->getPathname());
|
||||||
@@ -782,14 +786,14 @@ class Collection implements ControllerProviderInterface
|
|||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-too-big');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
|
|
||||||
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO);
|
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO);
|
||||||
|
|
||||||
$app['filesystem']->remove($file->getPathname());
|
$app['filesystem']->remove($file->getPathname());
|
||||||
@@ -814,9 +818,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
$success = false;
|
$success = false;
|
||||||
$msg = _('An error occured');
|
$msg = _('An error occured');
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
if ($collection->get_record_amount() > 0) {
|
if ($collection->get_record_amount() > 0) {
|
||||||
$msg = _('Empty the collection before removing');
|
$msg = _('Empty the collection before removing');
|
||||||
} else {
|
} else {
|
||||||
@@ -862,8 +866,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->unmount_collection($app);
|
$collection->unmount_collection($app);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -897,8 +902,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
|
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->set_name($name);
|
$collection->set_name($name);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -932,8 +938,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
|
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->set_public_presentation($watermark);
|
$collection->set_public_presentation($watermark);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -963,8 +970,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->enable($app['phraseanet.appbox']);
|
$collection->enable($app['phraseanet.appbox']);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -994,8 +1002,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
$collection->disable($app['phraseanet.appbox']);
|
$collection->disable($app['phraseanet.appbox']);
|
||||||
$success = true;
|
$success = true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -1044,7 +1053,7 @@ class Collection implements ControllerProviderInterface
|
|||||||
$suggestedValues[] = array(
|
$suggestedValues[] = array(
|
||||||
'key' => $ki, 'value' => $f, 'name' => $oneValue
|
'key' => $ki, 'value' => $f, 'name' => $oneValue
|
||||||
);
|
);
|
||||||
$f ++;
|
$f++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1087,9 +1096,9 @@ class Collection implements ControllerProviderInterface
|
|||||||
{
|
{
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
try {
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
|
||||||
|
|
||||||
|
try {
|
||||||
if ($mdesc = \DOMDocument::loadXML($request->request->get('str'))) {
|
if ($mdesc = \DOMDocument::loadXML($request->request->get('str'))) {
|
||||||
$collection->set_prefs($mdesc);
|
$collection->set_prefs($mdesc);
|
||||||
$success = true;
|
$success = true;
|
||||||
|
@@ -142,7 +142,7 @@ class Dashboard implements ControllerProviderInterface
|
|||||||
|
|
||||||
$parameters = array(
|
$parameters = array(
|
||||||
'cache_flushed' => $request->query->get('flush_cache') === 'ok',
|
'cache_flushed' => $request->query->get('flush_cache') === 'ok',
|
||||||
'admins' => \User_Adapter::get_sys_admins(),
|
'admins' => \User_Adapter::get_sys_admins($app),
|
||||||
'email_status' => $emailStatus,
|
'email_status' => $emailStatus,
|
||||||
'search_engine_status' => $searchEngineStatus,
|
'search_engine_status' => $searchEngineStatus,
|
||||||
'php_version_constraints' => \setup::check_php_version(),
|
'php_version_constraints' => \setup::check_php_version(),
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Admin;
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core;
|
|
||||||
use Alchemy\Phrasea\Core\Configuration;
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
@@ -31,7 +30,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
|
return $app['firewall']->requireAdmin($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -434,13 +433,13 @@ class Databox implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function getDatabaseCGU(Application $app, Request $request, $databox_id)
|
public function getDatabaseCGU(Application $app, Request $request, $databox_id)
|
||||||
{
|
{
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new Response($app['twig']->render('admin/databox/cgus.html.twig', array(
|
return new Response($app['twig']->render('admin/databox/cgus.html.twig', array(
|
||||||
'languages' => Core::getAvailableLanguages(),
|
'languages' => $app->getAvailableLanguages(),
|
||||||
'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(),
|
'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(),
|
||||||
'current_locale' => \Session_Handler::get_locale()
|
'current_locale' => \Session_Handler::get_locale()
|
||||||
)));
|
)));
|
||||||
@@ -558,7 +557,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function updateDatabaseCGU(Application $app, Request $request, $databox_id)
|
public function updateDatabaseCGU(Application $app, Request $request, $databox_id)
|
||||||
{
|
{
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,11 +595,11 @@ class Databox implements ControllerProviderInterface
|
|||||||
return $app->redirect('/admin/databoxes/?error=special-chars');
|
return $app->redirect('/admin/databoxes/?error=special-chars');
|
||||||
}
|
}
|
||||||
|
|
||||||
$registry = $app['phraseanet.core']['Registry'];
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) {
|
if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) {
|
||||||
|
|
||||||
$configuration = Configuration::build();
|
$configuration = $app['phraseanet.configuration'];
|
||||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
||||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
$connexion = $configuration->getConnexion($choosenConnexion);
|
||||||
|
|
||||||
@@ -619,9 +618,9 @@ class Databox implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$base = \databox::create($app['phraseanet.appbox'], $connbas, $dataTemplate, $registry);
|
$base = \databox::create($app, $connbas, $dataTemplate, $registry);
|
||||||
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
|
$base->registerAdmin($app['phraseanet.user']);
|
||||||
$app['phraseanet.core']->getAuthenticatedUser()->ACL()->delete_data_from_cache();
|
$app['phraseanet.user']->ACL()->delete_data_from_cache();
|
||||||
|
|
||||||
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -642,8 +641,8 @@ class Databox implements ControllerProviderInterface
|
|||||||
$data_template = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml');
|
$data_template = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml');
|
||||||
$connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $registry);
|
$connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $registry);
|
||||||
try {
|
try {
|
||||||
$base = \databox::create($app['phraseanet.appbox'], $connbas, $data_template, $registry);
|
$base = \databox::create($app, $connbas, $data_template, $registry);
|
||||||
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
|
$base->registerAdmin($app['phraseanet.user']);
|
||||||
|
|
||||||
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -677,11 +676,11 @@ class Databox implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$registry = $app['phraseanet.core']['Registry'];
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
if ((null === $request->request->get('new_settings'))) {
|
if ((null === $request->request->get('new_settings'))) {
|
||||||
try {
|
try {
|
||||||
$configuration = Configuration::build();
|
$configuration = $app['phraseanet.configuration'];
|
||||||
$connexion = $configuration->getConnexion();
|
$connexion = $configuration->getConnexion();
|
||||||
|
|
||||||
$hostname = $connexion->get('host');
|
$hostname = $connexion->get('host');
|
||||||
@@ -690,8 +689,8 @@ class Databox implements ControllerProviderInterface
|
|||||||
$password = $connexion->get('password');
|
$password = $connexion->get('password');
|
||||||
|
|
||||||
$appbox->get_connection()->beginTransaction();
|
$appbox->get_connection()->beginTransaction();
|
||||||
$base = \databox::mount($app['phraseanet.appbox'], $hostname, $port, $user, $password, $dbName, $registry);
|
$base = \databox::mount($app, $hostname, $port, $user, $password, $dbName, $registry);
|
||||||
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
|
$base->registerAdmin($app['phraseanet.user']);
|
||||||
$appbox->get_connection()->commit();
|
$appbox->get_connection()->commit();
|
||||||
|
|
||||||
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
||||||
@@ -711,8 +710,8 @@ class Databox implements ControllerProviderInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$appbox->get_connection()->beginTransaction();
|
$appbox->get_connection()->beginTransaction();
|
||||||
$base = \databox::mount($appbox, $hostname, $port, $userDb, $passwordDb, $dbName, $registry);
|
$base = \databox::mount($app, $hostname, $port, $userDb, $passwordDb, $dbName, $registry);
|
||||||
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
|
$base->registerAdmin($app['phraseanet.user']);
|
||||||
$appbox->get_connection()->commit();
|
$appbox->get_connection()->commit();
|
||||||
|
|
||||||
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
|
||||||
@@ -735,7 +734,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
public function mountCollection(Application $app, Request $request, $databox_id, $collection_id)
|
public function mountCollection(Application $app, Request $request, $databox_id, $collection_id)
|
||||||
{
|
{
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
if ( ! $user->ACL()->has_right_on_sbas($databox_id, 'bas_manage')) {
|
if ( ! $user->ACL()->has_right_on_sbas($databox_id, 'bas_manage')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
@@ -743,13 +742,13 @@ class Databox implements ControllerProviderInterface
|
|||||||
|
|
||||||
$appbox->get_connection()->beginTransaction();
|
$appbox->get_connection()->beginTransaction();
|
||||||
try {
|
try {
|
||||||
$baseId = \collection::mount_collection($databox_id, $collection_id, $user);
|
$baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $user);
|
||||||
|
|
||||||
if (null == $othCollSel = $request->request->get("othcollsel")) {
|
if (null == $othCollSel = $request->request->get("othcollsel")) {
|
||||||
$app->abort(400);
|
$app->abort(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = new \User_Query($appbox);
|
$query = new \User_Query($app);
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
|
||||||
while ($n < $query->on_base_ids(array($othCollSel))->get_total()) {
|
while ($n < $query->on_base_ids(array($othCollSel))->get_total()) {
|
||||||
@@ -1018,7 +1017,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
$ret['xml_indexed'] = $datas['xml_indexed'];
|
$ret['xml_indexed'] = $datas['xml_indexed'];
|
||||||
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
|
||||||
|
|
||||||
if ($app['filesystem']->exists($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'config/minilogos/logopdf_' . $databox_id . '.jpg')) {
|
if ($app['filesystem']->exists($app['phraseanet.registry']->get('GV_RootPath') . 'config/minilogos/logopdf_' . $databox_id . '.jpg')) {
|
||||||
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
|
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,7 +1059,7 @@ class Databox implements ControllerProviderInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
foreach ($request->request->get('order', array()) as $order => $baseId) {
|
foreach ($request->request->get('order', array()) as $order => $baseId) {
|
||||||
$collection = \collection::get_from_base_id($baseId);
|
$collection = \collection::get_from_base_id($app, $baseId);
|
||||||
$app['phraseanet.appbox']->set_collection_order($collection, $order);
|
$app['phraseanet.appbox']->set_collection_order($collection, $order);
|
||||||
unset($collection);
|
unset($collection);
|
||||||
}
|
}
|
||||||
@@ -1112,11 +1111,11 @@ class Databox implements ControllerProviderInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$databox = $app['phraseanet.appbox']->get_databox($databox_id);
|
$databox = $app['phraseanet.appbox']->get_databox($databox_id);
|
||||||
$collection = \collection::create($databox, $app['phraseanet.appbox'], $name, $app['phraseanet.core']->getAuthenticatedUser());
|
$collection = \collection::create($app, $databox, $app['phraseanet.appbox'], $name, $app['phraseanet.user']);
|
||||||
|
|
||||||
if (($request->request->get('ccusrothercoll') === "on")
|
if (($request->request->get('ccusrothercoll') === "on")
|
||||||
&& ($othcollsel = $request->request->get('othcollsel') !== null)) {
|
&& ($othcollsel = $request->request->get('othcollsel') !== null)) {
|
||||||
$query = new \User_Query($app['phraseanet.appbox']);
|
$query = new \User_Query($app);
|
||||||
$total = $query->on_base_ids(array($othcollsel))->get_total();
|
$total = $query->on_base_ids(array($othcollsel))->get_total();
|
||||||
$n = 0;
|
$n = 0;
|
||||||
while ($n < $total) {
|
while ($n < $total) {
|
||||||
|
@@ -30,7 +30,7 @@ class Databoxes implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
|
return $app['firewall']->requireAdmin($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +84,7 @@ class Databoxes implements ControllerProviderInterface
|
|||||||
$upgradeAvailable = true;
|
$upgradeAvailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
$sbasIds = array_merge(
|
$sbasIds = array_merge(
|
||||||
array_keys($user->ACL()->get_granted_sbas(array('bas_manage')))
|
array_keys($user->ACL()->get_granted_sbas(array('bas_manage')))
|
||||||
@@ -110,7 +110,7 @@ class Databoxes implements ControllerProviderInterface
|
|||||||
'version' => $databox->get_version(),
|
'version' => $databox->get_version(),
|
||||||
'image' => '/skins/icons/foldph20close_0.gif',
|
'image' => '/skins/icons/foldph20close_0.gif',
|
||||||
'server_info' => $databox->get_connection()->server_info(),
|
'server_info' => $databox->get_connection()->server_info(),
|
||||||
'name' => \phrasea::sbas_names($sbasId)
|
'name' => \phrasea::sbas_names($sbasId, $app)
|
||||||
);
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
@@ -147,10 +147,10 @@ class Databoxes implements ControllerProviderInterface
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$upgrader = new \Setup_Upgrade($app['phraseanet.appbox']);
|
$upgrader = new \Setup_Upgrade($app);
|
||||||
|
|
||||||
return new Response($app['twig']->render('admin/databases.html.twig', array(
|
return new Response($app['twig']->render('admin/databases.html.twig', array(
|
||||||
'files' => new \DirectoryIterator($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/conf.d/data_templates'),
|
'files' => new \DirectoryIterator($app['phraseanet.registry']->get('GV_RootPath') . 'lib/conf.d/data_templates'),
|
||||||
'sbas' => $sbas,
|
'sbas' => $sbas,
|
||||||
'upgrade_available' => $upgradeAvailable,
|
'upgrade_available' => $upgradeAvailable,
|
||||||
'error_msg' => $errorMsg,
|
'error_msg' => $errorMsg,
|
||||||
@@ -168,14 +168,14 @@ class Databoxes implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function databasesUpgrade(Application $app, Request $request)
|
public function databasesUpgrade(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
if (\phrasea::is_scheduler_started()) {
|
if (\phrasea::is_scheduler_started($app)) {
|
||||||
|
|
||||||
return $app->redirect('/admin/databoxes/?success=0&error=scheduler-started');
|
return $app->redirect('/admin/databoxes/?success=0&error=scheduler-started');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$upgrader = new \Setup_Upgrade($app['phraseanet.appbox']);
|
$upgrader = new \Setup_Upgrade($app);
|
||||||
$advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app['phraseanet.core']['CacheService'], $app['phraseanet.core']['EM'], $app['filesystem']);
|
$advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app);
|
||||||
|
|
||||||
return $app->redirect('/admin/databoxes/?success=1¬ice=restart&' . http_build_query(array('advices' => $advices)));
|
return $app->redirect('/admin/databoxes/?success=1¬ice=restart&' . http_build_query(array('advices' => $advices)));
|
||||||
} catch (\Exception_Setup_UpgradeAlreadyStarted $e) {
|
} catch (\Exception_Setup_UpgradeAlreadyStarted $e) {
|
||||||
|
@@ -165,7 +165,7 @@ class Description implements ControllerProviderInterface
|
|||||||
if (is_array($request->request->get('field_ids'))) {
|
if (is_array($request->request->get('field_ids'))) {
|
||||||
foreach ($request->request->get('field_ids') as $id) {
|
foreach ($request->request->get('field_ids') as $id) {
|
||||||
try {
|
try {
|
||||||
$field = \databox_field::get_instance($databox, $id);
|
$field = \databox_field::get_instance($app, $databox, $id);
|
||||||
$field->set_name($request->request->get('name_' . $id))
|
$field->set_name($request->request->get('name_' . $id))
|
||||||
->set_thumbtitle($request->request->get('thumbtitle_' . $id))
|
->set_thumbtitle($request->request->get('thumbtitle_' . $id))
|
||||||
->set_tag(\databox_field::loadClassFromTagName($request->request->get('src_' . $id)))
|
->set_tag(\databox_field::loadClassFromTagName($request->request->get('src_' . $id)))
|
||||||
@@ -181,7 +181,7 @@ class Description implements ControllerProviderInterface
|
|||||||
->setVocabularyRestricted(false);
|
->setVocabularyRestricted(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$vocabulary = VocabularyController::get($request->request->get('vocabulary_' . $id));
|
$vocabulary = VocabularyController::get($app, $request->request->get('vocabulary_' . $id));
|
||||||
$field->setVocabularyControl($vocabulary);
|
$field->setVocabularyControl($vocabulary);
|
||||||
$field->setVocabularyRestricted($request->request->get('vocabularyrestricted_' . $id));
|
$field->setVocabularyRestricted($request->request->get('vocabularyrestricted_' . $id));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -203,14 +203,14 @@ class Description implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->request->get('newfield')) {
|
if ($request->request->get('newfield')) {
|
||||||
$field = \databox_field::create($databox, $request->request->get('newfield'), $request->request->get('newfield_multi'));
|
$field = \databox_field::create($app, $databox, $request->request->get('newfield'), $request->request->get('newfield_multi'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (is_array($request->request->get('todelete_ids'))) {
|
if (is_array($request->request->get('todelete_ids'))) {
|
||||||
foreach ($request->request->get('todelete_ids') as $id) {
|
foreach ($request->request->get('todelete_ids') as $id) {
|
||||||
try {
|
try {
|
||||||
$field = \databox_field::get_instance($databox, $id);
|
$field = \databox_field::get_instance($app, $databox, $id);
|
||||||
$field->delete();
|
$field->delete();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ class Description implements ControllerProviderInterface
|
|||||||
|
|
||||||
return $app->redirect('/admin/description/' . $sbas_id . '/');
|
return $app->redirect('/admin/description/' . $sbas_id . '/');
|
||||||
})->before(function(Request $request) use ($app) {
|
})->before(function(Request $request) use ($app) {
|
||||||
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
|
if (false === $app['phraseanet.user']->ACL()
|
||||||
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
|
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
|
||||||
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
||||||
}
|
}
|
||||||
@@ -239,12 +239,12 @@ class Description implements ControllerProviderInterface
|
|||||||
'databox' => $databox,
|
'databox' => $databox,
|
||||||
'fields' => $databox->get_meta_structure(),
|
'fields' => $databox->get_meta_structure(),
|
||||||
'available_dc_fields' => $databox->get_available_dcfields(),
|
'available_dc_fields' => $databox->get_available_dcfields(),
|
||||||
'vocabularies' => VocabularyController::getAvailable(),
|
'vocabularies' => VocabularyController::getAvailable($app),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('admin/databox/doc_structure.html.twig', $params));
|
return new Response($app['twig']->render('admin/databox/doc_structure.html.twig', $params));
|
||||||
})->before(function(Request $request) use ($app) {
|
})->before(function(Request $request) use ($app) {
|
||||||
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
|
if (false === $app['phraseanet.user']->ACL()
|
||||||
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
|
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
|
||||||
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
throw new AccessDeniedHttpException('You are not allowed to access this zone');
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
$controllers->get('/list/', function(PhraseaApplication $app) {
|
$controllers->get('/list/', function(PhraseaApplication $app) {
|
||||||
|
|
||||||
$feeds = \Feed_Collection::load_all(
|
$feeds = \Feed_Collection::load_all(
|
||||||
$app['phraseanet.appbox'], $app['phraseanet.core']->getAuthenticatedUser()
|
$app, $app['phraseanet.user']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $app['twig']
|
return $app['twig']
|
||||||
@@ -40,23 +40,23 @@ class Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
|
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
|
||||||
|
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
$feed = \Feed_Adapter::create(
|
$feed = \Feed_Adapter::create(
|
||||||
$app['phraseanet.appbox'], $user, $request->request->get('title'), $request->request->get('subtitle')
|
$app, $user, $request->request->get('title'), $request->request->get('subtitle')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($request->request->get('public') == '1') {
|
if ($request->request->get('public') == '1') {
|
||||||
$feed->set_public(true);
|
$feed->set_public(true);
|
||||||
} elseif ($request->request->get('base_id')) {
|
} elseif ($request->request->get('base_id')) {
|
||||||
$feed->set_collection(\collection::get_from_base_id($request->request->get('base_id')));
|
$feed->set_collection(\collection::get_from_base_id($app, $request->request->get('base_id')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/feed/{id}/', function(PhraseaApplication $app, Request $request, $id) {
|
$controllers->get('/feed/{id}/', function(PhraseaApplication $app, Request $request, $id) {
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
|
|
||||||
return $app['twig']
|
return $app['twig']
|
||||||
->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->query->get('error')));
|
->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->query->get('error')));
|
||||||
@@ -64,10 +64,10 @@ class Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/feed/{id}/update/', function(PhraseaApplication $app, Request $request, $id) {
|
$controllers->post('/feed/{id}/update/', function(PhraseaApplication $app, Request $request, $id) {
|
||||||
|
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$collection = \collection::get_from_base_id($request->request->get('base_id'));
|
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$collection = null;
|
$collection = null;
|
||||||
}
|
}
|
||||||
@@ -79,9 +79,9 @@ class Publications implements ControllerProviderInterface
|
|||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
||||||
})->before(function(Request $request) use ($app) {
|
})->before(function(Request $request) use ($app) {
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $request->attributes->get('id'));
|
$feed = new \Feed_Adapter($app, $request->attributes->get('id'));
|
||||||
|
|
||||||
if ( ! $feed->is_owner($app['phraseanet.core']->getAuthenticatedUser())) {
|
if ( ! $feed->is_owner($app['phraseanet.user'])) {
|
||||||
return $app->redirect('/admin/publications/feed/' . $request->attributes->get('id') . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
return $app->redirect('/admin/publications/feed/' . $request->attributes->get('id') . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -93,9 +93,9 @@ class Publications implements ControllerProviderInterface
|
|||||||
'message' => '',
|
'message' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
|
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
$request = $app["request"];
|
$request = $app["request"];
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ class Publications implements ControllerProviderInterface
|
|||||||
throw new \Exception_BadRequest('Uploaded file is invalid');
|
throw new \Exception_BadRequest('Uploaded file is invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
$media = $app['phraseanet.core']['mediavorus']->guess($file);
|
$media = $app['mediavorus']->guess($file->getPathname());
|
||||||
|
|
||||||
if ($media->getType() !== \MediaVorus\Media\Media::TYPE_IMAGE) {
|
if ($media->getType() !== \MediaVorus\Media\MediaInterface::TYPE_IMAGE) {
|
||||||
throw new \Exception_BadRequest('Bad filetype');
|
throw new \Exception_BadRequest('Bad filetype');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
$tmpname = tempnam(sys_get_temp_dir(), 'feed_icon');
|
$tmpname = tempnam(sys_get_temp_dir(), 'feed_icon');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$app['phraseanet.core']['media-alchemyst']
|
$app['media-alchemyst']
|
||||||
->open($media->getFile()->getPathname())
|
->open($media->getFile()->getPathname())
|
||||||
->turnInto($tmpname, $spec)
|
->turnInto($tmpname, $spec)
|
||||||
->close();
|
->close();
|
||||||
@@ -162,8 +162,8 @@ class Publications implements ControllerProviderInterface
|
|||||||
$error = '';
|
$error = '';
|
||||||
try {
|
try {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app['phraseanet.appbox']);
|
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app);
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
$feed->add_publisher($user);
|
$feed->add_publisher($user);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
@@ -176,8 +176,8 @@ class Publications implements ControllerProviderInterface
|
|||||||
try {
|
try {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
$publisher = new \Feed_Publisher_Adapter($app['phraseanet.appbox'], $request->request->get('publisher_id'));
|
$publisher = new \Feed_Publisher_Adapter($app, $request->request->get('publisher_id'));
|
||||||
$user = $publisher->get_user();
|
$user = $publisher->get_user();
|
||||||
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
|
||||||
$publisher->delete();
|
$publisher->delete();
|
||||||
@@ -189,7 +189,7 @@ class Publications implements ControllerProviderInterface
|
|||||||
})->assert('id', '\d+');
|
})->assert('id', '\d+');
|
||||||
|
|
||||||
$controllers->post('/feed/{id}/delete/', function(PhraseaApplication $app, $id) {
|
$controllers->post('/feed/{id}/delete/', function(PhraseaApplication $app, $id) {
|
||||||
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
|
$feed = new \Feed_Adapter($app, $id);
|
||||||
$feed->delete();
|
$feed->delete();
|
||||||
|
|
||||||
return $app->redirect('/admin/publications/list/');
|
return $app->redirect('/admin/publications/list/');
|
||||||
|
@@ -30,11 +30,10 @@ class Root implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/', function(Application $app, Request $request) {
|
$controllers->get('/', function(Application $app, Request $request) {
|
||||||
|
|
||||||
$Core = $app['phraseanet.core'];
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$user = $Core->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
\User_Adapter::updateClientInfos(3);
|
\User_Adapter::updateClientInfos($app, 3);
|
||||||
|
|
||||||
$section = $request->query->get('section', false);
|
$section = $request->query->get('section', false);
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ class Root implements ControllerProviderInterface
|
|||||||
|
|
||||||
return new Response($app['twig']->render('admin/index.html.twig', array(
|
return new Response($app['twig']->render('admin/index.html.twig', array(
|
||||||
'module' => 'admin',
|
'module' => 'admin',
|
||||||
'events' => $app['phraseanet.core']['events-manager'],
|
'events' => $app['events-manager'],
|
||||||
'module_name' => 'Admin',
|
'module_name' => 'Admin',
|
||||||
'notice' => $request->query->get("notice"),
|
'notice' => $request->query->get("notice"),
|
||||||
'feature' => $feature,
|
'feature' => $feature,
|
||||||
@@ -102,11 +101,10 @@ class Root implements ControllerProviderInterface
|
|||||||
->bind('admin');
|
->bind('admin');
|
||||||
|
|
||||||
$controllers->get('/tree/', function(Application $app, Request $request) {
|
$controllers->get('/tree/', function(Application $app, Request $request) {
|
||||||
$Core = $app['phraseanet.core'];
|
|
||||||
$appbox = $app['phraseanet.appbox'];
|
$appbox = $app['phraseanet.appbox'];
|
||||||
$user = $Core->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
\User_Adapter::updateClientInfos(3);
|
\User_Adapter::updateClientInfos($app, 3);
|
||||||
|
|
||||||
$section = $request->query->get('section', false);
|
$section = $request->query->get('section', false);
|
||||||
|
|
||||||
@@ -198,7 +196,7 @@ class Root implements ControllerProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$controllers->get('/structure/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
$controllers->get('/structure/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +224,7 @@ class Root implements ControllerProviderInterface
|
|||||||
->bind('database_display_stucture');
|
->bind('database_display_stucture');
|
||||||
|
|
||||||
$controllers->post('/structure/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
$controllers->post('/structure/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +252,7 @@ class Root implements ControllerProviderInterface
|
|||||||
->bind('database_submit_stucture');
|
->bind('database_submit_stucture');
|
||||||
|
|
||||||
$controllers->get('/statusbit/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
$controllers->get('/statusbit/{databox_id}/', function(Application $app, Request $request, $databox_id) {
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +264,7 @@ class Root implements ControllerProviderInterface
|
|||||||
->bind('database_display_statusbit');
|
->bind('database_display_statusbit');
|
||||||
|
|
||||||
$controllers->get('/statusbit/{databox_id}/status/{bit}/', function(Application $app, Request $request, $databox_id, $bit) {
|
$controllers->get('/statusbit/{databox_id}/status/{bit}/', function(Application $app, Request $request, $databox_id, $bit) {
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,10 +304,14 @@ class Root implements ControllerProviderInterface
|
|||||||
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
$app->abort(400, _('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
|
$app->abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
$error = false;
|
$error = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\databox_status::deleteStatus($app['filesystem'], $databox_id, $bit);
|
\databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
@@ -318,7 +320,7 @@ class Root implements ControllerProviderInterface
|
|||||||
})->assert('databox_id', '\d+')->assert('bit', '\d+');
|
})->assert('databox_id', '\d+')->assert('bit', '\d+');
|
||||||
|
|
||||||
$controllers->post('/statusbit/{databox_id}/status/{bit}/', function(Application $app, Request $request, $databox_id, $bit) {
|
$controllers->post('/statusbit/{databox_id}/status/{bit}/', function(Application $app, Request $request, $databox_id, $bit) {
|
||||||
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
|
||||||
$app->abort(403);
|
$app->abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,15 +332,15 @@ class Root implements ControllerProviderInterface
|
|||||||
'labeloff' => $request->request->get('label_off', '')
|
'labeloff' => $request->request->get('label_off', '')
|
||||||
);
|
);
|
||||||
|
|
||||||
\databox_status::updateStatus($databox_id, $bit, $properties);
|
\databox_status::updateStatus($app, $databox_id, $bit, $properties);
|
||||||
|
|
||||||
if (null !== $request->request->get('delete_icon_off')) {
|
if (null !== $request->request->get('delete_icon_off')) {
|
||||||
\databox_status::deleteIcon($app['filesystem'], $databox_id, $bit, 'off');
|
\databox_status::deleteIcon($app, $databox_id, $bit, 'off');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $file = $request->files->get('image_off')) {
|
if (null !== $file = $request->files->get('image_off')) {
|
||||||
try {
|
try {
|
||||||
\databox_status::updateIcon($app['filesystem'], $databox_id, $bit, 'off', $file);
|
\databox_status::updateIcon($app, $databox_id, $bit, 'off', $file);
|
||||||
} catch (\Exception_Forbidden $e) {
|
} catch (\Exception_Forbidden $e) {
|
||||||
|
|
||||||
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');
|
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');
|
||||||
@@ -361,12 +363,12 @@ class Root implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $request->request->get('delete_icon_on')) {
|
if (null !== $request->request->get('delete_icon_on')) {
|
||||||
\databox_status::deleteIcon($app['filesystem'], $databox_id, $bit, 'on');
|
\databox_status::deleteIcon($app, $databox_id, $bit, 'on');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $file = $request->files->get('image_on')) {
|
if (null !== $file = $request->files->get('image_on')) {
|
||||||
try {
|
try {
|
||||||
\databox_status::updateIcon($app['filesystem'], $databox_id, $bit, 'on', $file);
|
\databox_status::updateIcon($app, $databox_id, $bit, 'on', $file);
|
||||||
} catch (\Exception_Forbidden $e) {
|
} catch (\Exception_Forbidden $e) {
|
||||||
|
|
||||||
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');
|
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');
|
||||||
|
@@ -16,7 +16,9 @@ namespace Alchemy\Phrasea\Controller\Admin;
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
use Silex\Application;
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Silex\Application as SilexApplication;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -30,12 +32,12 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
class Setup implements ControllerProviderInterface
|
class Setup implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(SilexApplication $app)
|
||||||
{
|
{
|
||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
|
return $app['firewall']->requireAdmin($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +84,7 @@ class Setup implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function getGlobals(Application $app, Request $request)
|
public function getGlobals(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
\phrasea::start($app['phraseanet.core']);
|
// \phrasea::start($app['phraseanet.configuration']);
|
||||||
|
|
||||||
require_once __DIR__ . "/../../../../conf.d/_GV_template.inc";
|
require_once __DIR__ . "/../../../../conf.d/_GV_template.inc";
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ class Setup implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function postGlobals(Application $app, Request $request)
|
public function postGlobals(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
if (\setup::create_global_values($app['phraseanet.core']['Registry'], $request->request->all())) {
|
if (\setup::create_global_values($app, $request->request->all())) {
|
||||||
return $app->redirect('/admin/globals/?success=1');
|
return $app->redirect('/admin/globals/?success=1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class Sphinx implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->before(function(Request $request) use ($app) {
|
$controllers->before(function(Request $request) use ($app) {
|
||||||
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
|
return $app['firewall']->requireAdmin($app);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,8 +76,8 @@ class Sphinx implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function getConfiguration(Application $app, Request $request)
|
public function getConfiguration(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
$selected_charsets = $app['phraseanet.core']['Registry']->get('sphinx_charset_tables');
|
$selected_charsets = $app['phraseanet.registry']->get('sphinx_charset_tables');
|
||||||
$selected_libstemmer = $app['phraseanet.core']['Registry']->get('sphinx_user_stemmer');
|
$selected_libstemmer = $app['phraseanet.registry']->get('sphinx_user_stemmer');
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
'charset_tables' => ( ! is_array($selected_charsets) ? array() : $selected_charsets),
|
'charset_tables' => ( ! is_array($selected_charsets) ? array() : $selected_charsets),
|
||||||
@@ -85,7 +85,7 @@ class Sphinx implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
return new Response($app['twig']->render('admin/sphinx/configuration.html.twig', array(
|
return new Response($app['twig']->render('admin/sphinx/configuration.html.twig', array(
|
||||||
'configuration' => new \sphinx_configuration(),
|
'configuration' => new \sphinx_configuration($app),
|
||||||
'options' => $options
|
'options' => $options
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -99,11 +99,11 @@ class Sphinx implements ControllerProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function submitConfiguration(Application $app, Request $request)
|
public function submitConfiguration(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
$app['phraseanet.core']['Registry']->set(
|
$app['phraseanet.registry']->set(
|
||||||
'sphinx_charset_tables', $request->request->get('charset_tables', array()), \registry::TYPE_ARRAY
|
'sphinx_charset_tables', $request->request->get('charset_tables', array()), \registry::TYPE_ARRAY
|
||||||
);
|
);
|
||||||
|
|
||||||
$app['phraseanet.core']['Registry']->set(
|
$app['phraseanet.registry']->set(
|
||||||
'sphinx_user_stemmer', $request->request->get('libstemmer', array()), \registry::TYPE_ARRAY
|
'sphinx_user_stemmer', $request->request->get('libstemmer', array()), \registry::TYPE_ARRAY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -32,14 +32,14 @@ class Users implements ControllerProviderInterface
|
|||||||
$controllers = $app['controllers_factory'];
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
$controllers->post('/rights/', function(Application $app) {
|
$controllers->post('/rights/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
|
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->get('/rights/', function(Application $app) {
|
$controllers->get('/rights/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
|
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
|
||||||
}
|
}
|
||||||
@@ -47,10 +47,9 @@ class Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/rights/reset/', function(Application $app, Request $request) {
|
$controllers->post('/rights/reset/', function(Application $app, Request $request) {
|
||||||
try {
|
try {
|
||||||
$core = $app['phraseanet.core'];
|
|
||||||
$datas = array('error' => false);
|
$datas = array('error' => false);
|
||||||
|
|
||||||
$helper = new UserHelper\Edit($core, $request);
|
$helper = new UserHelper\Edit($app, $request);
|
||||||
$helper->resetRights();
|
$helper->resetRights();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$datas['error'] = true;
|
$datas['error'] = true;
|
||||||
@@ -62,7 +61,7 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/delete/', function(Application $app) {
|
$controllers->post('/delete/', function(Application $app) {
|
||||||
$module = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$module = new UserHelper\Edit($app, $app['request']);
|
||||||
$module->delete_users();
|
$module->delete_users();
|
||||||
|
|
||||||
return $app->redirect('/admin/users/search/');
|
return $app->redirect('/admin/users/search/');
|
||||||
@@ -73,7 +72,7 @@ class Users implements ControllerProviderInterface
|
|||||||
$datas = array('error' => true);
|
$datas = array('error' => true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
$rights->apply_rights();
|
$rights->apply_rights();
|
||||||
|
|
||||||
if ($app['request']->request->get('template')) {
|
if ($app['request']->request->get('template')) {
|
||||||
@@ -92,14 +91,14 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/quotas/', function(Application $app) {
|
$controllers->post('/rights/quotas/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/editusers_quotas.html.twig', $rights->get_quotas());
|
return $app['twig']->render('admin/editusers_quotas.html.twig', $rights->get_quotas());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/quotas/apply/', function(Application $app) {
|
$controllers->post('/rights/quotas/apply/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
$rights->apply_quotas();
|
$rights->apply_quotas();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -107,14 +106,14 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/time/', function(Application $app) {
|
$controllers->post('/rights/time/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/editusers_timelimit.html.twig', $rights->get_time());
|
return $app['twig']->render('admin/editusers_timelimit.html.twig', $rights->get_time());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/time/apply/', function(Application $app) {
|
$controllers->post('/rights/time/apply/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
$rights->apply_time();
|
$rights->apply_time();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -122,14 +121,14 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/masks/', function(Application $app) {
|
$controllers->post('/rights/masks/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/editusers_masks.html.twig', $rights->get_masks());
|
return $app['twig']->render('admin/editusers_masks.html.twig', $rights->get_masks());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/rights/masks/apply/', function(Application $app) {
|
$controllers->post('/rights/masks/apply/', function(Application $app) {
|
||||||
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$rights = new UserHelper\Edit($app, $app['request']);
|
||||||
$rights->apply_masks();
|
$rights->apply_masks();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -137,7 +136,7 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->match('/search/', function(Application $app) {
|
$controllers->match('/search/', function(Application $app) {
|
||||||
$users = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
|
$users = new UserHelper\Manage($app, $app['request']);
|
||||||
|
|
||||||
return $app['twig']->render('admin/users.html.twig', $users->search());
|
return $app['twig']->render('admin/users.html.twig', $users->search());
|
||||||
}
|
}
|
||||||
@@ -146,7 +145,7 @@ class Users implements ControllerProviderInterface
|
|||||||
$controllers->post('/search/export/', function() use ($app) {
|
$controllers->post('/search/export/', function() use ($app) {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$users = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
|
$users = new UserHelper\Manage($app, $app['request']);
|
||||||
|
|
||||||
$userTable = array(
|
$userTable = array(
|
||||||
array(
|
array(
|
||||||
@@ -201,7 +200,7 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->post('/apply_template/', function() use ($app) {
|
$controllers->post('/apply_template/', function() use ($app) {
|
||||||
$users = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
|
$users = new UserHelper\Edit($app, $app['request']);
|
||||||
|
|
||||||
$users->apply_template();
|
$users->apply_template();
|
||||||
|
|
||||||
@@ -212,9 +211,9 @@ class Users implements ControllerProviderInterface
|
|||||||
$controllers->get('/typeahead/search/', function(Application $app) use ($appbox) {
|
$controllers->get('/typeahead/search/', function(Application $app) use ($appbox) {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$user_query = new \User_Query($appbox);
|
$user_query = new \User_Query($app);
|
||||||
|
|
||||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $app);
|
||||||
|
|
||||||
$like_value = $request->query->get('term');
|
$like_value = $request->query->get('term');
|
||||||
$rights = $request->query->get('filter_rights') ? : array();
|
$rights = $request->query->get('filter_rights') ? : array();
|
||||||
@@ -254,7 +253,7 @@ class Users implements ControllerProviderInterface
|
|||||||
$datas = array('error' => false, 'message' => '', 'data' => null);
|
$datas = array('error' => false, 'message' => '', 'data' => null);
|
||||||
try {
|
try {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$module = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
|
$module = new UserHelper\Manage($app, $app['request']);
|
||||||
if ($request->request->get('template') == '1') {
|
if ($request->request->get('template') == '1') {
|
||||||
$user = $module->create_template();
|
$user = $module->create_template();
|
||||||
} else {
|
} else {
|
||||||
@@ -275,9 +274,9 @@ class Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/export/csv/', function(Application $app) use ($appbox) {
|
$controllers->post('/export/csv/', function(Application $app) use ($appbox) {
|
||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
$user_query = new \User_Query($appbox, $app['phraseanet.core']);
|
$user_query = new \User_Query($app);
|
||||||
|
|
||||||
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
|
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $app);
|
||||||
$like_value = $request->request->get('like_value');
|
$like_value = $request->request->get('like_value');
|
||||||
$like_field = $request->request->get('like_field');
|
$like_field = $request->request->get('like_field');
|
||||||
$on_base = $request->request->get('base_id') ? : null;
|
$on_base = $request->request->get('base_id') ? : null;
|
||||||
@@ -328,7 +327,7 @@ class Users implements ControllerProviderInterface
|
|||||||
, $user->get_address()
|
, $user->get_address()
|
||||||
, $user->get_city()
|
, $user->get_city()
|
||||||
, $user->get_zipcode()
|
, $user->get_zipcode()
|
||||||
, $geoname->get_country($user->get_geonameid())
|
, $geoname->get_country($user->get_geonameid(), $app)
|
||||||
, $user->get_tel()
|
, $user->get_tel()
|
||||||
, $user->get_fax()
|
, $user->get_fax()
|
||||||
, $user->get_job()
|
, $user->get_job()
|
||||||
@@ -352,7 +351,7 @@ class Users implements ControllerProviderInterface
|
|||||||
);
|
);
|
||||||
|
|
||||||
$controllers->get('/demands/', function(Application $app, Request $request) use ($appbox) {
|
$controllers->get('/demands/', function(Application $app, Request $request) use ($appbox) {
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
$lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60);
|
$lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60);
|
||||||
$sql = "DELETE FROM demand WHERE date_modif < :date";
|
$sql = "DELETE FROM demand WHERE date_modif < :date";
|
||||||
@@ -460,10 +459,10 @@ class Users implements ControllerProviderInterface
|
|||||||
$cache_to_update = array();
|
$cache_to_update = array();
|
||||||
|
|
||||||
foreach ($templates as $usr => $template_id) {
|
foreach ($templates as $usr => $template_id) {
|
||||||
$user = \User_Adapter::getInstance($usr, $appbox);
|
$user = \User_Adapter::getInstance($usr, $app);
|
||||||
$cache_to_update[$usr] = true;
|
$cache_to_update[$usr] = true;
|
||||||
|
|
||||||
$user_template = \User_Adapter::getInstance($template_id, $appbox);
|
$user_template = \User_Adapter::getInstance($template_id, $app);
|
||||||
$base_ids = array_keys($user_template->ACL()->get_granted_base());
|
$base_ids = array_keys($user_template->ACL()->get_granted_base());
|
||||||
|
|
||||||
$user->ACL()->apply_model($user_template, $base_ids);
|
$user->ACL()->apply_model($user_template, $base_ids);
|
||||||
@@ -510,11 +509,11 @@ class Users implements ControllerProviderInterface
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
foreach ($accept as $usr => $bases) {
|
foreach ($accept as $usr => $bases) {
|
||||||
$user = \User_Adapter::getInstance($usr, $appbox);
|
$user = \User_Adapter::getInstance($usr, $app);
|
||||||
$cache_to_update[$usr] = true;
|
$cache_to_update[$usr] = true;
|
||||||
|
|
||||||
foreach ($bases as $bas) {
|
foreach ($bases as $bas) {
|
||||||
$user->ACL()->give_access_to_sbas(array(\phrasea::sbasFromBas($bas)));
|
$user->ACL()->give_access_to_sbas(array(\phrasea::sbasFromBas($app, $bas)));
|
||||||
|
|
||||||
$rights = array(
|
$rights = array(
|
||||||
'canputinalbum' => '1'
|
'canputinalbum' => '1'
|
||||||
@@ -541,7 +540,7 @@ class Users implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_keys($cache_to_update) as $usr_id) {
|
foreach (array_keys($cache_to_update) as $usr_id) {
|
||||||
$user = \User_Adapter::getInstance($usr_id, $appbox);
|
$user = \User_Adapter::getInstance($usr_id, $app);
|
||||||
$user->ACL()->delete_data_from_cache();
|
$user->ACL()->delete_data_from_cache();
|
||||||
unset($user);
|
unset($user);
|
||||||
}
|
}
|
||||||
@@ -561,13 +560,13 @@ class Users implements ControllerProviderInterface
|
|||||||
if (\PHPMailer::ValidateAddress($row['usr_mail'])) {
|
if (\PHPMailer::ValidateAddress($row['usr_mail'])) {
|
||||||
foreach ($bases as $bas => $isok) {
|
foreach ($bases as $bas => $isok) {
|
||||||
if ($isok) {
|
if ($isok) {
|
||||||
$accept .= '<li>' . \phrasea::bas_names($bas) . "</li>\n";
|
$accept .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
|
||||||
} else {
|
} else {
|
||||||
$deny .= '<li>' . \phrasea::bas_names($bas) . "</li>\n";
|
$deny .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (($accept != '' || $deny != '')) {
|
if (($accept != '' || $deny != '')) {
|
||||||
\mail::register_confirm($row['usr_mail'], $accept, $deny);
|
\mail::register_confirm($app, $row['usr_mail'], $accept, $deny);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,7 +584,7 @@ class Users implements ControllerProviderInterface
|
|||||||
->bind('users_display_import_file');
|
->bind('users_display_import_file');
|
||||||
|
|
||||||
$controllers->post('/import/file/', function(Application $app, Request $request) {
|
$controllers->post('/import/file/', function(Application $app, Request $request) {
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
if ((null === $file = $request->files->get('files')) || ! $file->isValid()) {
|
if ((null === $file = $request->files->get('files')) || ! $file->isValid()) {
|
||||||
|
|
||||||
@@ -648,7 +647,7 @@ class Users implements ControllerProviderInterface
|
|||||||
} elseif (isset($loginNew[$loginToAdd])) {
|
} elseif (isset($loginNew[$loginToAdd])) {
|
||||||
$out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $i);
|
$out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $i);
|
||||||
} else {
|
} else {
|
||||||
if (\User_Adapter::get_usr_id_from_login($loginToAdd)) {
|
if (\User_Adapter::get_usr_id_from_login($app, $loginToAdd)) {
|
||||||
$out['errors'][] = sprintf(_("Login %s already exists in database"), $loginToAdd);
|
$out['errors'][] = sprintf(_("Login %s already exists in database"), $loginToAdd);
|
||||||
} else {
|
} else {
|
||||||
$loginNew[$loginToAdd] = ($i + 1);
|
$loginNew[$loginToAdd] = ($i + 1);
|
||||||
@@ -722,7 +721,7 @@ class Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/import/', function(Application $app, Request $request) {
|
$controllers->post('/import/', function(Application $app, Request $request) {
|
||||||
$nbCreation = 0;
|
$nbCreation = 0;
|
||||||
$user = $app['phraseanet.core']->getAuthenticatedUser();
|
$user = $app['phraseanet.user'];
|
||||||
|
|
||||||
if ((null === $serializedArray = $request->request->get('sr')) || ('' === $serializedArray)) {
|
if ((null === $serializedArray = $request->request->get('sr')) || ('' === $serializedArray)) {
|
||||||
$app->abort(400);
|
$app->abort(400);
|
||||||
@@ -782,13 +781,13 @@ class Users implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($curUser['usr_login']) && trim($curUser['usr_login']) !== '' && isset($curUser['usr_password']) && trim($curUser['usr_password']) !== "") {
|
if (isset($curUser['usr_login']) && trim($curUser['usr_login']) !== '' && isset($curUser['usr_password']) && trim($curUser['usr_password']) !== "") {
|
||||||
$loginNotExist = ! \User_Adapter::get_usr_id_from_login($curUser['usr_login']);
|
$loginNotExist = ! \User_Adapter::get_usr_id_from_login($app, $curUser['usr_login']);
|
||||||
|
|
||||||
if ($loginNotExist) {
|
if ($loginNotExist) {
|
||||||
$NewUser = \User_Adapter::create($app['phraseanet.appbox'], $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
|
$NewUser = \User_Adapter::create($app, $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
|
||||||
|
|
||||||
$NewUser->ACL()->apply_model(
|
$NewUser->ACL()->apply_model(
|
||||||
\User_Adapter::getInstance($model, $app['phraseanet.appbox']), array_keys($user->ACL()->get_granted_base(array('manage')))
|
\User_Adapter::getInstance($model, $app), array_keys($user->ACL()->get_granted_base(array('manage')))
|
||||||
);
|
);
|
||||||
|
|
||||||
$nbCreation ++;
|
$nbCreation ++;
|
||||||
@@ -802,7 +801,7 @@ class Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/import/example/csv/', function(Application $app, Request $request) {
|
$controllers->get('/import/example/csv/', function(Application $app, Request $request) {
|
||||||
|
|
||||||
$file = new \SplFileInfo($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/Fixtures/exampleImportUsers.csv');
|
$file = new \SplFileInfo($app['phraseanet.registry']->get('GV_RootPath') . 'www/admin/exampleImportUsers.csv');
|
||||||
|
|
||||||
if ( ! $file->isFile()) {
|
if ( ! $file->isFile()) {
|
||||||
$app->abort(400);
|
$app->abort(400);
|
||||||
@@ -822,7 +821,7 @@ class Users implements ControllerProviderInterface
|
|||||||
|
|
||||||
$controllers->get('/import/example/rtf/', function(Application $app, Request $request) {
|
$controllers->get('/import/example/rtf/', function(Application $app, Request $request) {
|
||||||
|
|
||||||
$file = new \SplFileInfo($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/Fixtures/Fields.rtf');
|
$file = new \SplFileInfo($app['phraseanet.registry']->get('GV_RootPath') . 'www/admin/Fields.rtf');
|
||||||
|
|
||||||
if ( ! $file->isFile()) {
|
if ( ! $file->isFile()) {
|
||||||
$app->abort(400);
|
$app->abort(400);
|
||||||
|
Reference in New Issue
Block a user