mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Merge branch '3.8'
Conflicts: lib/Alchemy/Phrasea/Controller/Admin/Databox.php lib/classes/collection.php templates/web/admin/databox/databox.html.twig
This commit is contained in:
@@ -395,10 +395,9 @@ class Databox implements ControllerProviderInterface
|
||||
try {
|
||||
$baseId = \collection::mount_collection($app, $app['phraseanet.appbox']->get_databox($databox_id), $collection_id, $app['authentication']->getUser());
|
||||
|
||||
if (null == $othCollSel = $request->request->get("othcollsel")) {
|
||||
$app->abort(400);
|
||||
}
|
||||
$othCollSel = (int) $request->request->get("othcollsel") ?: null;
|
||||
|
||||
if (null !== $othCollSel) {
|
||||
$query = new \User_Query($app);
|
||||
$n = 0;
|
||||
|
||||
@@ -411,6 +410,7 @@ class Databox implements ControllerProviderInterface
|
||||
|
||||
$n += 50;
|
||||
}
|
||||
}
|
||||
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
|
||||
|
||||
@@ -546,6 +546,17 @@ class collection implements cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
private static function getNewOrder(\connection_pdo $conn, $sbas_id)
|
||||
{
|
||||
$sql = "SELECT GREATEST(0, MAX(ord)) + 1 AS ord FROM bas WHERE sbas_id = :sbas_id";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(array(':sbas_id' => $sbas_id));
|
||||
$ord = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $ord['ord'] ?: 1;
|
||||
}
|
||||
|
||||
public static function create(Application $app, databox $databox, appbox $appbox, $name, User_Adapter $user = null)
|
||||
{
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
@@ -560,12 +571,6 @@ class collection implements cache_cacheableInterface
|
||||
</sugestedValues>
|
||||
</baseprefs>';
|
||||
|
||||
$sql = "SELECT GREATEST(0, MAX(ord)) + 1 AS ord FROM bas WHERE sbas_id = :sbas_id";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':sbas_id' => $sbas_id]);
|
||||
$ord = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = "INSERT INTO coll (coll_id, asciiname, prefs, logo)
|
||||
VALUES (null, :name, :prefs, '')";
|
||||
|
||||
@@ -587,7 +592,7 @@ class collection implements cache_cacheableInterface
|
||||
$stmt->execute([
|
||||
':server_coll_id' => $new_id,
|
||||
':sbas_id' => $sbas_id,
|
||||
':ord' => $ord['ord'] ?: 1,
|
||||
':ord' => self::getNewOrder($conn, $sbas_id),
|
||||
]);
|
||||
$stmt->closeCursor();
|
||||
|
||||
@@ -639,11 +644,15 @@ class collection implements cache_cacheableInterface
|
||||
public static function mount_collection(Application $app, databox $databox, $coll_id, User_Adapter $user)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases)
|
||||
$sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases, ord)
|
||||
VALUES
|
||||
(null, 1, :server_coll_id, :sbas_id, '')";
|
||||
(null, 1, :server_coll_id, :sbas_id, '', :ord)";
|
||||
$stmt = $databox->get_appbox()->get_connection()->prepare($sql);
|
||||
$stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $databox->get_sbas_id()]);
|
||||
$stmt->execute(array(
|
||||
':server_coll_id' => $coll_id,
|
||||
':sbas_id' => $databox->get_sbas_id(),
|
||||
':ord' => self::getNewOrder($databox->get_appbox()->get_connection(), $databox->get_sbas_id()),
|
||||
));
|
||||
$stmt->closeCursor();
|
||||
|
||||
$new_bas = $databox->get_appbox()->get_connection()->lastInsertId();
|
||||
@@ -655,7 +664,8 @@ class collection implements cache_cacheableInterface
|
||||
|
||||
phrasea::reset_baseDatas($databox->get_appbox());
|
||||
|
||||
self::set_admin($new_bas, $user);
|
||||
$coll = self::get_from_base_id($app, $new_bas);
|
||||
$coll->set_admin($new_bas, $user);
|
||||
|
||||
return $new_bas;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
{% for collId, name in databox.get_mountable_colls() %}
|
||||
<li>
|
||||
<form class="form-inline" method="post" action="{{ path('admin_database_mount_collection', {'databox_id': databox.get_sbas_id(), 'collection_id' : collId }) }}">
|
||||
{{ "Monter" | trans }} {{ name }}
|
||||
{% trans %}Monter la collection {{ name }}{% endtrans %}<br/>
|
||||
{% if app['acl'].get(app['authentication'].getUser()).get_granted_base(["canadmin"]) | length > 0 %}
|
||||
<label for="othcollsel">{{ "admin::base:collection: Vous pouvez choisir une collection de reference pour donenr des acces" | trans }}</label>
|
||||
<select id="othcollsel" name="othcollsel" >
|
||||
|
||||
Reference in New Issue
Block a user