/** * Mount a collection on a databox * * @param Application $app The silex application * @param Request $request The current HTTP request * @param integer $databox_id The requested databox * @param integer $collection_id The requested collection id * @return RedirectResponse */ public function mountCollection(Application $app, Request $request, $databox_id, $collection_id) { $app['phraseanet.appbox']->get_connection()->beginTransaction(); try { $baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $app['authentication']->getUser()); $othCollSel = (int) $request->request->get("othcollsel") ?: null; if (null !== $othCollSel) { $query = $app['phraseanet.user-query']; $n = 0; while ($n < $query->on_base_ids([$othCollSel])->get_total()) { $results = $query->limit($n, 50)->execute()->get_results(); foreach ($results as $user) { $app['acl']->get($user)->duplicate_right_from_bas($othCollSel, $baseId); } $n += 50; } } $app['phraseanet.appbox']->get_connection()->commit(); return $app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ok']); } catch (\Exception $e) { $app['phraseanet.appbox']->get_connection()->rollBack(); return $app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ko']); } }
/** * Mount a collection on a databox * * @param Request $request The current HTTP request * @param integer $databox_id The requested databox * @param integer $collection_id The requested collection id * @return RedirectResponse */ public function mountCollection(Request $request, $databox_id, $collection_id) { $connection = $this->getApplicationBox()->get_connection(); $connection->beginTransaction(); try { /** @var Authenticator $authenticator */ $authenticator = $this->app->getAuthenticator(); $baseId = \collection::mount_collection($this->app, $this->findDataboxById($databox_id), $collection_id, $authenticator->getUser()); $othCollSel = (int) $request->request->get("othcollsel") ?: null; if (null !== $othCollSel) { $query = $this->createUserQuery(); $n = 0; /** @var ACLProvider $aclProvider */ $aclProvider = $this->app['acl']; while ($n < $query->on_base_ids([$othCollSel])->get_total()) { $results = $query->limit($n, 50)->execute()->get_results(); foreach ($results as $user) { $aclProvider->get($user)->duplicate_right_from_bas($othCollSel, $baseId); } $n += 50; } } $connection->commit(); return $this->app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ok']); } catch (\Exception $e) { $connection->rollBack(); return $this->app->redirectPath('admin_database', ['databox_id' => $databox_id, 'mount' => 'ko']); } }