Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
+ fix duplicate rule
Browse files Browse the repository at this point in the history
+ add a glpi method listObjects
  • Loading branch information
garnier-quentin committed Mar 31, 2016
1 parent 357827b commit 1c63bf6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
12 changes: 7 additions & 5 deletions www/modules/centreon-open-tickets/class/rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ protected function _setActivate($select, $val) {
$query = "UPDATE mod_open_tickets_rule SET `activate` = '$val' WHERE rule_id IN (";
$ruleList = "";
$ruleListAppend = "";
foreach ($select as $key => $value) {
$ruleList .= $ruleListAppend . "'" . $key . "'";
$ruleListAppend = ', ';
if (is_array($select)) {
foreach ($select as $key => $value) {
$ruleList .= $ruleListAppend . "'" . $key . "'";
$ruleListAppend = ', ';
}
}
if (isset($_REQUEST['rule_id'])) {
$ruleList .= $ruleListAppend . "'" . $_REQUEST['rule_id'] . "'";
Expand Down Expand Up @@ -257,8 +259,8 @@ public function duplicate($select = array(), $duplicateNb = array()) {
$res2 = $this->_db->query("SELECT * FROM mod_open_tickets_form_clone WHERE rule_id=$ruleId");
while (($row2 = $res2->fetchRow())) {
$query = "INSERT INTO mod_open_tickets_form_clone
(`uniq_id`, `label`, `value`, `rule_id`) VALUES " .
"('" . $this->_db->escape($row2['uniq_id']) . "', '" . $this->_db->escape($row2['label']) . "', '" . $this->_db->escape($row2['value']) . "', " . $nrule_id . ")";
(`uniq_id`, `label`, `value`, `rule_id`, `order`) VALUES " .
"('" . $this->_db->escape($row2['uniq_id']) . "', '" . $this->_db->escape($row2['label']) . "', '" . $this->_db->escape($row2['value']) . "', " . $nrule_id . ", '" . $row2['order'] . "')";
$this->_db->query($query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function _setDefaultValueMain() {
</table>
';
$this->default_data['format_popup'] = $this->change_html_tags($this->default_data['format_popup']);
$this->default_data['message_confirm'] = $this->change_html_tags($this->default_data['message_confirm']);
$this->default_data['message_confirm'] = $this->change_html_tags($this->default_data['message_confirm']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ protected function assignSubmittedValuesSelectMore($select_input_id, $selected_i
return array();
}

protected function doSubmit($db_storage, $contact, $host_problems, $service_problems) {
protected function doSubmit($db_storage, $contact, $host_problems, $service_problems, $extra_ticket_arguments=array()) {
$result = array('ticket_id' => null, 'ticket_error_message' => null,
'ticket_is_ok' => 0, 'ticket_time' => time());

Expand All @@ -397,7 +397,7 @@ protected function doSubmit($db_storage, $contact, $host_problems, $service_prob

$tpl->assign('body', $content);

$ticket_arguments = array();
$ticket_arguments = $extra_ticket_arguments;
if (isset($this->rule_data['clones']['mappingTicket'])) {
foreach ($this->rule_data['clones']['mappingTicket'] as $value) {
$tpl->assign('string', $value['Value']);
Expand Down Expand Up @@ -555,6 +555,21 @@ protected function createTicketGlpi($arguments) {
return 0;
}

protected function listObjects($arguments) {
if ($this->_glpi_connected == 0) {
if ($this->loginGlpi() == -1) {
return -1;
}
}

$this->glpi_call_response = $this->requestRpc('glpi.listObjects', $arguments);
if ($this->glpi_call_response['code'] == -1) {
return -1;
}

return 0;
}

protected function logoutGlpi() {
if ($this->_glpi_connected == 0) {
return 0;
Expand Down

0 comments on commit 1c63bf6

Please sign in to comment.