From ef49666ee3221a567900652875dfd8ed2705ab1c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 3 Dec 2015 16:13:49 +0100 Subject: [PATCH] Sync rule: allow zones and endpoints --- application/forms/SyncRuleForm.php | 26 ++++++++++++++------------ schema/mysql-changes/upgrade_51.sql | 2 ++ schema/mysql.sql | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 schema/mysql-changes/upgrade_51.sql diff --git a/application/forms/SyncRuleForm.php b/application/forms/SyncRuleForm.php index eaff0202..e29f148e 100644 --- a/application/forms/SyncRuleForm.php +++ b/application/forms/SyncRuleForm.php @@ -9,6 +9,19 @@ class SyncRuleForm extends DirectorObjectForm { public function setup() { + $availableTypes = array( + 'endpoint' => $this->translate('Endpoint'), + 'host' => $this->translate('Host'), + 'service' => $this->translate('Service'), + 'user' => $this->translate('User'), + 'hostgroup' => $this->translate('Hostgroup'), + 'servicegroup' => $this->translate('Servicegroup'), + 'usergroup' => $this->translate('Usergroup'), + 'datalistEntry' => $this->translate('Datalist entry'), + 'zone' => $this->translate('Zone'), + ); + asort($availableTypes); + $this->addElement('text', 'rule_name', array( 'label' => $this->translate('Rule name'), 'description' => $this->translate('Please provide a rule name'), @@ -19,18 +32,7 @@ class SyncRuleForm extends DirectorObjectForm 'label' => $this->translate('Object Type'), 'description' => $this->translate('Choose a object type'), 'required' => true, - 'multiOptions' => $this->optionalEnum(array( - 'host' => $this->translate('Host'), - 'host_template' => $this->translate('Host Template'), - 'service' => $this->translate('Service'), - 'service_template' => $this->translate('Service Template'), - 'user' => $this->translate('User'), - 'user_template' => $this->translate('User Template'), - 'hostgroup' => $this->translate('Hostgroup'), - 'servicegroup' => $this->translate('Servicegroup'), - 'usergroup' => $this->translate('Usergroup'), - 'datalistEntry' => $this->translate('Datalist entry'), - )) + 'multiOptions' => $this->optionalEnum($availableTypes) )); $this->addElement('select', 'update_policy', array( diff --git a/schema/mysql-changes/upgrade_51.sql b/schema/mysql-changes/upgrade_51.sql new file mode 100644 index 00000000..13df6d57 --- /dev/null +++ b/schema/mysql-changes/upgrade_51.sql @@ -0,0 +1,2 @@ +ALTER TABLE sync_rule MODIFY object_type enum('host', 'host_template', 'service', 'service_template', 'command', 'command_template', 'user', 'user_template', 'hostgroup', 'servicegroup', 'usergroup', 'datalistEntry', 'endpoint', 'zone') NOT NULL; + diff --git a/schema/mysql.sql b/schema/mysql.sql index e4a9344c..a82eebe5 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -948,7 +948,7 @@ CREATE TABLE imported_row_property ( CREATE TABLE sync_rule ( id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, rule_name VARCHAR(255) NOT NULL, - object_type enum('host', 'host_template', 'service', 'service_template', 'command', 'command_template', 'user', 'user_template', 'hostgroup', 'servicegroup', 'usergroup', 'datalistEntry') NOT NULL, + object_type enum('host', 'host_template', 'service', 'service_template', 'command', 'command_template', 'user', 'user_template', 'hostgroup', 'servicegroup', 'usergroup', 'datalistEntry', 'endpoint', 'zone') NOT NULL, update_policy ENUM('merge', 'override', 'ignore') NOT NULL, purge_existing ENUM('y', 'n') NOT NULL DEFAULT 'n', filter_expression TEXT DEFAULT NULL,