Пример #1
0
 private function bitfieldToFlagsMap($bitfield)
 {
     $flags = [];
     foreach ($this->field_names_map as $position => $name) {
         $flags[$name] = \databox_status::bitIsSet($bitfield, $position);
     }
     return $flags;
 }
Пример #2
0
 public function connect(SilexApplication $app)
 {
     $app['controller.prod'] = $this;
     $controllers = $app['controllers_factory'];
     $controllers->before(function (Request $request) use($app) {
         if (!$app['authentication']->isAuthenticated() && null !== $request->query->get('nolog')) {
             return $app->redirectPath('login_authenticate_as_guest');
         }
         if (null !== ($response = $app['firewall']->requireAuthentication())) {
             return $response;
         }
     });
     $controllers->get('/', function (Application $app) {
         try {
             \Session_Logger::updateClientInfos($app, 1);
         } catch (SessionNotFound $e) {
             return $app->redirectPath('logout');
         }
         $cssPath = $app['root.path'] . '/www/skins/prod/';
         $css = [];
         $cssfile = false;
         $finder = new Finder();
         $iterator = $finder->directories()->depth(0)->filter(function (\SplFileInfo $fileinfo) {
             return ctype_xdigit($fileinfo->getBasename());
         })->in($cssPath);
         foreach ($iterator as $dir) {
             $baseName = $dir->getBaseName();
             $css[$baseName] = $baseName;
         }
         $cssfile = $app['settings']->getUserSetting($app['authentication']->getUser(), 'css');
         if (!$cssfile && isset($css['000000'])) {
             $cssfile = '000000';
         }
         $feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($app['authentication']->getUser()));
         $aggregate = Aggregate::createFromUser($app, $app['authentication']->getUser());
         $thjslist = "";
         $queries_topics = '';
         if ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'popups') {
             $queries_topics = \queries::dropdown_topics($app['translator'], $app['locale']);
         } elseif ($app['conf']->get(['registry', 'classic', 'render-topics']) == 'tree') {
             $queries_topics = \queries::tree_topics($app['locale']);
         }
         $sbas = $bas2sbas = [];
         foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
             $sbas_id = $databox->get_sbas_id();
             $sbas['s' + $sbas_id] = ['sbid' => $sbas_id, 'seeker' => null];
             foreach ($databox->get_collections() as $coll) {
                 $bas2sbas['b' . $coll->get_base_id()] = ['sbid' => $sbas_id, 'ckobj' => ['checked' => false], 'waschecked' => false];
             }
         }
         return $app['twig']->render('prod/index.html.twig', ['module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($app, $app['request']), 'module_prod' => new Helper\Prod($app, $app['request']), 'cssfile' => $cssfile, 'module' => 'prod', 'events' => $app['events-manager'], 'GV_defaultQuery_type' => $app['conf']->get(['registry', 'searchengine', 'default-query-type']), 'GV_multiAndReport' => $app['conf']->get(['registry', 'modules', 'stories']), 'GV_thesaurus' => $app['conf']->get(['registry', 'modules', 'thesaurus']), 'cgus_agreement' => \databox_cgu::askAgreement($app), 'css' => $css, 'feeds' => $feeds, 'aggregate' => $aggregate, 'GV_google_api' => $app['conf']->get(['registry', 'webservices', 'google-charts-enabled']), 'queries_topics' => $queries_topics, 'search_status' => \databox_status::getSearchStatus($app), 'queries_history' => \queries::history($app, $app['authentication']->getUser()->getId()), 'thesau_js_list' => $thjslist, 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $app['locales.available']]);
     })->bind('prod');
     return $controllers;
 }
Пример #3
0
 public function testHex2bin()
 {
     $this->assertEquals('10100001', databox_status::hex2bin('0x0A1'));
     $this->assertEquals('10100001', databox_status::hex2bin('0A1'));
     try {
         databox_status::hex2bin('G1');
         $this->fail('Should raise an exception');
     } catch (Exception $e) {
         $this->assertEquals('Non-hexadecimal value', $e->getMessage());
     }
 }
