replace delete controllers by post controllers

fix tests

fix typo

fix tests
This commit is contained in:
Nicolas Le Goff
2012-08-23 13:06:29 +02:00
parent aeb14dcf15
commit c0dacd84b4
21 changed files with 596 additions and 498 deletions

View File

@@ -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;
}

View File

@@ -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();
}
}

View File

@@ -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;
}
@@ -1005,6 +1022,46 @@ class Databox implements ControllerProviderInterface
return new Response($app['twig']->render('admin/collection/create.html.twig'));
}
/**
* 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
*

View File

@@ -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;
}

View File

@@ -41,17 +41,17 @@ class Root implements ControllerProviderInterface
\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'
'connected',
'registrations',
'taskmanager',
'base',
'bases',
'collection',
'user',
'users'
);
$feature = 'connected';
@@ -83,27 +83,89 @@ class Root implements ControllerProviderInterface
$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)
'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();
\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];
}
}
}
return new Response($app['twig']->render(\module_admin::getTree($position)));
});
$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() {
@@ -163,7 +225,9 @@ class Root implements ControllerProviderInterface
'errorsStructure' => $errorsStructure,
'updateOk' => $updateOk
)));
})->assert('databox_id', '\d+');
})
->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')) {
@@ -189,7 +253,9 @@ class Root implements ControllerProviderInterface
return $app->redirect('/admin/structure/' . $databox_id . '/?error=struct');
}
})->assert('databox_id', '\d+');
})
->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')) {
@@ -201,7 +267,9 @@ class Root implements ControllerProviderInterface
return new Response($app['twig']->render('admin/statusbit.html.twig', array(
'status' => $databox->get_statusbits(),
)));
})->assert('databox_id', '\d+');
})
->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')) {
@@ -234,9 +302,12 @@ class Root implements ControllerProviderInterface
'status' => isset($status[$bit]) ? $status[$bit] : array(),
'errorMsg' => $errorMsg
)));
})->assert('databox_id', '\d+')->assert('bit', '\d+');
})
->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'));
}
@@ -324,7 +395,10 @@ class Root implements ControllerProviderInterface
}
return $app->redirect('/admin/statusbit/' . $databox_id . '/?update=ok');
})->assert('databox_id', '\d+')->assert('bit', '\d+');
})
->assert('databox_id', '\d+')
->assert('bit', '\d+')
->bind('database_submit_statusbit');
return $controllers;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -1,79 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class module_admin
{
public function getTree($position = false)
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->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);
}
}

View File

@@ -2,8 +2,21 @@
<h1>{% trans 'admin::base:collection: Creer une collection' %}</h1>
</div>
{% if app.request.get('error') == 'name' %}
<div class="alert alert-error">
<a class="close" data-dismiss="alert" href="#">×</a>
{% trans 'admin:: La collection n\'a pas ete creee : vous devez donner un nom a votre collection' %}
</div>
{% elseif app.request.get('error') == 'error' %}
<div class="alert alert-error">
<a class="close" data-dismiss="alert" href="#">×</a>
{% trans 'An error occured, please retry or contact an admin if problem persist' %}
</div>
{% endif %}
<div class="well-small">
<form class="form-horizontal" method='post' action='/admin/databox/{{ app.request.get('databox_id') }}/collection/'>
<form class="form-horizontal" method='post' action='{{ path('admin_database_submit_collection', {'databox_id': app.request.get('databox_id')}) }}'>
<fieldset>
<div class="control-group">
<label class="control-label" for="cnm">{% trans 'admin::base:collection: Nom de la nouvelle collection : ' %}</label>
@@ -31,7 +44,7 @@
</div>
<div class="form-actions">
<button class="btn btn-primary" type="submit">{% trans 'boutton::valider' %}</button>
<a href='/admin/databox/{{ app.request.get('databox_id') }}/' target='right' class="btn ajax">{% trans 'boutton::annuler' %}</a>
<a href='{{ path('admin_database', {'databox_id': app.request.get('databox_id')}) }}' target='right' class="btn ajax">{% trans 'boutton::annuler' %}</a>
</div>
</fieldset>
</form>

View File

@@ -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);
},

View File

@@ -65,7 +65,7 @@
<div class="board_section">
<h1>{% trans 'setup:: administrateurs de l\'application' %}</h1>
<form id="admin_adder" action="/admin/dashboard/new/" method="post">
<form id="admin_adder" action="/admin/dashboard/add-admins/" method="post">
<ul>
{% for usr_id, usr_login in admins %}
<li>

View File

@@ -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 %}
</script>
@@ -27,7 +27,7 @@
{% if sbas | length > 0 %}
{% for key, value in sbas %}
<li>
<a href='/admin/databox/{{ key }}/' target='_self'>
<a href='{{ path('admin_database', {'databox_id': key}) }}' target='_self'>
<img src="{{ value['image'] }}" /> {{ value['name'] }} ({% trans "version" %} {{ value['version'] }}) {{ value['server_info'] }}
</a>
</li>
@@ -64,7 +64,7 @@
{% endfor %}
{% endif %}
<form action="/admin/databoxes/upgrade/" method="post" >
<form action="{{ path('admin_databases_upgrade') }}" method="post" >
<input type="hidden" value="" name="upgrade" />
<input type="submit" class="btn btn-warning" value="{% trans 'update::Verifier els tables' %}" />
</form>
@@ -73,7 +73,7 @@
<div class="db_infos">
<h2>{% trans 'admin::base: creer une base' %}</h2>
<div id="create_base">
<form class="form-vertical" method="post" action="/admin/databox/">
<form class="form-vertical" method="post" action="{{ path('admin_database_new') }}">
<label class="checkbox">
<input type="checkbox" name="new_settings" onchange="if(this.checked == true)$('#server_opts').slideDown();else $('#server_opts').slideUp();" />
{% trans 'phraseanet:: Creer une base sur un serveur different de l\'application box' %}
@@ -106,7 +106,7 @@
<div class="db_infos">
<h2>{% trans 'admin::base: Monter une base' %}</h2>
<div id="mount_base">
<form method="post" action="/admin/databox/mount/">
<form method="post" action="{{ path('admin_database_mount') }}">
<label class="checkbox">
<input type="checkbox" name="new_settings" onchange="if(this.checked == true)$('#servermount_opts').slideDown();else $('#servermount_opts').slideUp();" />
{% trans "phraseanet:: Monter une base provenant d\'un serveur different de l\'application box" %}

View File

@@ -1,6 +1,6 @@
<h1>{% trans'Terms Of Use' %}</h1>
<form target="_self" method="post" action="/admin/databox/{{ app.request.get('databox_id') }}/cgus/">
<form target="_self" method="post" action="{{ path('admin_database_submit_cgus', {'databox_id': app.request.get('databox_id')}) }}">
<div class='well'>
<input type="submit" value="{% trans'Mettre a jour' %}" id="valid"/>
<label for="valid" class='checkbox'>

View File

@@ -11,7 +11,7 @@
{% if user.ACL().has_right_on_sbas(databox.get_sbas_id(), "bas_manage") %}
<img src="/skins/icons/edit_0.gif" id="show-view-name" />
<div class='well-small' id='change-view-name' style='display:none'>
<form method='post' action='/admin/databox/{{ databox.get_sbas_id() }}/view-name/'>
<form method='post' action='{{ path('admin_database_rename', {'databox_id': databox.get_sbas_id()}) }}'>
<div class="input-append">
<input id="db-view-name" name='viewname' class="span2" type="text" size="16">
<a class="btn submiter" type="button">{% trans 'Rename' %}</a>
@@ -25,7 +25,7 @@
{% trans 'admin::base: nombre d\'enregistrements sur la base :' %}
<span id="nrecords">{{ databox.get_record_amount() }}</span>
(<a href="/admin/databox/{{ databox.get_sbas_id() }}/informations/details/" class='ajax' target="rights">{% trans 'phraseanet:: details'%}</a>)
(<a href="{{ path('admin_database_display_document_details', {'databox_id': databox.get_sbas_id()}) }}" class='ajax' target="rights">{% trans 'phraseanet:: details'%}</a>)
</li>
{% if showDetail %}
@@ -67,7 +67,7 @@
{% if user.ACL().has_right_on_sbas(databox.get_sbas_id(), "bas_manage") %}
<div class=" well-small">
<form method="post" action="/admin/databox/{{ app.request.get('databox_id') }}/indexable/">
<form method="post" action="{{ path('admin_database_set_indexable', {'databox_id': databox.get_sbas_id()}) }}">
<label class="checkbox" for="is_indexable">
<input type="checkbox" id="is_indexable" name='indexable' {{ appbox.is_databox_indexable(databox) ? 'checked' : ''}} />
{% trans "admin::base: Cette base est indexable" %}
@@ -77,39 +77,39 @@
<div class="btn-group well-small">
<form method="post" action="/admin/databox/{{ app.request.get('bas_id') }}/reindex/">
<form method="post" action="{{ path('admin_database_reindex', {'databox_id': databox.get_sbas_id()}) }}">
<a class='btn submiter confirm' href='#' data-confirm-msg="{% trans 'Confirmez-vous la re-indexation de la base ?' %}">
{% trans "base:: re-indexer" %}
</a>
</form>
<a style='display:inline-block' target="right" class="ajax btn" href="/admin/databox/{{ databox.get_sbas_id() }}/collection/">
<a style='display:inline-block' target="right" class="ajax btn" href="{{ path('admin_database_get_new_collection', {'databox_id': databox.get_sbas_id()}) }}">
<img src="/skins/icons/create_coll.png" />
{% trans "admin::base:collection: Creer une collection" %}
</a>
<form style='display:inline' method="post" action="/admin/databox/{{ app.request.get('bas_id') }}/clear-logs/">
<form style='display:inline' method="post" action="{{ path('admin_database_clear_logs', {'databox_id': databox.get_sbas_id()}) }}">
<a href="#" class='btn submiter confirm'data-confirm-msg="{% trans 'admin::base: Confirmer la suppression de tous les logs' %}">
<img src="/skins/icons/clearLogs.png" />
{% trans "admin::base: supprimer tous les logs" %}
</a>
</form>
<form style='display:inline' method="post" action="/admin/databox/{{ app.request.get('bas_id') }}/unmount/">
<form style='display:inline' method="post" action="{{ path('admin_database_unmount', {'databox_id': databox.get_sbas_id()}) }}">
<a href="#" class='btn submiter confirm' data-confirm-msg="{% trans 'admin::base: Confirmer vous l\'arret de la publication de la base' %}">
<img src="/skins/icons/db-remove.png" />
{% trans "admin::base: arreter la publication de la base" %}
</a>
</form>
<form style='display:inline' method="post" action="/admin/databox/{{ app.request.get('bas_id') }}/empty/">
<form style='display:inline' method="post" action="{{ path('admin_database_empty', {'databox_id': databox.get_sbas_id()}) }}">
<a href="#" class='btn submiter confirm' data-confirm-msg="{% trans 'admin::base: Confirmer le vidage complet de la base' %}">
<img src="/skins/icons/trash.png" />
{% trans "admin::base: vider la base" %}
</a>
</form>
<form style='display:inline' method="post" action="/admin/databox/{{ app.request.get('bas_id') }}/delete/">
<form style='display:inline' method="post" action="{{ path('admin_database_delete', {'databox_id': databox.get_sbas_id()}) }}">
<a href="#" class='btn submiter confirm' data-confirm-msg="{% trans 'admin::base: Confirmer la suppression de la base' %}">
<img src="/skins/icons/delete.gif" />
{% trans "admin::base: supprimer la base" %}
@@ -127,13 +127,15 @@
<ul>
{% for collId, name in databox.get_mountable_colls() %}
<li>
<form class='form-inline' method="post" action="/admin/databox/{{ app.request.get('databox_id') }}/collection/{{ collId }}/mount/">
<form class='form-inline' method="post" action="{{ path('admin_database_mount_collection', {'databox_id': databox.get_sbas_id(), 'collection_id' : collId }) }}">
{% trans "Monter" %} {{ name }}
{% if user.ACL().get_granted_base(["canadmin"]) | length > 0 %}
<label for="othcollsel">{% trans "admin::base:collection: Vous pouvez choisir une collection de reference pour donenr des acces " %}</label>
<select id="othcollsel" name="othcollsel" >
<option>{% trans "choisir" %}</option>
{% for collection in databox.get_collections() %}
<option value='{{ collection.get_base_id() }}'>{{ collection. get_name() }}</option>
{% endfor %}
</select>
{% endif %}
<a href="#" class='btn btn-mini submiter'>
@@ -159,7 +161,7 @@
<ul>
{% for baseId in databox.get_activable_colls() %}
<li>
<form class='form-inline' method="post" action="/admin/collection/{{ baseId }}/activate/">
<form class='form-inline' method="post" action="{{ path('admin_collection_enable', {'bas_id': baseId}) }}">
{{ baseId|bas_names }}
<a href="#" class="btn btn-mini submiter">{% trans "Activer" %}></a>
</form>
@@ -183,7 +185,7 @@
<div id="printLogoDIV_OK">
<img id="printLogo" src="/print/{{ databox.get_sbas_id() }} " />
{% if user.ACL().has_right_on_sbas(databox.get_sbas_id(), "bas_manage") %}
<form method="post" action="/admin/databox/{{ app.request.get('databox_id') }}/logo/delete/"/>
<form method="post" action="{{ path('admin_database_delete_logo', {'databox_id': databox.get_sbas_id()}) }}"/>
<a href="#" class='btn submiter'>
{% trans "admin::base:collection: supprimer le logo" %}
</a>
@@ -192,10 +194,10 @@
</div>
<div id="printLogoDIV_NONE">
{% trans "admin::base:collection: aucun fichier (minilogo, watermark ...)" %}
<form method="post" name="flpdf" action="/admin/databox/{{ app.request.get('databox_id') }}/logo/" target="???" onsubmit="return(false);" ENCTYPE="multipart/form-data">
<form method="post" name="flpdf" action="{{ path('admin_database_submit_logo', {'databox_id': databox.get_sbas_id()}) }}" target="right" enctype="multipart/form-data">
{% if user.ACL().has_right_on_sbas(databox.get_sbas_id(), "bas_manage") %}
<input name="newLogoPdf" type="file" accept="image/jpeg" />
<input type="button" class="btn" value="{% trans "boutton::envoyer" %}" onclick="sendLogopdf();" />
<input class="btn submiter" value="{% trans "boutton::envoyer" %}" />
<i>{% trans "admin::base: envoyer un logo (jpeg 35px de hauteur max)" %}</i>
{% endif %}
</form>

View File

@@ -73,7 +73,7 @@
<li class="open">
<div class="{% if feature == 'bases' %}selected{% endif %}" style="padding:0 0 2px 0;">
<a id="TREE_DATABASES" target="right" href="/admin/databoxes/" class="ajax">
<a id="TREE_DATABASES" target="right" href="{{ path('admin_databases') }}" class="ajax">
<img src="/skins/admin/DatabasesAvailable.png" />
<span>{% trans 'admin::utilisateurs: bases de donnees' %}</span>
</a>

View File

@@ -31,7 +31,7 @@
<div>
<div class='well-small'>
<a href="/admin/users/import/example/user/"> <i class="icon-share"></i> {% trans 'You can download an example by clicking here' %}</a>
<a href="/admin/users/import/example/csv/"> <i class="icon-share"></i> {% trans 'You can download an example by clicking here' %}</a>
</div>
<div class='well-small'>
<a href="/admin/users/import/example/rtf/"> <i class="icon-share"></i> {% trans 'You can download the documentation here' %}</a>

View File

@@ -44,6 +44,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
$this->StubbedACL = $this->getMockBuilder('\ACL')
->disableOriginalConstructor()
@@ -95,7 +96,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function checkRedirection($response, $location)
{
$this->assertTrue($response->isRedirect());
// $this->assertRegexp('/' . str_replace("/", "\/", $location) . '/', $response->headers->get('location'));
$this->assertEquals($location, $response->headers->get('location'));
}
@@ -188,7 +188,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $collection = \collection::get_from_base_id(self::$collection->get_base_id());
$this->assertTrue( ! ! strrpos($collection->get_prefs(), 'my_new_value'));
$collection = null;
unset($collection);
}
/**
@@ -244,7 +244,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = \collection::get_from_base_id(self::$collection->get_base_id());
$this->assertTrue($collection->is_active());
$collection = null;
unset($collection);
}
/**
@@ -282,7 +282,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue($json->success);
$collection = \collection::get_from_base_id(self::$collection->get_base_id());
$this->assertFalse($collection->is_active());
$collection = null;
unset($collection);
}
/**
@@ -524,52 +524,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
}
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollectionBadRequestFormat()
{
$this->setAdmin(true);
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/unmount/');
}
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollectionUnauthorizedException()
{
$this->setAdmin(false);
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/unmount/');
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollection()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
$this->XMLHTTPRequest('POST', '/collection/' . $collection->get_base_id() . '/unmount/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
try {
\collection::get_from_base_id($collection->get_base_id());
$this->fail('Collection not unmounted');
} catch (\Exception_Databox_CollectionNotFound $e) {
}
unset($collection);
}
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setMiniLogo
@@ -639,7 +593,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/delete/');
}
/**
@@ -653,7 +607,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$this->XMLHTTPRequest('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/');
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
/* * todo check why file is not deleted */
@@ -685,7 +639,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/watermark/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/picture/watermark/delete/');
}
/**
@@ -698,7 +652,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
$this->setAdmin(true);
$this->XMLHTTPRequest('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/watermark/');
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/picture/watermark/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
@@ -731,7 +685,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/stamp-logo/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/picture/stamp-logo/delete/');
}
/**
@@ -745,7 +699,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$this->XMLHTTPRequest('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/stamp-logo/');
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/picture/stamp-logo/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
@@ -778,7 +732,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/banner/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/picture/banner/delete/');
}
/**
@@ -792,7 +746,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/picture/banner/');
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/picture/banner/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
@@ -841,7 +795,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/delete/');
}
/**
@@ -852,7 +806,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(false);
$this->client->request('DELETE', '/collection/' . self::$collection->get_base_id() . '/');
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/delete/');
}
/**
@@ -864,7 +818,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection();
$this->XMLHTTPRequest('DELETE', '/collection/' . $collection->get_base_id() . '/');
$this->XMLHTTPRequest('POST', '/collection/' . $collection->get_base_id() . '/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
@@ -892,10 +846,56 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestSkipped('No record were added');
}
$this->XMLHTTPRequest('DELETE', '/collection/' . $collection->get_base_id() . '/');
$this->XMLHTTPRequest('POST', '/collection/' . $collection->get_base_id() . '/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertFalse($json->success);
$collection->empty_collection();
}
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollectionBadRequestFormat()
{
$this->setAdmin(true);
$this->client->request('POST', '/collection/' . self::$collection->get_base_id() . '/unmount/');
}
/**
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollectionUnauthorizedException()
{
$this->setAdmin(false);
$this->XMLHTTPRequest('POST', '/collection/' . self::$collection->get_base_id() . '/unmount/');
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::unmount
*/
public function testPostUnmountCollection()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
$this->XMLHTTPRequest('POST', '/collection/' . $collection->get_base_id() . '/unmount/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
try {
\collection::get_from_base_id($collection->get_base_id());
$this->fail('Collection not unmounted');
} catch (\Exception_Databox_CollectionNotFound $e) {
}
unset($collection);
}
}

View File

@@ -124,14 +124,14 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
/**
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::resetAdminRights
*/
// public function testResetAdminRights()
// {
// $this->setAdmin(true);
//
// $this->client->request('POST', '/dashboard/reset-admin-rights/');
//
// $this->assertTrue($this->client->getResponse()->isRedirect());
// }
public function testResetAdminRights()
{
$this->setAdmin(true);
$this->client->request('POST', '/dashboard/reset-admin-rights/');
$this->assertTrue($this->client->getResponse()->isRedirect());
}
/**
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::addAdmins
@@ -140,10 +140,14 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$user = \User_Adapter::create($this->app['phraseanet.appbox'], 'test', "test", "test@email.com", false);
$admins = array_keys(\User_Adapter::get_sys_admins());
$this->client->request('POST', '/dashboard/new/', array(
'admins' => array($user->get_id())
$user = \User_Adapter::create($this->app['phraseanet.appbox'], uniqid('unit_test_user'), uniqid('unit_test_user'), uniqid('unit_test_user') ."@email.com", false);
$admins[] = $user->get_id();
$this->client->request('POST', '/dashboard/add-admins/', array(
'admins' => $admins
));
$this->assertTrue($this->client->getResponse()->isRedirect());

View File

@@ -22,6 +22,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
$this->StubbedACL = $this->getMockBuilder('\ACL')
->disableOriginalConstructor()
@@ -224,11 +225,14 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testSetReorder()
{
$databox = $this->createDatabox('unit_test_db8');
$collection = \collection::create($databox, $this->app['phraseanet.appbox'], 'TESTTODELETE');
$this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/collections/order/', array(
$this->XMLHTTPRequest('POST', '/databox/' . $databox->get_sbas_id() . '/collections/order/', array(
'order' => array(
2 => self::$collection->get_base_id()
2 => $collection->get_base_id()
)));
$this->assertTrue($this->client->getResponse()->isOk());
@@ -302,7 +306,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$databox = $this->app['phraseanet.appbox']->get_databox(self::$collection->get_sbas_id());
$cgus = $databox->get_cgus();
$this->assertEquals($cgus['fr_FR']['value'], $cgusUpdate);
$databox = null;
unset($databox);
}
/**
@@ -542,7 +546,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/view-name/');
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/view-name/', array(
'viewname' => 'new_databox_name'
));
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
@@ -552,7 +558,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertObjectHasAttribute('sbas_id', $content, $response->getContent());
$databox = new \databox(self::$collection->get_sbas_id());
$this->assertEquals('salut', $databox->get_viewname());
$this->assertEquals('new_databox_name', $databox->get_viewname());
}
/**
@@ -634,7 +640,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base = $this->createDatabox('unit_test_db2');
$this->XMLHTTPRequest('DELETE', '/databox/' . $base->get_sbas_id() . '/');
$this->XMLHTTPRequest('POST', '/databox/' . $base->get_sbas_id() . '/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
@@ -680,11 +686,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
unset($databox);
}
/**
* @covers \Alchemy\Phrasea\Controller\Admin\Database::mountCollection
*/
public function testMountCollection()
{
$this->markTestSkipped();
$this->setAdmin(true);
$collection = $this->createOneCollection();
@@ -725,7 +733,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestSkipped('No logo setted');
}
$this->XMLHTTPRequest('DELETE', '/databox/' . self::$collection->get_sbas_id() . '/logo/');
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/logo/delete/');
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);

View File

@@ -352,7 +352,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testGetExampleCSVFile()
{
$this->client->request('GET', '/users/import/example/user/');
$this->client->request('GET', '/users/import/example/csv/');
$this->assertTrue($this->client->getResponse()->isOk());
}