Commit b787d1b5 authored by Johan Cwiklinski's avatar Johan Cwiklinski

Merge branch '9.5/bugfixes'

parents 2a92529a 33619c57
......@@ -1844,7 +1844,7 @@ class AuthLDAP extends CommonDBTM {
'timestamp' => $user_infos[$userfound[$field_for_sync]]['timestamp'],
'date_sync' => $tmpuser->fields['date_sync'],
'dn' => $user['user_dn']];
} else if (($values['action'] == self::ACTION_ALL)
} else if (($values['mode'] == self::ACTION_ALL)
|| (($ldap_users[$user[$field_for_db]] - strtotime($user['date_sync'])) > 0)) {
//If entry was modified or if script should synchronize all the users
$glpi_users[] = ['id' => $user['id'],
......
......@@ -3338,7 +3338,7 @@ JAVASCRIPT;
}
if ($searchtype == "notcontains") {
$nott = !$nott;
$NOT = !$NOT;
}
return $this->makeTextCriteria($NAME, $val, $NOT, $LINK);
......
......@@ -1232,7 +1232,9 @@ class Ticket extends CommonITILObject {
}
}
/// Process Business Rules
// Process Business Rules
$this->fillInputForBusinessRules($input);
// Add actors on standard input
$rules = new RuleTicketCollection($entid);
$rule = $rules->getRuleClass();
......@@ -1936,25 +1938,9 @@ class Ticket extends CommonITILObject {
$input['_users_id_assign'] = Session::getLoginUserID();
}
// add calendars matching date creation (for business rules)
$calendars = [];
$ite_calandar = $DB->request([
'SELECT' => ['id'],
'FROM' => Calendar::getTable(),
'WHERE' => getEntitiesRestrictCriteria('', '', $input['entities_id'], true)
]);
foreach ($ite_calandar as $calendar_data) {
$calendar = new Calendar;
$calendar->getFromDB($calendar_data['id']);
if ($calendar->isAWorkingHour(time())) {
$calendars[] = $calendar_data['id'];
}
}
if (count($calendars)) {
$input['_date_creation_calendars_id'] = $calendars;
}
// Process Business Rules
$this->fillInputForBusinessRules($input);
$rules = new RuleTicketCollection($input['entities_id']);
// Set unset variables with are needed
......@@ -7242,4 +7228,43 @@ class Ticket extends CommonITILObject {
'add_now' => $this->getField('closedate') == ""
]);
}
/**
* Fill input with values related to business rules.
*
* @param array $input
*
* @return void
*/
private function fillInputForBusinessRules(array &$input) {
global $DB;
$entities_id = isset($input['entities_id'])
? $input['entities_id']
: $this->fields['entities_id'];
// If creation date is not set, then this function is called during ticket creation
$creation_date = !empty($this->fields['date_creation'])
? strtotime($this->fields['date_creation'])
: time();
// add calendars matching date creation (for business rules)
$calendars = [];
$ite_calendar = $DB->request([
'SELECT' => ['id'],
'FROM' => Calendar::getTable(),
'WHERE' => getEntitiesRestrictCriteria('', '', $entities_id, true)
]);
foreach ($ite_calendar as $calendar_data) {
$calendar = new Calendar();
$calendar->getFromDB($calendar_data['id']);
if ($calendar->isAWorkingHour($creation_date)) {
$calendars[] = $calendar_data['id'];
}
}
if (count($calendars)) {
$input['_date_creation_calendars_id'] = $calendars;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment