X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_config.inc;h=92c87511716d8da745d968cd700fa5d413b3c131;hb=382443db9d291ebe40f97a94534a0913f7c0a6ef;hp=ca4d376ec23c2d8d3952965ff5620519e3dc2754;hpb=04d9837e72728c01a0449760b158bd8616065d84;p=gosa.git diff --git a/include/class_config.inc b/include/class_config.inc index ca4d376ec..92c875117 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -38,7 +38,7 @@ class config { /* Configuration data */ var $data= array( 'TABS' => array(), 'LOCATIONS' => array(), 'SERVERS' => array(), - 'MAIN' => array( 'LANGUAGES' => array(), 'FAXFORMATS' => array() ), + 'MAIN' => array(), 'MENU' => array(), 'SERVICE' => array()); var $basedir= ""; @@ -47,6 +47,8 @@ class config { var $idepartments= array(); var $adepartments= array(); var $tdepartments= array(); + var $filename = ""; + var $last_modified = 0; function config($filename, $basedir= "") { @@ -62,16 +64,47 @@ class config { } } + + function check_and_reload() + { + if($this->filename != "" && filemtime($this->filename) != $this->last_modified){ + + $this->config_found= FALSE; + $this->tags= array(); + $this->level= 0; + $this->gpc= 0; + $this->section= ""; + $this->currentLocation= ""; + + $this->parser = xml_parser_create(); + xml_set_object($this->parser, $this); + xml_set_element_handler($this->parser, "tag_open", "tag_close"); + $this->parse($this->filename); + if(isset($_SESSION['plist'])){ + unset($_SESSION['plist']); + } + if(isset($_SESSION['plug'])){ + unset($_SESSION['plug']); + } + if(isset($_GET['plug'])){ + unset($_GET['plug']); + } + } + } + + function parse($filename) { + $this->last_modified = filemtime($filename); + $this->filename = $filename; $fh= fopen($filename, "r"); $xmldata= fread($fh, 100000); fclose($fh); if(!xml_parse($this->parser, chop($xmldata))){ - print_red(sprintf(_("XML error in gosa.conf: %s at line %d"), + $msg = sprintf(_("XML error in gosa.conf: %s at line %d"), xml_error_string(xml_get_error_code($this->parser)), - xml_get_current_line_number($this->parser))); - echo $_SESSION['errors']; + xml_get_current_line_number($this->parser)); + msg_dialog::display(_("Config file parsing"), $msg, FATAL_ERROR_DIALOG); exit; } } @@ -143,23 +176,6 @@ class config { } break; - /* Handle language */ - case 'LANGUAGE': - if ($this->tags[$this->level-2] == 'MAIN'){ - /* Add languages */ - $this->data['MAIN']['LANGUAGES'][$attrs['NAME']]= - $attrs['TAG']; - } - break; - - /* Handle faxformat */ - case 'FAXFORMAT': - if ($this->tags[$this->level-2] == 'MAIN'){ - /* Add fax formats */ - $this->data['MAIN']['FAXFORMATS'][]= $attrs['TYPE']; - } - break; - /* Load main parameters */ case 'MAIN': $this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs); @@ -317,26 +333,41 @@ class config { function load_servers () { /* Only perform actions if current is set */ - if ($this->current == NULL){ + if ($this->current === NULL){ return; } /* Fill imap servers */ $ldap= $this->get_ldap_link(); $ldap->cd ($this->current['BASE']); - $ldap->search ("(objectClass=goImapServer)"); + if (!isset($this->current['MAILMETHOD'])){ + $this->current['MAILMETHOD']= ""; + } + if ($this->current['MAILMETHOD'] == ""){ + $ldap->search ("(objectClass=goMailServer)", array('cn')); + $this->data['SERVERS']['IMAP']= array(); + error_reporting(0); + while ($attrs= $ldap->fetch()){ + $name= $attrs['cn'][0]; + $this->data['SERVERS']['IMAP'][$name]= $name; + } + error_reporting(E_ALL); + } else { + $ldap->search ("(objectClass=goImapServer)", array('goImapName', 'goImapConnect', 'goImapAdmin', 'goImapPassword', + 'goImapSieveServer', 'goImapSievePort')); - $this->data['SERVERS']['IMAP']= array(); - error_reporting(0); - while ($attrs= $ldap->fetch()){ - $name= $attrs['goImapName'][0]; - $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0], - "admin" => $attrs['goImapAdmin'][0], - "password" => $attrs['goImapPassword'][0], - "sieve_server" => $attrs['goImapSieveServer'][0], - "sieve_port" => $attrs['goImapSievePort'][0]); + $this->data['SERVERS']['IMAP']= array(); + error_reporting(0); + while ($attrs= $ldap->fetch()){ + $name= $attrs['goImapName'][0]; + $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0], + "admin" => $attrs['goImapAdmin'][0], + "password" => $attrs['goImapPassword'][0], + "sieve_server" => $attrs['goImapSieveServer'][0], + "sieve_port" => $attrs['goImapSievePort'][0]); + } + error_reporting(E_ALL); } - error_reporting(E_ALL); /* Get kerberos server. FIXME: only one is supported currently */ $ldap->cd ($this->current['BASE']); @@ -437,13 +468,14 @@ class config { $ldap->cd ($this->current['BASE']); $ldap->search ("(objectClass=gosaLogServer)"); if ($ldap->count()){ - $attrs= $ldap->fetch(); + while($attrs= $ldap->fetch()){ $this->data['SERVERS']['LOGGING'][$attrs['cn'][0]]= array( 'DN' => $attrs['dn'], 'USER' => $attrs['goLogDBUser'][0], 'DB' => $attrs['goLogDB'][0], 'PWD' => $attrs['goLogDBPassword'][0]); + } } @@ -759,6 +791,60 @@ class config { return FALSE; } + + function __search(&$arr, $name, $return) + { + $return= strtoupper($return); + if (is_array($arr)){ + foreach ($arr as &$a){ + if (isset($a['CLASS']) && strcasecmp($name, $a['CLASS']) == 0){ + return(isset($a[$return])?$a[$return]:""); + } else { + $res= $this->__search ($a, $name, $return); + if ($res != ""){ + return $res; + } + } + } + } + return (""); + } + + + function search($class, $value, $categories= "") + { + if (is_array($categories)){ + foreach ($categories as $category){ + $res= $this->__search($this->data[strtoupper($category)], $class, $value); + if ($res != ""){ + return $res; + } + } + } else { + if ($categories == "") { + return $this->__search($this->data, $class, $value); + } else { + return $this->__search($this->data[strtoupper($categories)], $class, $value); + } + } + + return (""); + } + + + /* On debian systems the session files are deleted with + * a cronjob, which detects all files older than specified + * in php.ini:'session.gc_maxlifetime' and removes them. + * This function checks if the gosa.conf value matches the range + * defined by session.gc_maxlifetime. + */ + function check_session_lifetime() + { + $cfg_lifetime = $this->data['MAIN']['SESSION_LIFETIME']; + $ini_lifetime = ini_get('session.gc_maxlifetime'); + $deb_system = file_exists('/etc/debian_version'); + return(!($deb_system && ($ini_lifetime < $cfg_lifetime))); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: