Skip to content

Commit 1334deb

Browse files
committed
Merge branch 'release/1.10.0'
2 parents 64765b9 + a80eaee commit 1334deb

33 files changed

+213
-168
lines changed

ajax/reorder.php

+63-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
11
<?php
22
include ("../../../inc/includes.php");
33

4-
$table = PluginFieldsField::getTable();
4+
if (!array_key_exists('container_id', $_POST)
5+
|| !array_key_exists('old_order', $_POST)
6+
|| !array_key_exists('new_order', $_POST)) {
7+
// Missing input
8+
exit();
9+
}
10+
11+
$table = PluginFieldsField::getTable();
12+
$container_id = (int)$_POST['container_id'];
13+
$old_order = (int)$_POST['old_order'];
14+
$new_order = (int)$_POST['new_order'];
15+
16+
// Retrieve id of field to update
17+
$field_iterator = $DB->request(
18+
[
19+
'SELECT' => 'id',
20+
'FROM' => $table,
21+
'WHERE' => [
22+
'plugin_fields_containers_id' => $container_id,
23+
'ranking' => $old_order,
24+
],
25+
]
26+
);
27+
28+
if (0 === $field_iterator->count()) {
29+
// Unknown field
30+
exit();
31+
}
532

6-
// Récupération de l'ID du champ à modifier
7-
$query = "SELECT id FROM $table
8-
WHERE plugin_fields_containers_id = {$_POST['container_id']}
9-
AND `ranking` = {$_POST['old_order']}";
10-
$result = $DB->queryOrDie($query, 'Erreur');
11-
$first = $result->fetch_assoc();
12-
$id_item = $first['id'];
33+
$field_id = $field_iterator->next()['id'];
1334

