index a7d3a53b6a0e17e7001f2bde8a2ab0560a667325..92c87511716d8da745d968cd700fa5d413b3c131 100644 (file)
--- a/include/class_config.inc
+++ b/include/class_config.inc
/* Configuration data */
var $data= array( 'TABS' => array(), 'LOCATIONS' => array(), 'SERVERS' => array(),
/* 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= "";
'MENU' => array(), 'SERVICE' => array());
var $basedir= "";
var $idepartments= array();
var $adepartments= array();
var $tdepartments= array();
var $idepartments= array();
var $adepartments= array();
var $tdepartments= array();
+ var $filename = "";
+ var $last_modified = 0;
function config($filename, $basedir= "")
{
function config($filename, $basedir= "")
{
}
}
}
}
+
+ 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)
{
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))){
$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_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;
}
}
exit;
}
}
}
break;
}
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);
/* Load main parameters */
case 'MAIN':
$this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs);
function load_servers ()
{
/* Only perform actions if current is set */
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']);
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']);
/* Get kerberos server. FIXME: only one is supported currently */
$ldap->cd ($this->current['BASE']);
return FALSE;
}
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:
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: