-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
213 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,71 @@ | ||
<?php | ||
include ("../../../inc/includes.php"); | ||
|
||
$table = PluginFieldsField::getTable(); | ||
if (!array_key_exists('container_id', $_POST) | ||
|| !array_key_exists('old_order', $_POST) | ||
|| !array_key_exists('new_order', $_POST)) { | ||
// Missing input | ||
exit(); | ||
} | ||
|
||
$table = PluginFieldsField::getTable(); | ||
$container_id = (int)$_POST['container_id']; | ||
$old_order = (int)$_POST['old_order']; | ||
$new_order = (int)$_POST['new_order']; | ||
|
||
// Retrieve id of field to update | ||
$field_iterator = $DB->request( | ||
[ | ||
'SELECT' => 'id', | ||
'FROM' => $table, | ||
'WHERE' => [ | ||
'plugin_fields_containers_id' => $container_id, | ||
'ranking' => $old_order, | ||
], | ||
] | ||
); | ||
|
||
if (0 === $field_iterator->count()) { | ||
// Unknown field | ||
exit(); | ||
} | ||
|
||
// Récupération de l'ID du champ à modifier | ||
$query = "SELECT id FROM $table | ||
WHERE plugin_fields_containers_id = {$_POST['container_id']} | ||
AND `ranking` = {$_POST['old_order']}"; | ||
$result = $DB->queryOrDie($query, 'Erreur'); | ||
$first = $result->fetch_assoc(); | ||
$id_item = $first['id']; | ||
$field_id = $field_iterator->next()['id']; | ||
|
||
// Réorganisation de tout les champs | ||
if ($_POST['old_order'] < $_POST['new_order']) { | ||
$DB->query("UPDATE $table SET | ||
`ranking` = `ranking`-1 | ||
WHERE plugin_fields_containers_id = {$_POST['container_id']} | ||
AND `ranking` > {$_POST['old_order']} | ||
AND `ranking` <= {$_POST['new_order']}"); | ||
// Move all elements to their new ranking | ||
if ($old_order < $new_order) { | ||
$DB->update( | ||
$table, | ||
[ | ||
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' - 1'), | ||
], | ||
[ | ||
'plugin_fields_containers_id' => $container_id, | ||
['ranking' => ['>', $old_order]], | ||
['ranking' => ['<=', $new_order]], | ||
] | ||
); | ||
} else { | ||
$DB->query("UPDATE $table SET | ||
`ranking` = `ranking`+1 | ||
WHERE plugin_fields_containers_id = {$_POST['container_id']} | ||
AND `ranking` < {$_POST['old_order']} | ||
AND `ranking` >= {$_POST['new_order']}"); | ||
$DB->update( | ||
$table, | ||
[ | ||
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' + 1'), | ||
], | ||
[ | ||
'plugin_fields_containers_id' => $container_id, | ||
['ranking' => ['<', $old_order]], | ||
['ranking' => ['>=', $new_order]], | ||
] | ||
); | ||
} | ||
|
||
$DB->query("UPDATE $table SET | ||
`ranking` = {$_POST['new_order']} | ||
WHERE id = $id_item"); | ||
// Update current element | ||
$DB->update( | ||
$table, | ||
[ | ||
'ranking' => $new_order, | ||
], | ||
[ | ||
'id' => $field_id, | ||
] | ||
); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,14 @@ | |
# Translators: | ||
# David Stepan <[email protected]>, 2016 | ||
# Merlin Merlin <[email protected]>, 2017 | ||
# Pavel Borecki <[email protected]>, 2018 | ||
# Pavel Borecki <[email protected]>, 2018-2019 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: GLPI Plugin - Fields\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-05-02 10:39+0000\n" | ||
"PO-Revision-Date: 2019-05-02 10:39+0000\n" | ||
"Last-Translator: Cédric Anne\n" | ||
"POT-Creation-Date: 2019-06-04 12:47+0000\n" | ||
"PO-Revision-Date: 2019-05-03 11:12+0000\n" | ||
"Last-Translator: Pavel Borecki <[email protected]>\n" | ||
"Language-Team: Czech (Czech Republic) (http://www.transifex.com/teclib/glpi-plugin-plugin-fields/language/cs_CZ/)\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
|
@@ -111,7 +111,7 @@ msgstr "Znovu vytvořit kontejnerové soubory" | |
|
||
#: inc/container.class.php:87 | ||
msgid "Fix container names" | ||
msgstr "" | ||
msgstr "Opravit názvy kontejnerů" | ||
|
||
#: inc/container.class.php:168 | ||
msgid "Updating generated containers files" | ||
|
@@ -145,27 +145,27 @@ msgstr "Blok" | |
msgid "Tab" | ||
msgstr "Tabulka" | ||
|
||
#: inc/container.class.php:824 | ||
#: inc/container.class.php:825 | ||
msgid "Add tab" | ||
msgstr "Přidat tabulku" | ||
|
||
#: inc/container.class.php:825 | ||
#: inc/container.class.php:826 | ||
msgid "Insertion in the form (before save button)" | ||
msgstr "Vložení do formuláře (před tlačítkem uložit)" | ||
|
||
#: inc/container.class.php:826 | ||
#: inc/container.class.php:827 | ||
msgid "Insertion in the form of a specific tab (before save button)" | ||
msgstr "Vložení do formuláře konkrétního panelu (před tlačítkem uložit)" | ||
|
||
#: inc/container.class.php:1188 | ||
#: inc/container.class.php:1189 | ||
msgid "Some mandatory fields are empty" | ||
msgstr "Některá povinná pole nejsou vyplněná" | ||
|
||
#: inc/container.class.php:1193 | ||
#: inc/container.class.php:1194 | ||
msgid "Some numeric fields contains non numeric values" | ||
msgstr "Některé číselné kolonky obsahují nečíselné hodnoty" | ||
|
||
#: inc/container.class.php:1198 | ||
#: inc/container.class.php:1199 | ||
msgid "Some URL fields contains invalid links" | ||
msgstr "Některé URL kolonky obsahují neplatné odkazy" | ||
|
||
|
@@ -183,4 +183,4 @@ msgstr "Aktualizují se vytvořené soubory rozbalovací nabídky" | |
|
||
#: inc/toolbox.class.php:90 | ||
msgid "Fix fields names" | ||
msgstr "" | ||
msgstr "Opravit názvy kolonek" |
Binary file not shown.
Oops, something went wrong.