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

Commit

Permalink
Merge branch '2.8.x' of https://github.com/centreon/centreon into 2.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmathis committed Sep 12, 2016
2 parents 99911a9 + 89a7322 commit b441b5c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
33 changes: 26 additions & 7 deletions www/api/class/centreon_configuration_service.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getList()
$isAdmin = $centreon->user->admin;
$aclServices = '';
$aclMetaServices = '';

/* Get ACL if user is not admin */
if (!$isAdmin) {
$acl = new CentreonACL($userId, $isAdmin);
Expand All @@ -84,7 +84,14 @@ public function getList()
} else {
$q = $this->arguments['q'];
}


// Check for service enable
if (false === isset($this->arguments['e'])) {
$e = '';
} else {
$e = $this->arguments['e'];
}

// Check for service type
if (false === isset($this->arguments['t'])) {
$t = 'host';
Expand Down Expand Up @@ -121,7 +128,7 @@ public function getList()
switch ($t) {
default:
case 'host':
$serviceList = $this->getServicesByHost($q, $aclServices, $range, $g, $aclMetaServices, $s);
$serviceList = $this->getServicesByHost($q, $aclServices, $range, $g, $aclMetaServices, $s, $e);
break;
case 'hostgroup':
$serviceList = $this->getServicesByHostgroup($q, $aclServices, $range);
Expand All @@ -137,9 +144,20 @@ public function getList()
* @param type $q
* @param type $aclServices
*/
private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = false, $aclMetaServices, $s)
private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = false, $aclMetaServices, $s, $e)
{

if( $e == 'enable'):
$enableQuery = 'AND s.service_activate = \'1\' AND h.host_activate = \'1\' ';
$enableQueryMeta = 'AND ms.service_activate = \'1\' AND mh.host_activate = \'1\' ';
elseif( $e == 'disable'):
$enableQuery = 'AND ( s.service_activate = \'0\' OR h.host_activate = \'0\' ) ';
$enableQueryMeta = 'AND ( ms.service_activate = \'0\' OR mh.host_activate = \'0\') ';
else:
$enableQuery = '';
$enableQueryMeta = '';
endif;

switch ($s) {
case 'all':
$queryService = "SELECT SQL_CALC_FOUND_ROWS DISTINCT service_description, service_id, host_name, host_id
Expand All @@ -151,6 +169,7 @@ private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = fa
. "AND h.host_register = '1' "
. "AND s.service_register = '1' "
. "AND (s.service_description LIKE '%$q%' OR h.host_name LIKE '%$q%') "
. $enableQuery
. $aclServices
. ")
UNION ALL ( "
Expand All @@ -160,6 +179,7 @@ private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = fa
. "AND mh.host_register = '2' "
. "AND ms.service_register = '2' "
. "AND (ms.display_name LIKE '%$q%') "
. $enableQueryMeta
. $aclMetaServices
.")
) as t_union "
Expand All @@ -174,6 +194,7 @@ private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = fa
. "AND h.host_register = '1' "
. "AND s.service_register = '1' "
. "AND (s.service_description LIKE '%$q%' OR h.host_name LIKE '%$q%') "
. $enableQuery
. $aclServices
. "ORDER BY h.host_name, s.service_description "
. $range;
Expand All @@ -185,16 +206,15 @@ private function getServicesByHost($q, $aclServices, $range = '', $hasGraph = fa
. "AND mh.host_register = '2' "
. "AND ms.service_register = '2' "
. "AND (ms.display_name LIKE '%$q%') "
. $enableQueryMeta
. $aclMetaServices
. "ORDER BY mh.host_name, ms.service_description "
. $range;
break;
}

$DBRESULT = $this->pearDB->query($queryService);

$total = $this->pearDB->numberRows();

$serviceList = array();
while ($data = $DBRESULT->fetchRow()) {
if ($hasGraph) {
Expand Down Expand Up @@ -251,7 +271,6 @@ private function getServicesByHostgroup($q, $aclServices, $range = '')
);
}


/**
*
* @param type $args
Expand Down
33 changes: 26 additions & 7 deletions www/include/monitoring/comments/AddSvcComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
* Database retrieve information for differents
* elements list we need on the page
*/
$query = "SELECT host_id, host_name FROM `host` WHERE host_register = '1' " . $centreon->user->access->queryBuilder("AND", "host_id", $hostStr) . "ORDER BY host_name";
$query = "SELECT host_id, host_name FROM `host` WHERE (host_register = '1' OR host_register = '2' )" . $centreon->user->access->queryBuilder("AND", "host_id", $hostStr) . "ORDER BY host_name";
$DBRESULT = $pearDB->query($query);
$hosts = array(null => null);
while ($row = $DBRESULT->fetchRow()) {
Expand Down Expand Up @@ -110,11 +110,15 @@
$form->addElement('hidden', 'host_id', $host_id);
$form->addElement('hidden', 'service_id', $service_id);
} else {
$form->addElement('select', 'host_id', _("Host Name"), $hosts, array("onChange" => "this.form.submit();"));
$form->addRule('host_id', _("Required Field"), 'required');
$disabled = " ";
$attrServices = array(
'datasourceOrigin' => 'ajax',
'availableDatasetRoute' => './api/internal.php?object=centreon_configuration_service&action=list&e=enable',
'multiple' => true,
'linkedObject' => 'centreonService'
);
$form->addElement('select2', 'service_id', _("Services"), array($disabled), $attrServices);

$form->addElement('select', 'service_id', _("Service"), $services);
$form->addRule('service_id', _("Required Field"), 'required');
}

$persistant = $form->addElement('checkbox', 'persistant', _("Persistent"));
Expand All @@ -123,7 +127,6 @@
$form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea);
$form->addRule('comment', _("Required Field"), 'required');


$form->addElement('submit', 'submitA', _("Save"), array("class" => "btc bt_success"));
$form->addElement('reset', 'reset', _("Reset"), array("class" => "btc bt_default"));

Expand All @@ -135,7 +138,23 @@
if (!isset($_POST["comment"])) {
$_POST["comment"] = 0;
}
AddSvcComment($_POST["host_id"], $_POST["service_id"], $_POST["comment"], $_POST["persistant"]);

//global services comment
if(!isset($_POST["host_id"])):
foreach ($_POST["service_id"] as $value) {
$info = split('-', $value);
AddSvcComment(
$info[0],
$info[1],
$_POST["comment"],
$_POST["persistant"]
);
}
else:
//specific service comment
AddSvcComment($_POST["host_id"], $_POST["service_id"], $_POST["comment"], $_POST["persistant"]);
endif;

$valid = true;
require_once($path."listComment.php");
} else {
Expand Down
2 changes: 1 addition & 1 deletion www/include/monitoring/comments/listComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
$tab_comments_svc[$i]['host_name_link'] = urlencode($tab_comments_svc[$i]['host_name']);
$tab_comments_svc[$i]['data'] = htmlentities($tab_comments_svc[$i]['data']);
if ($data['service_description'] != '') {
$tab_comments_svc[$i]['service_description'] = htmlentities($data['service_description']);
$tab_comments_svc[$i]['service_description'] = htmlentities($data['service_description'], ENT_QUOTES, 'UTF-8');
$tab_comments_svc[$i]['comment_type'] = 'SVC';
} else {
$tab_comments_svc[$i]['service_description'] = '-';
Expand Down
13 changes: 5 additions & 8 deletions www/include/monitoring/comments/template/AddSvcComment.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
<td class="ListColLeft"><b>{$host_name} / {$service_description}</b></td>
</tr>
{else}
<tr class="list_one">
<td class="ListColLeft">{$form.host_id.label}</td>
<td class="ListColLeft">{$form.host_id.html}</td>
</tr>
<tr class="list_one">
<td class="ListColLeft">{$form.service_id.label}</td>
<td class="ListColLeft">{$form.service_id.html}</td>
<tr class="list_one" id="service_input">
<td class="ListColLeft">{$form.service_id.label}</td>
<td class="ListColLeft">{$form.service_id.html}</td>
</tr>
{/if}
<tr class="list_two">
Expand All @@ -37,4 +33,5 @@
</div>
{$form.hidden}
</form>
</div>
</div>

2 changes: 1 addition & 1 deletion www/include/monitoring/downtime/AddDowntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
/* ----- Services ----- */
$attrServices = array(
'datasourceOrigin' => 'ajax',
'availableDatasetRoute' => './api/internal.php?object=centreon_configuration_service&action=list',
'availableDatasetRoute' => './api/internal.php?object=centreon_configuration_service&action=list&e=enable',
'multiple' => true,
'linkedObject' => 'centreonService'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<tr class={cycle values="list_two, list_one"}>
<td class="ListColPicker"><input type="checkbox" name='select[{$tds.downtime_type};{$tds.host_name_link};{$tds.internal_downtime_id}]'></td>
<td class="ListColLeft" width="150"><a href='./main.php?p=20202&o=hd&host_name={$tds.host_name_link}'>{$tds.host_name}</a></td>
<td class="ListColLeft" width="150"><a href='./main.php?p=202&o=svcd&host_name={$tds.host_name_link}&service_description={$tds.service_description}'>{$tds.service_description}</a></td>
<td class="ListColLeft" width="150"><a href='./main.php?p=202&o=svcd&host_name={$tds.host_name_link}&service_description={$tds.service_description}'>{$tds.service_description} 88 </a></td>
<td class="ListColRight" width="120">{$tds.scheduled_start_time}</td>
<td class="ListColRight" width="120">{$tds.scheduled_end_time}</td>
<td class="ListColRight" width="120">{$tds.duration} {$secondes}</td>
Expand Down

0 comments on commit b441b5c

Please sign in to comment.