14-
// Réorganisation de tout les champs
15-
if ($_POST['old_order'] < $_POST['new_order']) {
16-
$DB->query("UPDATE $table SET
17-
`ranking` = `ranking`-1
18-
WHERE plugin_fields_containers_id = {$_POST['container_id']}
19-
AND `ranking` > {$_POST['old_order']}
20-
AND `ranking` <= {$_POST['new_order']}");
35+
// Move all elements to their new ranking
36+
if ($old_order < $new_order) {
37+
$DB->update(
38+
$table,
39+
[
40+
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' - 1'),
41+
],
42+
[
43+
'plugin_fields_containers_id' => $container_id,
44+
['ranking' => ['>', $old_order]],
45+
['ranking' => ['<=', $new_order]],
46+
]
47+
);
2148
} else {
22-
$DB->query("UPDATE $table SET
23-
`ranking` = `ranking`+1
24-
WHERE plugin_fields_containers_id = {$_POST['container_id']}
25-
AND `ranking` < {$_POST['old_order']}
26-
AND `ranking` >= {$_POST['new_order']}");
49+
$DB->update(
50+
$table,
51+
[
52+
'ranking' => new \QueryExpression($DB->quoteName('ranking') . ' + 1'),
53+
],
54+
[
55+
'plugin_fields_containers_id' => $container_id,
56+
['ranking' => ['<', $old_order]],
57+
['ranking' => ['>=', $new_order]],
58+
]
59+
);
2760
}
2861

29-
$DB->query("UPDATE $table SET
30-
`ranking` = {$_POST['new_order']}
31-
WHERE id = $id_item");
62+
// Update current element
63+
$DB->update(
64+
$table,
65+
[
66+
'ranking' => $new_order,
67+
],
68+
[
69+
'id' => $field_id,
70+
]
71+
);

composer.lock

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/container.class.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ static function getItemtypes($is_domtab) {
755755
'Supplier' => Supplier::getTypeName(2),
756756
'Contact' => Contact::getTypeName(2),
757757
'Contract' => Contract::getTypeName(2),
758-
'Document' => Document::getTypeName(2)
758+
'Document' => Document::getTypeName(2),
759+
'Line' => Line::getTypeName(2),
759760
];
760761

761762
$tabs[__('Tools')] = [

inc/field.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static function prepareHtmlFields($fields, $items_id, $itemtype, $canedit = true
795795
break;
796796
case 'dropdownuser':
797797
if ($massiveaction) {
798-
continue;
798+
break;
799799
}
800800
if ($canedit && !$readonly) {
801801
$html.= User::dropdown(['name' => $field['name'],

locales/cs_CZ.mo

170 Bytes
Binary file not shown.

locales/cs_CZ.po

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
# Translators:
66
# David Stepan <stepand@tiscali.cz>, 2016
77
# Merlin Merlin <mmerlin10@gmail.com>, 2017
8-
# Pavel Borecki <pavel.borecki@gmail.com>, 2018
8+
# Pavel Borecki <pavel.borecki@gmail.com>, 2018-2019
99
msgid ""
1010
msgstr ""
1111
"Project-Id-Version: GLPI Plugin - Fields\n"
1212
"Report-Msgid-Bugs-To: \n"
13-
"POT-Creation-Date: 2019-05-02 10:39+0000\n"
14-
"PO-Revision-Date: 2019-05-02 10:39+0000\n"
15-
"Last-Translator: Cédric Anne\n"
13+
"POT-Creation-Date: 2019-06-04 12:47+0000\n"
14+
"PO-Revision-Date: 2019-05-03 11:12+0000\n"
15+
"Last-Translator: Pavel Borecki <pavel.borecki@gmail.com>\n"
1616
"Language-Team: Czech (Czech Republic) (http://www.transifex.com/teclib/glpi-plugin-plugin-fields/language/cs_CZ/)\n"
1717
"MIME-Version: 1.0\n"
1818
"Content-Type: text/plain; charset=UTF-8\n"
@@ -111,7 +111,7 @@ msgstr "Znovu vytvořit kontejnerové soubory"
111111

112112
#: inc/container.class.php:87
113113
msgid "Fix container names"
114-
msgstr ""
114+
msgstr "Opravit názvy kontejnerů"
115115

116116
#: inc/container.class.php:168
117117
msgid "Updating generated containers files"
@@ -145,27 +145,27 @@ msgstr "Blok"
145145
msgid "Tab"
146146
msgstr "Tabulka"
147147

148-
#: inc/container.class.php:824
148+
#: inc/container.class.php:825
149149
msgid "Add tab"
150150
msgstr "Přidat tabulku"
151151

152-
#: inc/container.class.php:825
152+
#: inc/container.class.php:826
153153
msgid "Insertion in the form (before save button)"
154154
msgstr "Vložení do formuláře (před tlačítkem uložit)"
155155

156-
#: inc/container.class.php:826
156+
#: inc/container.class.php:827
157157
msgid "Insertion in the form of a specific tab (before save button)"
158158
msgstr "Vložení do formuláře konkrétního panelu (před tlačítkem uložit)"
159159

160-
#: inc/container.class.php:1188
160+
#: inc/container.class.php:1189
161161
msgid "Some mandatory fields are empty"
162162
msgstr "Některá povinná pole nejsou vyplněná"
163163

164-
#: inc/container.class.php:1193
164+
#: inc/container.class.php:1194
165165
msgid "Some numeric fields contains non numeric values"
166166
msgstr "Některé číselné kolonky obsahují nečíselné hodnoty"
167167

168-
#: inc/container.class.php:1198
168+
#: inc/container.class.php:1199
169169
msgid "Some URL fields contains invalid links"
170170
msgstr "Některé URL kolonky obsahují neplatné odkazy"
171171

@@ -183,4 +183,4 @@ msgstr "Aktualizují se vytvořené soubory rozbalovací nabídky"
183183

184184
#: inc/toolbox.class.php:90
185185
msgid "Fix fields names"
186-
msgstr ""
186+
msgstr "Opravit názvy kolonek"

locales/en_GB.mo

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)