Пример #4
0
 public function indexAction(Request $request)
 {
     try {
         \Session_Logger::updateClientInfos($this->app, 1);
     } catch (SessionNotFound $e) {
         return $this->app->redirectPath('logout');
     }
     $cssPath = $this->app['root.path'] . '/www/assets/prod/skins';
     $css = [];
     $finder = new Finder();
     /** @var SplFileInfo[] $iterator */
     $iterator = $finder->directories()->depth(0)->filter(function (\SplFileInfo $fileinfo) {
         return ctype_xdigit($fileinfo->getBasename());
     })->in($cssPath);
     foreach ($iterator as $dir) {
         $baseName = $dir->getBaseName();
         $css[$baseName] = $baseName;
     }
     $user = $this->getAuthenticatedUser();
     $cssfile = $this->getSettings()->getUserSetting($user, 'css');
     if (!$cssfile && isset($css['000000'])) {
         $cssfile = '000000';
     }
     $feeds = $this->getFeedRepository()->getAllForUser($this->getAclForUser());
     $aggregate = Aggregate::createFromUser($this->app, $user);
     $thjslist = "";
     $queries_topics = '';
     $conf = $this->getConf();
     if ($conf->get(['registry', 'classic', 'render-topics']) == 'popups') {
         $queries_topics = \queries::dropdown_topics($this->app['translator'], $this->app['locale']);
     } elseif ($conf->get(['registry', 'classic', 'render-topics']) == 'tree') {
         $queries_topics = \queries::tree_topics($this->app['locale']);
     }
     $sbas = $bas2sbas = [];
     foreach ($this->getApplicationBox()->get_databoxes() as $databox) {
         $sbas_id = $databox->get_sbas_id();
         $sbas['s' . $sbas_id] = ['sbid' => $sbas_id, 'seeker' => null];
         foreach ($databox->get_collections() as $coll) {
             $bas2sbas['b' . $coll->get_base_id()] = ['sbid' => $sbas_id, 'ckobj' => ['checked' => false], 'waschecked' => false];
         }
     }
     $helper = new Helper\Prod($this->app, $request);
     /** @var \Closure $filter */
     $filter = $this->app['plugin.filter_by_authorization'];
     $plugins = ['workzone' => $filter('workzone'), 'actionbar' => $filter('actionbar')];
     return $this->render('prod/index.html.twig', ['module_name' => 'Production', 'WorkZone' => new Helper\WorkZone($this->app, $request), 'module_prod' => $helper, 'search_datas' => $helper->get_search_datas(), 'cssfile' => $cssfile, 'module' => 'prod', 'events' => $this->app['events-manager'], 'GV_defaultQuery_type' => $conf->get(['registry', 'searchengine', 'default-query-type']), 'GV_multiAndReport' => $conf->get(['registry', 'modules', 'stories']), 'GV_thesaurus' => $conf->get(['registry', 'modules', 'thesaurus']), 'cgus_agreement' => \databox_cgu::askAgreement($this->app), 'css' => $css, 'feeds' => $feeds, 'aggregate' => $aggregate, 'GV_google_api' => $conf->get(['registry', 'webservices', 'google-charts-enabled']), 'queries_topics' => $queries_topics, 'search_status' => \databox_status::getSearchStatus($this->app), 'queries_history' => \queries::history($this->app, $user->getId()), 'thesau_js_list' => $thjslist, 'thesau_json_sbas' => json_encode($sbas), 'thesau_json_bas2sbas' => json_encode($bas2sbas), 'thesau_languages' => $this->app['locales.available'], 'plugins' => $plugins]);
 }
Пример #5
0
 public function getRecordFlags(RecordInterface $record)
 {
     $recordStatuses = [];
     /** @var \appbox $appbox */
     $appbox = $this->app['phraseanet.appbox'];
     $databox = $appbox->get_databox($record->getDataboxId());
     $structure = $databox->getStatusStructure()->toArray();
     if (!$this->isGrantedOnCollection($record->getBaseId(), 'chgstatus')) {
         $structure = array_filter($structure, function ($status) {
             return (bool) $status['printable'];
         });
     }
     $bitValue = $record->getStatusBitField();
     foreach ($structure as $status) {
         $on = \databox_status::bitIsSet($bitValue, $status['bit']);
         if (null === ($on ? $status['img_on'] : $status['img_off'])) {
             continue;
         }
         $recordStatuses[] = ['path' => $on ? $status['img_on'] : $status['img_off'], 'labels' => $on ? $status['labels_on_i18n'] : $status['labels_off_i18n']];
     }
     return $recordStatuses;
 }
Пример #6
0
 public function __construct(Application $app, $status)
 {
     /**
      * We store a binary string
      */
     if (is_int($status)) {
         $status = decbin($status);
     } elseif (preg_match('/^[01]+$/', $status)) {
         $status = (string) $status;
     } elseif (ctype_digit($status)) {
         $status = decbin((int) $status);
     } elseif (strpos($status, '0x') === 0 && ctype_xdigit(substr($status, 2))) {
         $status = \databox_status::hex2bin($status);
     } elseif (strpos($status, '0b') === 0 && preg_match('/^[01]+$/', substr($status, 2))) {
         $status = substr($status, 2);
     } elseif (ctype_xdigit($status)) {
         $status = \databox_status::hex2bin($status);
     } else {
         throw new \InvalidArgumentException('Invalid status argument');
     }
     $this->status = $status;
 }
Пример #7
0
 /**
  *  Display Status property
  *
  * @param  Application $app
  * @param  Request     $request
  * @return Response
  */
 public function displayStatusProperty(Application $app, Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         $app->abort(400);
     }
     $records = RecordsRequest::fromRequest($app, $request, false, ['chgstatus']);
     $databoxStatus = \databox_status::getDisplayStatus($app);
     $statusBit = $nRec = [];
     foreach ($records as $record) {
         //perform logic
         $sbasId = $record->get_databox()->get_sbas_id();
         if (!isset($nRec[$sbasId])) {
             $nRec[$sbasId] = ['stories' => 0, 'records' => 0];
         }
         $nRec[$sbasId]['records']++;
         if ($record->is_grouping()) {
             $nRec[$sbasId]['stories']++;
         }
         if (!isset($statusBit[$sbasId])) {
             $statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : [];
             foreach (array_keys($statusBit[$sbasId]) as $bit) {
                 $statusBit[$sbasId][$bit]['nset'] = 0;
             }
         }
         $status = strrev($record->get_status());
         foreach (array_keys($statusBit[$sbasId]) as $bit) {
             $statusBit[$sbasId][$bit]["nset"] += substr($status, $bit, 1) !== "0" ? 1 : 0;
         }
     }
     foreach ($records->databoxes() as $databox) {
         $sbasId = $databox->get_sbas_id();
         foreach ($statusBit[$sbasId] as $bit => $values) {
             $statusBit[$sbasId][$bit]["status"] = $values["nset"] == 0 ? 0 : ($values["nset"] == $nRec[$sbasId]['records'] ? 1 : 2);
         }
     }
     return new Response($app['twig']->render('prod/actions/Property/index.html.twig', ['records' => $records, 'statusBit' => $statusBit, 'nRec' => $nRec]));
 }
Пример #8
0
 /**
  * Creates a record
  *
  * @param  \collection     $collection  The destination collection
  * @param  string          $pathfile    The file to archive
  * @param  string|null     $captionFile The Phrasea XML caption file or null if no caption file
  * @param  integer         $grp_rid     Add the record to a story
  * @param  integer         $force       Force lazaret or record ; use \Alchemy\Phrasea\Border\Manager::FORCE_* constants
  * @return \record_adapter
  */
 public function createRecord(Application $app, \collection $collection, $pathfile, $captionFile, $grp_rid, $force, $stat0, $stat1)
 {
     $status = \databox_status::operation_or($stat0, $stat1);
     $media = $app->getMediaFromUri($pathfile);
     $databox = $collection->get_databox();
     $metadatasStructure = $databox->get_meta_structure();
     $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
     $metaFields = [];
     if ($captionFile !== null && true === $app['filesystem']->exists($captionFile)) {
         $metaFields = $this->readXMLForDatabox($app, $metadatasStructure, $captionFile);
         $captionStatus = $this->parseStatusBit(@simplexml_load_file($captionFile));
         if ($captionStatus) {
             $status = \databox_status::operation_mask($status, $captionStatus);
         }
     }
     $file = new File($app, $media, $collection);
     $file->addAttribute(new BorderAttribute\Status($app, $status));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new MonoValue($media->getFile()->getRealPath()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new MonoValue(dirname($media->getFile()->getRealPath())))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfAtime(), new MonoValue($media->getFile()->getATime()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfMtime(), new MonoValue($media->getFile()->getMTime()))));
     $file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfCtime(), new MonoValue($media->getFile()->getCTime()))));
     foreach ($metadatas as $meta) {
         $file->addAttribute(new BorderAttribute\Metadata($meta));
     }
     foreach ($metaFields as $metaField) {
         $file->addAttribute($metaField);
     }
     if ($grp_rid) {
         $file->addAttribute(new BorderAttribute\Story(new \record_adapter($app, $databox->get_sbas_id(), $grp_rid)));
     }
     $record = null;
     $postProcess = function ($element, $visa, $code) use(&$record) {
         $record = $element;
     };
     $app['border-manager']->process($this->getLazaretSession($app), $file, $postProcess, $force);
     return $record;
 }
