Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a90c3e5
Revert "feat(glpiselectfield): support Cluster itemtype"
btry Mar 13, 2024
8e06c17
Revert "Revert "feat(glpiselectfield): support Cluster itemtype""
btry Mar 13, 2024
15907b8
fix(section): bad update when importing a section with conditions
btry Mar 4, 2024
e56eaca
fix(ldapfield): HTML encoding when copying filter from GLPI
btry Mar 21, 2024
5c64327
fix translation
Rom1-B Mar 22, 2024
e468aa3
fix(targetticket): actors format
btry Mar 22, 2024
3efc9cd
fix(target_actor): duplication requires export of ID, not name
btry Apr 8, 2024
2d5ad80
fix(glpiselectfield): ambiguous column with tickets
btry Apr 12, 2024
11d9e6b
fix(form): bad itemtypes names
btry Apr 23, 2024
603b8ea
fix(knowbase,form): kb item translation missing
btry Apr 23, 2024
9ac92f0
fix(fieldsfield): mandatory check failure on dropdowns
btry Apr 23, 2024
d81a43e
fix(dropdownfield): useless duplicate conditions for tickets
btry Apr 23, 2024
1ff8a55
fix(target_actor): duplication fails for some types
btry Apr 17, 2024
8a8f8d4
refactor(config): typo in class name
btry May 16, 2024
06d9089
fix(abstracttarget): missing escaping before SQL query
btry May 24, 2024
8011971
fix(knowbase): categories in reverse alphanumeric order
btry May 30, 2024
feb1de0
fix(fieldsfield): required property update on UI
btry Jun 7, 2024
17c0358
fix: SQL error when user ID missing
Rom1-B Jul 24, 2024
ed147ef
fix: handle negative due date for service levels
ccailly Aug 19, 2024
eefab6b
Fix: Section order duplicates
Rom1-B Aug 30, 2024
21ecb76
cs-fixer
Rom1-B Aug 30, 2024
aab508d
fix: adjust dashboard widget height
ccailly Apr 9, 2024
aa12610
fix: php lint
ccailly Apr 22, 2024
f6d63ea
fix: adding 2.13.10 empty sql file
ccailly Apr 23, 2024
580eba5
fix(issue): SQL warning if groups of the user contain an empty ID
btry Sep 12, 2024
6069ee6
Fix(Fields): fix target when more than one container is used (#3564)
stonebuzz Feb 11, 2025
af9a6f8
Fix FormcreatorIssues requester not updated (#3560)
RomainLvr Feb 12, 2025
46efb33
fix(dropdownfield, glpiselectfield): group restriction (#3489)
btry Feb 12, 2025
7fbfffb
fix(target) Removes the default user when a group requester is define…
MyvTsv Feb 17, 2025
72b6b54
Fix: remove unrelated items when a ticket target is set (#3565)
MyvTsv Feb 17, 2025
f336e1b
fix: set the default value of the dropdown as empty string (#3563)
MyvTsv Feb 18, 2025
f1ecc2d
fix(files): entity (#3566)
Rom1-B Feb 20, 2025
cdc5548
Release/2.13.10 (#3570)
Rom1-B Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## [2.13.10](https://github.com/pluginsGLPI/formcreator/compare/2.13.9...2.13.10) (2025-02-26)


### Bug Fixes

* **abstracttarget:** missing escaping before SQL query ([06d9089](https://github.com/pluginsGLPI/formcreator/commit/06d908937201e25515bbe5bdda5b93c465ce3f8a))
* adding 2.13.10 empty sql file ([f6d63ea](https://github.com/pluginsGLPI/formcreator/commit/f6d63ead12746c04b63e591b2f28e62486056be7))
* adjust dashboard widget height ([aab508d](https://github.com/pluginsGLPI/formcreator/commit/aab508ddac14cd51f7a90925a3d15623fc8a0b04))
* **dropdownfield, glpiselectfield:** group restriction ([#3489](https://github.com/pluginsGLPI/formcreator/issues/3489)) ([46efb33](https://github.com/pluginsGLPI/formcreator/commit/46efb336110722c8e99006997d4a8069eb46d2e7))
* **dropdownfield:** useless duplicate conditions for tickets ([d81a43e](https://github.com/pluginsGLPI/formcreator/commit/d81a43ebbec74f58f019da409f53a169e2ea06f8))
* **fieldsfield:** mandatory check failure on dropdowns ([9ac92f0](https://github.com/pluginsGLPI/formcreator/commit/9ac92f04705060106b122d6665a3bb27f4adc4f0))
* **fieldsfield:** required property update on UI ([feb1de0](https://github.com/pluginsGLPI/formcreator/commit/feb1de088e7f16b2a9ee7d4274b66ee1cb59f539))
* **files:** entity ([#3566](https://github.com/pluginsGLPI/formcreator/issues/3566)) ([f1ecc2d](https://github.com/pluginsGLPI/formcreator/commit/f1ecc2da717a3df39fcae6a16b9a5b6a08ef7d8a))
* **form:** bad itemtypes names ([11d9e6b](https://github.com/pluginsGLPI/formcreator/commit/11d9e6b8ed493a3155e770bb41b6f10f25fd9584))
* **glpiselectfield:** ambiguous column with tickets ([2d5ad80](https://github.com/pluginsGLPI/formcreator/commit/2d5ad80b2a11ac0476f3258d62969ac240e96fa5))
* handle negative due date for service levels ([ed147ef](https://github.com/pluginsGLPI/formcreator/commit/ed147efa2e175bb245e343af124d22909974806f))
* **issue:** SQL warning if groups of the user contain an empty ID ([580eba5](https://github.com/pluginsGLPI/formcreator/commit/580eba5b355ef0fd435d5caf5ac7dc95f21d7e61))
* **knowbase,form:** kb item translation missing ([603b8ea](https://github.com/pluginsGLPI/formcreator/commit/603b8eac9b93f70b3b95bdda529b17eb7935ef1d))
* **knowbase:** categories in reverse alphanumeric order ([8011971](https://github.com/pluginsGLPI/formcreator/commit/801197183ed8d96ac16f9a3d5bd6dd75ef7fbb83))
* **ldapfield:** HTML encoding when copying filter from GLPI ([e56eaca](https://github.com/pluginsGLPI/formcreator/commit/e56eacaeab5409cfd5b89cdfdbf4fd1d0e0cb0fc))
* php lint ([aa12610](https://github.com/pluginsGLPI/formcreator/commit/aa1261021d2712718b2ecc0b7bf0eb1e9a38e5b3))
* **section:** bad update when importing a section with conditions ([15907b8](https://github.com/pluginsGLPI/formcreator/commit/15907b8369099afc9d0b63b32e3152496ed7cdf8))
* set the default value of the dropdown as empty string ([#3563](https://github.com/pluginsGLPI/formcreator/issues/3563)) ([f336e1b](https://github.com/pluginsGLPI/formcreator/commit/f336e1b4e8940ce4b582c9b82cadf8f1241dfa3b))
* SQL error when user ID missing ([17c0358](https://github.com/pluginsGLPI/formcreator/commit/17c0358919d804b70e6c2e27b089dfbde177e0d1))
* **target_actor:** duplication fails for some types ([1ff8a55](https://github.com/pluginsGLPI/formcreator/commit/1ff8a555f1461d4dd4fa2225ce78a883a00d1225))
* **target_actor:** duplication requires export of ID, not name ([3efc9cd](https://github.com/pluginsGLPI/formcreator/commit/3efc9cd7ccdcc003f83f3409853b6f50e7d2d2f1))
* **targetticket:** actors format ([e468aa3](https://github.com/pluginsGLPI/formcreator/commit/e468aa350de569991274d97e1af7ce2fca7ed994))


### Reverts

* Revert "Revert "feat(glpiselectfield): support Cluster itemtype"" ([8e06c17](https://github.com/pluginsGLPI/formcreator/commit/8e06c17cd1b864f39a53e34e75a206acf3de66a5))



<a name="2.13.9"></a>
## [HEAD](https://github.com/pluginsGLPI/formcreator/compare/2.13.8..2.13.9) (2024-03-13)

Expand Down
3 changes: 3 additions & 0 deletions ajax/ldap_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* ---------------------------------------------------------------------
*/

use Glpi\Toolbox\Sanitizer;

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

Session::checkRight('entity', UPDATE);
Expand All @@ -37,4 +39,5 @@
$authldap->getFromDB($_POST['value']);
$filter = "(".$authldap->getField("login_field")."=*)";
$ldap_condition = $authldap->getField('condition');
$ldap_condition = Sanitizer::decodeHtmlSpecialChars($ldap_condition);
echo "(& $filter $ldap_condition)";
2 changes: 2 additions & 0 deletions ajax/question_design.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@
$question->fields['fieldtype'] = '';
if ($field !== null) {
$question->fields['fieldtype'] = $_REQUEST['fieldtype'];
$question->fields['_blocks_field'] = $_REQUEST['blocks_field'] ?? null;
$question->fields['_dropdown_fields_field'] = $_REQUEST['dropdown_fields_field'] ?? null;
}
$question->showForm($question->getID());
18 changes: 16 additions & 2 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
$groupList[] = $group['id'];
}
if (count($groupList) > 0) {
$groupList = array_filter($groupList);
$groupList = implode("', '", $groupList);
// Search option ID 16 is either from Formcreator, either from AdvForms
$complexJoinId = Search::computeComplexJoinID($issueSearchOptions[16]['joinparams']);
Expand All @@ -229,7 +230,7 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
$condition .= " OR `glpi_users_$complexJoinId`.`id` = '$currentUser'";

// Add users_id_recipient
$condition .= " OR `glpi_plugin_formcreator_issues`.`users_id_recipient` = $currentUser ";
$condition .= " OR `glpi_plugin_formcreator_issues`.`users_id_recipient` = '$currentUser' ";
return "($condition)";
break;

Expand Down Expand Up @@ -378,7 +379,7 @@ function plugin_formcreator_MassiveActions($itemtype) {
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'),
PluginFormcreatorForm::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'AccessRights' => _sx('button', 'Access rights', 'formcreator'),
];
}
return [];
Expand Down Expand Up @@ -442,6 +443,18 @@ function plugin_formcreator_hook_add_ticket(CommonDBTM $item) {
]);
}

function plugin_formcreator_hook_update_ticket_actors(CommonITILActor $item) {
if ($item::$itemtype_1 == Ticket::class) {
if ($item->fields['type'] == CommonITILActor::REQUESTER) {
$ticket_id = $item->fields['tickets_id'];
$ticket = new Ticket();
if ($ticket->getFromDB($ticket_id)) {
plugin_formcreator_hook_update_ticket($ticket);
}
}
}
}

function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
global $DB;

Expand Down Expand Up @@ -489,6 +502,7 @@ function plugin_formcreator_hook_update_ticket(CommonDBTM $item) {
'entities_id' => $item->fields['entities_id'],
'is_recursive' => '0',
'requester_id' => $requester,
'users_id_recipient' => $requester,
'comment' => $DB->escape($item->fields['content']),
]);
}
Expand Down
5 changes: 4 additions & 1 deletion inc/abstractitiltarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,10 @@ protected function setTargetDueDate($data, PluginFormcreatorFormAnswer $formansw
$period = "month";
break;
}
$str = "+" . $this->fields['due_date_value'] . " $period";
$str = $this->fields['due_date_value'] . " $period";
if ($str[0] !== '-') {
$str = '+' . $str;
}

switch ($this->fields['due_date_rule']) {
case self::DUE_DATE_RULE_ANSWER:
Expand Down
13 changes: 12 additions & 1 deletion inc/abstracttarget.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,15 @@ protected function appendFieldsData(array $input, PluginFormcreatorFormanswer $f
$field_name = $decodedValues['dropdown_fields_field'] ?? '';
$blocks_field = $decodedValues['blocks_field'] ?? '';

//load container field
$container = new PluginFieldsContainer();
$container->getFromDB($blocks_field);
$related_itemtype = json_decode($container->fields['itemtypes'], true);

if (!in_array(get_called_class()::getTargetItemtypeName(), $related_itemtype)) {
continue;
}

$field = new PluginFieldsField();
$field->getFromDbByCrit(['name' => $field_name]);

Expand Down Expand Up @@ -565,10 +574,12 @@ public function prepareInputForClone($input) {
}

protected static function getTemplateByName(string $name): int {
global $DB;

$targetTemplateType = (new static())->getTemplateItemtypeName();
$targetTemplate = new $targetTemplateType();
$targetTemplate->getFromDBByCrit([
'name' => $name,
'name' => $DB->escape($name),
]);

if ($targetTemplate->isNewItem()) {
Expand Down
33 changes: 2 additions & 31 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,40 +227,11 @@ public function buildParams($rand = null) {
if (Session::haveRight("ticket", Ticket::READALL)) {
break;
}
$currentUser = Session::getLoginUserID();
if (!Session::haveRight(Ticket::$rightname, Ticket::READMY) && !Session::haveRight(Ticket::$rightname, Ticket::READGROUP)) {
// No right to view any ticket, then force the dropdown to be empty
$dparams_cond_crit['OR'] = new QueryExpression('0=1');
break;
}
$tickets_filter = ['users_id_recipient' => $currentUser];

if (Session::haveRight(Ticket::$rightname, Ticket::READMY)) {
$requestersObserversQuery = new QuerySubQuery([
'SELECT' => 'tickets_id',
'FROM' => Ticket_User::getTable(),
'WHERE' => [
'users_id' => $currentUser,
'type' => [CommonITILActor::REQUESTER, CommonITILActor::OBSERVER]
],
]);
$tickets_filter[] = [
Ticket::getTableField('id') => $requestersObserversQuery,
];
}

if (Session::haveRight(Ticket::$rightname, Ticket::READGROUP) && count($_SESSION['glpigroups']) > '0') {
$requestersObserversGroupsQuery = new QuerySubQuery([
'SELECT' => 'tickets_id',
'FROM' => Group_Ticket::getTable(),
'WHERE' => [
'type' => [CommonITILActor::REQUESTER, CommonITILActor::OBSERVER],
'groups_id' => $_SESSION['glpigroups'],
],
]);
$tickets_filter[] = ['id' => $requestersObserversGroupsQuery];
}
$dparams_cond_crit['OR'] = $tickets_filter;
break;

default:
Expand All @@ -277,7 +248,7 @@ public function buildParams($rand = null) {
$canViewGroupHardware = Session::haveRight('show_group_hardware', '1');
$groups = [];
if ($canViewGroupHardware) {
$groups = $this->getMyGroups(Session::getLoginUserID());
$groups = $_SESSION['glpigroups'];
}
if ($DB->fieldExists($itemtype::getTable(), $userFk)
&& !$canViewAllHardware && $canViewMyHardware
Expand All @@ -295,7 +266,7 @@ public function buildParams($rand = null) {
];
}
// Check if helpdesk availability is fine tunable on a per item basis
if (Session::getCurrentInterface() == "helpdesk" && $DB->fieldExists($itemtype::getTable(), 'is_helpdesk_visible')) {
if ($DB->fieldExists($itemtype::getTable(), 'is_helpdesk_visible')) {
$dparams_cond_crit[] = [
'is_helpdesk_visible' => '1',
];
Expand Down
22 changes: 19 additions & 3 deletions inc/field/fieldsfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FieldsField extends PluginFormcreatorAbstractField
public function getField(): ?PluginFieldsField {
if ($this->field === null && isset($this->question->fields['values'])) {
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
$field_name = $decodedValues['dropdown_fields_field'] ?? '';
$field_name = $decodedValues['dropdown_fields_field'] ?? ($this->question->fields['_field_name'] ?? '');
$fieldObj = new PluginFieldsField();
if ($fieldObj->getFromDBByCrit(['name' => $field_name])) {
$this->field = $fieldObj;
Expand Down Expand Up @@ -208,13 +208,15 @@ public function prepareHtmlField($fieldName, $canedit = true, $value = '') {
$field['value'] = $value;
} else {
//get default value
if ($this->getField()->fields['default_value'] !== "") {
if (!empty($this->getField()->fields['default_value'])) {
$value = $this->getField()->fields['default_value'];
// shortcut for date/datetime
if (in_array($this->getField()->fields['type'], ['date', 'datetime'])
&& $value == 'now') {
$value = $_SESSION["glpi_currenttime"];
}
} else {
$value = '';
}
$field['value'] = $value;
}
Expand Down Expand Up @@ -483,7 +485,7 @@ public function isValidValue($value): bool {
public function isValid(): bool {
if (!is_null($this->getField())) {
// If the field is required it can't be empty
if ($this->getField()->fields['mandatory'] && $this->value == '') {
if ($this->isAdditionalFieldEmpty()) {
Session::addMessageAfterRedirect(
__('A required field is empty:', 'formcreator') . ' ' . $this->getLabel(),
false,
Expand All @@ -498,6 +500,20 @@ public function isValid(): bool {
return true;
}

/**
* Undocumented function
*
* @return boolean
*/
private function isAdditionalFieldEmpty(): bool {
switch ($this->getField()->fields['type']) {
case 'dropdown':
return $this->getField()->fields['mandatory'] && empty($this->value);
}

return $this->getField()->fields['mandatory'] && $this->value == '';
}

public function moveUploads() {

}
Expand Down
13 changes: 12 additions & 1 deletion inc/field/filefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,20 @@ private function saveDocument($file, $prefix) {
return;
}

$entities_id = $form->getField('entities_id');
if ($form->getField('is_recursive')) {
$entities_sons = getSonsOf('glpi_entities', $entities_id);
if (isset($_SESSION['glpiactive_entity'])
&& $_SESSION['glpiactive_entity'] != $entities_id
&& in_array($_SESSION['glpiactive_entity'], $entities_sons)
) {
$entities_id = $_SESSION['glpiactive_entity'];
}
}

$file_data = [
'name' => Toolbox::addslashes_deep($form->fields['name'] . ' - ' . $this->question->fields['name']),
'entities_id' => $_SESSION['glpiactive_entity'] ?? $form->getField('entities_id'),
'entities_id' => $entities_id,
'is_recursive' => $form->getField('is_recursive'),
'_filename' => [$file],
'_prefix_filename' => [$prefix],
Expand Down
6 changes: 3 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,8 @@ public static function getFormList(int $rootCategory = 0, string $keywords = '',

$table_cat = getTableForItemType(PluginFormcreatorCategory::class);
$table_form = getTableForItemType(PluginFormcreatorForm::class);
$table_section = getTableForItemType(PluginFormcreatorSections::class);
$table_question = getTableForItemType(PluginFormcreatorQuestions::class);
$table_section = getTableForItemType(PluginFormcreatorSection::class);
$table_question = getTableForItemType(PluginFormcreatorQuestion::class);

$categoryFk = PluginFormcreatorCategory::getForeignKeyField();

Expand Down Expand Up @@ -843,7 +843,7 @@ public static function getFormList(int $rootCategory = 0, string $keywords = '',
foreach ($result_faqs as $faq) {
$formList[] = [
'id' => $faq['id'],
'name' => $faq['name'],
'name' => $faq['transname'] ?? $faq['name'],
'icon' => '',
'icon_color' => '',
'background_color' => '',
Expand Down
4 changes: 2 additions & 2 deletions inc/knowbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function getCategoryTree() {
'FROM' => $cat_table,
'ORDER' => [
KnowbaseItemCategory::getTableField('level') . ' DESC',
KnowbaseItemCategory::getTableField('name'),
KnowbaseItemCategory::getTableField('name') . ' DESC',
]
]);

Expand Down Expand Up @@ -222,7 +222,7 @@ public static function getFaqItems($rootCategory = 0, $keywords = '') {
foreach ($result_faqs as $faq) {
$formList[] = [
'id' => $faq['id'],
'name' => $faq['name'],
'name' => $faq['transname'] ?? $faq['name'],
'icon' => '',
'icon_color' => '',
'background_color' => '',
Expand Down
37 changes: 35 additions & 2 deletions inc/section.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ public function prepareInputForUpdate($input) {
$input['uuid'] = plugin_formcreator_getUuid();
}

if (!$this->checkConditionSettings($input)) {
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
if (!$this->skipChecks) {
if (!$this->checkConditionSettings($input)) {
$input['show_rule'] = PluginFormcreatorCondition::SHOW_RULE_ALWAYS;
}
}

return $input;
Expand Down Expand Up @@ -268,6 +270,8 @@ public function duplicate(array $options = []) {
public function moveUp() {
global $DB;

$this->fixOrder();

$order = $this->fields['order'];
$formId = $this->fields['plugin_formcreator_forms_id'];
$otherItem = new static();
Expand Down Expand Up @@ -311,6 +315,8 @@ public function moveUp() {
public function moveDown() {
global $DB;

$this->fixOrder();

$order = $this->fields['order'];
$formId = $this->fields['plugin_formcreator_forms_id'];
$otherItem = new static();
Expand Down Expand Up @@ -347,6 +353,33 @@ public function moveDown() {
return $success;
}

public function fixOrder(): void {
global $DB;

$formId = $this->fields['plugin_formcreator_forms_id'];

$iterator = $DB->request([
'FROM' => static::getTable(),
'WHERE' => [
'AND' => [
'plugin_formcreator_forms_id' => $formId,
]
],
'ORDER' => ['order ASC']
]);
$order = 1;
foreach ($iterator as $row) {
if ($row['order'] !== $order) {
$DB->update(static::getTable(), [
'order' => $order
], [
'id' => $row['id']
]);
}
$order++;
}
}

public static function import(PluginFormcreatorLinker $linker, $input = [], $containerId = 0) {
global $DB;

Expand Down
Loading