Skip to content

Commit d103bb4

Browse files
committed
fix(form_language): limit items with langaues for the form only
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 2e530b3 commit d103bb4

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

front/form.form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
if ($_SESSION['glpiname'] == 'formcreator_temp_user') {
146146
// Form was saved by an annymous user
147147
unset($_SESSION['glpiname']);
148-
Html::redirect('formdisplay.php?answer_saved');
148+
Html::redirect('formdisplay.php?answer_saved&id=' . $form->getID());
149149
}
150150

151151
// redirect to created item

front/formdisplay.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
// Check if plugin is activated...
3636
if (!(new Plugin())->isActivated('formcreator')) {
37+
PluginFormcreatorForm::header();
3738
Html::displayNotFoundError();
3839
}
3940

inc/form.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ public function post_purgeItem() {
14761476
PluginFormcreatorSection::class,
14771477
PluginFormcreatorForm_Validator::class,
14781478
PluginFormcreatorForm_Profile::class,
1479+
pluginFormcreatorForm_Language::class,
14791480
];
14801481
foreach ($associated as $itemtype) {
14811482
$item = new $itemtype();
@@ -2569,8 +2570,7 @@ public function getTranslatableStrings(array $options = []) : array {
25692570
}
25702571
foreach ($strings[$type] as $id => $original) {
25712572
if ($options['is_translated'] === true && !isset($translations[$original])
2572-
|| $options['is_translated'] === false && isset($translations[$original]))
2573-
{
2573+
|| $options['is_translated'] === false && isset($translations[$original])) {
25742574
unset($strings[$type][$id]);
25752575
unset($strings['id'][$id]);
25762576
}
@@ -2656,7 +2656,7 @@ public function setTranslations(string $language, array $translations) : bool {
26562656
*
26572657
* @return string the best language for this form and session context
26582658
*/
2659-
public function getBestLanguage() {
2659+
public function getBestLanguage() {
26602660
global $DB;
26612661

26622662
if ($this->isNewItem()) {

inc/form_language.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function showForm($ID, $options = []) {
167167
echo '<tr class="tab_bg_1">';
168168
echo '<td><strong>' . __('Name') . ' <span class="red">*</span></strong></td>';
169169
$used = [];
170-
$rows = $this->find();
170+
$rows = $this->find([PluginFormcreatorForm::getForeignKeyField() => $item->getID()]);
171171
foreach ($rows as $row) {
172172
$used[$row['name']] = $row['name'];
173173
}

inc/translatable.class.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ public function getMyTranslatableStrings(array $options) : array {
9898
$id = PluginFormcreatorTranslation::getTranslatableStringId($this->fields[$searchOption['field']]);
9999
if ($options['id'] != '' && $id != $options['id']) {
100100
continue;
101-
}
102-
if (isset($options['is_untranslated']) && $options['is_untranslated']) {
103-
104101
}
105102
$strings[$searchOption['datatype']][$id] = $this->fields[$searchOption['field']];
106103
$strings['id'][$id] = $searchOption['datatype'];

inc/translation.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static function getDropdownValue($post, $json = true) {
107107

108108
$foundCount = 0;
109109
$data = [];
110-
foreach(['itemlink', 'string', 'text'] as $stringType) {
110+
foreach (['itemlink', 'string', 'text'] as $stringType) {
111111
foreach ($strings[$stringType] as $id => $string) {
112112
$foundCount++;
113113
if ($foundCount < ((int) $post['page'] - 1) * (int) $post['page_limit']) {

0 commit comments

Comments
 (0)