Пример #9
0
 public function connect(Application $app)
 {
     $app['controller.admin.root'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireAccessToModule('admin');
     });
     $controllers->get('/', function (Application $app, Request $request) {
         try {
             \Session_Logger::updateClientInfos($app, 3);
         } catch (SessionNotFound $e) {
             return $app->redirectPath('logout');
         }
         $section = $request->query->get('section', false);
         $available = ['connected', 'registrations', 'taskmanager', 'base', 'bases', 'collection', 'user', 'users'];
         $feature = 'connected';
         $featured = false;
         $position = explode(':', $section);
         if (count($position) > 0) {
             if (in_array($position[0], $available)) {
                 $feature = $position[0];
                 if (isset($position[1])) {
                     $featured = $position[1];
                 }
             }
         }
         $databoxes = $off_databoxes = [];
         foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
             try {
                 if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) {
                     continue;
                 }
                 $databox->get_connection();
             } catch (\Exception $e) {
                 $off_databoxes[] = $databox;
                 continue;
             }
             $databoxes[] = $databox;
         }
         $params = ['feature' => $feature, 'featured' => $featured, 'databoxes' => $databoxes, 'off_databoxes' => $off_databoxes];
         return $app['twig']->render('admin/index.html.twig', ['module' => 'admin', 'events' => $app['events-manager'], 'module_name' => 'Admin', 'notice' => $request->query->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 (Application $app, Request $request) {
         try {
             \Session_Logger::updateClientInfos($app, 3);
         } catch (SessionNotFound $e) {
             return $app->redirectPath('logout');
         }
         $available = ['connected', 'registrations', 'taskmanager', 'base', 'bases', 'collection', 'user', 'users'];
         $feature = 'connected';
         $featured = false;
         $position = explode(':', $request->query->get('position', false));
         if (count($position) > 0) {
             if (in_array($position[0], $available)) {
                 $feature = $position[0];
                 if (isset($position[1])) {
                     $featured = $position[1];
                 }
             }
         }
         $databoxes = $off_databoxes = [];
         foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
             try {
                 if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_sbas($databox->get_sbas_id())) {
                     continue;
                 }
                 $databox->get_connection();
             } catch (\Exception $e) {
                 $off_databoxes[] = $databox;
                 continue;
             }
             $databoxes[] = $databox;
         }
         $params = ['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 (Application $app, Request $request) {
         if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
             $app->abort(400, $app->trans('Bad request format, only JSON is allowed'));
         }
         if (0 !== count($tests = $request->query->get('tests', []))) {
             $app->abort(400, $app->trans('Missing tests parameter'));
         }
         if (null !== ($path = $request->query->get('path'))) {
             $app->abort(400, $app->trans('Missing path parameter'));
         }
         foreach ($tests as $test) {
             switch ($test) {
                 case 'writeable':
                     if (!is_writable($path)) {
                         $result = false;
                     }
                     break;
                 case 'readable':
                 default:
                     if (!is_readable($path)) {
                         $result = true;
                     }
                     break;
             }
         }
         return $app->json(['results' => $result]);
     })->bind('admin_test_paths');
     $controllers->get('/structure/{databox_id}/', function (Application $app, Request $request, $databox_id) {
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         $databox = $app['phraseanet.appbox']->get_databox((int) $databox_id);
         $structure = $databox->get_structure();
         $errors = \databox::get_structure_errors($app['translator'], $structure);
         if ($updateOk = !!$request->query->get('success', false)) {
             $updateOk = true;
         }
         if (false !== ($errorsStructure = $request->query->get('error', false))) {
             $errorsStructure = true;
         }
         return $app['twig']->render('admin/structure.html.twig', ['databox' => $databox, 'errors' => $errors, 'structure' => $structure, 'errorsStructure' => $errorsStructure, 'updateOk' => $updateOk]);
     })->assert('databox_id', '\\d+')->bind('database_display_stucture');
     $controllers->post('/structure/{databox_id}/', function (Application $app, Request $request, $databox_id) {
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         if (null === ($structure = $request->request->get('structure'))) {
             $app->abort(400, $app->trans('Missing "structure" parameter'));
         }
         $errors = \databox::get_structure_errors($app['translator'], $structure);
         $domst = new \DOMDocument('1.0', 'UTF-8');
         $domst->preserveWhiteSpace = false;
         $domst->formatOutput = true;
         if (count($errors) == 0 && $domst->loadXML($structure)) {
             $databox = $app['phraseanet.appbox']->get_databox($databox_id);
             $databox->saveStructure($domst);
             return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 1]);
         } else {
             return $app->redirectPath('database_display_stucture', ['databox_id' => $databox_id, 'success' => 0, 'error' => 'struct']);
         }
     })->assert('databox_id', '\\d+')->bind('database_submit_stucture');
     $controllers->get('/statusbit/{databox_id}/', function (Application $app, Request $request, $databox_id) {
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         return $app['twig']->render('admin/statusbit.html.twig', ['databox' => $app['phraseanet.appbox']->get_databox($databox_id)]);
     })->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['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         $databox = $app['phraseanet.appbox']->get_databox($databox_id);
         $status = $databox->get_statusbits();
         switch ($errorMsg = $request->query->get('error')) {
             case 'rights':
                 $errorMsg = $app->trans('You do not enough rights to update status');
                 break;
             case 'too-big':
                 $errorMsg = $app->trans('File is too big : 64k max');
                 break;
             case 'upload-error':
                 $errorMsg = $app->trans('Status icon upload failed : upload error');
                 break;
             case 'wright-error':
                 $errorMsg = $app->trans('Status icon upload failed : can not write on disk');
                 break;
             case 'unknow-error':
                 $errorMsg = $app->trans('Something wrong happend');
                 break;
         }
         if (isset($status[$bit])) {
             $status = $status[$bit];
         } else {
             $status = ["labeloff" => '', "labelon" => '', "img_off" => '', "img_on" => '', "path_off" => '', "path_on" => '', "searchable" => false, "printable" => false];
             foreach ($app['locales.available'] as $code => $language) {
                 $status['labels_on'][$code] = null;
                 $status['labels_off'][$code] = null;
             }
         }
         return $app['twig']->render('admin/statusbit/edit.html.twig', ['status' => $status, 'errorMsg' => $errorMsg]);
     })->assert('databox_id', '\\d+')->assert('bit', '\\d+')->bind('database_display_statusbit_form');
     $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, $app->trans('Bad request format, only JSON is allowed'));
         }
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         $error = false;
         try {
             \databox_status::deleteStatus($app, $app['phraseanet.appbox']->get_databox($databox_id), $bit);
         } catch (\Exception $e) {
             $error = true;
         }
         return $app->json(['success' => !$error]);
     })->bind('admin_statusbit_delete')->assert('databox_id', '\\d+')->assert('bit', '\\d+');
     $controllers->post('/statusbit/{databox_id}/status/{bit}/', function (Application $app, Request $request, $databox_id, $bit) {
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
             $app->abort(403);
         }
         $properties = ['searchable' => $request->request->get('searchable') ? '1' : '0', 'printable' => $request->request->get('printable') ? '1' : '0', 'name' => $request->request->get('name', ''), 'labelon' => $request->request->get('label_on', ''), 'labeloff' => $request->request->get('label_off', ''), 'labels_on' => $request->request->get('labels_on', []), 'labels_off' => $request->request->get('labels_off', [])];
         \databox_status::updateStatus($app, $databox_id, $bit, $properties);
         if (null !== $request->request->get('delete_icon_off')) {
             \databox_status::deleteIcon($app, $databox_id, $bit, 'off');
         }
         if (null !== ($file = $request->files->get('image_off'))) {
             try {
                 \databox_status::updateIcon($app, $databox_id, $bit, 'off', $file);
             } catch (AccessDeniedHttpException $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']);
             } catch (\Exception_InvalidArgument $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
             } catch (\Exception_Upload_FileTooBig $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']);
             } catch (\Exception_Upload_Error $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']);
             } catch (\Exception_Upload_CannotWriteFile $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']);
             } catch (\Exception $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
             }
         }
         if (null !== $request->request->get('delete_icon_on')) {
             \databox_status::deleteIcon($app, $databox_id, $bit, 'on');
         }
         if (null !== ($file = $request->files->get('image_on'))) {
             try {
                 \databox_status::updateIcon($app, $databox_id, $bit, 'on', $file);
             } catch (AccessDeniedHttpException $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']);
             } catch (\Exception_InvalidArgument $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
             } catch (\Exception_Upload_FileTooBig $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']);
             } catch (\Exception_Upload_Error $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']);
             } catch (\Exception_Upload_CannotWriteFile $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']);
             } catch (\Exception $e) {
                 return $app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
             }
         }
         return $app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]);
     })->assert('databox_id', '\\d+')->assert('bit', '\\d+')->bind('database_submit_statusbit');
     return $controllers;
 }
Пример #10
0
 public function testHex2bin()
 {
     $this->assertEquals('10100001', databox_status::hex2bin(self::$DI['app'], '0x0A1'));
     $this->assertEquals('10100001', databox_status::hex2bin(self::$DI['app'], '0A1'));
     try {
         databox_status::hex2bin(self::$DI['app'], 'G1');
         $this->fail('Should raise an exception');
     } catch (Exception $e) {
     }
 }
Пример #11
0
 /**
  *
  * @return databox_status
  */
 public function get_statusbits()
 {
     return databox_status::getStatus($this->app, $this->id);
 }
Пример #12
0
 /**
  *
  * @return string
  */
 public function get_status_icons()
 {
     $dstatus = databox_status::getDisplayStatus($this->app);
     $sbas_id = $this->get_sbas_id();
     $status = '';
     if (isset($dstatus[$sbas_id])) {
         foreach ($dstatus[$sbas_id] as $n => $statbit) {
             if ($statbit['printable'] == '0' && !$this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($this->base_id, 'chgstatus')) {
                 continue;
             }
             $x = substr(strrev($this->get_status()), $n, 1);
             $source0 = "/skins/icons/spacer.gif";
             $style0 = "visibility:hidden;display:none;";
             $source1 = "/skins/icons/spacer.gif";
             $style1 = "visibility:hidden;display:none;";
             if ($statbit["img_on"]) {
                 $source1 = $statbit["img_on"];
                 $style1 = "visibility:auto;display:none;";
             }
             if ($statbit["img_off"]) {
                 $source0 = $statbit["img_off"];
                 $style0 = "visibility:auto;display:none;";
             }
             if ($x == '1') {
                 if ($statbit["img_on"]) {
                     $style1 = "visibility:auto;display:inline;";
                 }
             } else {
                 if ($statbit["img_off"]) {
                     $style0 = "visibility:auto;display:inline;";
                 }
             }
             $status .= '<img style="margin:1px;' . $style1 . '" ' . 'class="STAT_' . $this->base_id . '_' . $this->record_id . '_' . $n . '_1" ' . 'src="' . $source1 . '" title="' . $statbit['labels_on_i18n'][$this->app['locale']] . '"/>';
             $status .= '<img style="margin:1px;' . $style0 . '" ' . 'class="STAT_' . $this->base_id . '_' . $this->record_id . '_' . $n . '_0" ' . 'src="' . $source0 . '" title="' . $statbit['labels_off_i18n'][$this->app['locale']] . '"/>';
         }
     }
     return $status;
 }
Пример #13
0
 /**
  * Retrieve detailed information about one status
  *
  * @param \record_adapter $record
  * @return array
  */
 private function listRecordStatus(\record_adapter $record)
 {
     $ret = [];
     foreach ($record->getStatusStructure() as $bit => $status) {
         $ret[] = ['bit' => $bit, 'state' => \databox_status::bitIsSet($record->getStatusBitField(), $bit)];
     }
     return $ret;
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function updateRecord(\record_adapter $record)
 {
     $record->set_binary_status(\databox_status::dec2bin($this->app, bindec($record->get_status()) & ~7 | 4));
     return $this;
 }
Пример #15
0
 public function applyAction(Request $request)
 {
     $records = RecordsRequest::fromRequest($this->app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']);
     $databoxes = $records->databoxes();
     if (count($databoxes) !== 1) {
         throw new \Exception('Unable to edit on multiple databoxes');
     }
     /** @var \databox $databox */
     $databox = reset($databoxes);
     if ($request->request->get('act_option') == 'SAVEGRP' && $request->request->get('newrepresent') && $records->isSingleStory()) {
         try {
             $reg_record = $records->singleStory();
             $newsubdef_reg = new \record_adapter($this->app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
             foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
                 if (!in_array($name, ['thumbnail', 'preview'])) {
                     continue;
                 }
                 if ($value->get_type() !== \media_subdef::TYPE_IMAGE) {
                     continue;
                 }
                 $media = $this->app->getMediaFromUri($value->get_pathfile());
                 $this->getSubDefinitionSubstituer()->substitute($reg_record, $name, $media);
                 $this->getDispatcher()->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($reg_record));
                 $this->getDataboxLogger($reg_record->get_databox())->log($reg_record, \Session_Logger::EVENT_SUBSTITUTE, $name == 'document' ? 'HD' : $name, '');
             }
         } catch (\Exception $e) {
         }
     }
     if (!is_array($request->request->get('mds'))) {
         return $this->app->json(['message' => '', 'error' => false]);
     }
     $elements = $records->toArray();
     foreach ($request->request->get('mds') as $rec) {
         try {
             $record = $databox->get_record($rec['record_id']);
         } catch (\Exception $e) {
             continue;
         }
         $key = $record->get_serialize_key();
         if (!array_key_exists($key, $elements)) {
             continue;
         }
         $statbits = $rec['status'];
         $editDirty = $rec['edit'];
         if ($editDirty == '0') {
             $editDirty = false;
         } else {
             $editDirty = true;
         }
         if (isset($rec['metadatas']) && is_array($rec['metadatas'])) {
             $record->set_metadatas($rec['metadatas']);
             $this->getDispatcher()->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($record));
         }
         $newstat = $record->get_status();
         $statbits = ltrim($statbits, 'x');
         if (!in_array($statbits, ['', 'null'])) {
             $mask_and = ltrim(str_replace(['x', '0', '1', 'z'], ['1', 'z', '0', '1'], $statbits), '0');
             if ($mask_and != '') {
                 $newstat = \databox_status::operation_and_not($newstat, $mask_and);
             }
             $mask_or = ltrim(str_replace('x', '0', $statbits), '0');
             if ($mask_or != '') {
                 $newstat = \databox_status::operation_or($newstat, $mask_or);
             }
             $record->set_binary_status($newstat);
         }
         $record->write_metas()->get_collection()->reset_stamp($record->get_record_id());
         if ($statbits != '') {
             $this->getDataboxLogger($databox)->log($record, \Session_Logger::EVENT_STATUS, '', '');
         }
         if ($editDirty) {
             $this->getDataboxLogger($databox)->log($record, \Session_Logger::EVENT_EDIT, '', '');
         }
     }
     return $this->app->json(['success' => true]);
 }
Пример #16
0
 public static function purge()
 {
     self::$_status = self::$_statuses = [];
 }
Пример #17
0
 public function connect(Application $app)
 {
     $app['controller.prod.edit'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->before(function (Request $request) use($app) {
         $app['firewall']->requireNotGuest()->requireRight('modifyrecord');
     });
     $controllers->post('/', function (Application $app, Request $request) {
         $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']);
         $thesaurus = false;
         $status = $ids = $elements = $suggValues = $fields = $JSFields = [];
         $databox = null;
         $multipleDataboxes = count($records->databoxes()) > 1;
         if (1 === count($records->databoxes())) {
             $databoxes = $records->databoxes();
             $databox = array_pop($databoxes);
             /**
              * generate javascript fields
              */
             foreach ($databox->get_meta_structure() as $meta) {
                 $fields[] = $meta;
                 $separator = $meta->get_separator();
                 /** @Ignore */
                 $JSFields[$meta->get_id()] = ['meta_struct_id' => $meta->get_id(), 'name' => $meta->get_name(), '_status' => 0, '_value' => '', '_sgval' => [], 'required' => $meta->is_required(), 'label' => $meta->get_label($app['locale']), 'readonly' => $meta->is_readonly(), 'type' => $meta->get_type(), 'format' => '', 'explain' => '', 'tbranch' => $meta->get_tbranch(), 'maxLength' => $meta->get_tag()->getMaxLength(), 'minLength' => $meta->get_tag()->getMinLength(), 'multi' => $meta->is_multi(), 'separator' => $separator, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null, 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false];
                 if (trim($meta->get_tbranch()) !== '') {
                     $thesaurus = true;
                 }
             }
             /**
              * generate javascript sugg values
              */
             foreach ($records->collections() as $collection) {
                 /* @var $record record_adapter */
                 $suggValues['b' . $collection->get_base_id()] = [];
                 if ($sxe = simplexml_load_string($collection->get_prefs())) {
                     $z = $sxe->xpath('/baseprefs/sugestedValues');
                     if (!$z || !is_array($z)) {
                         continue;
                     }
                     foreach ($z[0] as $ki => $vi) {
                         // les champs
                         $field = $databox->get_meta_structure()->get_element_by_name($ki);
                         if (!$field || !$vi) {
                             continue;
                         }
                         $suggValues['b' . $collection->get_base_id()][$field->get_id()] = [];
                         foreach ($vi->value as $oneValue) {
                             $suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue;
                         }
                     }
                 }
                 unset($collection);
             }
             /**
              * generate javascript status
              */
             if ($app['acl']->get($app['authentication']->getUser())->has_right('changestatus')) {
                 $dbstatus = \databox_status::getDisplayStatus($app);
                 if (isset($dbstatus[$databox->get_sbas_id()])) {
                     foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) {
                         $status[$n] = [];
                         $status[$n]['label0'] = $statbit['labels_off_i18n'][$app['locale']];
                         $status[$n]['label1'] = $statbit['labels_on_i18n'][$app['locale']];
                         $status[$n]['img_off'] = $statbit['img_off'];
                         $status[$n]['img_on'] = $statbit['img_on'];
                         $status[$n]['_value'] = 0;
                     }
                 }
             }
             /**
              * generate javascript elements
              */
             foreach ($databox->get_meta_structure() as $field) {
                 $databox_fields[$field->get_id()] = ['dirty' => false, 'meta_struct_id' => $field->get_id(), 'values' => []];
             }
             foreach ($records as $record) {
                 $indice = $record->get_number();
                 $elements[$indice] = ['bid' => $record->get_base_id(), 'rid' => $record->get_record_id(), 'sselcont_id' => null, '_selected' => false, 'fields' => $databox_fields];
                 $elements[$indice]['statbits'] = [];
                 if ($app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'chgstatus')) {
                     foreach ($status as $n => $s) {
                         $tmp_val = substr(strrev($record->get_status()), $n, 1);
                         $elements[$indice]['statbits'][$n]['value'] = $tmp_val == '1' ? '1' : '0';
                         $elements[$indice]['statbits'][$n]['dirty'] = false;
                     }
                 }
                 $elements[$indice]['originalname'] = $record->get_original_name();
                 foreach ($record->get_caption()->get_fields(null, true) as $field) {
                     $meta_struct_id = $field->get_meta_struct_id();
                     if (!isset($JSFields[$meta_struct_id])) {
                         continue;
                     }
                     $values = [];
                     foreach ($field->get_values() as $value) {
                         $type = $id = null;
                         if ($value->getVocabularyType()) {
                             $type = $value->getVocabularyType()->getType();
                             $id = $value->getVocabularyId();
                         }
                         $values[$value->getId()] = ['meta_id' => $value->getId(), 'value' => $value->getValue(), 'vocabularyId' => $id, 'vocabularyType' => $type];
                     }
                     $elements[$indice]['fields'][$meta_struct_id] = ['dirty' => false, 'meta_struct_id' => $meta_struct_id, 'values' => $values];
                 }
                 $elements[$indice]['subdefs'] = [];
                 $thumbnail = $record->get_thumbnail();
                 $elements[$indice]['subdefs']['thumbnail'] = ['url' => $thumbnail->get_url(), 'w' => $thumbnail->get_width(), 'h' => $thumbnail->get_height()];
                 $elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', ['record' => $record]);
                 $elements[$indice]['type'] = $record->get_type();
             }
         }
         $params = ['multipleDataboxes' => $multipleDataboxes, 'recordsRequest' => $records, 'databox' => $databox, 'JSonStatus' => json_encode($status), 'JSonRecords' => json_encode($elements), 'JSonFields' => json_encode($JSFields), 'JSonIds' => json_encode(array_keys($elements)), 'status' => $status, 'fields' => $fields, 'JSonSuggValues' => json_encode($suggValues), 'thesaurus' => $thesaurus];
         return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
     });
     $controllers->get('/vocabulary/{vocabulary}/', function (Application $app, Request $request, $vocabulary) {
         $datas = ['success' => false, 'message' => '', 'results' => []];
         $sbas_id = (int) $request->query->get('sbas_id');
         try {
             if ($sbas_id === 0) {
                 throw new \Exception('Invalid sbas_id');
             }
             $VC = VocabularyController::get($app, $vocabulary);
             $databox = $app['phraseanet.appbox']->get_databox($sbas_id);
         } catch (\Exception $e) {
             $datas['message'] = $app->trans('Vocabulary not found');
             return $app->json($datas);
         }
         $query = $request->query->get('query');
         $results = $VC->find($query, $app['authentication']->getUser(), $databox);
         $list = [];
         foreach ($results as $Term) {
             /* @var $Term \Alchemy\Phrasea\Vocabulary\Term */
             $list[] = ['id' => $Term->getId(), 'context' => $Term->getContext(), 'value' => $Term->getValue()];
         }
         $datas['success'] = true;
         $datas['results'] = $list;
         return $app->json($datas);
     });
     $controllers->post('/apply/', function (Application $app, Request $request) {
         $records = RecordsRequest::fromRequest($app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, ['canmodifrecord']);
         if (count($records->databoxes()) !== 1) {
             throw new \Exception('Unable to edit on multiple databoxes');
         }
         if ($request->request->get('act_option') == 'SAVEGRP' && $request->request->get('newrepresent') && $records->isSingleStory()) {
             try {
                 $reg_record = $records->singleStory();
                 $newsubdef_reg = new \record_adapter($app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
                 if ($newsubdef_reg->get_type() !== 'image') {
                     throw new \Exception('A reg image must come from image data');
                 }
                 foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
                     if (!in_array($name, ['thumbnail', 'preview'])) {
                         continue;
                     }
                     $media = $app['mediavorus']->guess($value->get_pathfile());
                     $app['subdef.substituer']->substitute($reg_record, $name, $media);
                     $app['phraseanet.logger']($reg_record->get_databox())->log($reg_record, \Session_Logger::EVENT_SUBSTITUTE, $name == 'document' ? 'HD' : $name, '');
                 }
             } catch (\Exception $e) {
             }
         }
         if (!is_array($request->request->get('mds'))) {
             return $app->json(['message' => '', 'error' => false]);
         }
         $databoxes = $records->databoxes();
         $databox = array_pop($databoxes);
         $meta_struct = $databox->get_meta_structure();
         $write_edit_el = false;
         $date_obj = new \DateTime();
         foreach ($meta_struct->get_elements() as $meta_struct_el) {
             if ($meta_struct_el->get_tag() instanceof TfEditdate) {
                 $write_edit_el = $meta_struct_el;
             }
         }
         $elements = $records->toArray();
         foreach ($request->request->get('mds') as $rec) {
             try {
                 $record = $databox->get_record($rec['record_id']);
             } catch (\Exception $e) {
                 continue;
             }
             $key = $record->get_serialize_key();
             if (!array_key_exists($key, $elements)) {
                 continue;
             }
             $statbits = $rec['status'];
             $editDirty = $rec['edit'];
             if ($editDirty == '0') {
                 $editDirty = false;
             } else {
                 $editDirty = true;
             }
             if (is_array($rec['metadatas'])) {
                 $record->set_metadatas($rec['metadatas']);
             }
             /**
              * todo : this should not work
              */
             if ($write_edit_el instanceof \databox_field) {
                 $fields = $record->get_caption()->get_fields([$write_edit_el->get_name()], true);
                 $field = array_pop($fields);
                 $meta_id = null;
                 if ($field && !$field->is_multi()) {
                     $values = $field->get_values();
                     $meta_id = array_pop($values)->getId();
                 }
                 $metas = [['meta_struct_id' => $write_edit_el->get_id(), 'meta_id' => $meta_id, 'value' => $date_obj->format('Y-m-d h:i:s')]];
                 $record->set_metadatas($metas, true);
             }
             $newstat = $record->get_status();
             $statbits = ltrim($statbits, 'x');
             if (!in_array($statbits, ['', 'null'])) {
                 $mask_and = ltrim(str_replace(['x', '0', '1', 'z'], ['1', 'z', '0', '1'], $statbits), '0');
                 if ($mask_and != '') {
                     $newstat = \databox_status::operation_and_not($app, $newstat, $mask_and);
                 }
                 $mask_or = ltrim(str_replace('x', '0', $statbits), '0');
                 if ($mask_or != '') {
                     $newstat = \databox_status::operation_or($app, $newstat, $mask_or);
                 }
                 $record->set_binary_status($newstat);
             }
             $record->write_metas()->get_collection()->reset_stamp($record->get_record_id());
             if ($statbits != '') {
                 $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_STATUS, '', '');
             }
             if ($editDirty) {
                 $app['phraseanet.logger']($record->get_databox())->log($record, \Session_Logger::EVENT_EDIT, '', '');
             }
         }
         return $app->json(['success' => true]);
     });
     return $controllers;
 }
Пример #18
0
 /**
  *    Truth table for status rights
  *
  *    +-----------+
  *    | and | xor |
  *    +-----------+
  *    |  0  |  0  | -> BOTH STATES ARE CHECKED
  *    +-----------+
  *    |  1  |  0  | -> UNSET STATE IS CHECKED
  *    +-----------+
  *    |  0  |  1  | -> UNSET STATE IS CHECKED (not possible)
  *    +-----------+
  *    |  1  |  1  | -> SET STATE IS CHECKED
  *    +-----------+
  *
  */
 private function computeAccess($and, $xor, $bit)
 {
     $xorBit = \databox_status::bitIsSet($xor, $bit);
     $andBit = \databox_status::bitIsSet($and, $bit);
     if (!$xorBit && !$andBit) {
         return self::FLAG_ALLOW_BOTH;
     }
     if ($xorBit && $andBit) {
         return self::FLAG_SET_ONLY;
     }
     return self::FLAG_UNSET_ONLY;
 }
Пример #19
0
 public function submitStatusBitAction(Request $request, $databox_id, $bit)
 {
     if (!$this->getAclForUser()->has_right_on_sbas($databox_id, 'bas_modify_struct')) {
         $this->app->abort(403);
     }
     $properties = ['searchable' => $request->request->get('searchable') ? '1' : '0', 'printable' => $request->request->get('printable') ? '1' : '0', 'name' => $request->request->get('name', ''), 'labelon' => $request->request->get('label_on', ''), 'labeloff' => $request->request->get('label_off', ''), 'labels_on' => $request->request->get('labels_on', []), 'labels_off' => $request->request->get('labels_off', [])];
     $databox = $this->findDataboxById($databox_id);
     /** @var StatusStructureProviderInterface $statusProvider */
     $statusProvider = $this->app['status.provider'];
     $statusProvider->updateStatus($databox->getStatusStructure(), $bit, $properties);
     if (null !== $request->request->get('delete_icon_off')) {
         \databox_status::deleteIcon($this->app, $databox_id, $bit, 'off');
     }
     if (null !== ($file = $request->files->get('image_off'))) {
         try {
             \databox_status::updateIcon($this->app, $databox_id, $bit, 'off', $file);
         } catch (AccessDeniedHttpException $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']);
         } catch (\Exception_InvalidArgument $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
         } catch (\Exception_Upload_FileTooBig $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']);
         } catch (\Exception_Upload_Error $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']);
         } catch (\Exception_Upload_CannotWriteFile $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']);
         } catch (\Exception $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
         }
     }
     if (null !== $request->request->get('delete_icon_on')) {
         \databox_status::deleteIcon($this->app, $databox_id, $bit, 'on');
     }
     if (null !== ($file = $request->files->get('image_on'))) {
         try {
             \databox_status::updateIcon($this->app, $databox_id, $bit, 'on', $file);
         } catch (AccessDeniedHttpException $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'rights']);
         } catch (\Exception_InvalidArgument $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
         } catch (\Exception_Upload_FileTooBig $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'too-big']);
         } catch (\Exception_Upload_Error $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'upload-error']);
         } catch (\Exception_Upload_CannotWriteFile $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'wright-error']);
         } catch (\Exception $e) {
             return $this->app->redirectPath('database_display_statusbit_form', ['databox_id' => $databox_id, 'bit' => $bit, 'error' => 'unknow-error']);
         }
     }
     return $this->app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]);
 }
 public function tearDown()
 {
     ACLProvider::purge();
     \collection::purge();
     \databox::purge();
     \caption_field::purge();
     \caption_Field_Value::purge();
     \databox_field::purge();
     \databox_status::purge();
     \thesaurus_xpath::purge();
     /**
      * Kris Wallsmith pro-tip
      * @see http://kriswallsmith.net/post/18029585104/faster-phpunit
      */
     $refl = new ReflectionObject($this);
     foreach ($refl->getProperties() as $prop) {
         if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_') && 0 !== strpos($prop->getDeclaringClass()->getName(), 'Phraseanet')) {
             $prop->setAccessible(true);
             $prop->setValue($this, null);
         }
     }
     $refl = null;
     parent::tearDown();
     //In case some executed script modify 'max_execution_time' ini var
     //Initialize set_time_limit(0) which is the default value for PHP CLI
     set_time_limit(0);
 }