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

Commit

Permalink
fix(ui): saving configuration > services filters (#7355)
Browse files Browse the repository at this point in the history
* fix(ui): saving configuration > services by host filters
* fix(ui): saving configuration > services by hostgroups filters
* fix(ui): saving configuration > servicesgroups filters
* fix(ui): saving configuration > service template filters
* fix(ui): saving configuration > service categories filters
* fix(ui): saving configuration > meta services filters
  • Loading branch information
sc979 committed Apr 3, 2019
1 parent 598e696 commit 19defc5
Show file tree
Hide file tree
Showing 7 changed files with 538 additions and 537 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -37,46 +37,49 @@
exit();
}

include_once("./class/centreonUtils.class.php");
include_once "./class/centreonUtils.class.php";

include("./include/common/autoNumLimit.php");
include "./include/common/autoNumLimit.php";

$search = null;
if (isset($_POST['searchMS'])) {
$search = $_POST['searchMS'];
$centreon->historySearch[$url] = $search;
} elseif (isset($_GET['searchMS'])) {
$search = $_GET['searchMS'];
$centreon->historySearch[$url] = $search;
} elseif (isset($centreon->historySearch[$url])) {
$search = $centreon->historySearch[$url];
$search = filter_var(
$_POST['searchMS'] ?? $_GET['searchMS'] ?? null,
FILTER_SANITIZE_STRING
);

if (isset($_POST['searchMS']) || isset($_GET['searchMS'])) {
//initializing filters values
$centreon->historySearch[$url] = array();
$centreon->historySearch[$url]["searchMS"] = $search;
} else {
//restoring saved values
$search = $centreon->historySearch[$url]["searchMS"] ?? null;
}

/*
* Meta Service list
*/
$rq = "SELECT SQL_CALC_FOUND_ROWS * FROM meta_service ";
if ($search) {
$rq .= "WHERE meta_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' " .
$rq .= "WHERE meta_name LIKE '%" . $search . "%' " .
$acl->queryBuilder("AND", "meta_id", $metaStr);
} else {
$rq .= $acl->queryBuilder("WHERE", "meta_id", $metaStr);
}
$rq .= " ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit;

$DBRESULT = $pearDB->query($rq);
$dbResult = $pearDB->query($rq);
$rows = $pearDB->query("SELECT FOUND_ROWS()")->fetchColumn();

include("./include/common/checkPagination.php");
include "./include/common/checkPagination.php";

/*
* Smarty template Init
*/
$tpl = new Smarty();
$tpl = initSmartyTpl($path, $tpl);

/* Access level */
($centreon->user->access->page($p) == 1) ? $lvl_access = 'w' : $lvl_access = 'r';
// Access level
$lvl_access = ($centreon->user->access->page($p) == 1) ? 'w' : 'r';
$tpl->assign('mode_access', $lvl_access);

/*
Expand All @@ -96,28 +99,24 @@
*/
if ($search) {
$rq = "SELECT * FROM meta_service " .
"WHERE meta_name LIKE '%" . htmlentities($search, ENT_QUOTES, "UTF-8") . "%' " .
"WHERE meta_name LIKE '%" . $search . "%' " .
$acl->queryBuilder("AND", "meta_id", $metaStr) .
"ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit;
" ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit;
} else {
$rq = "SELECT * FROM meta_service " .
$acl->queryBuilder("WHERE", "meta_id", $metaStr) .
"ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit;
" ORDER BY meta_name LIMIT " . $num * $limit . ", " . $limit;
}
$DBRESULT = $pearDB->query($rq);
$dbResult = $pearDB->query($rq);

$form = new HTML_QuickFormCustom('select_form', 'GET', "?p=" . $p);

/*
* Different style between each lines
*/
// Different style between each lines
$style = "one";

/*
* Fill a tab with a mutlidimensionnal Array we put in $tpl
*/
// Fill a tab with a multidimensional Array we put in $tpl
$elemArr = array();
for ($i = 0; $ms = $DBRESULT->fetchRow(); $i++) {
for ($i = 0; $ms = $dbResult->fetch(); $i++) {
$moptions = "";
$selectedElements = $form->addElement('checkbox', "select[" . $ms['meta_id'] . "]");
if ($ms["meta_select_mode"] == 1) {
Expand All @@ -130,12 +129,12 @@

if ($ms["meta_activate"]) {
$moptions .= "<a href='main.php?p=" . $p . "&meta_id=" . $ms['meta_id'] . "&o=u&limit=" . $limit .
"&num=" . $num . "&search=" . $search . "'><img src='img/icons/disabled.png' class='ico-14 margin_right' " .
"border='0' alt='" . _("Disabled") . "'></a>&nbsp;&nbsp;";
"&num=" . $num . "&search=" . $search . "'><img src='img/icons/disabled.png' class='ico-14 margin_right' "
. "border='0' alt='" . _("Disabled") . "'></a>&nbsp;&nbsp;";
} else {
$moptions .= "<a href='main.php?p=" . $p . "&meta_id=" . $ms['meta_id'] . "&o=s&limit=" . $limit .
"&num=" . $num . "&search=" . $search . "'><img src='img/icons/enabled.png' class='ico-14 margin_right' " .
"border='0' alt='" . _("Enabled") . "'></a>&nbsp;&nbsp;";
"&num=" . $num . "&search=" . $search . "'><img src='img/icons/enabled.png' class='ico-14 margin_right' "
. "border='0' alt='" . _("Enabled") . "'></a>&nbsp;&nbsp;";
}
$moptions .= "&nbsp;";

Expand All @@ -160,9 +159,7 @@
}
$tpl->assign("elemArr", $elemArr);

/*
* Different messages we put in the template
*/
// Different messages we put in the template
$tpl->assign(
'msg',
array(
Expand All @@ -172,15 +169,13 @@
)
);

/*
* Toolbar select
*/
// Toolbar select
?>
<script type="text/javascript">
function setO(_i) {
document.forms['form'].elements['o'].value = _i;
}
</script>
<script type="text/javascript">
function setO(_i) {
document.forms['form'].elements['o'].value = _i;
}
</script>
<?php

$attrs1 = array(
Expand Down Expand Up @@ -242,9 +237,7 @@ function setO(_i) {
$tpl->assign('limit', $limit);
$tpl->assign('searchMS', $search);

/*
* Apply a template definition
*/
// Apply a template definition
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form->accept($renderer);
$tpl->assign('form', $renderer->toArray());
Expand Down
80 changes: 44 additions & 36 deletions www/include/configuration/configObject/service/listService.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<script type="text/javascript" src="./include/common/javascript/resize_td.js"></script>
<form name='form' method='POST'>
<table class="ajaxOption table">
<tbody>
<tr>
<th>
<h5>{t}Filters{/t}</h5>
<tbody>
<tr>
<th>
<h5>{t}Filters{/t}</h5>
</th>
</tr>
<tr>
Expand All @@ -16,7 +16,6 @@
{/if}
<td><h4>{$Services}</h4></td>
<td><h4>{$ServiceTemplates}</h4></td>

<td><h4>{$ServiceStatus}</h4></td>
</tr>
<tr>
Expand All @@ -29,7 +28,7 @@
<td><select name='template'>{$templateFilter}</select></td>
<td><select name='status'>{$statusFilter}</select></td>
{if (! isset($hostgroupsFilter))}
<td><h4><input type="checkbox" name='statusHostFilter' {$hostStatusChecked}/>{$HostStatus}</h4></td>
<td><h4><input type="checkbox" name='statusHostFilter' {$hostStatusChecked}/>{$HostStatus}</h4></td>
{/if}
<td><input type='submit' name='Search' value='{$Search}' class="btc bt_success" /></td>
</tr>
Expand All @@ -38,11 +37,11 @@
<table class="ToolbarTable table">
<tr class="ToolbarTR">
{if $mode_access == 'w'}
<td>
{$msg.options} {$form.o1.html}<a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a>
</td>
<td>
{$msg.options} {$form.o1.html}<a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a>
</td>
{else}
<td>&nbsp;</td>
<td>&nbsp;</td>
{/if}
<input name="p" value="{$p}" type="hidden" />
{php}
Expand All @@ -52,7 +51,9 @@
</table>
<table class="ListTable">
<tr class="ListHeader">
<td class="ListColHeaderPicker"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/></td>
<td class="ListColHeaderPicker">
<input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/>
</td>
<td class="ListColHeaderLeft">{$headerMenu_name}</td>
<td class="ListColHeaderLeft">{$headerMenu_desc}</td>
<td class="ListColHeaderCenter">{$headerMenu_retry}</td>
Expand All @@ -61,44 +62,51 @@
<td class="ListColHeaderCenter">{$headerMenu_options}</td>
</tr>
{section name=elem loop=$elemArr}
<tr class={$elemArr[elem].MenuClass}>
<td class="ListColPicker">{$elemArr[elem].RowMenu_select}</td>
<td class="ListColLeft">
{if $elemArr[elem].RowMenu_name != "" && $elemArr[elem].RowMenu_icone != ""}
<img src="{$elemArr[elem].RowMenu_icone}" class="ico-18" />
{/if}
<a href="{$elemArr[elem].RowMenu_link}">{$elemArr[elem].RowMenu_name}</a>
</td>
<td class="ListColLeft resizeTitle">
<a href="{$elemArr[elem].RowMenu_link2}">{if $elemArr[elem].RowMenu_sicon != ""}
<img src="{$elemArr[elem].RowMenu_sicon}" class="ico-14 margin_right"/>{/if}{$elemArr[elem].RowMenu_desc}</a>
</td>
<td class="ListColCenter">{$elemArr[elem].RowMenu_retry}</td>
<td class="ListColLeft resizeTitle">{$elemArr[elem].RowMenu_parent}</td>
<td class="ListColCenter"><span class="badge {$elemArr[elem].RowMenu_badge}">{$elemArr[elem].RowMenu_status}</span></td>
<td class="ListColRight" style="white-space: nowrap;">{if $mode_access == 'w' }{$elemArr[elem].RowMenu_options}{else}&nbsp;{/if}</td>
</tr>
<tr class={$elemArr[elem].MenuClass}>
<td class="ListColPicker">{$elemArr[elem].RowMenu_select}</td>
<td class="ListColLeft">
{if $elemArr[elem].RowMenu_name != "" && $elemArr[elem].RowMenu_icone != ""}
<img src="{$elemArr[elem].RowMenu_icone}" class="ico-18" />
{/if}
<a href="{$elemArr[elem].RowMenu_link}">{$elemArr[elem].RowMenu_name}</a>
</td>
<td class="ListColLeft resizeTitle">
<a href="{$elemArr[elem].RowMenu_link2}">
{if $elemArr[elem].RowMenu_sicon != ""}
<img src="{$elemArr[elem].RowMenu_sicon}" class="ico-14 margin_right"/>
{/if}{$elemArr[elem].RowMenu_desc}
</a>
</td>
<td class="ListColCenter">{$elemArr[elem].RowMenu_retry}</td>
<td class="ListColLeft resizeTitle">{$elemArr[elem].RowMenu_parent}</td>
<td class="ListColCenter">
<span class="badge {$elemArr[elem].RowMenu_badge}">{$elemArr[elem].RowMenu_status}</span>
</td>
<td class="ListColRight" style="white-space: nowrap;">
{if $mode_access == 'w' }{$elemArr[elem].RowMenu_options}{else}&nbsp;{/if}
</td>
</tr>
{/section}
</table>
<table class="ToolbarTable ToolbarTR table">
<tr>
{if $mode_access == 'w'}
<td class="Toolbar_TDSelectAction_Bottom">
{$msg.options} {$form.o2.html}
<a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a>
</td>
<td class="Toolbar_TDSelectAction_Bottom">
{$msg.options} {$form.o2.html}
<a href="{$msg.addL}" class="btc bt_success">{$msg.addT}</a>
</td>
{else}
<td>&nbsp;</td>
<td>&nbsp;</td>
{/if}
<input name="p" value="{$p}" type="hidden">
{php}
include('./include/common/pagination.php');
{/php}
</tr>
</table>
<input type='hidden' name='o' id='o' value='42'>
<input type='hidden' id='limit' name='limit' value='{$limit}'>
{$form.hidden}
<input type='hidden' name='o' id='o' value='42'>
<input type='hidden' id='limit' name='limit' value='{$limit}'>
{$form.hidden}
</form>
{literal}
<script type='text/javascript'>
Expand Down
Loading

0 comments on commit 19defc5

Please sign in to comment.