From: guiguidoc Date: Tue, 20 Sep 2005 10:08:17 +0000 (+0000) Subject: Nagios Tab in user info. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=779459dbc8f08af7dff822371360c07b7995cda0;p=gosa.git Nagios Tab in user info. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1401 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/personal/nagios/class_nagiosAccount.inc b/plugins/personal/nagios/class_nagiosAccount.inc new file mode 100644 index 000000000..0d668cab0 --- /dev/null +++ b/plugins/personal/nagios/class_nagiosAccount.inc @@ -0,0 +1,166 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* These contain attributes to be loaded. We're not doing an LDAP plugin currently, so we don't + care... */ + var $attributes= array("NagiosAlias","NagiosPager","NagiosMail","HostNotificationPeriod","ServiceNotificationPeriod","HostNotificationCommands","ServiceNotificationCommands", + "HostNotificationOptions", + "ServiceNotificationOptions", + "HostNotificationPeriod", + "ServiceNotificationPeriod", + "AuthorizedAllHosts", + "AuthorizedAllServices", + "AuthorizedSystemCommands", + "AuthorizedAllHostCommands", + "AuthorizedAllServiceCommands", + "AuthorizedConfigurationInformation", + "AuthorizedSystemInformation"); + var $objectclasses= array("nagiosContact"); + + /* The constructor just saves a copy of the config. You may add what ever you need. */ + function nagiosAccount ($config, $dn= NULL) + { + /* Include config object */ + $this->config= $config; + plugin::plugin ($config, $dn); + $this->initially_was_account= $this->is_account; +} + + /* Execute is the function all plugins need. It fills the plugin with life and produces the output. */ + function execute() + { + $display= ""; + /* Use the smarty templating engine here... */ + $smarty= get_smarty(); + + //echo "
";print_r($_POST);echo "
"; + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + /* Do we represent a valid account? */ + if (!$this->is_account && $this->parent == NULL){ + $display= "\"\"src=\"images/stop.png\" ". + _("This account has no nagios extensions.").""; + $display.= back_to_main(); + return ($display); + } + /* Load attributes */ + foreach($this->attributes as $val){ + $smarty->assign("$val", $this->$val); + $smarty->assign($val."ACL", chkacl($this->acl, "$val")); + } + + if ($this->is_account){ + $smarty->assign("nagiosAuth","checked"); + $smarty->assign("nagiosContact","checked"); + } + + /* Show tab dialog headers */ + if ($this->parent != NULL){ + if ($this->is_account){ + $display= $this->show_header(_("Remove nagios account"), + _("This account has nagios features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_header(_("Create nagios account"), _("This account has nagios features disabled. You can enable them by clicking below.")); + return($display); + } + } + $display.= $smarty->fetch (get_template_path('nagios.tpl', TRUE, dirname(__FILE__))); + //echo "
";print_r($_POST);echo "
"; + return ($display); + } + /* Save to LDAP */ +function save() +{ + /* Load uid and gid of this 'dn' */ + $ldap= $this->config->get_ldap_link(); + $ldap->cat($this->dn); + $tmp= $ldap->fetch(); + + plugin::save(); + + //nagiosContact + //ugly code but i will correct this after :) + + if(isset($_POST['NagiosAlias']))$this->attrs['NagiosAlias']=$_POST['NagiosAlias']; + if(isset($_POST['NagiosPager']))$this->attrs['NagiosAlias']=$_POST['NagiosAlias']; + if(isset($_POST['NagiosMail']))$this->attrs['NagiosMail']=$_POST['NagiosMail']; + if(isset($_POST['ServiceNotificationPeriod']))$this->attrs['ServiceNotificationPeriod']=$_POST['ServiceNotificationPeriod']; + if(isset($_POST['HostNotificationPeriod']))$this->attrs['HostNotificationPeriod']=$_POST['HostNotificationPeriod']; + if(isset($_POST['ServiceNotificationOptions']))$this->attrs['ServiceNotificationOptions']=$_POST['ServiceNotificationOptions']; + if(isset($_POST['HostNotificationOptions']))$this->attrs['HostNotificationOptions']=$_POST['HostNotificationOptions']; + if(isset($_POST['ServiceNotificationCommands']))$this->attrs['ServiceNotificationCommands']=$_POST['ServiceNotificationCommands']; + if(isset($_POST['HostNotificationCommands']))$this->attrs['HostNotificationCommands']=$_POST['HostNotificationCommands']; + + //nagiosAuth + if(isset($_POST['AuthorizedSystemInformation']))$this->attrs['AuthorizedSystemInformation']="checked";else $this->attrs['AuthorizedSystemInformation']="unchecked"; + if(isset($_POST['AuthorizedConfigurationInformation']))$this->attrs['AuthorizedConfigurationInformation']="checked";else $this->attrs['AuthorizedConfigurationInformation']="unchecked"; + if(isset($_POST['AuthorizedSystemCommands']))$this->attrs['AuthorizedSystemCommands']="checked";else $this->attrs['AuthorizedSystemCommands']="unchecked"; + if(isset($_POST['AuthorizedAllServices']))$this->attrs['AuthorizedAllServices']="checked";else $this->attrs['AuthorizedAllServices']="unchecked"; + if(isset($_POST['AuthorizedAllHosts']))$this->attrs['AuthorizedAllHosts']="checked";else $this->attrs['AuthorizedAllHosts']="unchecked"; + if(isset($_POST['AuthorizedAllServiceCommands']))$this->attrs['AuthorizedAllServiceCommands']="checked";else $this->attrs['AuthorizedAllServiceCommands']="unchecked"; + if(isset($_POST['AuthorizedAllHostCommands']))$this->attrs['AuthorizedAllHostCommands']="checked";else $this->attrs['AuthorizedAllHostCommands']="unchecked"; + + /* Write back to ldap */ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + if ($this->initially_was_account == $this->is_account){ + if ($this->is_modified){ + $this->handle_post_events("modify"); + } + } else { + $this->handle_post_events("add"); + } + +} + +function save_object() +{ + + if (!$this->is_account && ($_POST['nagiosAuth'] == "B" || $_POST['nagiosContact'] == "B")) { + $this->is_account= TRUE; + } + else { + $this->is_account= FALSE; + } + plugin::save_object(); +} + +function remove_from_parent() +{ + /* Cancel if there's nothing to do here */ + if (!$this->initially_was_account){ + return; + } + + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + + $ldap->cd($this->dn); + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, + $this->attributes, "Save"); + $ldap->modify($this->attrs); + show_ldap_error($ldap->get_error()); + + /* Optionally execute a command after we're done */ + $this->handle_post_events('remove'); +} +} +?> \ No newline at end of file diff --git a/plugins/personal/nagios/nagios.tpl b/plugins/personal/nagios/nagios.tpl new file mode 100644 index 000000000..1ffb10ecf --- /dev/null +++ b/plugins/personal/nagios/nagios.tpl @@ -0,0 +1,42 @@ + + +

{t}Nagios Contact{/t}

+ + + + + + + + + + + + + + + + + + + + +
nagios alias
nagios email
nagios pager

service_notification_periodhost_notification_options
service_notification_optionshost_notification_period
service_notification_commandshost_notification_commands
+ +
+

{t}Nagios authorisation{/t}

+ +authorized_for_system_information
+ +authorized_for_configuration_information
+ +authorized_for_system_commands
+ +authorized_for_all_services
+ +authorized_for_all_hosts
+ +authorized_for_all_service_commands
+ +authorized_for_all_host_commands
+