2001-07-30 17:59:25 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-01-27 21:49:25 +01:00
|
|
|
* eGroupWare - Setup *
|
|
|
|
* http://www.egroupware.org *
|
2001-07-30 17:59:25 +02:00
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
|
|
|
'noheader' => True,
|
|
|
|
'nonavbar' => True,
|
|
|
|
'currentapp' => 'home',
|
|
|
|
'noapi' => True
|
|
|
|
));
|
2001-07-30 17:59:25 +02:00
|
|
|
include('./inc/functions.inc.php');
|
2001-12-18 03:20:31 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
Authorize the user to use setup app and load the database
|
|
|
|
Does not return unless user is authorized
|
|
|
|
*/
|
2005-03-04 13:40:28 +01:00
|
|
|
if(!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
|
2001-12-18 03:20:31 +01:00
|
|
|
{
|
|
|
|
Header('Location: index.php');
|
|
|
|
exit;
|
|
|
|
}
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
2002-08-12 01:54:58 +02:00
|
|
|
$setup_tpl = CreateObject('setup.Template',$tpl_root);
|
2003-08-28 16:31:11 +02:00
|
|
|
|
2001-07-30 17:59:25 +02:00
|
|
|
$setup_tpl->set_file(array(
|
|
|
|
'T_head' => 'head.tpl',
|
|
|
|
'T_footer' => 'footer.tpl',
|
|
|
|
'T_alert_msg' => 'msg_alert_msg.tpl',
|
|
|
|
'T_config_pre_script' => 'config_pre_script.tpl',
|
|
|
|
'T_config_post_script' => 'config_post_script.tpl'
|
|
|
|
));
|
|
|
|
|
2001-11-15 00:17:27 +01:00
|
|
|
/* Following to ensure windows file paths are saved correctly */
|
|
|
|
set_magic_quotes_runtime(0);
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->loaddb();
|
2001-07-30 17:59:25 +02:00
|
|
|
|
|
|
|
/* Check api version, use correct table */
|
2005-03-04 13:40:28 +01:00
|
|
|
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions();
|
2003-08-28 16:31:11 +02:00
|
|
|
|
2003-10-04 15:24:34 +02:00
|
|
|
$newsettings = $_POST['newsettings'];
|
2003-08-28 16:31:11 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
if(@get_var('submit',Array('POST')) && @$newsettings)
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2004-11-28 19:38:50 +01:00
|
|
|
/* Load hook file with functions to validate each config (one/none/all) */
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->hook('config_validate','setup');
|
2004-11-28 19:38:50 +01:00
|
|
|
|
2002-08-14 01:39:39 +02:00
|
|
|
$datetime = CreateObject('phpgwapi.datetime');
|
2003-12-10 12:45:03 +01:00
|
|
|
switch((int)$newsettings['daytime_port'])
|
2002-08-14 01:39:39 +02:00
|
|
|
{
|
|
|
|
case 13:
|
|
|
|
$newsettings['tz_offset'] = $datetime->getntpoffset();
|
|
|
|
break;
|
|
|
|
case 80:
|
|
|
|
$newsettings['tz_offset'] = $datetime->gethttpoffset();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$newsettings['tz_offset'] = $datetime->getbestguess();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
unset($datetime);
|
|
|
|
|
|
|
|
print_debug('TZ_OFFSET',$newsettings['tz_offset']);
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->db->transaction_begin();
|
2005-11-02 12:45:52 +01:00
|
|
|
foreach($newsettings as $setting => $value)
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting))
|
2001-12-21 23:41:44 +01:00
|
|
|
{
|
2005-11-14 15:51:58 +01:00
|
|
|
$setting($newsettings);
|
2004-11-28 19:38:50 +01:00
|
|
|
if($GLOBALS['config_error'])
|
|
|
|
{
|
2005-11-14 15:51:58 +01:00
|
|
|
$GLOBALS['error'] .= '<b>'.$GLOBALS['config_error'] ."</b><br />\n";
|
2004-11-28 19:38:50 +01:00
|
|
|
$GLOBALS['config_error'] = '';
|
|
|
|
/* Bail out, stop writing config data */
|
|
|
|
break;
|
|
|
|
}
|
2005-11-14 15:51:58 +01:00
|
|
|
$value = $newsettings[$setting]; // it might be changed by the validation hook
|
2001-12-21 23:41:44 +01:00
|
|
|
}
|
2005-11-02 12:45:52 +01:00
|
|
|
/* Don't erase passwords, since we also do not print them below */
|
|
|
|
if(empty($value) && !(stristr($setting,'passwd') || stristr($setting,'password') || stristr($setting,'root_pw')))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->config_table,array(
|
|
|
|
'config_name' => $setting,
|
|
|
|
'config_app' => 'phpgwapi',
|
|
|
|
),__LINE__,__FILE__);
|
2006-03-08 10:41:53 +01:00
|
|
|
unset($newsettings[$setting]);
|
2005-11-02 12:45:52 +01:00
|
|
|
}
|
|
|
|
elseif($value)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
|
|
|
|
'config_value' => $value,
|
|
|
|
),array(
|
|
|
|
'config_name' => $setting,
|
|
|
|
'config_app' => 'phpgwapi',
|
|
|
|
),__LINE__,__FILE__);
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
}
|
2004-11-28 19:38:50 +01:00
|
|
|
if(!$GLOBALS['error'])
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->db->transaction_commit();
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
if($newsettings['auth_type'] == 'ldap')
|
|
|
|
{
|
2005-11-02 12:45:52 +01:00
|
|
|
Header('Location: ldap.php');
|
2004-11-28 19:38:50 +01:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Header('Location: index.php');
|
|
|
|
exit;
|
|
|
|
}
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->html->show_header(lang('Configuration'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2006-03-08 10:41:53 +01:00
|
|
|
// if we have an validation error, use the new settings made by the user and not the stored config
|
|
|
|
if($GLOBALS['error'] && is_array($newsettings))
|
2001-07-30 17:59:25 +02:00
|
|
|
{
|
2006-03-08 10:41:53 +01:00
|
|
|
$GLOBALS['current_config'] = $newsettings;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'*',false,__LINES__,__FILES__);
|
|
|
|
while($GLOBALS['egw_setup']->db->next_record())
|
|
|
|
{
|
|
|
|
$GLOBALS['current_config'][$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
|
|
|
|
}
|
2001-07-30 17:59:25 +02:00
|
|
|
}
|
|
|
|
$setup_tpl->pparse('out','T_config_pre_script');
|
|
|
|
|
2001-09-21 22:14:04 +02:00
|
|
|
/* Now parse each of the templates we want to show here */
|
|
|
|
class phpgw
|
|
|
|
{
|
|
|
|
var $common;
|
|
|
|
var $accounts;
|
|
|
|
var $applications;
|
|
|
|
var $db;
|
|
|
|
}
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw'] = new phpgw;
|
2005-11-02 12:45:52 +01:00
|
|
|
$GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
|
|
|
|
$GLOBALS['egw']->db =& $GLOBALS['egw_setup']->db;
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$t = CreateObject('setup.Template',$GLOBALS['egw']->common->get_tpl_dir('setup'));
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
$t->set_unknowns('keep');
|
|
|
|
$t->set_file(array('config' => 'config.tpl'));
|
|
|
|
$t->set_block('config','body','body');
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
$vars = $t->get_undefined('body');
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->hook('config','setup');
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2005-11-14 15:51:58 +01:00
|
|
|
foreach($vars as $value)
|
2004-11-28 19:38:50 +01:00
|
|
|
{
|
|
|
|
$valarray = explode('_',$value);
|
|
|
|
$type = $valarray[0];
|
|
|
|
$new = $newval = '';
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
while($chunk = next($valarray))
|
|
|
|
{
|
|
|
|
$new[] = $chunk;
|
|
|
|
}
|
|
|
|
$newval = implode(' ',$new);
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2004-11-28 19:38:50 +01:00
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case 'lang':
|
|
|
|
$t->set_var($value,lang($newval));
|
|
|
|
break;
|
|
|
|
case 'value':
|
|
|
|
$newval = str_replace(' ','_',$newval);
|
|
|
|
/* Don't show passwords in the form */
|
|
|
|
if(strstr($value,'passwd') || strstr($value,'password') || strstr($value,'root_pw'))
|
|
|
|
{
|
2001-09-21 22:14:04 +02:00
|
|
|
$t->set_var($value,'');
|
2004-11-28 19:38:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var($value,@$current_config[$newval]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'selected':
|
|
|
|
$configs = array();
|
|
|
|
$config = '';
|
|
|
|
$newvals = explode(' ',$newval);
|
|
|
|
$setting = end($newvals);
|
|
|
|
for($i=0;$i<(count($newvals) - 1); $i++)
|
|
|
|
{
|
|
|
|
$configs[] = $newvals[$i];
|
|
|
|
}
|
|
|
|
$config = implode('_',$configs);
|
|
|
|
/* echo $config . '=' . $current_config[$config]; */
|
|
|
|
if(@$current_config[$config] == $setting)
|
|
|
|
{
|
|
|
|
$t->set_var($value,' selected');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var($value,'');
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'hook':
|
|
|
|
$newval = str_replace(' ','_',$newval);
|
|
|
|
$t->set_var($value,$newval($current_config));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$t->set_var($value,'');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($GLOBALS['error'])
|
|
|
|
{
|
|
|
|
if($GLOBALS['error'] == 'badldapconnection')
|
|
|
|
{
|
|
|
|
/* Please check the number and dial again :) */
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->html->show_alert_msg('Error',
|
2005-07-11 20:02:19 +02:00
|
|
|
lang('There was a problem trying to connect to your LDAP server. <br />'
|
2004-11-28 19:38:50 +01:00
|
|
|
.'please check your LDAP server configuration') . '.');
|
2001-09-21 22:14:04 +02:00
|
|
|
}
|
|
|
|
|
2005-11-14 15:51:58 +01:00
|
|
|
$GLOBALS['egw_setup']->html->show_alert_msg('Error',$GLOBALS['error'].'<p>');
|
2004-11-28 19:38:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$t->pfp('out','body');
|
|
|
|
unset($t);
|
2001-09-21 22:14:04 +02:00
|
|
|
|
2003-12-19 13:34:45 +01:00
|
|
|
$setup_tpl->set_var('more_configs',lang('Please login to egroupware and run the admin application for additional site configuration') . '.');
|
2001-07-30 17:59:25 +02:00
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
$setup_tpl->set_var('lang_submit',lang('Save'));
|
|
|
|
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
|
2001-07-30 17:59:25 +02:00
|
|
|
$setup_tpl->pparse('out','T_config_post_script');
|
2002-03-03 22:53:00 +01:00
|
|
|
|
2005-03-04 13:40:28 +01:00
|
|
|
$GLOBALS['egw_setup']->html->show_footer();
|
2001-07-30 17:59:25 +02:00
|
|
|
?>
|