- setup uses now the system_charset, that fixes various errors reported:

+ setup_demo gives errors under postgres
 + setup_demo can save special chars in the admin name
- renamed setup_demo into admin_account, as setting up demo accounts is the least used function of it
- fixed warning db::delete missing params, if delete_all was checked
This commit is contained in:
Ralf Becker 2005-11-27 07:48:22 +00:00
parent 3617eeda1f
commit 7b2b823835
12 changed files with 87 additions and 74 deletions

View File

@ -69,14 +69,7 @@
}
else
{
$this->db->select($this->config_table,'config_value',array(
'config_app'=>'phpgwapi',
'config_name'=>'system_charset'
),__LINE__,__FILE__);
if ($this->db->next_record())
{
$this->system_charset = $this->db->f(0);
}
$this->system_charset =& $GLOBALS['egw_setup']->system_charset;
}
// load multi-byte-string-extension if needed, and set its internal encodeing to your system_charset
if ($this->system_charset && substr($this->system_charset,0,9) != 'iso-8859-1')

View File

@ -29,8 +29,28 @@
Header('Location: index.php');
exit;
}
$GLOBALS['egw_setup']->loaddb(true);
if(!get_var('submit',Array('POST')))
$error = '';
if ($_POST['submit'])
{
/* Posted admin data */
$passwd = get_var('passwd',Array('POST'));
$passwd2 = get_var('passwd2',Array('POST'));
$username = get_var('username',Array('POST'));
$fname = get_var('fname',Array('POST'));
$lname = get_var('lname',Array('POST'));
if($passwd != $passwd2 || !$username)
{
$error = '<p>'.lang('Passwords did not match, please re-enter') . ".</p>\n";
}
if(!$username)
{
$error = '<p>'.lang('You must enter a username for the admin') . ".</p>\n";
}
}
if(!$_POST['submit'] || $error)
{
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('setup.Template',$tpl_root);
@ -40,14 +60,20 @@
'T_alert_msg' => 'msg_alert_msg.tpl',
'T_login_main' => 'login_main.tpl',
'T_login_stage_header' => 'login_stage_header.tpl',
'T_setup_demo' => 'setup_demo.tpl'
'T_admin_account' => 'admin_account.tpl'
));
$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
$GLOBALS['egw_setup']->html->show_header(lang('Demo Server Setup'));
$GLOBALS['egw_setup']->html->show_header(lang('Create admin account'));
$setup_tpl->set_var('action_url','setup_demo.php');
$setup_tpl->set_var(array(
'error' => $error,
'username' => $username,
'fname' => $fname,
'lname' => $lname,
));
$setup_tpl->set_var('action_url','admin_account.php');
$setup_tpl->set_var('description',lang('<b>This will create 1 admin account and 3 demo accounts</b><br />The username/passwords are: demo/guest, demo2/guest and demo3/guest.'));
$setup_tpl->set_var('lang_deleteall',lang('Delete all existing SQL accounts, groups, ACLs and preferences (normally not necessary)?'));
@ -61,42 +87,21 @@
$setup_tpl->set_var('lang_submit',lang('Save'));
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
$setup_tpl->pparse('out','T_setup_demo');
$setup_tpl->pparse('out','T_admin_account');
$GLOBALS['egw_setup']->html->show_footer();
}
else
{
/* Posted admin data */
$passwd = get_var('passwd',Array('POST'));
$passwd2 = get_var('passwd2',Array('POST'));
$username = get_var('username',Array('POST'));
$fname = get_var('fname',Array('POST'));
$lname = get_var('lname',Array('POST'));
if($passwd != $passwd2)
{
echo lang('Passwords did not match, please re-enter') . '.';
exit;
}
if(!$username)
{
echo lang('You must enter a username for the admin') . '.';
exit;
}
$GLOBALS['egw_setup']->loaddb();
/* Begin transaction for acl, etc */
$GLOBALS['egw_setup']->db->transaction_begin();
if($_POST['delete_all'])
{
/* Now, clear out existing tables */
foreach(array($GLOBALS['egw_setup']->accounts_table,$GLOBALS['egw_setup']->prefs_table,$GLOBALS['egw_setup']->acl_table) as $table)
foreach(array($GLOBALS['egw_setup']->accounts_table,$GLOBALS['egw_setup']->prefs_table,$GLOBALS['egw_setup']->acl_table,'egw_access_log') as $table)
{
$GLOBALS['egw_setup']->db->delete($table,'1=1');
$GLOBALS['egw_setup']->db->delete($table,'1=1',__LINE__,__FILE__);
}
/* Clear the access log, since these are all new users anyway */
$GLOBALS['egw_setup']->db->query('DELETE FROM egw_access_log');
}
/* Create the demo groups */
$defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);

View File

@ -38,10 +38,12 @@
var $cats_table = 'egw_categories';
var $oProc;
var $detection = '';
var $process = '';
var $lang = '';
var $html = '';
var $detection;
var $process;
var $lang;
var $html;
var $system_charset;
/* table name vars */
var $tbl_apps;
@ -50,12 +52,17 @@
function setup($html=False, $translation=False)
{
// setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects
$GLOBALS['egw_setup'] =& $this;
$this->detection =& CreateObject('setup.setup_detection');
$this->process =& CreateObject('setup.setup_process');
if ($_REQUEST['system_charset']) $this->system_charset = $_REQUEST['system_charset'];
/* The setup application needs these */
$this->html = $html ? CreateObject('setup.setup_html') : '';
$this->translation = $translation ? CreateObject('setup.setup_translation') : '';
if ($html) $this->html =& CreateObject('setup.setup_html');
if ($translation) $this->translation =& CreateObject('setup.setup_translation');
}
/**

View File

@ -114,9 +114,9 @@
function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
{
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
header('Content-type: text/html; charset='.lang('charset'));
header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset);
$GLOBALS['setup_tpl']->set_var('charset',lang('charset'));
$GLOBALS['setup_tpl']->set_var('charset',$GLOBALS['egw_setup']->system_charset);
$style = array(
'th_bg' => '#486591',
'th_text' => '#FFFFFF',

View File

@ -57,7 +57,7 @@
* @param boolean $force_en=false install english language files
* @param string $system_charset=null charset to use
*/
function pass($setup_info,$method='new',$DEBUG=False,$force_en=False,$system_charset=null)
function pass($setup_info,$method='new',$DEBUG=False,$force_en=False)
{
if(!$method)
{
@ -118,7 +118,7 @@
case 'new':
/* Create tables and insert new records for each app in this list */
$passing = $this->current($pass,$DEBUG);
$this->save_minimal_config($system_charset);
$this->save_minimal_config();
$passing = $this->default_records($passing,$DEBUG);
$do_langs = true; // just do it once at the end of all passes
break;
@ -191,7 +191,7 @@
* saves a minimal default config, so you get a running install without entering and saveing Step #2 config
*
*/
function save_minimal_config($system_charset)
function save_minimal_config()
{
$GLOBALS['current_config']['site_title'] = 'eGroupWare';
$GLOBALS['current_config']['hostname'] = $_SERVER['HTTP_HOST'];
@ -202,9 +202,9 @@
{
$GLOBALS['current_config']['temp_dir'] = '/tmp';
}
elseif(@is_dir('c:\\temp'))
elseif(@is_dir('c:\\windows\\temp'))
{
$GLOBALS['current_config']['temp_dir'] = 'c:\\temp';
$GLOBALS['current_config']['temp_dir'] = 'c:\\windows\\temp';
}
else
{
@ -223,13 +223,9 @@
// RalfBecker: php.net recommend this for security reasons, it should be our default too
$GLOBALS['current_config']['usecookies'] = 'True';
if ($system_charset)
if ($GLOBALS['egw_setup']->system_charset)
{
$GLOBALS['current_config']['system_charset'] = $system_charset;
if (is_object($GLOBALS['egw_setup']->translation->sql))
{
$GLOBALS['egw_setup']->translation->sql->system_charset = $system_charset;
}
$GLOBALS['current_config']['system_charset'] = $GLOBALS['egw_setup']->system_charset;
}
foreach($GLOBALS['current_config'] as $name => $value)

View File

@ -65,6 +65,11 @@
$this->langarray[strtolower(trim($message_id))] = str_replace("\n",'',$content);
}
fclose($fp);
if (!$GLOBALS['egw_setup']->system_charset)
{
$GLOBALS['egw_setup']->system_charset = $this->langarray['charset'];
}
}
}
@ -82,6 +87,14 @@
{
$ret = $this->langarray[$key];
}
if ($GLOBALS['egw_setup']->system_charset != $this->langarray['charset'])
{
if (!is_object($this->sql))
{
$this->setup_translation_sql();
}
$ret = $this->sql->convert($ret,$this->langarray['charset']);
}
if (is_array($vars))
{
foreach($vars as $n => $var)

View File

@ -179,7 +179,7 @@
$setup_tpl->set_var('db_step_text',lang('Step %1 - Simple Application Management',1));
$setup_tpl->set_var('lang_system_charset',lang('<b>charset to use</b> (use utf-8 if you plan to use languages with different charsets):'));
$setup_tpl->set_var('system_charset',$GLOBALS['egw_setup']->translation->get_charsets('system_charset',
$_POST['system_charset'] ? $_POST['system_charset'] : lang('charset')));
$GLOBALS['egw_setup']->system_charset));
switch($GLOBALS['egw_info']['setup']['stage']['db'])
{
@ -339,7 +339,7 @@
$GLOBALS['egw_setup']->system_charset = $_REQUEST['system_charset'];
$GLOBALS['egw_setup']->db->Link_ID->SetCharSet($_REQUEST['system_charset']);
}
$setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True,$_REQUEST['system_charset']);
$setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True);
$GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
}
break;
@ -373,7 +373,7 @@
$GLOBALS['egw_setup']->db->Halt_On_Error = 'no';
$setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation'));
$setup_tpl->set_var('system_charset',$_POST['system_charset']);
$setup_tpl->set_var('system_charset',$GLOBALS['egw']->system_charset);
$setup_tpl->parse('V_db_stage_6_post','B_db_stage_6_post');
$db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post');
$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
@ -504,7 +504,7 @@
$setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed'));
$setup_tpl->set_var('admin_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple(
$no_accounts ? lang('No accounts existing') : lang('Accounts existing'),
'post','setup_demo.php',
'post','admin_account.php',
'submit',lang('Create admin account'),
''
));
@ -551,10 +551,8 @@
'submit',lang('Manage Languages'),
'');
// show system-charset and offer conversation
include_once(EGW_API_INC.'/class.translation.inc.php');
$translation = new translation;
$btn_manage_lang .= lang('Current system-charset is %1, click %2here%3 to change it.',
$translation->system_charset ? "'$translation->system_charset'" : lang('not set'),
$GLOBALS['egw_setup']->system_charset ? "'".$GLOBALS['egw_setup']->system_charset."'" : lang('not set'),
'<a href="system_charset.php">','</a>');
$setup_tpl->set_var('lang_table_data',$btn_manage_lang);
break;

View File

@ -1,14 +1,14 @@
bg Bulgarian
ca Catalán
ca Catal&aacute;n
cs Czech
da Danish
de Deutsch
en English
el Greek
es-es Español
es-es Espa&ntilde;ol
fa Persian
fi Suomi
fr Français
fr Fran&ccedil;ais
hr Croatian
hu Hungarian
it Italiano

View File

@ -428,7 +428,7 @@ step %1 - db backup and restore setup de Schritt %1 - DB Datensicherung und Wied
step %1 - language management setup de Schritt %1 - Verwaltung der Sprachen
step %1 - simple application management setup de Schritt %1 - Einfache Verwaltung der Anwendungen
succesfully uploaded file %1 setup de Datei %1 erfolgreich hochgeladen
table change messages setup de Tabellen&auml;nderungsmeldungen
table change messages setup de Tabellenänderungsmeldungen
tables dropped setup de Tabellen wurden gelöscht
tables installed, unless there are errors printed above setup de Tabellen wurden installiert, au&szlig;er oben sind Fehlermelungen zu sehen
tables upgraded setup de Tabellen wurden aktualisiert

View File

@ -64,7 +64,7 @@
$setup_tpl->set_var('ldapmodify','ldapmodify.php');
$setup_tpl->set_var('ldapimport','ldapimport.php');
$setup_tpl->set_var('ldapexport','ldapexport.php');
$setup_tpl->set_var('ldapdummy','setup_demo.php');
$setup_tpl->set_var('ldapdummy','admin_account.php');
$setup_tpl->set_var('action_url','index.php');
$setup_tpl->set_var('cancel',lang('Cancel'));

View File

@ -1,4 +1,4 @@
<!-- BEGIN setup_demo -->
<!-- BEGIN admin_account -->
<form method="post" action="{action_url}">
<table border="0" width="90%" cellspacing="0" cellpadding="2">
<tr>
@ -7,6 +7,7 @@
<p>
<input type="checkbox" name="delete_all" />{lang_deleteall}
</p>
<font color="red">{error}</font>
</td>
</tr>
<tr>
@ -17,15 +18,15 @@
<table border="0">
<tr>
<td>{adminusername}</td>
<td><input type="text" name="username" /></td>
<td><input type="text" name="username" value="{username}" /></td>
</tr>
<tr>
<td>{adminfirstname}</td>
<td><input type="text" name="fname" /></td>
<td><input type="text" name="fname" value="{fname}" /></td>
</tr>
<tr>
<td>{adminlastname}</td>
<td><input type="text" name="lname" /></td>
<td><input type="text" name="lname" value="{lname}" /></td>
</tr>
<tr>
<td>{adminpassword}</td>
@ -48,4 +49,4 @@
</tr>
</table>
</form>
<!-- END setup_demo -->
<!-- END admin_account -->

View File

@ -110,7 +110,7 @@
<input type="hidden" name="action" value="Dont touch my data" />
<input type="submit" name="label" value="{configuration}" />
</form>
<form method="post" action="setup_demo.php">
<form method="post" action="admin_account.php">
<input type="hidden" name="action" value="Dont touch my data" />
<input type="submit" name="label" value="{admin_account}" />
</form>