diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php index de214a049e..e49debeee4 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php @@ -46,7 +46,7 @@ class Collection implements ControllerProviderInterface /** * Get a collection * - * name : admin_database_collection + * name : admin_display_collection * * description : Display collection information page * @@ -58,12 +58,12 @@ class Collection implements ControllerProviderInterface */ $controllers->get('/{bas_id}/', $this->call('getCollection')) ->assert('bas_id', '\d+') - ->bind('admin_database_collection'); + ->bind('admin_display_collection'); /** * Get a collection suggested values * - * name : admin_database_suggested_values + * name : admin_collection_display_suggested_values * * description : Display page to edit suggested values * @@ -75,12 +75,12 @@ class Collection implements ControllerProviderInterface */ $controllers->get('/{bas_id}/suggested-values/', $this->call('getSuggestedValues')) ->assert('bas_id', '\d+') - ->bind('admin_database_suggested_values'); + ->bind('admin_collection_display_suggested_values'); /** * Submit suggested values * - * name : admin_database_submit_suggested_values + * name : admin_collection_submit_suggested_values * * description : Submit suggested values * @@ -92,7 +92,7 @@ class Collection implements ControllerProviderInterface */ $controllers->post('/{bas_id}/suggested-values/', $this->call('submitSuggestedValues')) ->assert('bas_id', '\d+') - ->bind('admin_database_submit_suggested_values'); + ->bind('admin_collection_submit_suggested_values'); /** * Delete a collection @@ -101,14 +101,15 @@ class Collection implements ControllerProviderInterface * * description : Delete a collection * - * method : DELETE + * method : POST * * parameters : none * * return : JSON Response */ - $controllers->delete('/{bas_id}/', $this->call('delete')) - ->assert('bas_id', '\d+')->bind('admin_collection_delete'); + $controllers->post('/{bas_id}/delete/', $this->call('delete')) + ->assert('bas_id', '\d+') + ->bind('admin_collection_delete'); /** * Enable a collection @@ -124,12 +125,13 @@ class Collection implements ControllerProviderInterface * return : JSON Response */ $controllers->post('/{bas_id}/enable/', $this->call('enable')) - ->assert('bas_id', '\d+')->bind('admin_collection_enable'); + ->assert('bas_id', '\d+') + ->bind('admin_collection_enable'); /** * Disable a collection * - * name : admin_collection_disabled + * name : admin_collection_disable * * description : Disable a collection * @@ -141,12 +143,12 @@ class Collection implements ControllerProviderInterface */ $controllers->post('/{bas_id}/disabled/', $this->call('disabled')) ->assert('bas_id', '\d+') - ->bind('admin_collection_disabled'); + ->bind('admin_collection_disable'); /** * Set new order admin * - * name : admin_collection_order_admins + * name : admin_collection_submit_order_admins * * description : Set new admins for handle items order * @@ -158,7 +160,7 @@ class Collection implements ControllerProviderInterface */ $controllers->post('/{bas_id}/order/admins/', $this->call('setOrderAdmins')) ->assert('bas_id', '\d+') - ->bind('admin_collection_order_admins'); + ->bind('admin_collection_submit_order_admins'); /** * Set publication watermark @@ -252,13 +254,13 @@ class Collection implements ControllerProviderInterface * * description : Delete the current collection mini logo * - * method : DELETE + * method : POST * * parameters : none * * return : JSON Response */ - $controllers->delete('/{bas_id}/picture/mini-logo/', $this->call('deleteLogo')) + $controllers->post('/{bas_id}/picture/mini-logo/delete/', $this->call('deleteLogo')) ->assert('bas_id', '\d+') ->bind('admin_collection_delete_logo'); @@ -286,13 +288,13 @@ class Collection implements ControllerProviderInterface * * description : Delete a mini logo * - * method : DELETE + * method : POST * * parameters : none * * return : JSON Response */ - $controllers->delete('/{bas_id}/picture/watermark/', $this->call('deleteWatermark')) + $controllers->post('/{bas_id}/picture/watermark/delete/', $this->call('deleteWatermark')) ->assert('bas_id', '\d+') ->bind('admin_collection_delete_watermark'); @@ -320,13 +322,13 @@ class Collection implements ControllerProviderInterface * * description : Delete a stamp * - * method : DELETE + * method : POST * * parameters : none * * return : JSON Response */ - $controllers->delete('/{bas_id}/picture/stamp-logo/', $this->call('deleteStamp')) + $controllers->post('/{bas_id}/picture/stamp-logo/delete/', $this->call('deleteStamp')) ->assert('bas_id', '\d+') ->bind('admin_collection_delete_stamp'); @@ -354,20 +356,20 @@ class Collection implements ControllerProviderInterface * * description : Delete a mini logo * - * method : DELETE + * method : POST * * parameters : none * * return : REDIRECT Response */ - $controllers->delete('/{bas_id}/picture/banner/', $this->call('deleteBanner')) + $controllers->post('/{bas_id}/picture/banner/delete/', $this->call('deleteBanner')) ->assert('bas_id', '\d+') ->bind('admin_collection_delete_banner'); /** * Get document details in the requested collection * - * name : admin_document_details + * name : admin_collection_display_document_details * * description : Get documents collection details * @@ -379,7 +381,7 @@ class Collection implements ControllerProviderInterface */ $controllers->get('/{bas_id}/informations/details/', $this->call('getDetails')) ->assert('bas_id', '\d+') - ->bind('admin_collection_document_details'); + ->bind('admin_collection_display_document_details'); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php index bc2c69a8f4..69ecced050 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php @@ -50,7 +50,8 @@ class Dashboard implements ControllerProviderInterface * * return : HTML Response */ - $controllers->get('/', $this->call('slash'))->bind('admin_dashbord'); + $controllers->get('/', $this->call('slash')) + ->bind('admin_dashbord'); /** * Reset cache @@ -65,7 +66,8 @@ class Dashboard implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/flush-cache/', $this->call('flush'))->bind('admin_dashboard_flush_cache'); + $controllers->post('/flush-cache/', $this->call('flush')) + ->bind('admin_dashboard_flush_cache'); /** * Test send mail @@ -80,12 +82,13 @@ class Dashboard implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/send-mail-test/', $this->call('sendMail'))->bind('admin_dashboard_test_mail'); + $controllers->post('/send-mail-test/', $this->call('sendMail')) + ->bind('admin_dashboard_test_mail'); /** * Reset admin rights * - * name : admin_dashboard_reset_rights + * name : admin_dashboard_reset_admin_rights * * description : Reset admin rights * @@ -95,14 +98,15 @@ class Dashboard implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/reset-admin-rights/', $this->call('resetAdminRights'))->bind('admin_dashboard_reset_rights'); + $controllers->post('/reset-admin-rights/', $this->call('resetAdminRights')) + ->bind('admin_dashboard_reset_admin_rights'); /** - * add admins + * Add admins * * name : admin_dashboard_new * - * description : Add new admins + * description : Add new admin_dashboard_add_admins * * method : POST * @@ -110,7 +114,8 @@ class Dashboard implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/new/', $this->call('addAdmins'))->bind('admin_dashboard_new'); + $controllers->post('/add-admins/', $this->call('addAdmins')) + ->bind('admin_dashboard_add_admins'); return $controllers; } @@ -225,14 +230,14 @@ class Dashboard implements ControllerProviderInterface { $user = $app['phraseanet.core']->getAuthenticatedUser(); - if (count($admins = array_filter($request->get('admins', array()))) > 0) { + if (count($admins = $request->get('admins', array())) > 0) { if ( ! in_array($user->get_id(), $admins)) { $admins[] = $user->get_id(); } if ($admins > 0) { - \User_Adapter::set_sys_admins($admins); + \User_Adapter::set_sys_admins(array_filter($admins)); \User_Adapter::reset_sys_admins_rights(); } } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php index f12a0ad105..62ebf32b8e 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databox.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databox.php @@ -59,7 +59,7 @@ class Databox implements ControllerProviderInterface /** * Get admin database * - * name : admin_get_database + * name : admin_database * * description : Get database informations * @@ -71,27 +71,27 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/', $this->call('getDatabase')) ->assert('databox_id', '\d+') - ->bind('admin_get_database'); + ->bind('admin_database'); /** * Delete a database * - * name : admin_delete_databases + * name : admin_database_delete * * description : Delete a database * - * method : DELETE + * method : POST * * parameters : none * * return : JSON Response */ - $controllers->delete('/{databox_id}/', $this->call('deleteBase')) + $controllers->post('/{databox_id}/delete/', $this->call('deleteBase')) ->assert('databox_id', '\d+') - ->bind('admin_delete_databases'); + ->bind('admin_database_delete'); /** - * mount a database + * Mount a database * * name : admin_database_mount * @@ -143,7 +143,7 @@ class Databox implements ControllerProviderInterface /** * Reorder database collection * - * name : admin_database_collections_order + * name : admin_database_display_collections_order * * description : Reorder database collection * @@ -155,7 +155,7 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/collections/order/', $this->call('getReorder')) ->assert('databox_id', '\d+') - ->bind('admin_database_collections_order'); + ->bind('admin_database_display_collections_order'); /** * Reorder database collection @@ -174,10 +174,27 @@ class Databox implements ControllerProviderInterface ->assert('databox_id', '\d+') ->bind('admin_database_submit_collections_order'); + /** + * Create new collection + * + * name : admin_database_submit_collection + * + * description : Create a new collection + * + * method : POST + * + * parameters : none + * + * return : HTML Response + */ + $controllers->post('/{databox_id}/collection/', $this->call('createCollection')) + ->assert('databox_id', '\d+') + ->bind('admin_database_submit_collection'); + /** * Get database CGU * - * name : admin_database_cgu + * name : admin_database_display_cgus * * description : Get database CGU * @@ -189,12 +206,12 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/cgus/', $this->call('getDatabaseCGU')) ->assert('databox_id', '\d+') - ->bind('admin_database_cgu'); + ->bind('admin_database_display_cgus'); /** * Update database CGU * - * name : admin_update_database_cgu + * name : admin_database_submit_cgus * * description : Update database CGU * @@ -206,12 +223,12 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/cgus/', $this->call('updateDatabaseCGU')) ->assert('databox_id', '\d+') - ->bind('admin_update_database_cgu'); + ->bind('admin_database_submit_cgus'); /** * Update document information * - * name : admin_document_information + * name : admin_database_display_document_information * * description : Update document information * @@ -223,12 +240,12 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/informations/documents/', $this->call('progressBarInfos')) ->assert('databox_id', '\d+') - ->bind('admin_document_information'); + ->bind('admin_database_display_document_information'); /** * Get document details * - * name : admin_document_details + * name : admin_database_display_document_details * * description : Get document details * @@ -240,7 +257,7 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/informations/details/', $this->call('getDetails')) ->assert('databox_id', '\d+') - ->bind('admin_document_details'); + ->bind('admin_database_display_document_details'); /** * Mount collection on collection @@ -263,7 +280,7 @@ class Databox implements ControllerProviderInterface /** * Get a new collection form * - * name : admin_database_get_new_collection + * name : admin_database_display_new_collection_form * * description : New collection form * @@ -275,12 +292,12 @@ class Databox implements ControllerProviderInterface */ $controllers->get('/{databox_id}/collection/', $this->call('getNewCollection')) ->assert('databox_id', '\d+') - ->bind('admin_database_get_new_collection'); + ->bind('admin_database_display_new_collection_form'); /** - * Add logo databox + * Add databox logo * - * name : admin_submit_database_logo + * name : admin_database_submit_logo * * description : add logo to databox * @@ -292,29 +309,29 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/logo/', $this->call('sendLogoPdf')) ->assert('databox_id', '\d+') - ->bind('admin_submit_database_logo'); + ->bind('admin_database_submit_logo'); /** - * Delete logo databox + * Delete databox logo * - * name : admin_delete_database_logo + * name : admin_database_delete_logo * * description : delete logo databox * - * method : DELETE + * method : POST * * parameters : none * * return : HTML Response */ - $controllers->delete('/{databox_id}/logo/', $this->call('deleteLogoPdf')) + $controllers->post('/{databox_id}/logo/delete/', $this->call('deleteLogoPdf')) ->assert('databox_id', '\d+') - ->bind('admin_delete_database_logo'); + ->bind('admin_database_delete_logo'); /** * Clear databox logs * - * name : admin_delete_database_clear_logs + * name : admin_database_clear_logs * * description : Clear databox logs * @@ -326,7 +343,7 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/clear-logs/', $this->call('clearLogs')) ->assert('databox_id', '\d+') - ->bind('admin_delete_database_clear_logs'); + ->bind('admin_database_clear_logs'); /** * Reindex database @@ -348,7 +365,7 @@ class Databox implements ControllerProviderInterface /** * Set database indexable * - * name : admin_database_indexable + * name : admin_database_set_indexable * * description : Set database indexable * @@ -360,12 +377,12 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/indexable/', $this->call('setIndexable')) ->assert('databox_id', '\d+') - ->bind('admin_database_indexable'); + ->bind('admin_database_set_indexable'); /** * Set database name * - * name : admin_database_submit_name + * name : admin_database_rename * * description : Set database indexable * @@ -377,7 +394,7 @@ class Databox implements ControllerProviderInterface */ $controllers->post('/{databox_id}/view-name/', $this->call('changeViewName')) ->assert('databox_id', '\d+') - ->bind('admin_database_submit_name'); + ->bind('admin_database_rename'); return $controllers; } @@ -954,14 +971,14 @@ class Databox implements ControllerProviderInterface return $app->json($ret); } - /** - * Display page for reaorder collections on a databox - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @param integer $databox_id The requested databox - * @return Response - */ + /** + * Display page for reaorder collections on a databox + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return Response + */ public function getReorder(Application $app, Request $request, $databox_id) { return new Response($app['twig']->render('admin/collection/reorder.html.twig', array( @@ -969,14 +986,14 @@ class Databox implements ControllerProviderInterface ))); } - /** - * Apply collection reorder changes - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @param integer $databox_id The requested databox - * @return JsonResponse - */ + /** + * Apply collection reorder changes + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return JsonResponse + */ public function setReorder(Application $app, Request $request, $databox_id) { if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { @@ -992,27 +1009,67 @@ class Databox implements ControllerProviderInterface return $app->json(array('sbas_id' => $databox_id)); } - /** - * Display page to create a new collection - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @param integer $databox_id The requested databox - * @return Response - */ + /** + * Display page to create a new collection + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return Response + */ public function getNewCollection(Application $app, Request $request, $databox_id) { return new Response($app['twig']->render('admin/collection/create.html.twig')); } - /** - * Display page to get some details on a appbox - * - * @param Application $app The silex application - * @param Request $request The current HTTP request - * @param integer $databox_id The requested databox - * @return Response - */ + /** + * Create a new collection + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return Response + */ + public function createCollection(Application $app, Request $request, $databox_id) + { + if ($name = trim($request->request->get('cnm', '')) === '') { + + return $app->redirect('/admin/databox/' . $databox_id . '/collection/error=name'); + } + + try { + $databox = $app['phraseanet.appbox']->get_databox($databox_id); + $collection = \collection::create($databox, $app['phraseanet.appbox'], $name, $app['phraseanet.core']->getAuthenticatedUser()); + + if (($request->request->get('ccusrothercoll') === "on") + && ($othcollsel = $request->request->get('othcollsel') !== null)) { + $query = new \User_Query($app['phraseanet.appbox']); + $total = $query->on_base_ids(array($othcollsel))->get_total(); + $n = 0; + while ($n < $total) { + $results = $query->limit($n, 20)->execute()->get_results(); + foreach ($results as $user) { + $user->ACL()->duplicate_right_from_bas($othcollsel, $collection->get_base_id()); + } + $n += 20; + } + } + + return $app->redirect('/admin/collection/' . $collection->get_base_id() . '/'); + } catch (\Exception $e) { + + return $app->redirect('/admin/databox/' . $databox_id . '/collection/error=error'); + } + } + + /** + * Display page to get some details on a appbox + * + * @param Application $app The silex application + * @param Request $request The current HTTP request + * @param integer $databox_id The requested databox + * @return Response + */ public function getDetails(Application $app, Request $request, $databox_id) { $databox = $app['phraseanet.appbox']->get_databox($databox_id); diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php index b0197591f8..b3c8f8d125 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php @@ -51,11 +51,12 @@ class Databoxes implements ControllerProviderInterface * * return : HTML Response */ - $controllers->get('/', $this->call('getDatabases'))->bind('admin_databases'); + $controllers->get('/', $this->call('getDatabases')) + ->bind('admin_databases'); /** - * Upgrade databases + * Upgrade all databases * * name : admin_databases_upgrade * @@ -67,7 +68,8 @@ class Databoxes implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/upgrade/', $this->call('databasesUpgrade'))->bind('admin_databases_upgrade'); + $controllers->post('/upgrade/', $this->call('databasesUpgrade')) + ->bind('admin_databases_upgrade'); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Root.php b/lib/Alchemy/Phrasea/Controller/Admin/Root.php index c0b6e3e28e..7a9a60c9b8 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Root.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Root.php @@ -35,75 +35,137 @@ class Root implements ControllerProviderInterface $controllers->get('/', function(Application $app, Request $request) { - $Core = $app['phraseanet.core']; - $appbox = $app['phraseanet.appbox']; - $user = $Core->getAuthenticatedUser(); + $Core = $app['phraseanet.core']; + $appbox = $app['phraseanet.appbox']; + $user = $Core->getAuthenticatedUser(); - \User_Adapter::updateClientInfos(3); + \User_Adapter::updateClientInfos(3); - $section = $request->query->get('section', false); + $section = $request->get('section', false); - $available = array( - 'connected' - , 'registrations' - , 'taskmanager' - , 'base' - , 'bases' - , 'collection' - , 'user' - , 'users' - ); + $available = array( + 'connected', + 'registrations', + 'taskmanager', + 'base', + 'bases', + 'collection', + 'user', + 'users' + ); - $feature = 'connected'; - $featured = false; - $position = explode(':', $section); - if (count($position) > 0) { - if (in_array($position[0], $available)) { - $feature = $position[0]; + $feature = 'connected'; + $featured = false; + $position = explode(':', $section); + if (count($position) > 0) { + if (in_array($position[0], $available)) { + $feature = $position[0]; - if (isset($position[1])) { - $featured = $position[1]; + if (isset($position[1])) { + $featured = $position[1]; + } } } - } - $databoxes = $off_databoxes = array(); - foreach ($appbox->get_databoxes() as $databox) { - try { - if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + $databoxes = $off_databoxes = array(); + foreach ($appbox->get_databoxes() as $databox) { + try { + if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + continue; + } + + $databox->get_connection(); + } catch (\Exception $e) { + $off_databoxes[] = $databox; continue; } - $databox->get_connection(); - } catch (\Exception $e) { - $off_databoxes[] = $databox; - continue; + $databoxes[] = $databox; } - $databoxes[] = $databox; - } + $params = array( + 'feature' => $feature, + 'featured' => $featured, + 'databoxes' => $databoxes, + 'off_databoxes' => $off_databoxes + ); - return new Response($app['twig']->render('admin/index.html.twig', array( - 'module' => 'admin' - , 'events' => \eventsmanager_broker::getInstance($appbox, $Core) - , 'module_name' => 'Admin' - , 'notice' => $request->query->get("notice") - , 'feature' => $feature - , 'featured' => $featured - , 'databoxes' => $databoxes - , 'off_databoxes' => $off_databoxes - , 'tree' => \module_admin::getTree($section) - )) - ); - }); + + return new Response($app['twig']->render('admin/index.html.twig', array( + 'module' => 'admin', + 'events' => \eventsmanager_broker::getInstance($appbox, $Core), + 'module_name' => 'Admin', + 'notice' => $request->get("notice"), + 'feature' => $feature, + 'featured' => $featured, + 'databoxes' => $databoxes, + 'off_databoxes' => $off_databoxes, + 'tree' => $app['twig']->render('admin/tree.html.twig', $params), + )) + ); + }) + ->bind('admin'); $controllers->get('/tree/', function() { - if (null === $position = $request->get('position')) { - $app->abort(400, _('Missing position parameter')); - } + $Core = $app['phraseanet.core']; + $appbox = $app['phraseanet.appbox']; + $user = $Core->getAuthenticatedUser(); - return new Response($app['twig']->render(\module_admin::getTree($position))); - }); + \User_Adapter::updateClientInfos(3); + + $section = $request->get('section', false); + + $available = array( + 'connected', + 'registrations', + 'taskmanager', + 'base', + 'bases', + 'collection', + 'user', + 'users' + ); + + $feature = 'connected'; + $featured = false; + + $position = explode(':', $request->query->get('position', false)); + if (count($position) > 0) { + if (in_array($position[0], $available)) { + $feature = $position[0]; + + if (isset($position[1])) { + $featured = $position[1]; + } + } + } + + $databoxes = $off_databoxes = array(); + foreach ($appbox->get_databoxes() as $databox) { + try { + if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) { + continue; + } + + $databox->get_connection(); + } catch (\Exception $e) { + $off_databoxes[] = $databox; + continue; + } + + $databoxes[] = $databox; + } + + $params = array( + 'feature' => $feature, + 'featured' => $featured, + 'databoxes' => $databoxes, + 'off_databoxes' => $off_databoxes + ); + + return $app['twig']->render('admin/tree.html.twig', $params); + }) + ->bind('admin_display_tree'); $controllers->get('/test-paths/', function() { @@ -141,102 +203,111 @@ class Root implements ControllerProviderInterface }); $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')) { - $app->abort(403); - } + if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { + $app->abort(403); + } - $databox = $app['phraseanet.appbox']->get_databox((int) $databox_id); - $structure = $databox->get_structure(); - $errors = \databox::get_structure_errors($structure); + $databox = $app['phraseanet.appbox']->get_databox((int) $databox_id); + $structure = $databox->get_structure(); + $errors = \databox::get_structure_errors($structure); - if ('ok' === $updateOk = $request->get('update', false)) { - $updateOk = true; - } + if ('ok' === $updateOk = $request->get('update', false)) { + $updateOk = true; + } - if (false !== $errorsStructure = $request->get('error', false)) { - $errorsStructure = true; - } + if (false !== $errorsStructure = $request->get('error', false)) { + $errorsStructure = true; + } - return new Response($app['twig']->render('admin/structure.html.twig', array( - 'errors' => $errors, - 'structure' => $structure, - 'errorsStructure' => $errorsStructure, - 'updateOk' => $updateOk - ))); - })->assert('databox_id', '\d+'); + return new Response($app['twig']->render('admin/structure.html.twig', array( + 'errors' => $errors, + 'structure' => $structure, + 'errorsStructure' => $errorsStructure, + 'updateOk' => $updateOk + ))); + }) + ->assert('databox_id', '\d+') + ->bind('database_display_stucture'); $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')) { - $app->abort(403); - } + if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { + $app->abort(403); + } - if (null === $structure = $request->get('structure')) { - $app->abort(400, _('Missing "structure" parameter')); - } + if (null === $structure = $request->get('structure')) { + $app->abort(400, _('Missing "structure" parameter')); + } - $errors = \databox::get_structure_errors($structure); + $errors = \databox::get_structure_errors($structure); - $domst = new \DOMDocument('1.0', 'UTF-8'); - $domst->preserveWhiteSpace = false; - $domst->formatOutput = true; + $domst = new \DOMDocument('1.0', 'UTF-8'); + $domst->preserveWhiteSpace = false; + $domst->formatOutput = true; - if (count($errors) == 0 && $domst->loadXML($structure)) { - $databox = $app['phraseanet.appbox']->get_databox($databox_id); - $databox->saveStructure($domst); + if (count($errors) == 0 && $domst->loadXML($structure)) { + $databox = $app['phraseanet.appbox']->get_databox($databox_id); + $databox->saveStructure($domst); - return $app->redirect('/admin/structure/' . $databox_id . '/?update=ok'); - } else { + return $app->redirect('/admin/structure/' . $databox_id . '/?update=ok'); + } else { - return $app->redirect('/admin/structure/' . $databox_id . '/?error=struct'); - } - })->assert('databox_id', '\d+'); + return $app->redirect('/admin/structure/' . $databox_id . '/?error=struct'); + } + }) + ->assert('databox_id', '\d+') + ->bind('database_submit_stucture'); $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')) { - $app->abort(403); - } + if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { + $app->abort(403); + } - $databox = $app['phraseanet.appbox']->get_databox($databox_id); + $databox = $app['phraseanet.appbox']->get_databox($databox_id); - return new Response($app['twig']->render('admin/statusbit.html.twig', array( - 'status' => $databox->get_statusbits(), - ))); - })->assert('databox_id', '\d+'); + return new Response($app['twig']->render('admin/statusbit.html.twig', array( + 'status' => $databox->get_statusbits(), + ))); + }) + ->assert('databox_id', '\d+') + ->bind('database_display_statusbit'); $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')) { - $app->abort(403); - } + if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { + $app->abort(403); + } - $databox = $app['phraseanet.appbox']->get_databox($databox_id); + $databox = $app['phraseanet.appbox']->get_databox($databox_id); - $status = $databox->get_statusbits(); + $status = $databox->get_statusbits(); - switch ($errorMsg = $request->get('error')) { - case 'rights': - $errorMsg = _('You do not enough rights to update status'); - break; - case 'too-big': - $errorMsg = _('File is too big : 64k max'); - break; - case 'upload-error': - $errorMsg = _('Status icon upload failed : upload error'); - break; - case 'wright-error': - $errorMsg = _('Status icon upload failed : can not write on disk'); - break; - case 'unknow-error': - $errorMsg = _('Something wrong happend'); - break; - } + switch ($errorMsg = $request->get('error')) { + case 'rights': + $errorMsg = _('You do not enough rights to update status'); + break; + case 'too-big': + $errorMsg = _('File is too big : 64k max'); + break; + case 'upload-error': + $errorMsg = _('Status icon upload failed : upload error'); + break; + case 'wright-error': + $errorMsg = _('Status icon upload failed : can not write on disk'); + break; + case 'unknow-error': + $errorMsg = _('Something wrong happend'); + break; + } - return new Response($app['twig']->render('admin/statusbit/edit.html.twig', array( - 'status' => isset($status[$bit]) ? $status[$bit] : array(), - 'errorMsg' => $errorMsg - ))); - })->assert('databox_id', '\d+')->assert('bit', '\d+'); + return new Response($app['twig']->render('admin/statusbit/edit.html.twig', array( + 'status' => isset($status[$bit]) ? $status[$bit] : array(), + 'errorMsg' => $errorMsg + ))); + }) + ->assert('databox_id', '\d+') + ->assert('bit', '\d+') + ->bind('database_display_statusbit_form'); - $controllers->delete('/statusbit/{databox_id}/status/{bit}/', function(Application $app, Request $request, $databox_id, $bit) { + $controllers->post('/statusbit/{databox_id}/status/{bit}/delete/', function(Application $app, Request $request, $databox_id, $bit) { if ( ! $request->isXmlHttpRequest() || ! array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { $app->abort(400, _('Bad request format, only JSON is allowed')); } @@ -253,78 +324,81 @@ class Root implements ControllerProviderInterface })->assert('databox_id', '\d+')->assert('bit', '\d+'); $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')) { - $app->abort(403); - } - - $properties = array( - 'searchable' => $request->get('searchable') ? '1' : '0', - 'printable' => $request->get('printable') ? '1' : '0', - 'name' => $request->get('name', ''), - 'labelon' => $request->get('label_on', ''), - 'labeloff' => $request->get('label_off', '') - ); - - \databox_status::updateStatus($databox_id, $bit, $properties); - - if (null !== $request->get('delete_icon_off')) { - \databox_status::deleteIcon($databox_id, $bit, 'off'); - } - - if (null !== $file = $request->files->get('image_off')) { - try { - \databox_status::updateIcon($databox_id, $bit, 'off', $file); - } catch (\Exception_Forbidden $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights'); - } catch (\Exception_InvalidArgument $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); - } catch (\Exception_Upload_FileTooBig $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=too-big'); - } catch (\Exception_Upload_Error $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=upload-error'); - } catch (\Exception_Upload_CannotWriteFile $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=wright-error'); - } catch (\Exception $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) { + $app->abort(403); } - } - if (null !== $request->get('delete_icon_on')) { - \databox_status::deleteIcon($databox_id, $bit, 'on'); - } + $properties = array( + 'searchable' => $request->get('searchable') ? '1' : '0', + 'printable' => $request->get('printable') ? '1' : '0', + 'name' => $request->get('name', ''), + 'labelon' => $request->get('label_on', ''), + 'labeloff' => $request->get('label_off', '') + ); - if (isset($_FILES['image_on']) && $_FILES['image_on']['name']) { - try { - \databox_status::updateIcon($databox_id, $bit, 'on', $_FILES['image_on']); - } catch (\Exception_Forbidden $e) { + \databox_status::updateStatus($databox_id, $bit, $properties); - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights'); - } catch (\Exception_InvalidArgument $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); - } catch (\Exception_Upload_FileTooBig $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=too-big'); - } catch (\Exception_Upload_Error $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=upload-error'); - } catch (\Exception_Upload_CannotWriteFile $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=wright-error'); - } catch (\Exception $e) { - - return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + if (null !== $request->get('delete_icon_off')) { + \databox_status::deleteIcon($databox_id, $bit, 'off'); } - } - return $app->redirect('/admin/statusbit/' . $databox_id . '/?update=ok'); - })->assert('databox_id', '\d+')->assert('bit', '\d+'); + if (null !== $file = $request->files->get('image_off')) { + try { + \databox_status::updateIcon($databox_id, $bit, 'off', $file); + } catch (\Exception_Forbidden $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights'); + } catch (\Exception_InvalidArgument $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + } catch (\Exception_Upload_FileTooBig $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=too-big'); + } catch (\Exception_Upload_Error $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=upload-error'); + } catch (\Exception_Upload_CannotWriteFile $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=wright-error'); + } catch (\Exception $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + } + } + + if (null !== $request->get('delete_icon_on')) { + \databox_status::deleteIcon($databox_id, $bit, 'on'); + } + + if (isset($_FILES['image_on']) && $_FILES['image_on']['name']) { + try { + \databox_status::updateIcon($databox_id, $bit, 'on', $_FILES['image_on']); + } catch (\Exception_Forbidden $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights'); + } catch (\Exception_InvalidArgument $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + } catch (\Exception_Upload_FileTooBig $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=too-big'); + } catch (\Exception_Upload_Error $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=upload-error'); + } catch (\Exception_Upload_CannotWriteFile $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=wright-error'); + } catch (\Exception $e) { + + return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=unknow-error'); + } + } + + return $app->redirect('/admin/statusbit/' . $databox_id . '/?update=ok'); + }) + ->assert('databox_id', '\d+') + ->assert('bit', '\d+') + ->bind('database_submit_statusbit'); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php index fa0f299a88..1c7e45ef60 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Setup.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Setup.php @@ -41,7 +41,7 @@ class Setup implements ControllerProviderInterface /** * Get globals values * - * name : setup_globals + * name : setup_display_globals * * description : Display globals values * @@ -51,12 +51,13 @@ class Setup implements ControllerProviderInterface * * return : HTML Response */ - $controllers->get('/', $this->call('getGlobals'))->bind('setup_globals'); + $controllers->get('/', $this->call('getGlobals')) + ->bind('setup_display_globals'); /** * Submit global values * - * name : submit_setup_globals + * name : setup_submit_globals * * description : Change globals values * @@ -66,7 +67,8 @@ class Setup implements ControllerProviderInterface * * return : Redirect Response */ - $controllers->post('/', $this->call('postGlobals'))->bind('submit_setup_globals'); + $controllers->post('/', $this->call('postGlobals')) + ->bind('setup_submit_globals'); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php b/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php index 9511b4b186..e4d4615c60 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Sphinx.php @@ -41,7 +41,7 @@ class Sphinx implements ControllerProviderInterface /** * Sphinx configuration * - * name : sphinx_configuration + * name : sphinx_display_configuration * * description : Display sphinx configuration * @@ -51,12 +51,13 @@ class Sphinx implements ControllerProviderInterface * * return : HTML Response */ - $controllers->get('/configuration/', $this->call('getConfiguration'))->bind('sphinx_configuration'); + $controllers->get('/configuration/', $this->call('getConfiguration')) + ->bind('sphinx_display_configuration'); /** * Sphinx configuration * - * name : submit_sphinx_configuration + * name : sphinx_submit_configuration * * description : Submit new sphinx configuration * @@ -66,7 +67,7 @@ class Sphinx implements ControllerProviderInterface * * return : REDIRECT Response */ - $controllers->post('/configuration/', $this->call('submitConfiguration'))->bind('submit_sphinx_configuration'); + $controllers->post('/configuration/', $this->call('submitConfiguration'))->bind('sphinx_submit_configuration'); return $controllers; } diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php index bcc9bf7da2..34c9b9edae 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php @@ -408,7 +408,8 @@ class Users implements ControllerProviderInterface 'table' => $table, 'models' => $models, )); - }); + }) + ->bind('users_display_demands'); $controllers->post('/demands/', function(Application $app, Request $request) use ($appbox) { @@ -574,12 +575,14 @@ class Users implements ControllerProviderInterface } return $app->redirect('/admin/users/demands/?demands=ok'); - }); + }) + ->bind('users_submit_demands'); $controllers->get('/import/file/', function(Application $app, Request $request) { return $app['twig']->render('admin/user/import/file.html.twig'); - }); + }) + ->bind('users_display_import_file'); $controllers->post('/import/file/', function(Application $app, Request $request) { $user = $app['phraseanet.core']->getAuthenticatedUser(); @@ -714,7 +717,8 @@ class Users implements ControllerProviderInterface 'array_serialized' => serialize($array) )); } - }); + }) + ->bind('users_submit_import_file'); $controllers->post('/import/', function(Application $app, Request $request) { $nbCreation = 0; @@ -792,10 +796,11 @@ class Users implements ControllerProviderInterface } return $app->redirect('/admin/users/search/?user-updated=' . $nbCreation); - }); + }) + ->bind('users_submit_import'); - $controllers->get('/import/example/user/', 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') . 'www/admin/exampleImportUsers.csv'); @@ -812,7 +817,8 @@ class Users implements ControllerProviderInterface $response->setContent(file_get_contents($file->getPathname())); return $response; - }); + }) + ->bind('users_import_csv'); $controllers->get('/import/example/rtf/', function(Application $app, Request $request) { @@ -831,7 +837,8 @@ class Users implements ControllerProviderInterface $response->setContent(file_get_contents($file->getPathname())); return $response; - }); + }) + ->bind('users_import_rtf'); return $controllers; } diff --git a/lib/classes/module/admin.class.php b/lib/classes/module/admin.class.php deleted file mode 100644 index 351bc94d64..0000000000 --- a/lib/classes/module/admin.class.php +++ /dev/null @@ -1,79 +0,0 @@ -get_session(); - - $usr_id = $session->get_usr_id(); - - $user = User_Adapter::getInstance($usr_id, $appbox); - - $available = array( - 'connected' - , 'registrations' - , 'taskmanager' - , 'base' - , 'bases' - , 'collection' - , 'user' - , 'users' - ); - - $feature = 'connected'; - $featured = false; - $position = explode(':', $position); - if (count($position) > 0) { - if (in_array($position[0], $available)) { - $feature = $position[0]; - if (isset($position[1])) - $featured = $position[1]; - } - } - - $databoxes = $off_databoxes = array(); - foreach ($appbox->get_databoxes() as $databox) { - try { - if ( ! $user->ACL()->has_access_to_sbas($databox->get_sbas_id())) - continue; - - $connbas = $databox->get_connection(); - } catch (Exception $e) { - $off_databoxes[] = $databox; - continue; - } - $databoxes[] = $databox; - } - - $params = array( - 'feature' => $feature - , 'featured' => $featured - , 'databoxes' => $databoxes - , 'off_databoxes' => $off_databoxes - ); - - $core = \bootstrap::getCore(); - $twig = $core->getTwig(); - - return $twig->render('admin/tree.html.twig', $params); - } -} - diff --git a/templates/web/admin/collection/create.html.twig b/templates/web/admin/collection/create.html.twig index 5bb0cfbb9f..eecedb42d7 100644 --- a/templates/web/admin/collection/create.html.twig +++ b/templates/web/admin/collection/create.html.twig @@ -2,8 +2,21 @@

{% trans 'admin::base:collection: Creer une collection' %}

+{% if app.request.get('error') == 'name' %} +
+ × + {% trans 'admin:: La collection n\'a pas ete creee : vous devez donner un nom a votre collection' %} +
+ +{% elseif app.request.get('error') == 'error' %} +
+ × + {% trans 'An error occured, please retry or contact an admin if problem persist' %} +
+{% endif %} +
-
+
@@ -31,7 +44,7 @@
diff --git a/templates/web/admin/collection/reorder.html.twig b/templates/web/admin/collection/reorder.html.twig index 73097d1fc1..67e3ae391f 100644 --- a/templates/web/admin/collection/reorder.html.twig +++ b/templates/web/admin/collection/reorder.html.twig @@ -62,7 +62,7 @@ dataType:'json', type:'POST', data: {order: order}, - url: '/admin/databox/{{ app.request.get('databox_id') }}/collections/order/', + url: '{{ path('admin_database_submit_collections_order', {'databox_id': app.request.get('databox_id')}) }}', beforeSend : function() { $this.attr('disabled', true); }, diff --git a/templates/web/admin/dashboard.html.twig b/templates/web/admin/dashboard.html.twig index aafab375d9..bf64157a07 100644 --- a/templates/web/admin/dashboard.html.twig +++ b/templates/web/admin/dashboard.html.twig @@ -65,7 +65,7 @@

{% trans 'setup:: administrateurs de l\'application' %}

-
+
    {% for usr_id, usr_login in admins %}
  • diff --git a/templates/web/admin/databases.html.twig b/templates/web/admin/databases.html.twig index 91ef779b36..ca95c846fd 100644 --- a/templates/web/admin/databases.html.twig +++ b/templates/web/admin/databases.html.twig @@ -4,7 +4,7 @@ {% endif %} {% if createBase %} - document.location.replace('/admin/databox/{{ app.request.get('sbas_id') }}/'); + document.location.replace('{{ path('admin_database', {'databox_id': app.request.get('databox_id')}) }}'); {% endif %} @@ -27,7 +27,7 @@ {% if sbas | length > 0 %} {% for key, value in sbas %}
  • - + {{ value['name'] }} ({% trans "version" %} {{ value['version'] }}) {{ value['server_info'] }}
  • @@ -64,7 +64,7 @@ {% endfor %} {% endif %} - + @@ -73,7 +73,7 @@

    {% trans 'admin::base: creer une base' %}

    -
    +