Skip to content

Commit

Permalink
Merge branch 'support/2.13.0' into support/2.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Apr 23, 2024
2 parents 2fbc6bd + d81a43e commit 33f4a67
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
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(PluginFormcreatorForm::$rightname, 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: 1 addition & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,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
29 changes: 0 additions & 29 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,40 +265,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 Down
16 changes: 15 additions & 1 deletion inc/field/fieldsfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,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 @@ -499,6 +499,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'] && $this->value == 0;
}

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

public function moveUploads() {

}
Expand Down
6 changes: 3 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,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 @@ -797,7 +797,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
2 changes: 1 addition & 1 deletion inc/knowbase.class.php
Original file line number Diff line number Diff line change
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
9 changes: 6 additions & 3 deletions inc/target_actor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,23 @@ public function export(bool $remove_uuid = false) : array {
case self::ACTOR_TYPE_PERSON:
case self::ACTOR_TYPE_AUTHORS_SUPERVISOR:
$user = new User;
$field = $idToRemove == 'uuid' ? 'id' : 'completename';
if ($user->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $user->fields['name'];
$target_actor['actor_value'] = $user->fields[$field];
}
break;
case self::ACTOR_TYPE_GROUP:
$group = new Group;
$field = $idToRemove == 'uuid' ? 'id' : 'completename';
if ($group->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $group->fields['completename'];
$target_actor['actor_value'] = $group->fields[$field];
}
break;
case self::ACTOR_TYPE_SUPPLIER:
$supplier = new Supplier;
$field = $idToRemove == 'uuid' ? 'id' : 'completename';
if ($supplier->getFromDB($target_actor['actor_value'])) {
$target_actor['actor_value'] = $supplier->fields['name'];
$target_actor['actor_value'] = $supplier->fields[$field];
}
break;
}
Expand Down
8 changes: 8 additions & 0 deletions inc/targetticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,14 @@ public function save(PluginFormcreatorFormAnswer $formanswer): ?CommonDBTM {
// Cleanup actors array
$data = $this->cleanActors($data);

// Specific format for actors in tickets
// @see CommonITILObject::setTechAndGroupFromItilCategory()
if ($data['_users_id_assign'] === 0) {
$data['_users_id_assign'] = [];
$data['_users_id_assign_notif']['use_notification'] = [];
$data['_users_id_assign_notif']['alternative_email'] = [];
}

// Create the target ticket
$data['_auto_import'] = true;
$data['_skip_sla_assign'] = true;
Expand Down

0 comments on commit 33f4a67

Please sign in to comment.