summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f7ee21)
raw | patch | inline | side by side (parent: 6f7ee21)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Dec 2009 11:07:09 +0000 (11:07 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Dec 2009 11:07:09 +0000 (11:07 +0000) |
-Database connection are now optional
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14974 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14974 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/rsyslog/admin/systems/services/rsyslog/class_rSyslogServer.inc | patch | blob | history | |
gosa-plugins/rsyslog/admin/systems/services/rsyslog/rSyslogServer.tpl | patch | blob | history |
diff --git a/gosa-plugins/rsyslog/admin/systems/services/rsyslog/class_rSyslogServer.inc b/gosa-plugins/rsyslog/admin/systems/services/rsyslog/class_rSyslogServer.inc
index 9204611423f96fd2ee136c8eaa17d6db169b4712..74fcdaab0dd18196a92176957e2db0d6e4976e4c 100644 (file)
class rSyslogServer extends goService{
/* This plugin only writes its objectClass */
- var $objectclasses = array("goLogDBServer");
- var $attributes = array("gosaLogDB","goLogAdmin","goLogPassword");
+ var $objectclasses = array("goSyslogServer");
+ var $attributes = array();
+ var $db_attributes = array("gosaLogDB","goLogAdmin","goLogPassword");
var $StatusFlag = "";
/* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goLogDBServer");
+ var $conflicts = array("goSyslogServer");
var $DisplayName = "";
var $dn = NULL;
var $acl;
var $cn = "";
- var $gosaLogDB = "Syslog";
- var $goLogAdmin = "rsyslog";
- var $goLogPassword = "";
- var $view_logged =FALSE;
+ var $use_database = FALSE;
+ var $initial_use_database = FALSE;
+ var $gosaLogDB = "Syslog";
+ var $goLogAdmin = "rsyslog";
+ var $goLogPassword = "";
+ var $view_logged = FALSE;
function rSyslogServer(&$config,$dn)
{
goService::goService($config,$dn);
$this->DisplayName = _("rSyslog");
+ $this->initial_use_database = $this->use_database = isset($this->attrs['objectClass']) &&in_array("goLogDBServer", $this->attrs['objectClass']);
+
+ if($this->use_database){
+ foreach($this->db_attributes as $attr){
+ if(isset($this->attrs[$attr][0])){
+ $this->$attr = $this->attrs[$attr][0];
+ }
+ }
+ }
}
$smarty->assign($name."ACL",$this->getacl($name));
}
- foreach($this->attributes as $attr){
+ foreach($this->db_attributes as $attr){
$smarty->assign($attr,$this->$attr);
}
+ $smarty->assign("use_database" , $this->use_database);
return($smarty->fetch(get_template_path("rSyslogServer.tpl",TRUE,dirname(__FILE__))));
}
function getListEntry()
{
$fields = goService::getListEntry();
- $fields['Message'] = _("rSyslog logging service");
+ $fields['Message'] = _("Logging service");
#$fields['AllowEdit'] = true;
#$fields['AllowStart'] = FALSE;
#$fields['AllowStop'] = FALSE;
function check()
{
$message = plugin::check();
- if (empty($this->goLogAdmin)){
- $message[]= msgPool::required(_("User"));
- }
- if (empty($this->goLogPassword)){
- $message[]= msgPool::required(_("Password"));
- }
- if (empty($this->gosaLogDB)){
- $message[]= msgPool::required(_("Database"));
+ if($this->use_database){
+ if (empty($this->goLogAdmin)){
+ $message[]= msgPool::required(_("User"));
+ }
+ if (empty($this->gosaLogDB)){
+ $message[]= msgPool::required(_("Database"));
+ }
+ if (empty($this->goLogPassword)){
+ $message[]= msgPool::required(_("Password"));
+ }
}
return($message);
}
{
if(isset($_POST['rSyslogServerPosted'])){
plugin::save_object();
+
+ foreach($this->db_attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = get_post($attr);
+ }
+ }
+ $this->use_database = isset($_POST['use_database']);
+ }
+ }
+
+
+ function save()
+ {
+ // Store rSyslog database connection info if enabled.
+ if($this->use_database){
+ $this->attributes = array('gosaLogDB','goLogAdmin','goLogPassword');
+ $this->objectclasses = array('goSyslogServer','goLogDBServer');
+ }else{
+ $this->attributes = array();
+ $this->objectclasses = array('goSyslogServer');
+
+ }
+
+ plugin::save();
+
+ if(!$this->use_database && $this->initial_use_database){
+ $this->attrs['objectClass'] = array_remove_entries(array('goLogDBServer'),$this->attrs['objectClass']);
+ $this->attrs['objectClass'] = array_values($this->attrs['objectClass']);
+ foreach($this->db_attributes as $attr){
+ $this->attrs[$attr] = array();
+ }
}
- }
+
+ /* Check if this is a new entry ... add/modify */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cat($this->dn,array("objectClass"));
+ if($ldap->count()){
+ $ldap->cd($this->dn);
+ $ldap->modify($this->attrs);
+ }else{
+ $ldap->cd($this->dn);
+ $ldap->add($this->attrs);
+ }
+ if($this->initially_was_account){
+ new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ $this->handle_post_events("modify");
+ }else{
+ $this->handle_post_events("add");
+ new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+ }
+ }
+
+
+ /* Remove service */
+ function remove_from_parent()
+ {
+ // Store rSyslog database connection info if enabled.
+ if($this->initial_use_database){
+ $this->attributes = array('gosaLogDB','goLogAdmin','goLogPassword');
+ $this->objectclasses = array('goSyslogServer','goLogDBServer');
+ }else{
+ $this->attributes = array();
+ $this->objectclasses = array('goSyslogServer');
+ }
+
+ goService::remove_from_parent();
+ }
+
/* Return plugin informations for acl handling */
static function plInfo()
diff --git a/gosa-plugins/rsyslog/admin/systems/services/rsyslog/rSyslogServer.tpl b/gosa-plugins/rsyslog/admin/systems/services/rsyslog/rSyslogServer.tpl
index aaa903d8041bc9745f7030698cd5e75fc0894f1a..61f1ab0d197d15946c648c311a1e0e7c9b0c47f1 100644 (file)
-<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}rSyslog logging database{/t}</h2>
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}Syslog logging{/t}</h2>
+
+<br>
+<input type="checkbox" name="use_database" value="1" {if $use_database} checked {/if}
+ onChange="changeState('gosaLogDB'); changeState('goLogAdmin');changeState('goLogPassword');"
+ class="center">
+<b>{t}This server provides a rSyslog mysql database{/t}</b>
<table summary="">
<tr>
<td>{t}Database{/t}{$must}</td>
<td>
{render acl=$gosaLogDBACL}
- <input name="gosaLogDB" id="gosaLogDB" size=30 maxlength=60 value="{$gosaLogDB}">
+ <input name="gosaLogDB" id="gosaLogDB" size=30 maxlength=60 value="{$gosaLogDB}"
+ {if !$use_database} disabled {/if}>
{/render}
</td>
</tr>
<td>{t}Database user{/t}{$must}</td>
<td>
{render acl=$goLogAdminACL}
- <input name="goLogAdmin" id="goLogAdmin" size=30 maxlength=60 value="{$goLogAdmin}">
+ <input name="goLogAdmin" id="goLogAdmin" size=30 maxlength=60 value="{$goLogAdmin}"
+ {if !$use_database} disabled {/if}>
{/render}
</td>
</tr>
<td>{t}Password{/t}{$must}</td>
<td>
{render acl=$goLogPasswordACL}
- <input type="password" name="goLogPassword" id="goLogPassword" size=30 maxlength=60 value="{$goLogPassword}">
+ <input type="password" name="goLogPassword" id="goLogPassword" size=30 maxlength=60 value="{$goLogPassword}"
+ {if !$use_database} disabled {/if}>
{/render}
</td>
</tr>