2001-12-24 01:00:09 +01:00
|
|
|
<?php
|
2005-10-14 19:03:16 +02:00
|
|
|
/**************************************************************************\
|
|
|
|
* eGroupWare - Admin config *
|
2005-11-26 14:48:28 +01:00
|
|
|
* Written by Miles Lott <milos@groupwhere.org> *
|
2005-10-14 19:03:16 +02:00
|
|
|
* http://www.egroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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$ */
|
2001-12-24 01:00:09 +01:00
|
|
|
|
|
|
|
class uiconfig
|
|
|
|
{
|
|
|
|
var $public_functions = array('index' => True);
|
|
|
|
|
|
|
|
function index()
|
|
|
|
{
|
2005-03-03 17:57:07 +01:00
|
|
|
if ($GLOBALS['egw']->acl->check('site_config_access',1,'admin'))
|
2002-02-21 13:27:56 +01:00
|
|
|
{
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->redirect_link('/index.php');
|
|
|
|
}
|
|
|
|
$referer = $_POST['submit'] || $_POST['cancel'] ? $_POST['referer'] : $_SERVER['HTTP_REFERER'];
|
|
|
|
if (!$referer) $referer = $GLOBALS['egw']->link('/admin/index.php');
|
2006-06-22 07:38:31 +02:00
|
|
|
if ($GLOBALS['egw_info']['server']['webserver_url'])
|
|
|
|
{
|
|
|
|
list(,$show_app) = explode($GLOBALS['egw_info']['server']['webserver_url'],$referer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$parts = parse_url($referer);
|
|
|
|
$show_app = $parts['path'];
|
|
|
|
unset($parts);
|
|
|
|
}
|
2005-03-03 17:57:07 +01:00
|
|
|
list(,$show_app) = explode('/',$show_app);
|
|
|
|
if (!$show_app) $show_app = 'admin';
|
|
|
|
|
|
|
|
// load the translations of the app we show too, so they dont need to be in admin!
|
|
|
|
if ($_GET['appname'] != 'admin')
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->translation->add_app($_GET['appname']);
|
2002-02-21 13:27:56 +01:00
|
|
|
}
|
2003-09-14 18:30:27 +02:00
|
|
|
|
|
|
|
if(get_magic_quotes_gpc() && is_array($_POST['newsettings']))
|
|
|
|
{
|
2006-12-29 08:08:47 +01:00
|
|
|
$_POST['newsettings'] = $this->array_stripslashes($_POST['newsettings']);
|
2003-09-14 18:30:27 +02:00
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
|
|
|
|
switch($_GET['appname'])
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
case 'admin':
|
|
|
|
case 'addressbook':
|
|
|
|
case 'calendar':
|
|
|
|
case 'email':
|
|
|
|
case 'nntp':
|
2001-12-24 01:30:48 +01:00
|
|
|
/*
|
|
|
|
Other special apps can go here for now, e.g.:
|
|
|
|
case 'bogusappname':
|
|
|
|
*/
|
2003-08-28 16:16:30 +02:00
|
|
|
$appname = $_GET['appname'];
|
2001-12-24 01:30:48 +01:00
|
|
|
$config_appname = 'phpgwapi';
|
|
|
|
break;
|
2001-12-24 06:17:07 +01:00
|
|
|
case 'phpgwapi':
|
2001-12-24 01:33:53 +01:00
|
|
|
case '':
|
|
|
|
/* This keeps the admin from getting into what is a setup-only config */
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->redirect_link('/admin/index.php');
|
2001-12-24 01:33:53 +01:00
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
default:
|
2003-08-28 16:16:30 +02:00
|
|
|
$appname = $_GET['appname'];
|
2001-12-24 01:30:48 +01:00
|
|
|
$config_appname = $appname;
|
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
2005-10-14 19:03:16 +02:00
|
|
|
$t =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir($appname));
|
2001-12-24 01:00:09 +01:00
|
|
|
$t->set_unknowns('keep');
|
|
|
|
$t->set_file(array('config' => 'config.tpl'));
|
|
|
|
$t->set_block('config','header','header');
|
|
|
|
$t->set_block('config','body','body');
|
|
|
|
$t->set_block('config','footer','footer');
|
|
|
|
|
2005-10-14 19:03:16 +02:00
|
|
|
$c =& CreateObject('phpgwapi.config',$config_appname);
|
2001-12-24 01:00:09 +01:00
|
|
|
$c->read_repository();
|
|
|
|
|
2005-03-03 17:57:07 +01:00
|
|
|
if ($_POST['cancel'] || $_POST['submit'] && $GLOBALS['egw']->acl->check('site_config_access',2,'admin'))
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->redirect($referer);
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
if ($_POST['submit'])
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
/* Load hook file with functions to validate each config (one/none/all) */
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->hooks->single('config_validate',$appname);
|
2001-12-24 01:00:09 +01:00
|
|
|
|
2004-08-24 21:59:31 +02:00
|
|
|
foreach($_POST['newsettings'] as $key => $config)
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
if ($config)
|
|
|
|
{
|
2006-04-06 12:46:59 +02:00
|
|
|
$c->config_data[$key] = $config;
|
2005-03-03 17:57:07 +01:00
|
|
|
if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists($key))
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
call_user_func($key,$config);
|
|
|
|
if($GLOBALS['config_error'])
|
|
|
|
{
|
|
|
|
$errors .= lang($GLOBALS['config_error']) . ' ';
|
|
|
|
$GLOBALS['config_error'] = False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-06 12:46:59 +02:00
|
|
|
/* don't erase passwords, since we also don't print them */
|
|
|
|
elseif(!ereg('passwd',$key) && !ereg('password',$key) && !ereg('root_pw',$key))
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
2006-04-06 12:46:59 +02:00
|
|
|
unset($c->config_data[$key]);
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
}
|
2005-03-03 17:57:07 +01:00
|
|
|
if($GLOBALS['egw_info']['server']['found_validation_hook'] && function_exists('final_validation'))
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
2006-04-06 12:46:59 +02:00
|
|
|
final_validation($_POST['newsettings']);
|
2001-12-24 01:00:09 +01:00
|
|
|
if($GLOBALS['config_error'])
|
|
|
|
{
|
|
|
|
$errors .= lang($GLOBALS['config_error']) . ' ';
|
|
|
|
$GLOBALS['config_error'] = False;
|
|
|
|
}
|
2005-03-03 17:57:07 +01:00
|
|
|
unset($GLOBALS['egw_info']['server']['found_validation_hook']);
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
$c->save_repository();
|
2001-12-24 01:00:09 +01:00
|
|
|
|
|
|
|
if(!$errors)
|
|
|
|
{
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->redirect($referer);
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($errors)
|
|
|
|
{
|
|
|
|
$t->set_var('error',lang('Error') . ': ' . $errors);
|
|
|
|
$t->set_var('th_err','#FF8888');
|
|
|
|
unset($errors);
|
|
|
|
unset($GLOBALS['config_error']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var('error','');
|
2005-03-03 17:57:07 +01:00
|
|
|
$t->set_var('th_err',$GLOBALS['egw_info']['theme']['th_bg']);
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
|
2005-03-03 17:57:07 +01:00
|
|
|
$GLOBALS['egw']->js->validate_file('jscode','openwindow','admin');
|
2004-02-26 10:01:42 +01:00
|
|
|
|
2005-03-03 17:57:07 +01:00
|
|
|
// set currentapp to our calling app, to show the right sidebox-menu
|
|
|
|
$GLOBALS['egw_info']['flags']['currentapp'] = $show_app;
|
2005-10-14 19:03:16 +02:00
|
|
|
$GLOBALS['egw']->common->egw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-12-24 01:00:09 +01:00
|
|
|
|
|
|
|
$t->set_var('title',lang('Site Configuration'));
|
2005-03-03 17:57:07 +01:00
|
|
|
$t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname));
|
|
|
|
$t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']);
|
|
|
|
$t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']);
|
|
|
|
$t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']);
|
|
|
|
$t->set_var('hidden_vars','<input type="hidden" name="referer" value="'.$referer.'">');
|
2001-12-24 01:00:09 +01:00
|
|
|
$t->pparse('out','header');
|
|
|
|
|
|
|
|
$vars = $t->get_undefined('body');
|
|
|
|
|
2006-04-06 09:52:50 +02:00
|
|
|
if ($GLOBALS['egw']->hooks->single('config',$appname)) // reload the config-values, they might have changed
|
|
|
|
{
|
|
|
|
$c->read_repository();
|
|
|
|
}
|
2004-08-25 13:21:23 +02:00
|
|
|
foreach($vars as $value)
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
$valarray = explode('_',$value);
|
2004-08-25 13:21:23 +02:00
|
|
|
$type = array_shift($valarray);
|
|
|
|
$newval = implode(' ',$valarray);
|
2001-12-24 01:00:09 +01:00
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
switch ($type)
|
2001-12-24 01:00:09 +01:00
|
|
|
{
|
|
|
|
case 'lang':
|
2002-02-02 20:01:17 +01:00
|
|
|
$t->set_var($value,lang($newval));
|
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
case 'value':
|
2003-12-20 19:51:51 +01:00
|
|
|
$newval = str_replace(' ','_',$newval);
|
2002-02-02 20:01:17 +01:00
|
|
|
/* Don't show passwords in the form */
|
|
|
|
if(ereg('passwd',$value) || ereg('password',$value) || ereg('root_pw',$value))
|
|
|
|
{
|
|
|
|
$t->set_var($value,'');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-06 12:46:59 +02:00
|
|
|
$t->set_var($value,$c->config_data[$newval]);
|
2002-02-02 20:01:17 +01:00
|
|
|
}
|
|
|
|
break;
|
2003-08-28 16:16:30 +02:00
|
|
|
/*
|
2001-12-24 01:00:09 +01:00
|
|
|
case 'checked':
|
2003-12-20 19:51:51 +01:00
|
|
|
$newval = str_replace(' ','_',$newval);
|
2006-04-06 12:46:59 +02:00
|
|
|
if ($c->config_data[$newval])
|
2002-02-02 20:01:17 +01:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$t->set_var($value,' checked');
|
2002-02-02 20:01:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$t->set_var($value,'');
|
2002-02-02 20:01:17 +01:00
|
|
|
}
|
|
|
|
break;
|
2003-08-28 16:16:30 +02:00
|
|
|
*/
|
2001-12-24 01:00:09 +01:00
|
|
|
case 'selected':
|
2002-02-02 20:01:17 +01:00
|
|
|
$configs = array();
|
|
|
|
$config = '';
|
|
|
|
$newvals = explode(' ',$newval);
|
|
|
|
$setting = end($newvals);
|
|
|
|
for ($i=0;$i<(count($newvals) - 1); $i++)
|
|
|
|
{
|
|
|
|
$configs[] = $newvals[$i];
|
|
|
|
}
|
|
|
|
$config = implode('_',$configs);
|
2006-04-06 12:46:59 +02:00
|
|
|
/* echo $config . '=' . $c->config_data[$config]; */
|
|
|
|
if ($c->config_data[$config] == $setting)
|
2002-02-02 20:01:17 +01:00
|
|
|
{
|
|
|
|
$t->set_var($value,' selected');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var($value,'');
|
|
|
|
}
|
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
case 'hook':
|
2003-12-20 19:51:51 +01:00
|
|
|
$newval = str_replace(' ','_',$newval);
|
2002-02-02 20:01:17 +01:00
|
|
|
if(function_exists($newval))
|
|
|
|
{
|
2006-04-06 12:46:59 +02:00
|
|
|
$t->set_var($value,$newval($c->config_data));
|
2002-02-02 20:01:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var($value,'');
|
|
|
|
}
|
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
default:
|
2003-08-28 16:16:30 +02:00
|
|
|
$t->set_var($value,'');
|
|
|
|
break;
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$t->pfp('out','body');
|
|
|
|
|
2005-03-03 17:57:07 +01:00
|
|
|
$t->set_var('lang_submit', $GLOBALS['egw']->acl->check('site_config_access',2,'admin') ? lang('Cancel') : lang('Save'));
|
2003-08-28 16:16:30 +02:00
|
|
|
$t->set_var('lang_cancel', lang('Cancel'));
|
2001-12-24 01:00:09 +01:00
|
|
|
$t->pfp('out','footer');
|
|
|
|
}
|
2006-12-29 08:08:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* applies stripslashes recursivly on each element of an array
|
|
|
|
*
|
|
|
|
* @param array &$var
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function array_stripslashes($var)
|
|
|
|
{
|
|
|
|
if (!is_array($var))
|
|
|
|
{
|
|
|
|
return stripslashes($var);
|
|
|
|
}
|
|
|
|
foreach($var as $key => $val)
|
|
|
|
{
|
|
|
|
$var[$key] = is_array($val) ? $this->array_stripslashes($val) : stripslashes($val);
|
|
|
|
}
|
|
|
|
return $var;
|
|
|
|
}
|
2001-12-24 01:00:09 +01:00
|
|
|
}
|
|
|
|
?>
|