Update admin controllers

This commit is contained in:
Romain Neutron
2012-09-18 17:33:37 +02:00
parent 1fc9a78e7f
commit afbb28a025
10 changed files with 166 additions and 155 deletions

View File

@@ -491,8 +491,8 @@ class Collection implements ControllerProviderInterface
$success = false;
$msg = _('An error occurred');
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
if ($collection->get_record_amount() <= 500) {
$collection->empty_collection(500);
@@ -532,8 +532,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_PRESENTATION);
$success = true;
} catch (\Exception $e) {
@@ -564,8 +565,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_STAMP);
$success = true;
} catch (\Exception $e) {
@@ -596,8 +598,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_WM);
$success = true;
} catch (\Exception $e) {
@@ -628,8 +631,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->update_logo(null);
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, null, \collection::PIC_LOGO);
$success = true;
@@ -673,9 +677,9 @@ class Collection implements ControllerProviderInterface
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
}
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_PRESENTATION);
$app['filesystem']->remove($file->getPathname());
@@ -711,9 +715,9 @@ class Collection implements ControllerProviderInterface
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
}
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_STAMP);
$app['filesystem']->remove($file->getPathname());
@@ -749,9 +753,9 @@ class Collection implements ControllerProviderInterface
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
}
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_WM);
$app['filesystem']->remove($file->getPathname());
@@ -787,9 +791,9 @@ class Collection implements ControllerProviderInterface
return $app->redirect('/admin/collection/' . $bas_id . '/?success=0&error=file-invalid');
}
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$app['phraseanet.appbox']->write_collection_pic($app['media-alchemyst'], $app['filesystem'], $collection, $file, \collection::PIC_LOGO);
$app['filesystem']->remove($file->getPathname());
@@ -814,9 +818,9 @@ class Collection implements ControllerProviderInterface
$success = false;
$msg = _('An error occured');
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
if ($collection->get_record_amount() > 0) {
$msg = _('Empty the collection before removing');
} else {
@@ -862,8 +866,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->unmount_collection($app);
$success = true;
} catch (\Exception $e) {
@@ -897,8 +902,9 @@ class Collection implements ControllerProviderInterface
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->set_name($name);
$success = true;
} catch (\Exception $e) {
@@ -932,8 +938,9 @@ class Collection implements ControllerProviderInterface
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->set_public_presentation($watermark);
$success = true;
} catch (\Exception $e) {
@@ -963,8 +970,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->enable($app['phraseanet.appbox']);
$success = true;
} catch (\Exception $e) {
@@ -994,8 +1002,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
$collection->disable($app['phraseanet.appbox']);
$success = true;
} catch (\Exception $e) {
@@ -1087,9 +1096,9 @@ class Collection implements ControllerProviderInterface
{
$success = false;
try {
$collection = \collection::get_from_base_id($app, $bas_id);
try {
if ($mdesc = \DOMDocument::loadXML($request->request->get('str'))) {
$collection->set_prefs($mdesc);
$success = true;

View File

@@ -142,7 +142,7 @@ class Dashboard implements ControllerProviderInterface
$parameters = array(
'cache_flushed' => $request->query->get('flush_cache') === 'ok',
'admins' => \User_Adapter::get_sys_admins(),
'admins' => \User_Adapter::get_sys_admins($app),
'email_status' => $emailStatus,
'search_engine_status' => $searchEngineStatus,
'php_version_constraints' => \setup::check_php_version(),

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Core;
use Alchemy\Phrasea\Core\Configuration;
use Silex\Application;
use Silex\ControllerProviderInterface;
@@ -31,7 +30,7 @@ class Databox implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->before(function(Request $request) use ($app) {
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
return $app['firewall']->requireAdmin($app);
});
@@ -434,13 +433,13 @@ class Databox implements ControllerProviderInterface
*/
public function getDatabaseCGU(Application $app, Request $request, $databox_id)
{
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
return new Response($app['twig']->render('admin/databox/cgus.html.twig', array(
'languages' => Core::getAvailableLanguages(),
'languages' => $app->getAvailableLanguages(),
'cgus' => $app['phraseanet.appbox']->get_databox($databox_id)->get_cgus(),
'current_locale' => \Session_Handler::get_locale()
)));
@@ -558,7 +557,7 @@ class Databox implements ControllerProviderInterface
*/
public function updateDatabaseCGU(Application $app, Request $request, $databox_id)
{
if ( ! $app['phraseanet.core']->getAuthenticatedUser()->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -596,11 +595,11 @@ class Databox implements ControllerProviderInterface
return $app->redirect('/admin/databoxes/?error=special-chars');
}
$registry = $app['phraseanet.core']['Registry'];
$registry = $app['phraseanet.registry'];
if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) {
$configuration = Configuration::build();
$configuration = $app['phraseanet.configuration'];
$choosenConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($choosenConnexion);
@@ -619,9 +618,9 @@ class Databox implements ControllerProviderInterface
}
try {
$base = \databox::create($app['phraseanet.appbox'], $connbas, $dataTemplate, $registry);
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
$app['phraseanet.core']->getAuthenticatedUser()->ACL()->delete_data_from_cache();
$base = \databox::create($app, $connbas, $dataTemplate, $registry);
$base->registerAdmin($app['phraseanet.user']);
$app['phraseanet.user']->ACL()->delete_data_from_cache();
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
} catch (\Exception $e) {
@@ -642,8 +641,8 @@ class Databox implements ControllerProviderInterface
$data_template = new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/' . $dataTemplate . '.xml');
$connbas = new \connection_pdo('databox_creation', $hostname, $port, $userDb, $passwordDb, $dbName, array(), $registry);
try {
$base = \databox::create($app['phraseanet.appbox'], $connbas, $data_template, $registry);
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
$base = \databox::create($app, $connbas, $data_template, $registry);
$base->registerAdmin($app['phraseanet.user']);
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
} catch (\Exception $e) {
@@ -677,11 +676,11 @@ class Databox implements ControllerProviderInterface
}
$appbox = $app['phraseanet.appbox'];
$registry = $app['phraseanet.core']['Registry'];
$registry = $app['phraseanet.registry'];
if ((null === $request->request->get('new_settings'))) {
try {
$configuration = Configuration::build();
$configuration = $app['phraseanet.configuration'];
$connexion = $configuration->getConnexion();
$hostname = $connexion->get('host');
@@ -690,8 +689,8 @@ class Databox implements ControllerProviderInterface
$password = $connexion->get('password');
$appbox->get_connection()->beginTransaction();
$base = \databox::mount($app['phraseanet.appbox'], $hostname, $port, $user, $password, $dbName, $registry);
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
$base = \databox::mount($app, $hostname, $port, $user, $password, $dbName, $registry);
$base->registerAdmin($app['phraseanet.user']);
$appbox->get_connection()->commit();
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
@@ -711,8 +710,8 @@ class Databox implements ControllerProviderInterface
try {
$appbox->get_connection()->beginTransaction();
$base = \databox::mount($appbox, $hostname, $port, $userDb, $passwordDb, $dbName, $registry);
$base->registerAdmin($app['phraseanet.core']->getAuthenticatedUser());
$base = \databox::mount($app, $hostname, $port, $userDb, $passwordDb, $dbName, $registry);
$base->registerAdmin($app['phraseanet.user']);
$appbox->get_connection()->commit();
return $app->redirect('/admin/databox/' . $base->get_sbas_id() . '/?success=1&reload-tree=1');
@@ -735,7 +734,7 @@ class Databox implements ControllerProviderInterface
public function mountCollection(Application $app, Request $request, $databox_id, $collection_id)
{
$appbox = $app['phraseanet.appbox'];
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
if ( ! $user->ACL()->has_right_on_sbas($databox_id, 'bas_manage')) {
$app->abort(403);
@@ -743,13 +742,13 @@ class Databox implements ControllerProviderInterface
$appbox->get_connection()->beginTransaction();
try {
$baseId = \collection::mount_collection($databox_id, $collection_id, $user);
$baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $user);
if (null == $othCollSel = $request->request->get("othcollsel")) {
$app->abort(400);
}
$query = new \User_Query($appbox);
$query = new \User_Query($app);
$n = 0;
while ($n < $query->on_base_ids(array($othCollSel))->get_total()) {
@@ -1018,7 +1017,7 @@ class Databox implements ControllerProviderInterface
$ret['xml_indexed'] = $datas['xml_indexed'];
$ret['thesaurus_indexed'] = $datas['thesaurus_indexed'];
if ($app['filesystem']->exists($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'config/minilogos/logopdf_' . $databox_id . '.jpg')) {
if ($app['filesystem']->exists($app['phraseanet.registry']->get('GV_RootPath') . 'config/minilogos/logopdf_' . $databox_id . '.jpg')) {
$ret['printLogoURL'] = '/custom/minilogos/logopdf_' . $databox_id . '.jpg';
}
@@ -1060,7 +1059,7 @@ class Databox implements ControllerProviderInterface
try {
foreach ($request->request->get('order', array()) as $order => $baseId) {
$collection = \collection::get_from_base_id($baseId);
$collection = \collection::get_from_base_id($app, $baseId);
$app['phraseanet.appbox']->set_collection_order($collection, $order);
unset($collection);
}
@@ -1112,11 +1111,11 @@ class Databox implements ControllerProviderInterface
try {
$databox = $app['phraseanet.appbox']->get_databox($databox_id);
$collection = \collection::create($databox, $app['phraseanet.appbox'], $name, $app['phraseanet.core']->getAuthenticatedUser());
$collection = \collection::create($app, $databox, $app['phraseanet.appbox'], $name, $app['phraseanet.user']);
if (($request->request->get('ccusrothercoll') === "on")
&& ($othcollsel = $request->request->get('othcollsel') !== null)) {
$query = new \User_Query($app['phraseanet.appbox']);
$query = new \User_Query($app);
$total = $query->on_base_ids(array($othcollsel))->get_total();
$n = 0;
while ($n < $total) {

View File

@@ -30,7 +30,7 @@ class Databoxes implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->before(function(Request $request) use ($app) {
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
return $app['firewall']->requireAdmin($app);
});
/**
@@ -84,7 +84,7 @@ class Databoxes implements ControllerProviderInterface
$upgradeAvailable = true;
}
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
$sbasIds = array_merge(
array_keys($user->ACL()->get_granted_sbas(array('bas_manage')))
@@ -110,7 +110,7 @@ class Databoxes implements ControllerProviderInterface
'version' => $databox->get_version(),
'image' => '/skins/icons/foldph20close_0.gif',
'server_info' => $databox->get_connection()->server_info(),
'name' => \phrasea::sbas_names($sbasId)
'name' => \phrasea::sbas_names($sbasId, $app)
);
} catch (\Exception $e) {
@@ -147,10 +147,10 @@ class Databoxes implements ControllerProviderInterface
break;
}
$upgrader = new \Setup_Upgrade($app['phraseanet.appbox']);
$upgrader = new \Setup_Upgrade($app);
return new Response($app['twig']->render('admin/databases.html.twig', array(
'files' => new \DirectoryIterator($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/conf.d/data_templates'),
'files' => new \DirectoryIterator($app['phraseanet.registry']->get('GV_RootPath') . 'lib/conf.d/data_templates'),
'sbas' => $sbas,
'upgrade_available' => $upgradeAvailable,
'error_msg' => $errorMsg,
@@ -168,14 +168,14 @@ class Databoxes implements ControllerProviderInterface
*/
public function databasesUpgrade(Application $app, Request $request)
{
if (\phrasea::is_scheduler_started()) {
if (\phrasea::is_scheduler_started($app)) {
return $app->redirect('/admin/databoxes/?success=0&error=scheduler-started');
}
try {
$upgrader = new \Setup_Upgrade($app['phraseanet.appbox']);
$advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app['phraseanet.core']['CacheService'], $app['phraseanet.core']['EM'], $app['filesystem']);
$upgrader = new \Setup_Upgrade($app);
$advices = $app['phraseanet.appbox']->forceUpgrade($upgrader, $app);
return $app->redirect('/admin/databoxes/?success=1&notice=restart&' . http_build_query(array('advices' => $advices)));
} catch (\Exception_Setup_UpgradeAlreadyStarted $e) {

View File

@@ -165,7 +165,7 @@ class Description implements ControllerProviderInterface
if (is_array($request->request->get('field_ids'))) {
foreach ($request->request->get('field_ids') as $id) {
try {
$field = \databox_field::get_instance($databox, $id);
$field = \databox_field::get_instance($app, $databox, $id);
$field->set_name($request->request->get('name_' . $id))
->set_thumbtitle($request->request->get('thumbtitle_' . $id))
->set_tag(\databox_field::loadClassFromTagName($request->request->get('src_' . $id)))
@@ -181,7 +181,7 @@ class Description implements ControllerProviderInterface
->setVocabularyRestricted(false);
try {
$vocabulary = VocabularyController::get($request->request->get('vocabulary_' . $id));
$vocabulary = VocabularyController::get($app, $request->request->get('vocabulary_' . $id));
$field->setVocabularyControl($vocabulary);
$field->setVocabularyRestricted($request->request->get('vocabularyrestricted_' . $id));
} catch (\Exception $e) {
@@ -203,14 +203,14 @@ class Description implements ControllerProviderInterface
}
if ($request->request->get('newfield')) {
$field = \databox_field::create($databox, $request->request->get('newfield'), $request->request->get('newfield_multi'));
$field = \databox_field::create($app, $databox, $request->request->get('newfield'), $request->request->get('newfield_multi'));
}
if (is_array($request->request->get('todelete_ids'))) {
foreach ($request->request->get('todelete_ids') as $id) {
try {
$field = \databox_field::get_instance($databox, $id);
$field = \databox_field::get_instance($app, $databox, $id);
$field->delete();
} catch (\Exception $e) {
@@ -225,7 +225,7 @@ class Description implements ControllerProviderInterface
return $app->redirect('/admin/description/' . $sbas_id . '/');
})->before(function(Request $request) use ($app) {
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
if (false === $app['phraseanet.user']->ACL()
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
throw new AccessDeniedHttpException('You are not allowed to access this zone');
}
@@ -239,12 +239,12 @@ class Description implements ControllerProviderInterface
'databox' => $databox,
'fields' => $databox->get_meta_structure(),
'available_dc_fields' => $databox->get_available_dcfields(),
'vocabularies' => VocabularyController::getAvailable(),
'vocabularies' => VocabularyController::getAvailable($app),
);
return new Response($app['twig']->render('admin/databox/doc_structure.html.twig', $params));
})->before(function(Request $request) use ($app) {
if (false === $app['phraseanet.core']->getAuthenticatedUser()->ACL()
if (false === $app['phraseanet.user']->ACL()
->has_right_on_sbas($request->attributes->get('sbas_id'), 'bas_modify_struct')) {
throw new AccessDeniedHttpException('You are not allowed to access this zone');
}

View File

@@ -31,7 +31,7 @@ class Publications implements ControllerProviderInterface
$controllers->get('/list/', function(PhraseaApplication $app) {
$feeds = \Feed_Collection::load_all(
$app['phraseanet.appbox'], $app['phraseanet.core']->getAuthenticatedUser()
$app, $app['phraseanet.user']
);
return $app['twig']
@@ -40,23 +40,23 @@ class Publications implements ControllerProviderInterface
$controllers->post('/create/', function(PhraseaApplication $app, Request $request) {
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
$feed = \Feed_Adapter::create(
$app['phraseanet.appbox'], $user, $request->request->get('title'), $request->request->get('subtitle')
$app, $user, $request->request->get('title'), $request->request->get('subtitle')
);
if ($request->request->get('public') == '1') {
$feed->set_public(true);
} elseif ($request->request->get('base_id')) {
$feed->set_collection(\collection::get_from_base_id($request->request->get('base_id')));
$feed->set_collection(\collection::get_from_base_id($app, $request->request->get('base_id')));
}
return $app->redirect('/admin/publications/list/');
});
$controllers->get('/feed/{id}/', function(PhraseaApplication $app, Request $request, $id) {
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed = new \Feed_Adapter($app, $id);
return $app['twig']
->render('admin/publications/fiche.html.twig', array('feed' => $feed, 'error' => $app['request']->query->get('error')));
@@ -64,10 +64,10 @@ class Publications implements ControllerProviderInterface
$controllers->post('/feed/{id}/update/', function(PhraseaApplication $app, Request $request, $id) {
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed = new \Feed_Adapter($app, $id);
try {
$collection = \collection::get_from_base_id($request->request->get('base_id'));
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
} catch (\Exception $e) {
$collection = null;
}
@@ -79,9 +79,9 @@ class Publications implements ControllerProviderInterface
return $app->redirect('/admin/publications/list/');
})->before(function(Request $request) use ($app) {
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $request->attributes->get('id'));
$feed = new \Feed_Adapter($app, $request->attributes->get('id'));
if ( ! $feed->is_owner($app['phraseanet.core']->getAuthenticatedUser())) {
if ( ! $feed->is_owner($app['phraseanet.user'])) {
return $app->redirect('/admin/publications/feed/' . $request->attributes->get('id') . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
}
})
@@ -93,9 +93,9 @@ class Publications implements ControllerProviderInterface
'message' => '',
);
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed = new \Feed_Adapter($app, $id);
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
$request = $app["request"];
@@ -120,9 +120,9 @@ class Publications implements ControllerProviderInterface
throw new \Exception_BadRequest('Uploaded file is invalid');
}
$media = $app['phraseanet.core']['mediavorus']->guess($file);
$media = $app['mediavorus']->guess($file->getPathname());
if ($media->getType() !== \MediaVorus\Media\Media::TYPE_IMAGE) {
if ($media->getType() !== \MediaVorus\Media\MediaInterface::TYPE_IMAGE) {
throw new \Exception_BadRequest('Bad filetype');
}
@@ -136,7 +136,7 @@ class Publications implements ControllerProviderInterface
$tmpname = tempnam(sys_get_temp_dir(), 'feed_icon');
try {
$app['phraseanet.core']['media-alchemyst']
$app['media-alchemyst']
->open($media->getFile()->getPathname())
->turnInto($tmpname, $spec)
->close();
@@ -162,8 +162,8 @@ class Publications implements ControllerProviderInterface
$error = '';
try {
$request = $app['request'];
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app['phraseanet.appbox']);
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$user = \User_Adapter::getInstance($request->request->get('usr_id'), $app);
$feed = new \Feed_Adapter($app, $id);
$feed->add_publisher($user);
} catch (\Exception $e) {
$error = $e->getMessage();
@@ -176,8 +176,8 @@ class Publications implements ControllerProviderInterface
try {
$request = $app['request'];
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$publisher = new \Feed_Publisher_Adapter($app['phraseanet.appbox'], $request->request->get('publisher_id'));
$feed = new \Feed_Adapter($app, $id);
$publisher = new \Feed_Publisher_Adapter($app, $request->request->get('publisher_id'));
$user = $publisher->get_user();
if ($feed->is_publisher($user) === true && $feed->is_owner($user) === false)
$publisher->delete();
@@ -189,7 +189,7 @@ class Publications implements ControllerProviderInterface
})->assert('id', '\d+');
$controllers->post('/feed/{id}/delete/', function(PhraseaApplication $app, $id) {
$feed = new \Feed_Adapter($app['phraseanet.appbox'], $id);
$feed = new \Feed_Adapter($app, $id);
$feed->delete();
return $app->redirect('/admin/publications/list/');

View File

@@ -30,11 +30,10 @@ class Root implements ControllerProviderInterface
$controllers->get('/', function(Application $app, Request $request) {
$Core = $app['phraseanet.core'];
$appbox = $app['phraseanet.appbox'];
$user = $Core->getAuthenticatedUser();
$user = $app['phraseanet.user'];
\User_Adapter::updateClientInfos(3);
\User_Adapter::updateClientInfos($app, 3);
$section = $request->query->get('section', false);
@@ -88,7 +87,7 @@ class Root implements ControllerProviderInterface
return new Response($app['twig']->render('admin/index.html.twig', array(
'module' => 'admin',
'events' => $app['phraseanet.core']['events-manager'],
'events' => $app['events-manager'],
'module_name' => 'Admin',
'notice' => $request->query->get("notice"),
'feature' => $feature,
@@ -102,11 +101,10 @@ class Root implements ControllerProviderInterface
->bind('admin');
$controllers->get('/tree/', function(Application $app, Request $request) {
$Core = $app['phraseanet.core'];
$appbox = $app['phraseanet.appbox'];
$user = $Core->getAuthenticatedUser();
$user = $app['phraseanet.user'];
\User_Adapter::updateClientInfos(3);
\User_Adapter::updateClientInfos($app, 3);
$section = $request->query->get('section', false);
@@ -198,7 +196,7 @@ 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')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -226,7 +224,7 @@ class Root implements ControllerProviderInterface
->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')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -254,7 +252,7 @@ class Root implements ControllerProviderInterface
->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')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -266,7 +264,7 @@ class Root implements ControllerProviderInterface
->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')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -306,10 +304,14 @@ class Root implements ControllerProviderInterface
$app->abort(400, _('Bad request format, only JSON is allowed'));
}
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
$error = false;
try {
\databox_status::deleteStatus($app['filesystem'], $databox_id, $bit);
\databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit);
} catch (\Exception $e) {
$error = true;
}
@@ -318,7 +320,7 @@ 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')) {
if ( ! $app['phraseanet.user']->ACL()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
$app->abort(403);
}
@@ -330,15 +332,15 @@ class Root implements ControllerProviderInterface
'labeloff' => $request->request->get('label_off', '')
);
\databox_status::updateStatus($databox_id, $bit, $properties);
\databox_status::updateStatus($app, $databox_id, $bit, $properties);
if (null !== $request->request->get('delete_icon_off')) {
\databox_status::deleteIcon($app['filesystem'], $databox_id, $bit, 'off');
\databox_status::deleteIcon($app, $databox_id, $bit, 'off');
}
if (null !== $file = $request->files->get('image_off')) {
try {
\databox_status::updateIcon($app['filesystem'], $databox_id, $bit, 'off', $file);
\databox_status::updateIcon($app, $databox_id, $bit, 'off', $file);
} catch (\Exception_Forbidden $e) {
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');
@@ -361,12 +363,12 @@ class Root implements ControllerProviderInterface
}
if (null !== $request->request->get('delete_icon_on')) {
\databox_status::deleteIcon($app['filesystem'], $databox_id, $bit, 'on');
\databox_status::deleteIcon($app, $databox_id, $bit, 'on');
}
if (null !== $file = $request->files->get('image_on')) {
try {
\databox_status::updateIcon($app['filesystem'], $databox_id, $bit, 'on', $file);
\databox_status::updateIcon($app, $databox_id, $bit, 'on', $file);
} catch (\Exception_Forbidden $e) {
return $app->redirect('/admin/statusbit/' . $databox_id . '/status/' . $bit . '/?error=rights');

View File

@@ -16,7 +16,9 @@ namespace Alchemy\Phrasea\Controller\Admin;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Alchemy\Phrasea\Application;
use Silex\Application as SilexApplication;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -30,12 +32,12 @@ use Symfony\Component\HttpFoundation\Response;
class Setup implements ControllerProviderInterface
{
public function connect(Application $app)
public function connect(SilexApplication $app)
{
$controllers = $app['controllers_factory'];
$controllers->before(function(Request $request) use ($app) {
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
return $app['firewall']->requireAdmin($app);
});
/**
@@ -82,7 +84,7 @@ class Setup implements ControllerProviderInterface
*/
public function getGlobals(Application $app, Request $request)
{
\phrasea::start($app['phraseanet.core']);
// \phrasea::start($app['phraseanet.configuration']);
require_once __DIR__ . "/../../../../conf.d/_GV_template.inc";
@@ -110,7 +112,7 @@ class Setup implements ControllerProviderInterface
*/
public function postGlobals(Application $app, Request $request)
{
if (\setup::create_global_values($app['phraseanet.core']['Registry'], $request->request->all())) {
if (\setup::create_global_values($app, $request->request->all())) {
return $app->redirect('/admin/globals/?success=1');
}

View File

@@ -30,7 +30,7 @@ class Sphinx implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->before(function(Request $request) use ($app) {
return $app['phraseanet.core']['Firewall']->requireAdmin($app);
return $app['firewall']->requireAdmin($app);
});
/**
@@ -76,8 +76,8 @@ class Sphinx implements ControllerProviderInterface
*/
public function getConfiguration(Application $app, Request $request)
{
$selected_charsets = $app['phraseanet.core']['Registry']->get('sphinx_charset_tables');
$selected_libstemmer = $app['phraseanet.core']['Registry']->get('sphinx_user_stemmer');
$selected_charsets = $app['phraseanet.registry']->get('sphinx_charset_tables');
$selected_libstemmer = $app['phraseanet.registry']->get('sphinx_user_stemmer');
$options = array(
'charset_tables' => ( ! is_array($selected_charsets) ? array() : $selected_charsets),
@@ -85,7 +85,7 @@ class Sphinx implements ControllerProviderInterface
);
return new Response($app['twig']->render('admin/sphinx/configuration.html.twig', array(
'configuration' => new \sphinx_configuration(),
'configuration' => new \sphinx_configuration($app),
'options' => $options
)));
}
@@ -99,11 +99,11 @@ class Sphinx implements ControllerProviderInterface
*/
public function submitConfiguration(Application $app, Request $request)
{
$app['phraseanet.core']['Registry']->set(
$app['phraseanet.registry']->set(
'sphinx_charset_tables', $request->request->get('charset_tables', array()), \registry::TYPE_ARRAY
);
$app['phraseanet.core']['Registry']->set(
$app['phraseanet.registry']->set(
'sphinx_user_stemmer', $request->request->get('libstemmer', array()), \registry::TYPE_ARRAY
);

View File

@@ -32,14 +32,14 @@ class Users implements ControllerProviderInterface
$controllers = $app['controllers_factory'];
$controllers->post('/rights/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
}
);
$controllers->get('/rights/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
return $app['twig']->render('admin/editusers.html.twig', $rights->get_users_rights());
}
@@ -47,10 +47,9 @@ class Users implements ControllerProviderInterface
$controllers->post('/rights/reset/', function(Application $app, Request $request) {
try {
$core = $app['phraseanet.core'];
$datas = array('error' => false);
$helper = new UserHelper\Edit($core, $request);
$helper = new UserHelper\Edit($app, $request);
$helper->resetRights();
} catch (\Exception $e) {
$datas['error'] = true;
@@ -62,7 +61,7 @@ class Users implements ControllerProviderInterface
);
$controllers->post('/delete/', function(Application $app) {
$module = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$module = new UserHelper\Edit($app, $app['request']);
$module->delete_users();
return $app->redirect('/admin/users/search/');
@@ -73,7 +72,7 @@ class Users implements ControllerProviderInterface
$datas = array('error' => true);
try {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
$rights->apply_rights();
if ($app['request']->request->get('template')) {
@@ -92,14 +91,14 @@ class Users implements ControllerProviderInterface
);
$controllers->post('/rights/quotas/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
return $app['twig']->render('admin/editusers_quotas.html.twig', $rights->get_quotas());
}
);
$controllers->post('/rights/quotas/apply/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
$rights->apply_quotas();
return;
@@ -107,14 +106,14 @@ class Users implements ControllerProviderInterface
);
$controllers->post('/rights/time/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
return $app['twig']->render('admin/editusers_timelimit.html.twig', $rights->get_time());
}
);
$controllers->post('/rights/time/apply/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
$rights->apply_time();
return;
@@ -122,14 +121,14 @@ class Users implements ControllerProviderInterface
);
$controllers->post('/rights/masks/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
return $app['twig']->render('admin/editusers_masks.html.twig', $rights->get_masks());
}
);
$controllers->post('/rights/masks/apply/', function(Application $app) {
$rights = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$rights = new UserHelper\Edit($app, $app['request']);
$rights->apply_masks();
return;
@@ -137,7 +136,7 @@ class Users implements ControllerProviderInterface
);
$controllers->match('/search/', function(Application $app) {
$users = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
$users = new UserHelper\Manage($app, $app['request']);
return $app['twig']->render('admin/users.html.twig', $users->search());
}
@@ -146,7 +145,7 @@ class Users implements ControllerProviderInterface
$controllers->post('/search/export/', function() use ($app) {
$request = $app['request'];
$users = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
$users = new UserHelper\Manage($app, $app['request']);
$userTable = array(
array(
@@ -201,7 +200,7 @@ class Users implements ControllerProviderInterface
);
$controllers->post('/apply_template/', function() use ($app) {
$users = new UserHelper\Edit($app['phraseanet.core'], $app['request']);
$users = new UserHelper\Edit($app, $app['request']);
$users->apply_template();
@@ -212,9 +211,9 @@ class Users implements ControllerProviderInterface
$controllers->get('/typeahead/search/', function(Application $app) use ($appbox) {
$request = $app['request'];
$user_query = new \User_Query($appbox);
$user_query = new \User_Query($app);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $app);
$like_value = $request->query->get('term');
$rights = $request->query->get('filter_rights') ? : array();
@@ -254,7 +253,7 @@ class Users implements ControllerProviderInterface
$datas = array('error' => false, 'message' => '', 'data' => null);
try {
$request = $app['request'];
$module = new UserHelper\Manage($app['phraseanet.core'], $app['request']);
$module = new UserHelper\Manage($app, $app['request']);
if ($request->request->get('template') == '1') {
$user = $module->create_template();
} else {
@@ -275,9 +274,9 @@ class Users implements ControllerProviderInterface
$controllers->post('/export/csv/', function(Application $app) use ($appbox) {
$request = $app['request'];
$user_query = new \User_Query($appbox, $app['phraseanet.core']);
$user_query = new \User_Query($app);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $app);
$like_value = $request->request->get('like_value');
$like_field = $request->request->get('like_field');
$on_base = $request->request->get('base_id') ? : null;
@@ -328,7 +327,7 @@ class Users implements ControllerProviderInterface
, $user->get_address()
, $user->get_city()
, $user->get_zipcode()
, $geoname->get_country($user->get_geonameid())
, $geoname->get_country($user->get_geonameid(), $app)
, $user->get_tel()
, $user->get_fax()
, $user->get_job()
@@ -352,7 +351,7 @@ class Users implements ControllerProviderInterface
);
$controllers->get('/demands/', function(Application $app, Request $request) use ($appbox) {
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
$lastMonth = time() - (3 * 4 * 7 * 24 * 60 * 60);
$sql = "DELETE FROM demand WHERE date_modif < :date";
@@ -460,10 +459,10 @@ class Users implements ControllerProviderInterface
$cache_to_update = array();
foreach ($templates as $usr => $template_id) {
$user = \User_Adapter::getInstance($usr, $appbox);
$user = \User_Adapter::getInstance($usr, $app);
$cache_to_update[$usr] = true;
$user_template = \User_Adapter::getInstance($template_id, $appbox);
$user_template = \User_Adapter::getInstance($template_id, $app);
$base_ids = array_keys($user_template->ACL()->get_granted_base());
$user->ACL()->apply_model($user_template, $base_ids);
@@ -510,11 +509,11 @@ class Users implements ControllerProviderInterface
$stmt->closeCursor();
foreach ($accept as $usr => $bases) {
$user = \User_Adapter::getInstance($usr, $appbox);
$user = \User_Adapter::getInstance($usr, $app);
$cache_to_update[$usr] = true;
foreach ($bases as $bas) {
$user->ACL()->give_access_to_sbas(array(\phrasea::sbasFromBas($bas)));
$user->ACL()->give_access_to_sbas(array(\phrasea::sbasFromBas($app, $bas)));
$rights = array(
'canputinalbum' => '1'
@@ -541,7 +540,7 @@ class Users implements ControllerProviderInterface
}
foreach (array_keys($cache_to_update) as $usr_id) {
$user = \User_Adapter::getInstance($usr_id, $appbox);
$user = \User_Adapter::getInstance($usr_id, $app);
$user->ACL()->delete_data_from_cache();
unset($user);
}
@@ -561,13 +560,13 @@ class Users implements ControllerProviderInterface
if (\PHPMailer::ValidateAddress($row['usr_mail'])) {
foreach ($bases as $bas => $isok) {
if ($isok) {
$accept .= '<li>' . \phrasea::bas_names($bas) . "</li>\n";
$accept .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
} else {
$deny .= '<li>' . \phrasea::bas_names($bas) . "</li>\n";
$deny .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
}
}
if (($accept != '' || $deny != '')) {
\mail::register_confirm($row['usr_mail'], $accept, $deny);
\mail::register_confirm($app, $row['usr_mail'], $accept, $deny);
}
}
}
@@ -585,7 +584,7 @@ class Users implements ControllerProviderInterface
->bind('users_display_import_file');
$controllers->post('/import/file/', function(Application $app, Request $request) {
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
if ((null === $file = $request->files->get('files')) || ! $file->isValid()) {
@@ -648,7 +647,7 @@ class Users implements ControllerProviderInterface
} elseif (isset($loginNew[$loginToAdd])) {
$out['errors'][] = sprintf(_("Login %s is already defined in the file at line %d"), $loginToAdd, $i);
} else {
if (\User_Adapter::get_usr_id_from_login($loginToAdd)) {
if (\User_Adapter::get_usr_id_from_login($app, $loginToAdd)) {
$out['errors'][] = sprintf(_("Login %s already exists in database"), $loginToAdd);
} else {
$loginNew[$loginToAdd] = ($i + 1);
@@ -722,7 +721,7 @@ class Users implements ControllerProviderInterface
$controllers->post('/import/', function(Application $app, Request $request) {
$nbCreation = 0;
$user = $app['phraseanet.core']->getAuthenticatedUser();
$user = $app['phraseanet.user'];
if ((null === $serializedArray = $request->request->get('sr')) || ('' === $serializedArray)) {
$app->abort(400);
@@ -782,13 +781,13 @@ class Users implements ControllerProviderInterface
}
if (isset($curUser['usr_login']) && trim($curUser['usr_login']) !== '' && isset($curUser['usr_password']) && trim($curUser['usr_password']) !== "") {
$loginNotExist = ! \User_Adapter::get_usr_id_from_login($curUser['usr_login']);
$loginNotExist = ! \User_Adapter::get_usr_id_from_login($app, $curUser['usr_login']);
if ($loginNotExist) {
$NewUser = \User_Adapter::create($app['phraseanet.appbox'], $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
$NewUser = \User_Adapter::create($app, $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
$NewUser->ACL()->apply_model(
\User_Adapter::getInstance($model, $app['phraseanet.appbox']), array_keys($user->ACL()->get_granted_base(array('manage')))
\User_Adapter::getInstance($model, $app), array_keys($user->ACL()->get_granted_base(array('manage')))
);
$nbCreation ++;
@@ -802,7 +801,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/csv/', function(Application $app, Request $request) {
$file = new \SplFileInfo($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/Fixtures/exampleImportUsers.csv');
$file = new \SplFileInfo($app['phraseanet.registry']->get('GV_RootPath') . 'www/admin/exampleImportUsers.csv');
if ( ! $file->isFile()) {
$app->abort(400);
@@ -822,7 +821,7 @@ class Users implements ControllerProviderInterface
$controllers->get('/import/example/rtf/', function(Application $app, Request $request) {
$file = new \SplFileInfo($app['phraseanet.core']['Registry']->get('GV_RootPath') . 'lib/Fixtures/Fields.rtf');
$file = new \SplFileInfo($app['phraseanet.registry']->get('GV_RootPath') . 'www/admin/Fields.rtf');
if ( ! $file->isFile()) {
$app->abort(400);