Skip to content

Commit

Permalink
Merge branch 'support/2.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed May 30, 2023
2 parents 3f4f770 + 1d8a8d2 commit 51d632a
Show file tree
Hide file tree
Showing 129 changed files with 19,245 additions and 14,474 deletions.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@
<a name="2.13.6"></a>
## [2.13.6](https://github.com/pluginsGLPI/formcreator/compare/2.13.5..2.13.6) (2023-05-26)


### Bug Fixes

* SQL error when inconsistency in DB ([1af78720](https://github.com/pluginsGLPI/formcreator/commit/1af78720)), closes [#3242](https://github.com/pluginsGLPI/formcreator/issues/3242)
* confirrmation strings ([8ced5744](https://github.com/pluginsGLPI/formcreator/commit/8ced5744))
* translate field label in error messages ([a4bf10a6](https://github.com/pluginsGLPI/formcreator/commit/a4bf10a6))
* **DropdownField:** fix array key value format ([7729fe20](https://github.com/pluginsGLPI/formcreator/commit/7729fe20))
* **FormAnswer:** redirect to FormAnswer or to list if needed ([44e4ab6d](https://github.com/pluginsGLPI/formcreator/commit/44e4ab6d))
* **category:** SQL statement cause MariaDB crash ([fb94035a](https://github.com/pluginsGLPI/formcreator/commit/fb94035a))
* **checkboxesfield,multiselectfield:** php warning ([342c39e9](https://github.com/pluginsGLPI/formcreator/commit/342c39e9))
* **condition:** conditions don't work when not sanitized ([f2b0fad5](https://github.com/pluginsGLPI/formcreator/commit/f2b0fad5))
* **faq:** visibility (#3118) ([252ef204](https://github.com/pluginsGLPI/formcreator/commit/252ef204))
* **filefield:** rebuild uploads for answer edition ([4f1cdf6e](https://github.com/pluginsGLPI/formcreator/commit/4f1cdf6e))
* **form:** double post broken ([07b8a1a1](https://github.com/pluginsGLPI/formcreator/commit/07b8a1a1))
* **form_language:** inverted arguments ([261e5361](https://github.com/pluginsGLPI/formcreator/commit/261e5361))
* **form_language:** restrict languages to those known by GLPI ([f8dc0803](https://github.com/pluginsGLPI/formcreator/commit/f8dc0803))
* **formanswer:** catch and report exception to end user ([9dd9777f](https://github.com/pluginsGLPI/formcreator/commit/9dd9777f))
* **formanswer:** too many escaping ([e518b7de](https://github.com/pluginsGLPI/formcreator/commit/e518b7de)), closes [#3271](https://github.com/pluginsGLPI/formcreator/issues/3271)
* **formanswer:** translate question label ([61722daf](https://github.com/pluginsGLPI/formcreator/commit/61722daf))
* **glpiselectfield:** max_tree_depth_not_saved ([462ea695](https://github.com/pluginsGLPI/formcreator/commit/462ea695))
* **install:** prevent fatal error in migration ([306c2c3f](https://github.com/pluginsGLPI/formcreator/commit/306c2c3f))
* **item_targetticket:** export of question based composition ([dc8c931a](https://github.com/pluginsGLPI/formcreator/commit/dc8c931a))
* **radiosfield, selectfield:** allow unset default value ([020bd45b](https://github.com/pluginsGLPI/formcreator/commit/020bd45b))
* **radiosfield, selectfield:** check default value before save ([d4a2ecb4](https://github.com/pluginsGLPI/formcreator/commit/d4a2ecb4))
* **section:** condition rule loss after duplicate / import ([7bfe6ca0](https://github.com/pluginsGLPI/formcreator/commit/7bfe6ca0))
* **selectfield:** show contact field ([11c86b7c](https://github.com/pluginsGLPI/formcreator/commit/11c86b7c))
* **selectfield,radiosfield:** abusive escaping ([db01a561](https://github.com/pluginsGLPI/formcreator/commit/db01a561))
* **targetchange,targetproblem:** several fields must use rich text ([cf24aa19](https://github.com/pluginsGLPI/formcreator/commit/cf24aa19))
* **targetticket:** request source ([c72901c7](https://github.com/pluginsGLPI/formcreator/commit/c72901c7))
* **targetticket:** request source may be unexpected value ([2fd6cf54](https://github.com/pluginsGLPI/formcreator/commit/2fd6cf54))
* **targetticket,targetchange,targetproblem:** missing translation of target content ([902efa78](https://github.com/pluginsGLPI/formcreator/commit/902efa78))
* **textfield:** Unescaped HTML when displaying a form answer ([d4763859](https://github.com/pluginsGLPI/formcreator/commit/d4763859))
* **translation:** delete rich editor's ghost toolbar ([ba97c842](https://github.com/pluginsGLPI/formcreator/commit/ba97c842))
* **translation:** dialog width ([0b46dec3](https://github.com/pluginsGLPI/formcreator/commit/0b46dec3))
* **translation:** typo in localizable tring ([3bb2f3d4](https://github.com/pluginsGLPI/formcreator/commit/3bb2f3d4))


### Features

* reminders ([6ed85cd3](https://github.com/pluginsGLPI/formcreator/commit/6ed85cd3))
* **abstractitiltarget:** duplicate ([3c093012](https://github.com/pluginsGLPI/formcreator/commit/3c093012))
* **category:** show category comment in service catalog ([09727147](https://github.com/pluginsGLPI/formcreator/commit/09727147)), closes [#394](https://github.com/pluginsGLPI/formcreator/issues/394)
* **clean_tickets_command:** Take merged tickets into account ([768cd467](https://github.com/pluginsGLPI/formcreator/commit/768cd467))
* **form:** edit recursion with massive actions ([7c918d3b](https://github.com/pluginsGLPI/formcreator/commit/7c918d3b))
* **formaccesstype:** massive action ([53a4285a](https://github.com/pluginsGLPI/formcreator/commit/53a4285a))
* **glpiselectfield:** PDU in assets section ([bc6a790d](https://github.com/pluginsGLPI/formcreator/commit/bc6a790d))
* **glpiselectfield:** refactor entity_restriction ([b3fb0804](https://github.com/pluginsGLPI/formcreator/commit/b3fb0804))
* **install:** stronger upgrade for unsigned columns ([030f93e3](https://github.com/pluginsGLPI/formcreator/commit/030f93e3))
* **notificationtargetformanswer:** label tags ([f1dc000c](https://github.com/pluginsGLPI/formcreator/commit/f1dc000c)), closes [#1023](https://github.com/pluginsGLPI/formcreator/issues/1023)
* **section:** update condition count after section edition ([8c04048f](https://github.com/pluginsGLPI/formcreator/commit/8c04048f))


<a name="2.13.5"></a>
## [2.13.5](https://github.com/pluginsGLPI/formcreator/compare/2.13.4..2.13.5) (2023-03-24)

Expand Down
48 changes: 48 additions & 0 deletions ajax/form_duplicate_target.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* ---------------------------------------------------------------------
* Formcreator is a plugin which allows creation of custom forms of
* easy access.
* ---------------------------------------------------------------------
* LICENSE
*
* This file is part of Formcreator.
*
* Formcreator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Formcreator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* @copyright Copyright © 2011 - 2021 Teclib'
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
* @link https://github.com/pluginsGLPI/formcreator/
* @link https://pluginsglpi.github.io/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ---------------------------------------------------------------------
*/

include ('../../../inc/includes.php');

// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
http_response_code(404);
die();
}

if (!isset($_REQUEST['itemtype']) || !isset($_REQUEST['items_id']) || !isset($_REQUEST['action'])) {
http_response_code(500);
die();
}

Session::checkRight('entity', UPDATE);
if (!PluginFormcreatorCommon::getForm()->duplicateTarget($_REQUEST)) {
http_response_code(500);
}
2 changes: 1 addition & 1 deletion ajax/formanswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
die();
}

if (!isset($_POST['submit_formcreator']) || !isset($_POST['plugin_formcreator_forms_id'])) {
if (!isset($_POST['add']) || !isset($_POST['plugin_formcreator_forms_id'])) {
http_response_code(500);
die();
}
Expand Down
11 changes: 6 additions & 5 deletions ajax/homepage_wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
exit;
}

if (!isset($_REQUEST['wizard'])) {
http_response_code(400);
die();
}

if ($_REQUEST['wizard'] == 'categories') {
plugin_formcreator_showWizardCategories();
} else if ($_REQUEST['wizard'] == 'forms') {
if (isset($_REQUEST['categoriesId'])) {
$categoriesId = (int) $_REQUEST['categoriesId'];
} else {
$categoriesId = 0;
}
$categoriesId = (int) ($_REQUEST['categoriesId'] ?? 0);
$keywords = isset($_REQUEST['keywords']) ? $_REQUEST['keywords'] : '';
$helpdeskHome = isset($_REQUEST['helpdeskHome']) ? $_REQUEST['helpdeskHome'] != '0' : false;
plugin_formcreator_showWizardForms($categoriesId, $keywords, $helpdeskHome);
Expand Down
2 changes: 1 addition & 1 deletion ajax/section_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
Session::addMessageAfterRedirect(__('Could not update the section', 'formcreator'), false, ERROR);
exit;
}
echo json_encode(['id' => $section->getID(), 'name' => $section->fields['name']], JSON_UNESCAPED_UNICODE);
echo json_encode(['id' => $section->getID(), 'name' => $section->getDesignLabel()], JSON_UNESCAPED_UNICODE);
15 changes: 7 additions & 8 deletions front/formanswer.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@
$formanswer->update($_POST);
Html::back();

} else if (isset($_POST['refuse_formanswer'])) {
$formanswer->update($_POST);
$formanswer->redirectToList();

} else if (isset($_POST['accept_formanswer'])) {
$formanswer->update($_POST);
$formanswer->redirectToList();

} else if (isset($_POST['refuse_formanswer']) || isset($_POST['accept_formanswer'])) {
if ($formanswer->update($_POST)) {
$formanswer->redirectToList();
} else {
//redirect to formanswer if update failed (ex : missing mandatory field)
Html::back();
}
} else if (isset($_POST['save_formanswer'])) {
if (!$formanswer->update($_POST)) {
Html::back();
Expand Down
60 changes: 60 additions & 0 deletions front/wizardreminders.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* ---------------------------------------------------------------------
* Formcreator is a plugin which allows creation of custom forms of
* easy access.
* ---------------------------------------------------------------------
* LICENSE
*
* This file is part of Formcreator.
*
* Formcreator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Formcreator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Formcreator. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
* @copyright Copyright © 2011 - 2021 Teclib'
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+
* @link https://github.com/pluginsGLPI/formcreator/
* @link https://pluginsglpi.github.io/formcreator/
* @link http://plugins.glpi-project.org/#/plugin/formcreator
* ---------------------------------------------------------------------
*/

global $CFG_GLPI;
include ("../../../inc/includes.php");

// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

if (! plugin_formcreator_replaceHelpdesk()) {
Html::redirect($CFG_GLPI['root_doc']."/front/helpdesk.public.php");
}

if (!Reminder::canView()) {
Html::displayRightError();
}

if (Session::getCurrentInterface() == "helpdesk") {
Html::helpHeader(__('Service catalog', 'formcreator'));
} else {
Html::header(__('Service catalog', 'formcreator'));
}

Reminder::showListForCentral(false);

if (Session::getCurrentInterface() == "helpdesk") {
Html::helpFooter();
} else {
Html::footer();
}
16 changes: 10 additions & 6 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
$issueSearchOptions = Search::getOptions($itemtype);
$complexJoinId = Search::computeComplexJoinID($issueSearchOptions[9]['joinparams']);
$colname = $issueSearchOptions[9]['linkfield'];
$condition .= "`glpi_users_${colname}_$complexJoinId`.`id` = '$currentUser'";
$condition .= "`glpi_users_{$colname}_$complexJoinId`.`id` = '$currentUser'";

// condition where current user is a member of a validator group of the issue
$groupList = [];
Expand All @@ -209,7 +209,7 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
// Search option ID 16 is either from Formcreator, either from AdvForms
$complexJoinId = Search::computeComplexJoinID($issueSearchOptions[16]['joinparams']);
$colname = $issueSearchOptions[16]['linkfield'];
$condition .= " OR `glpi_groups_${colname}_$complexJoinId`.`id` IN ('$groupList')";
$condition .= " OR `glpi_groups_{$colname}_$complexJoinId`.`id` IN ('$groupList')";
}

// condition where current user is a validator of a issue of type ticket
Expand Down Expand Up @@ -265,6 +265,9 @@ function plugin_formcreator_addDefaultWhere($itemtype) {

$groupIDs = [];
foreach ($groups as $group) {
if ($group['id'] === null) {
continue;
}
$groupIDs[] = $group['id'];
}
$groupIDs = implode(',', $groupIDs);
Expand Down Expand Up @@ -372,9 +375,10 @@ function plugin_formcreator_MassiveActions($itemtype) {
switch ($itemtype) {
case PluginFormcreatorForm::class:
return [
'PluginFormcreatorForm' . MassiveAction::CLASS_ACTION_SEPARATOR . 'Duplicate' => _x('button', 'Duplicate'),
'PluginFormcreatorForm' . MassiveAction::CLASS_ACTION_SEPARATOR . 'Transfert' => __('Transfer'),
'PluginFormcreatorForm' . MassiveAction::CLASS_ACTION_SEPARATOR . 'Export' => _sx('button', 'Export'),
PluginFormcreatorForm::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'Duplicate' => _x('button', 'Duplicate'),
PluginFormcreatorForm::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'Transfert' => __('Transfer'),
PluginFormcreatorForm::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'Export' => _sx('button', 'Export'),
PluginFormcreatorForm::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'AccessRights' => _sx('button', 'Access rights'),
];
}
return [];
Expand Down Expand Up @@ -800,4 +804,4 @@ function plugin_formcreator_transfer(array $options) {
'tickets_id' => $options['newID'],
]);
}
}
}
11 changes: 11 additions & 0 deletions inc/abstractfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,15 @@ public function getTranslatableStrings(array $options = []) : array {

return $strings;
}

/**
* Translates the label of the field into the current language
*
* @return string
*/
protected function getTtranslatedLabel(): string {
$form = PluginFormcreatorForm::getByItem($this->question);
$domain = PluginFormcreatorForm::getTranslationDomain($form->getID());
return __($this->getLabel(), $domain);
}
}
18 changes: 18 additions & 0 deletions inc/abstractitiltarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,11 @@ public function getDefaultData(PluginFormcreatorFormAnswer $formanswer): array {
}

$data = array_merge($data, $predefined_fields);

if (($data['requesttypes_id'] ?? 0) == 0) {
unset($data['requesttypes_id']);
}

return $data;
}

Expand Down Expand Up @@ -2493,4 +2498,17 @@ public static function getMailImage() {
public static function getNoMailImage() {
return '<i class="fas fa-envelope pointer" title="' . __('Email followup') . ' ' . __('No') . '" width="20"></i>';
}

public function getCloneRelations(): array {
return [
PluginFormcreatorTarget_Actor::class,
PluginFormcreatorCondition::class,
];
}

public function prepareInputForClone($input) {
$input = parent::prepareInputForClone($input);
$input['_skip_create_actors'] = true;
return $input;
}
}
8 changes: 7 additions & 1 deletion inc/abstracttarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

use Glpi\Application\View\TemplateRenderer;
use Glpi\Toolbox\Sanitizer;
use \Glpi\Features\Clonable;

if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access this file directly");
Expand All @@ -43,6 +43,7 @@ abstract class PluginFormcreatorAbstractTarget extends CommonDBChild implements
PluginFormcreatorConditionnableInterface,
PluginFormcreatorTranslatableInterface
{
use Clonable;
use PluginFormcreatorConditionnableTrait;
use PluginFormcreatorExportableTrait;
use PluginFormcreatorTranslatable;
Expand Down Expand Up @@ -553,4 +554,9 @@ protected function showDestinationEntitySetings($rand) {
echo '</td>';
echo '</tr>';
}

public function prepareInputForClone($input) {
unset($input['uuid']);
return $input;
}
}
Loading

0 comments on commit 51d632a

Please sign in to comment.