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

Commit

Permalink
fix(TA): status disabled is chosen by default + style and psr2
Browse files Browse the repository at this point in the history
  • Loading branch information
sc979 committed Apr 3, 2019
1 parent 05532ce commit 598e696
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 68 deletions.
26 changes: 8 additions & 18 deletions www/include/configuration/configObject/host/listHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@

// $status values : 1 = enabled, 0 = disabled, -1 = both
$status = filter_var(
$_POST["status"] ?? $centreon->historySearch[$url]["status"] ?? -1,
$_POST["status"] ?? -1,
FILTER_VALIDATE_INT
);

if (isset($_POST['searchH']) || isset($_GET['searchB'])) {
if (isset($_POST['searchH']) || isset($_GET)) {
//saving chosen filters values
$centreon->historySearch[$url] = array();
$centreon->historySearch[$url]["searchH"] = $search;
Expand Down Expand Up @@ -141,16 +141,12 @@
$templateFROM = '';
$templateWHERE = '';
}
/*
* Smarty template Init
*/

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

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

$tpl->assign('mode_access', $lvl_access);

Expand Down Expand Up @@ -183,24 +179,17 @@
'SELECT nhr.host_host_id, nhr.nagios_server_id FROM ns_host_relation nhr'
);
while ($relation = $DBRESULT->fetchRow()) {
$tab_relation[$relation['host_host_id']] =
$nagios_server[$relation['nagios_server_id']];

$tab_relation[$relation['host_host_id']] = $nagios_server[$relation['nagios_server_id']];
$tab_relation_id[$relation['host_host_id']] = $relation['nagios_server_id'];
}
$DBRESULT->closeCursor();

// Init Formulary

// Init Form
$form = new HTML_QuickFormCustom('select_form', 'POST', "?p={$p}");

// Different style between each lines
$style = 'one';

/*
Fill a tab with a multidimensional Array we put in $tpl
*/

/*
* Select hosts
*/
Expand Down Expand Up @@ -268,6 +257,7 @@

$search = tidySearchKey($search, $advanced_search);

// Fill a tab with a multidimensional Array we put in $tpl
$elemArr = array();
$search = str_replace('\_', "_", $search);
for ($i = 0; $host = $DBRESULT->fetch(); $i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
exit();
}

include_once("./class/centreonUtils.class.php");
include("./include/common/autoNumLimit.php");
require_once "./class/centreonUtils.class.php";
include "./include/common/autoNumLimit.php";

/*
* Search
Expand Down Expand Up @@ -75,7 +75,7 @@
$search = tidySearchKey($search, $advanced_search);
$rows = $pearDB->query("SELECT FOUND_ROWS()")->fetchColumn();

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

// Smarty template Init
$tpl = new Smarty();
Expand Down Expand Up @@ -131,12 +131,13 @@
$aclFrom = ", $aclDbName.centreon_acl acl ";
$aclCond = " AND h.host_id = acl.host_id AND acl.group_id IN (" . $acl->getAccessGroupsString() . ") ";
}
$rq = "SELECT h.host_id, h.host_activate
FROM hostcategories_relation hcr, host h $aclFrom
WHERE hostcategories_hc_id = '" . $hc['hc_id'] . "'
AND h.host_id = hcr.host_host_id $aclCond
AND h.host_register = '1' ";
$DBRESULT2 = $pearDB->query($rq);
$DBRESULT2 = $pearDB->query(
"SELECT h.host_id, h.host_activate " .
"FROM hostcategories_relation hcr, host h " . $aclFrom .
" WHERE hostcategories_hc_id = '" . $hc['hc_id'] . "'" .
" AND h.host_id = hcr.host_host_id " . $aclCond .
" AND h.host_register = '1' "
);
$nbrhostActArr = array();
$nbrhostDeactArr = array();
while ($row = $DBRESULT2->fetch()) {
Expand Down Expand Up @@ -170,7 +171,11 @@
// Different messages we put in the template
$tpl->assign(
'msg',
array("addL" => "main.php?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?"))
array(
"addL" => "main.php?p=" . $p . "&o=a",
"addT" => _("Add"),
"delConfirm" => _("Do you confirm the deletion ?")
)
);

?>
Expand Down Expand Up @@ -198,13 +203,19 @@ function setO(_i) {
" setO(this.form.elements['" . $option . "'].value); submit();} " .
"this.form.elements['" . $option . "'].selectedIndex = 0"
);
$form->addElement('select', $option, null, array(
null => _("More actions..."),
"m" => _("Duplicate"),
"d" => _("Delete"),
"ms" => _("Enable"),
"mu" => _("Disable")
), $attrs1);
$form->addElement(
'select',
$option,
null,
array(
null => _("More actions..."),
"m" => _("Duplicate"),
"d" => _("Delete"),
"ms" => _("Enable"),
"mu" => _("Disable")
),
$attrs1
);
$form->setDefaults(array($option => null));
$o1 = $form->getElement($option);
$o1->setValue(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
exit();
}

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

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

// Init Host Method
$host_method = new CentreonHost($pearDB);
Expand Down
47 changes: 16 additions & 31 deletions www/include/configuration/configObject/hostgroup/listHostGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
exit();
}

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

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

/*
* Object init
Expand Down Expand Up @@ -80,47 +80,37 @@
$tpl = new Smarty();
$tpl = initSmartyTpl($path, $tpl);

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

/*
* start header menu
*/
// start header menu
$tpl->assign("headerMenu_name", _("Name"));
$tpl->assign("headerMenu_desc", _("Alias"));
$tpl->assign("headerMenu_status", _("Status"));
$tpl->assign("headerMenu_hostAct", _("Enabled Hosts"));
$tpl->assign("headerMenu_hostDeact", _("Disabled Hosts"));
$tpl->assign("headerMenu_options", _("Options"));

/*
* Hostgroup list
*/
$rq = "SELECT SQL_CALC_FOUND_ROWS hg_id, hg_name, hg_alias, hg_activate, hg_icon_image
FROM hostgroup
WHERE {$searchFilterQuery} hg_id NOT IN (SELECT hg_child_id FROM hostgroup_hg_relation) " .
// Hostgroup list
$rq = "SELECT SQL_CALC_FOUND_ROWS hg_id, hg_name, hg_alias, hg_activate, hg_icon_image " .
"FROM hostgroup " .
"WHERE {$searchFilterQuery} hg_id NOT IN (SELECT hg_child_id FROM hostgroup_hg_relation) " .
$acl->queryBuilder('AND', 'hg_id', $hgString) .
" ORDER BY hg_name LIMIT " . $num * $limit . ", " . $limit;
$DBRESULT = $pearDB->query($rq, $mainQueryParameters);

/*
* Pagination
*/
// Pagination
$rows = $pearDB->query("SELECT FOUND_ROWS()")->fetchColumn();
include("./include/common/checkPagination.php");
require_once "./include/common/checkPagination.php";

$search = tidySearchKey($search, $advanced_search);

$form = new HTML_QuickFormCustom('select_form', 'POST', "?p=" . $p);
/*
* Different style between each lines
*/
// Different style between each lines
$style = "one";

/*
* Fill a tab with a multidimensional Array we put in $tpl
*/
// Fill a tab with a multidimensional Array we put in $tpl
$elemArr = array();
for ($i = 0; $hg = $DBRESULT->fetch(); $i++) {
$selectedElements = $form->addElement('checkbox', "select[" . $hg['hg_id'] . "]");
Expand Down Expand Up @@ -193,16 +183,13 @@
"RowMenu_hostDeact" => $nbrhostDeact,
"RowMenu_options" => $moptions
);
/*
* Switch color line
*/

// Switch color line
$style != "two" ? $style = "two" : $style = "one";
}
$tpl->assign("elemArr", $elemArr);

/*
* Different messages we put in the template
*/
// Different messages put in the template
$tpl->assign(
'msg',
array(
Expand Down Expand Up @@ -253,9 +240,7 @@ function setO(_i) {
$tpl->assign('searchHg', $search);
$tpl->assign('limit', $limit);

/*
* 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

0 comments on commit 598e696

Please sign in to comment.