Private GIT

Skip to content
Snippets Groups Projects
Commit 6e7ef074 authored by Julien Mathis's avatar Julien Mathis
Browse files

Hostgroup configuration page is now OK

parent e7966f5b
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ require_once __DIR__.'/centreonFormSelect2.class.php';
class CentreonForm
{
private $form;
public $form;
private $tpl;
private $renderer;
private $attibutes;
......@@ -56,7 +56,7 @@ class CentreonForm
$this->helpData = array();
$this->path = $path;
$this->o = $o;
$this->applyFilter('__ALL__', array('this', 'myTrim'));
//$this->applyFilter('__ALL__', array('this', 'myTrim'));
$this->setRequiredNote();
$this->setFormAttributes();
$this->s2Config = new CentreonFormSelect2();
......@@ -64,6 +64,11 @@ class CentreonForm
$this->getHelpData();
}
public function getForm()
{
return $this->form;
}
private function setFormAttributes()
{
$this->attibutes['text'] = array("size" => "30");
......@@ -204,7 +209,6 @@ class CentreonForm
public function validate()
{
print "Validate";
return $this->form->validate();
}
......
......@@ -56,6 +56,7 @@ function testHostGroupExistence($name = null)
{
global $pearDB, $form, $centreon;
$id = null;
if (isset($form)) {
$id = $form->getSubmitValue('hg_id');
}
......@@ -216,7 +217,7 @@ function updateHostGroupInDB($hg_id = null, $ret = array(), $increment = false)
function insertHostGroup($ret = array())
{
global $form, $pearDB, $centreon, $is_admin;
global $pearDB, $form, $centreon, $is_admin;
if (!count($ret)) {
$ret = $form->getSubmitValues();
......
......@@ -78,7 +78,7 @@ $obj->addInputText('hg_alias', _("Alias"));
/*
* Hosts Selection
*/
$obj->addSelect2('hg_hosts', _("Linked Hosts"), 'hostgroup', array('object' => 'centreon_configuration_host', 'action' => 'defaultValues', 'target' => 'hostgroups', 'field' => 'hg_hosts', 'id' => $hg_id));
$obj->addSelect2('hg_hosts', _("Linked Hosts"), 'host', array('object' => 'centreon_configuration_host', 'action' => 'defaultValues', 'target' => 'hostgroups', 'field' => 'hg_hosts', 'id' => $hg_id));
/*
* Extended information
......@@ -114,7 +114,10 @@ $obj->registerRule('exist', 'callback', 'testHostGroupExistence');
$obj->addRule('hg_name', _("Compulsory Name"), 'required');
$obj->addRule('hg_alias', _("Compulsory Alias"), 'required');
if ($o == "a") {
$obj->addRule('hg_name', _("Name is already in use"), 'exist');
}
if ($o == "w") {
/*
......@@ -142,14 +145,14 @@ if ($o == "w") {
$valid = false;
if ($obj->validate()) {
$hgObj = $obj->getElement('hg_id');
$form = $obj->getForm();
if ($obj->getSubmitValue("submitA")) {
$hgObj->setValue(insertHostGroupInDB($obj->getSubmitValues()));
insertHostGroupInDB();
} elseif ($obj->getSubmitValue("submitC")) {
updateHostGroupInDB($hgObj->getValue());
$hg_id = $obj->getElement('hg_id')->getValue();
updateHostGroupInDB($hg_id, $obj->getSubmitValues());
}
$o = null;
$hgObj = $obj->getElement('hg_id');
$valid = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment