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 > contacts filters (#7360)
Browse files Browse the repository at this point in the history
* fix(ui): saving configuration > contact users filters
* fix(ui): saving configuration > contact template filters
* fix(ui): saving configuration > contactgroup filters
* fix(ui): saving configuration > timeperiod filters
  • Loading branch information
sc979 committed Apr 3, 2019
1 parent 19defc5 commit 5621cf0
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 195 deletions.
131 changes: 67 additions & 64 deletions www/include/configuration/configObject/contact/listContact.php
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,33 +37,34 @@
exit();
}

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

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

/*
* Create Timeperiod Cache
*/
$tpCache = array("" => "");
$DBRESULT = $pearDB->query("SELECT tp_name, tp_id FROM timeperiod");
while ($data = $DBRESULT->fetchRow()) {
$dbResult = $pearDB->query("SELECT tp_name, tp_id FROM timeperiod");
while ($data = $dbResult->fetch()) {
$tpCache[$data["tp_id"]] = $data["tp_name"];
}
unset($data);
$DBRESULT->closeCursor();
$dbResult->closeCursor();

$search = filter_var(
$_POST['searchC'] ?? $_GET['search'] ?? null,
FILTER_SANITIZE_STRING
);

$clauses = array();
$search = null;
if (isset($_POST['searchC'])) {
$search = $_POST['searchC'];
$centreon->historySearch[$url] = $search;
} elseif (isset($_GET['search'])) {
$search = $_GET['search'];
if (isset($_POST['searchC']) || isset($_GET['search'])) {
$centreon->historySearch[$url] = $search;
} elseif (isset($centreon->historySearch[$url])) {
} else {
$search = $centreon->historySearch[$url];
}

$clauses = array();
if ($search) {
$clauses = array(
'contact_name' => array('LIKE', '%' . $search . '%'),
Expand Down Expand Up @@ -94,21 +95,17 @@
$contacts = $acl->getContactAclConf($aclOptions);
$rows = count($contacts);

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

/*
* Smarty template Init
*/
// Smarty template Init
$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", _("Full Name"));
$tpl->assign("headerMenu_desc", _("Alias / Login"));
$tpl->assign("headerMenu_email", _("Email"));
Expand All @@ -130,9 +127,7 @@

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

/*
* Different style between each lines
*/
// Different style between each lines
$style = "one";
$contactTypeIcone = array(
1 => "./img/icons/admin.png",
Expand All @@ -145,13 +140,17 @@
3 => _("This is a contact template.")
);

/*
* Fill a tab with a mutlidimensionnal Array we put in $tpl
*/
// Fill a tab with a multidimensional Array we put in $tpl
$elemArr = array();
foreach ($contacts as $contact) {
if ($centreon->user->get_id() == $contact['contact_id']) {
$selectedElements = $form->addElement('checkbox', "select[" . $contact['contact_id'] . "]", '', '', 'disabled');
$selectedElements = $form->addElement(
'checkbox',
"select[" . $contact['contact_id'] . "]",
'',
'',
'disabled'
);
} else {
$selectedElements = $form->addElement('checkbox', "select[" . $contact['contact_id'] . "]");
}
Expand Down Expand Up @@ -229,38 +228,38 @@
}
$tpl->assign("elemArr", $elemArr);

/*
* Different messages we put in the template
*/
$tpl->assign('msg', array(
"addL" => "main.php?p=" . $p . "&o=a",
"addT" => _("Add"),
"ldap_importL" => "main.php?p=" . $p . "&o=li",
"ldap_importT" => _("LDAP Import"),
"view_notif" => _("View contact notifications")
));
// Different messages we put in the template
$tpl->assign(
'msg',
array(
"addL" => "main.php?p=" . $p . "&o=a",
"addT" => _("Add"),
"ldap_importL" => "main.php?p=" . $p . "&o=li",
"ldap_importT" => _("LDAP Import"),
"view_notif" => _("View contact notifications")
)
);

# Display import ldap users button if ldap is configured
$query = "SELECT count(ar_id) as count_ldap "
. "FROM auth_ressource ";
$res = $pearDB->query($query);
$row = $res->fetchRow();
// Display import ldap users button if ldap is configured
$res = $pearDB->query(
"SELECT count(ar_id) as count_ldap " .
"FROM auth_ressource "
);
$row = $res->fetch();
if ($row['count_ldap'] > 0) {
$tpl->assign('ldap', '1');
}

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

/* Manage options */
// Manage options
foreach (array('o1', 'o2') as $option) {
$attrs1 = array(
'onchange' => "javascript: " .
Expand All @@ -278,14 +277,20 @@ 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"),
"mc" => _("Massive Change"),
"ms" => _("Enable"),
"mu" => _("Disable")
), $attrs1);
$form->addElement(
'select',
$option,
null,
array(
null => _("More actions..."),
"m" => _("Duplicate"),
"d" => _("Delete"),
"mc" => _("Massive Change"),
"ms" => _("Enable"),
"mu" => _("Disable")
),
$attrs1
);
$form->setDefaults(array($option => null));

$o1 = $form->getElement($option);
Expand All @@ -296,9 +301,7 @@ function setO(_i) {
$tpl->assign('limit', $limit);
$tpl->assign('searchC', $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
Loading

0 comments on commit 5621cf0

Please sign in to comment.