mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-16 10:21:23 +01:00
phpDoc headers
This commit is contained in:
parent
c475f86147
commit
93112e0277
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Setup - Account migration between SQL <--> LDAP
|
||||
*
|
||||
* eGroupware Setup - Account migration between SQL <--> LDAP
|
||||
*
|
||||
* The migration is done to the account-repository configured for eGroupWare!
|
||||
*
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
@ -11,13 +11,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
@ -49,7 +42,7 @@ $setup_tpl->set_file(array(
|
||||
function hash_sql2ldap($hash)
|
||||
{
|
||||
$type = $GLOBALS['egw_info']['server']['sql_encryption_type'];
|
||||
|
||||
|
||||
if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches))
|
||||
{
|
||||
$type = $matches[1];
|
||||
@ -64,7 +57,7 @@ function hash_sql2ldap($hash)
|
||||
case 'crypt':
|
||||
$hash = '{crypt}' . $hash;
|
||||
break;
|
||||
|
||||
|
||||
case 'plain':
|
||||
break;
|
||||
}
|
||||
@ -91,15 +84,15 @@ if (!$to && !($to = $GLOBALS['egw_info']['server']['auth_type']))
|
||||
$from = $to == 'sql' ? 'ldap' : 'sql';
|
||||
$direction = strtoupper($from).' --> '.strtoupper($to);
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_header($direction,False,'config',$GLOBALS['egw_setup']->ConfigDomain .
|
||||
$GLOBALS['egw_setup']->html->show_header($direction,False,'config',$GLOBALS['egw_setup']->ConfigDomain .
|
||||
'(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
|
||||
|
||||
if (!$_POST['migrate'])
|
||||
{
|
||||
// fetch and display the accounts of the NOT set $from repository
|
||||
$GLOBALS['egw_info']['server']['account_repository'] = $from;
|
||||
$GLOBALS['egw_setup']->setup_account_object($GLOBALS['egw_info']['server']);
|
||||
|
||||
|
||||
// fetch all users and groups
|
||||
$accounts = $GLOBALS['egw_setup']->accounts->search(array(
|
||||
'type' => 'both',
|
||||
@ -127,14 +120,14 @@ if (!$_POST['migrate'])
|
||||
// store the complete info in the session to be availible after user selected what to migrate
|
||||
// we cant instanciate to account-repositories at the same time, as the backend-classes have identical names
|
||||
$_SESSION['all_accounts'] =& $accounts;
|
||||
|
||||
|
||||
// now outputting the account selection
|
||||
$setup_tpl->set_block('migration','header','header');
|
||||
$setup_tpl->set_block('migration','user_list','user_list');
|
||||
$setup_tpl->set_block('migration','group_list','group_list');
|
||||
$setup_tpl->set_block('migration','submit','submit');
|
||||
$setup_tpl->set_block('migration','footer','footer');
|
||||
|
||||
|
||||
foreach($accounts as $account_id => $account)
|
||||
{
|
||||
if ($account['account_type'] == 'g')
|
||||
@ -151,14 +144,14 @@ if (!$_POST['migrate'])
|
||||
$setup_tpl->set_var('action_url','account_migration.php');
|
||||
$setup_tpl->set_var('users',$user_list);
|
||||
$setup_tpl->set_var('groups',$group_list);
|
||||
|
||||
|
||||
$setup_tpl->set_var('description',lang('Migration between eGroupWare account repositories').': '.$direction);
|
||||
$setup_tpl->set_var('select_users',lang('Select which user(s) will be exported'));
|
||||
$setup_tpl->set_var('select_groups',lang('Select which group(s) will be exported'));
|
||||
$setup_tpl->set_var('memberships',lang('Group memberships will be migrated too.'));
|
||||
$setup_tpl->set_var('migrate',$direction);
|
||||
$setup_tpl->set_var('cancel',lang('Cancel'));
|
||||
|
||||
|
||||
$setup_tpl->pfp('out','header');
|
||||
if($user_list)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Setup - create admin account
|
||||
* eGroupware Setup - create admin account
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
@ -10,212 +10,205 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') !== false)
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') !== false)
|
||||
{
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if(!$GLOBALS['egw_setup']->auth('Config') || get_var('cancel',Array('POST')))
|
||||
{
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if(!$GLOBALS['egw_setup']->auth('Config') || get_var('cancel',Array('POST')))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$GLOBALS['egw_setup']->loaddb(true);
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$error = '';
|
||||
if ($_POST['submit'])
|
||||
$GLOBALS['egw_setup']->loaddb(true);
|
||||
}
|
||||
$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'));
|
||||
$email = get_var('email',Array('POST'));
|
||||
|
||||
if($passwd != $passwd2 || !$username)
|
||||
{
|
||||
/* 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'));
|
||||
$email = get_var('email',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('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl',
|
||||
'T_login_main' => 'login_main.tpl',
|
||||
'T_login_stage_header' => 'login_stage_header.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('Create admin account'));
|
||||
|
||||
$setup_tpl->set_var(array(
|
||||
'error' => $error,
|
||||
'username' => $username,
|
||||
'fname' => $fname,
|
||||
'lname' => $lname,
|
||||
'email' => $email,
|
||||
));
|
||||
$setup_tpl->set_var('action_url','admin_account.php');
|
||||
$setup_tpl->set_var('description',lang('This will create a first user in eGroupWare or reset password and admin rights of an exiting user'));
|
||||
$setup_tpl->set_var('lang_deleteall',lang('Delete all existing SQL accounts, groups, ACLs and preferences (normally not necessary)?'));
|
||||
|
||||
$setup_tpl->set_var('detailadmin',lang('Details for Admin account'));
|
||||
$setup_tpl->set_var('adminusername',lang('Admin username'));
|
||||
$setup_tpl->set_var('adminfirstname',lang('Admin first name'));
|
||||
$setup_tpl->set_var('adminlastname',lang('Admin last name'));
|
||||
$setup_tpl->set_var('adminemail',lang('Admin email address'));
|
||||
$setup_tpl->set_var('adminpassword',lang('Admin password'));
|
||||
$setup_tpl->set_var('adminpassword2',lang('Re-enter password'));
|
||||
$setup_tpl->set_var('admin_all_apps',lang('Give admin access to all installed apps'));
|
||||
$setup_tpl->set_var('all_apps_desc',lang('Usually more annoying.<br />Admins can use Admin >> Manage accounts or groups to give access to further apps.'));
|
||||
$setup_tpl->set_var('create_demo_accounts',lang('Create demo accounts'));
|
||||
$setup_tpl->set_var('demo_desc',lang('The username/passwords are: demo/guest, demo2/guest and demo3/guest.'));
|
||||
|
||||
$setup_tpl->set_var('lang_submit',lang('Save'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
|
||||
$setup_tpl->pparse('out','T_admin_account');
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 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,'egw_access_log') as $table)
|
||||
{
|
||||
$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";
|
||||
$GLOBALS['egw_setup']->db->delete($table,'1=1',__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
if(!$_POST['submit'] || $error)
|
||||
/* Create the demo groups */
|
||||
$defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
|
||||
$admingroupid = (int)$GLOBALS['egw_setup']->add_account('Admins','Admin','Group',False,False);
|
||||
|
||||
if (!$defaultgroupid || !$admingroupid)
|
||||
{
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl',
|
||||
'T_login_main' => 'login_main.tpl',
|
||||
'T_login_stage_header' => 'login_stage_header.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('Create admin account'));
|
||||
|
||||
$setup_tpl->set_var(array(
|
||||
'error' => $error,
|
||||
'username' => $username,
|
||||
'fname' => $fname,
|
||||
'lname' => $lname,
|
||||
'email' => $email,
|
||||
));
|
||||
$setup_tpl->set_var('action_url','admin_account.php');
|
||||
$setup_tpl->set_var('description',lang('This will create a first user in eGroupWare or reset password and admin rights of an exiting user'));
|
||||
$setup_tpl->set_var('lang_deleteall',lang('Delete all existing SQL accounts, groups, ACLs and preferences (normally not necessary)?'));
|
||||
|
||||
$setup_tpl->set_var('detailadmin',lang('Details for Admin account'));
|
||||
$setup_tpl->set_var('adminusername',lang('Admin username'));
|
||||
$setup_tpl->set_var('adminfirstname',lang('Admin first name'));
|
||||
$setup_tpl->set_var('adminlastname',lang('Admin last name'));
|
||||
$setup_tpl->set_var('adminemail',lang('Admin email address'));
|
||||
$setup_tpl->set_var('adminpassword',lang('Admin password'));
|
||||
$setup_tpl->set_var('adminpassword2',lang('Re-enter password'));
|
||||
$setup_tpl->set_var('admin_all_apps',lang('Give admin access to all installed apps'));
|
||||
$setup_tpl->set_var('all_apps_desc',lang('Usually more annoying.<br />Admins can use Admin >> Manage accounts or groups to give access to further apps.'));
|
||||
$setup_tpl->set_var('create_demo_accounts',lang('Create demo accounts'));
|
||||
$setup_tpl->set_var('demo_desc',lang('The username/passwords are: demo/guest, demo2/guest and demo3/guest.'));
|
||||
|
||||
$setup_tpl->set_var('lang_submit',lang('Save'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
|
||||
$setup_tpl->pparse('out','T_admin_account');
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') === false)
|
||||
{
|
||||
return 42; //lang('Error in group-creation !!!'); // dont exit on setup-cli
|
||||
}
|
||||
echo '<p><b>'.lang('Error in group-creation !!!')."</b></p>\n";
|
||||
echo '<p>'.lang('click <a href="index.php">here</a> to return to setup.')."</p>\n";
|
||||
$GLOBALS['egw_setup']->db->transaction_abort();
|
||||
exit;
|
||||
}
|
||||
else
|
||||
|
||||
// Group perms for the default group
|
||||
$GLOBALS['egw_setup']->add_acl(array('addressbook','calendar','infolog','felamimail','preferences','home','manual'),'run',$defaultgroupid);
|
||||
|
||||
$apps = array();
|
||||
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'app_name','app_enabled < 3',__LINE__,__FILE__);
|
||||
while ($GLOBALS['egw_setup']->db->next_record())
|
||||
{
|
||||
/* Begin transaction for acl, etc */
|
||||
$GLOBALS['egw_setup']->db->transaction_begin();
|
||||
$apps[] = $GLOBALS['egw_setup']->db->f('app_name');
|
||||
}
|
||||
// if not otherwise selected, give admin only access to the rest of the default apps,
|
||||
// not yet set for the default group or development only apps like (etemplate, jinn, tt's)
|
||||
if (!$_POST['admin_all_apps'])
|
||||
{
|
||||
$apps = array_intersect(array('admin','emailadmin','filemanager','mydms','news_admin','phpbrain','phpsysinfo','polls','projectmanager','resources','sambaadmin','sitemgr','timesheet','wiki'),$apps);
|
||||
}
|
||||
$GLOBALS['egw_setup']->add_acl($apps,'run',$admingroupid);
|
||||
|
||||
if($_POST['delete_all'])
|
||||
// give admin access to default apps, not yet set for the default group
|
||||
function insert_default_prefs($accountid)
|
||||
{
|
||||
$defaultprefs = array(
|
||||
'common' => array(
|
||||
'maxmatchs' => 15,
|
||||
'template_set' => 'idots',
|
||||
'theme' => 'idots',
|
||||
'navbar_format' => 'icons',
|
||||
'tz_offset' => 0,
|
||||
'dateformat' => 'Y/m/d',
|
||||
'timeformat' => '24',
|
||||
'lang' => get_var('ConfigLang',Array('POST','COOKIE'),'en'),
|
||||
'default_app' => 'calendar',
|
||||
'currency' => '$',
|
||||
'show_help' => True,
|
||||
'max_icons' => 12,
|
||||
),
|
||||
'calendar' => array(
|
||||
'workdaystarts' => 9,
|
||||
'workdayends' => 17,
|
||||
'weekdaystarts' => 'Monday',
|
||||
'defaultcalendar' => 'day',
|
||||
'planner_start_with_group' => $GLOBALS['defaultgroupid'],
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($defaultprefs as $app => $prefs)
|
||||
{
|
||||
/* Now, clear out existing tables */
|
||||
foreach(array($GLOBALS['egw_setup']->accounts_table,$GLOBALS['egw_setup']->prefs_table,$GLOBALS['egw_setup']->acl_table,'egw_access_log') as $table)
|
||||
// only insert them, if they not already exist
|
||||
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->prefs_table,'*',array(
|
||||
'preference_owner' => $accountid,
|
||||
'preference_app' => $app,
|
||||
),__LINE__,__FILE__);
|
||||
if (!$GLOBALS['egw_setup']->db->next_record())
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->delete($table,'1=1',__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
/* Create the demo groups */
|
||||
$defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
|
||||
$admingroupid = (int)$GLOBALS['egw_setup']->add_account('Admins','Admin','Group',False,False);
|
||||
|
||||
if (!$defaultgroupid || !$admingroupid)
|
||||
{
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') === false)
|
||||
{
|
||||
return 42; //lang('Error in group-creation !!!'); // dont exit on setup-cli
|
||||
}
|
||||
echo '<p><b>'.lang('Error in group-creation !!!')."</b></p>\n";
|
||||
echo '<p>'.lang('click <a href="index.php">here</a> to return to setup.')."</p>\n";
|
||||
$GLOBALS['egw_setup']->db->transaction_abort();
|
||||
exit;
|
||||
}
|
||||
|
||||
// Group perms for the default group
|
||||
$GLOBALS['egw_setup']->add_acl(array('addressbook','calendar','infolog','felamimail','preferences','home','manual'),'run',$defaultgroupid);
|
||||
|
||||
$apps = array();
|
||||
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'app_name','app_enabled < 3',__LINE__,__FILE__);
|
||||
while ($GLOBALS['egw_setup']->db->next_record())
|
||||
{
|
||||
$apps[] = $GLOBALS['egw_setup']->db->f('app_name');
|
||||
}
|
||||
// if not otherwise selected, give admin only access to the rest of the default apps,
|
||||
// not yet set for the default group or development only apps like (etemplate, jinn, tt's)
|
||||
if (!$_POST['admin_all_apps'])
|
||||
{
|
||||
$apps = array_intersect(array('admin','emailadmin','filemanager','mydms','news_admin','phpbrain','phpsysinfo','polls','projectmanager','resources','sambaadmin','sitemgr','timesheet','wiki'),$apps);
|
||||
}
|
||||
$GLOBALS['egw_setup']->add_acl($apps,'run',$admingroupid);
|
||||
|
||||
// give admin access to default apps, not yet set for the default group
|
||||
function insert_default_prefs($accountid)
|
||||
{
|
||||
$defaultprefs = array(
|
||||
'common' => array(
|
||||
'maxmatchs' => 15,
|
||||
'template_set' => 'idots',
|
||||
'theme' => 'idots',
|
||||
'navbar_format' => 'icons',
|
||||
'tz_offset' => 0,
|
||||
'dateformat' => 'Y/m/d',
|
||||
'timeformat' => '24',
|
||||
'lang' => get_var('ConfigLang',Array('POST','COOKIE'),'en'),
|
||||
'default_app' => 'calendar',
|
||||
'currency' => '$',
|
||||
'show_help' => True,
|
||||
'max_icons' => 12,
|
||||
),
|
||||
'calendar' => array(
|
||||
'workdaystarts' => 9,
|
||||
'workdayends' => 17,
|
||||
'weekdaystarts' => 'Monday',
|
||||
'defaultcalendar' => 'day',
|
||||
'planner_start_with_group' => $GLOBALS['defaultgroupid'],
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($defaultprefs as $app => $prefs)
|
||||
{
|
||||
// only insert them, if they not already exist
|
||||
$GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->prefs_table,'*',array(
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->prefs_table,array(
|
||||
'preference_value' => serialize($prefs)
|
||||
),array(
|
||||
'preference_owner' => $accountid,
|
||||
'preference_app' => $app,
|
||||
),__LINE__,__FILE__);
|
||||
if (!$GLOBALS['egw_setup']->db->next_record())
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->prefs_table,array(
|
||||
'preference_value' => serialize($prefs)
|
||||
),array(
|
||||
'preference_owner' => $accountid,
|
||||
'preference_app' => $app,
|
||||
),__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
insert_default_prefs(-2); // -2 = default prefs
|
||||
|
||||
/* Creation of the demo accounts is optional - the checkbox is on by default. */
|
||||
if(get_var('create_demo',Array('POST')))
|
||||
{
|
||||
// Create 3 demo accounts
|
||||
$GLOBALS['egw_setup']->add_account('demo','Demo','Account','guest');
|
||||
$GLOBALS['egw_setup']->add_account('demo2','Demo2','Account','guest');
|
||||
$GLOBALS['egw_setup']->add_account('demo3','Demo3','Account','guest');
|
||||
}
|
||||
|
||||
/* Create records for administrator account, with Admins as primary and Default as additional group */
|
||||
$accountid = $GLOBALS['egw_setup']->add_account($username,$fname,$lname,$passwd,'Admins',True,$email);
|
||||
if (!$accountid)
|
||||
{
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') === false)
|
||||
{
|
||||
return 41; //lang('Error in admin-creation !!!'); // dont exit on setup-cli
|
||||
}
|
||||
echo '<p><b>'.lang('Error in admin-creation !!!')."</b></p>\n";
|
||||
echo '<p>'.lang('click <a href="index.php">here</a> to return to setup.')."</p>\n";
|
||||
$GLOBALS['egw_setup']->db->transaction_abort();
|
||||
exit;
|
||||
}
|
||||
$GLOBALS['egw_setup']->set_memberships(array($admingroupid,$defaultgroupid),$accountid);
|
||||
|
||||
$GLOBALS['egw_setup']->db->transaction_commit();
|
||||
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') !== false)
|
||||
{
|
||||
Header('Location: index.php');
|
||||
}
|
||||
}
|
||||
insert_default_prefs(-2); // -2 = default prefs
|
||||
|
||||
/* Creation of the demo accounts is optional - the checkbox is on by default. */
|
||||
if(get_var('create_demo',Array('POST')))
|
||||
{
|
||||
// Create 3 demo accounts
|
||||
$GLOBALS['egw_setup']->add_account('demo','Demo','Account','guest');
|
||||
$GLOBALS['egw_setup']->add_account('demo2','Demo2','Account','guest');
|
||||
$GLOBALS['egw_setup']->add_account('demo3','Demo3','Account','guest');
|
||||
}
|
||||
|
||||
/* Create records for administrator account, with Admins as primary and Default as additional group */
|
||||
$accountid = $GLOBALS['egw_setup']->add_account($username,$fname,$lname,$passwd,'Admins',True,$email);
|
||||
if (!$accountid)
|
||||
{
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') === false)
|
||||
{
|
||||
return 41; //lang('Error in admin-creation !!!'); // dont exit on setup-cli
|
||||
}
|
||||
echo '<p><b>'.lang('Error in admin-creation !!!')."</b></p>\n";
|
||||
echo '<p>'.lang('click <a href="index.php">here</a> to return to setup.')."</p>\n";
|
||||
$GLOBALS['egw_setup']->db->transaction_abort();
|
||||
exit;
|
||||
}
|
||||
$GLOBALS['egw_setup']->set_memberships(array($admingroupid,$defaultgroupid),$accountid);
|
||||
|
||||
$GLOBALS['egw_setup']->db->transaction_commit();
|
||||
|
||||
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') !== false)
|
||||
{
|
||||
Header('Location: index.php');
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
421
setup/config.php
421
setup/config.php
@ -1,239 +1,230 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - Setup *
|
||||
* 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. *
|
||||
\**************************************************************************/
|
||||
/**
|
||||
* eGroupWare Setup - System configuration
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Miles Lott <milos@groupwhere.org>
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
/*
|
||||
Authorize the user to use setup app and load the database
|
||||
Does not return unless user is authorized
|
||||
*/
|
||||
if(!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
Authorize the user to use setup app and load the database
|
||||
Does not return unless user is authorized
|
||||
*/
|
||||
if(!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
|
||||
$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'
|
||||
));
|
||||
|
||||
/* Following to ensure windows file paths are saved correctly */
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
|
||||
/* Check api version, use correct table */
|
||||
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions();
|
||||
|
||||
$newsettings = $_POST['newsettings'];
|
||||
|
||||
if(@get_var('submit',Array('POST')) && @$newsettings)
|
||||
{
|
||||
/* Load hook file with functions to validate each config (one/none/all) */
|
||||
$GLOBALS['egw_setup']->hook('config_validate','setup');
|
||||
|
||||
$datetime = CreateObject('phpgwapi.datetime');
|
||||
switch((int)$newsettings['daytime_port'])
|
||||
{
|
||||
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']);
|
||||
|
||||
$GLOBALS['egw_setup']->db->transaction_begin();
|
||||
foreach($newsettings as $setting => $value)
|
||||
{
|
||||
if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting))
|
||||
{
|
||||
$setting($newsettings);
|
||||
if($GLOBALS['config_error'])
|
||||
{
|
||||
$GLOBALS['error'] .= '<b>'.$GLOBALS['config_error'] ."</b><br />\n";
|
||||
$GLOBALS['config_error'] = '';
|
||||
/* Bail out, stop writing config data */
|
||||
break;
|
||||
}
|
||||
$value = $newsettings[$setting]; // it might be changed by the validation hook
|
||||
}
|
||||
/* 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')))
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->config_table,array(
|
||||
'config_name' => $setting,
|
||||
'config_app' => 'phpgwapi',
|
||||
),__LINE__,__FILE__);
|
||||
unset($newsettings[$setting]);
|
||||
}
|
||||
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__);
|
||||
}
|
||||
}
|
||||
if(!$GLOBALS['error'])
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->transaction_commit();
|
||||
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$GLOBALS['egw_setup']->html->show_header(lang('Configuration'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
|
||||
$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'
|
||||
));
|
||||
|
||||
/* Following to ensure windows file paths are saved correctly */
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
|
||||
/* Check api version, use correct table */
|
||||
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions();
|
||||
|
||||
$newsettings = $_POST['newsettings'];
|
||||
|
||||
if(@get_var('submit',Array('POST')) && @$newsettings)
|
||||
// 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))
|
||||
{
|
||||
$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())
|
||||
{
|
||||
/* Load hook file with functions to validate each config (one/none/all) */
|
||||
$GLOBALS['egw_setup']->hook('config_validate','setup');
|
||||
$GLOBALS['current_config'][$GLOBALS['egw_setup']->db->f('config_name')] = $GLOBALS['egw_setup']->db->f('config_value');
|
||||
}
|
||||
}
|
||||
$setup_tpl->pparse('out','T_config_pre_script');
|
||||
|
||||
$datetime = CreateObject('phpgwapi.datetime');
|
||||
switch((int)$newsettings['daytime_port'])
|
||||
{
|
||||
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);
|
||||
/* Now parse each of the templates we want to show here */
|
||||
class phpgw
|
||||
{
|
||||
var $common;
|
||||
var $accounts;
|
||||
var $applications;
|
||||
var $db;
|
||||
}
|
||||
$GLOBALS['egw'] = new phpgw;
|
||||
$GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
|
||||
$GLOBALS['egw']->db =& $GLOBALS['egw_setup']->db;
|
||||
|
||||
print_debug('TZ_OFFSET',$newsettings['tz_offset']);
|
||||
$t = CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('setup'));
|
||||
|
||||
$GLOBALS['egw_setup']->db->transaction_begin();
|
||||
foreach($newsettings as $setting => $value)
|
||||
{
|
||||
if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting))
|
||||
$t->set_unknowns('keep');
|
||||
$t->set_file(array('config' => 'config.tpl'));
|
||||
$t->set_block('config','body','body');
|
||||
|
||||
$vars = $t->get_undefined('body');
|
||||
$GLOBALS['egw_setup']->hook('config','setup');
|
||||
|
||||
foreach($vars as $value)
|
||||
{
|
||||
$valarray = explode('_',$value);
|
||||
$type = $valarray[0];
|
||||
$new = $newval = '';
|
||||
|
||||
while($chunk = next($valarray))
|
||||
{
|
||||
$new[] = $chunk;
|
||||
}
|
||||
$newval = implode(' ',$new);
|
||||
|
||||
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(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false)
|
||||
{
|
||||
$setting($newsettings);
|
||||
if($GLOBALS['config_error'])
|
||||
{
|
||||
$GLOBALS['error'] .= '<b>'.$GLOBALS['config_error'] ."</b><br />\n";
|
||||
$GLOBALS['config_error'] = '';
|
||||
/* Bail out, stop writing config data */
|
||||
break;
|
||||
}
|
||||
$value = $newsettings[$setting]; // it might be changed by the validation hook
|
||||
}
|
||||
/* 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')))
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->config_table,array(
|
||||
'config_name' => $setting,
|
||||
'config_app' => 'phpgwapi',
|
||||
),__LINE__,__FILE__);
|
||||
unset($newsettings[$setting]);
|
||||
}
|
||||
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__);
|
||||
}
|
||||
}
|
||||
if(!$GLOBALS['error'])
|
||||
{
|
||||
$GLOBALS['egw_setup']->db->transaction_commit();
|
||||
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_header(lang('Configuration'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
|
||||
// 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))
|
||||
{
|
||||
$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');
|
||||
}
|
||||
}
|
||||
$setup_tpl->pparse('out','T_config_pre_script');
|
||||
|
||||
/* Now parse each of the templates we want to show here */
|
||||
class phpgw
|
||||
{
|
||||
var $common;
|
||||
var $accounts;
|
||||
var $applications;
|
||||
var $db;
|
||||
}
|
||||
$GLOBALS['egw'] = new phpgw;
|
||||
$GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
|
||||
$GLOBALS['egw']->db =& $GLOBALS['egw_setup']->db;
|
||||
|
||||
$t = CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('setup'));
|
||||
|
||||
$t->set_unknowns('keep');
|
||||
$t->set_file(array('config' => 'config.tpl'));
|
||||
$t->set_block('config','body','body');
|
||||
|
||||
$vars = $t->get_undefined('body');
|
||||
$GLOBALS['egw_setup']->hook('config','setup');
|
||||
|
||||
foreach($vars as $value)
|
||||
{
|
||||
$valarray = explode('_',$value);
|
||||
$type = $valarray[0];
|
||||
$new = $newval = '';
|
||||
|
||||
while($chunk = next($valarray))
|
||||
{
|
||||
$new[] = $chunk;
|
||||
}
|
||||
$newval = implode(' ',$new);
|
||||
|
||||
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(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false)
|
||||
{
|
||||
$t->set_var($value,'');
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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'])
|
||||
{
|
||||
if($GLOBALS['error'] == 'badldapconnection')
|
||||
{
|
||||
if($GLOBALS['error'] == 'badldapconnection')
|
||||
{
|
||||
/* Please check the number and dial again :) */
|
||||
$GLOBALS['egw_setup']->html->show_alert_msg('Error',
|
||||
lang('There was a problem trying to connect to your LDAP server. <br />'
|
||||
.'please check your LDAP server configuration') . '.');
|
||||
}
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_alert_msg('Error',$GLOBALS['error'].'<p>');
|
||||
/* Please check the number and dial again :) */
|
||||
$GLOBALS['egw_setup']->html->show_alert_msg('Error',
|
||||
lang('There was a problem trying to connect to your LDAP server. <br />'
|
||||
.'please check your LDAP server configuration') . '.');
|
||||
}
|
||||
|
||||
$t->pfp('out','body');
|
||||
unset($t);
|
||||
$GLOBALS['egw_setup']->html->show_alert_msg('Error',$GLOBALS['error'].'<p>');
|
||||
}
|
||||
|
||||
$setup_tpl->set_var('more_configs',lang('Please login to egroupware and run the admin application for additional site configuration') . '.');
|
||||
$t->pfp('out','body');
|
||||
unset($t);
|
||||
|
||||
$setup_tpl->set_var('lang_submit',lang('Save'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
|
||||
$setup_tpl->pparse('out','T_config_post_script');
|
||||
$setup_tpl->set_var('more_configs',lang('Please login to egroupware and run the admin application for additional site configuration') . '.');
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
?>
|
||||
$setup_tpl->set_var('lang_submit',lang('Save'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('Cancel'));
|
||||
$setup_tpl->pparse('out','T_config_post_script');
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
|
@ -1,239 +1,228 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - Setup - DB backup and restore *
|
||||
* http://www.egroupware.org *
|
||||
* Written by RalfBecker@outdoor-training.de *
|
||||
* -------------------------------------------- *
|
||||
* 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. *
|
||||
\**************************************************************************/
|
||||
/**
|
||||
* eGroupWare Setup - DB backup and restore
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
if (!is_object(@$GLOBALS['egw'])) // called from outside eGW ==> setup
|
||||
{
|
||||
include ('./inc/functions.inc.php');
|
||||
|
||||
if (!is_object(@$GLOBALS['egw'])) // called from outside eGW ==> setup
|
||||
{
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include ('./inc/functions.inc.php');
|
||||
@set_time_limit(0);
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
// Check header and authentication
|
||||
if (!$GLOBALS['egw_setup']->auth('Config'))
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
// Does not return unless user is authorized
|
||||
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$self = 'db_backup.php';
|
||||
}
|
||||
$db_backup = CreateObject('phpgwapi.db_backup');
|
||||
$asyncservice = CreateObject('phpgwapi.asyncservice');
|
||||
|
||||
// download a backup, has to be before any output !!!
|
||||
if ($_POST['download'])
|
||||
// Check header and authentication
|
||||
if (!$GLOBALS['egw_setup']->auth('Config'))
|
||||
{
|
||||
list($file) = each($_POST['download']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to now allow to change the dir
|
||||
|
||||
$browser = CreateObject('phpgwapi.browser');
|
||||
$browser->content_header(basename($file));
|
||||
fpassthru($f = fopen($file,'rb'));
|
||||
fclose($f);
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_db_backup' => 'db_backup.tpl',
|
||||
));
|
||||
$setup_tpl->set_block('T_db_backup','schedule_row','schedule_rows');
|
||||
$setup_tpl->set_block('T_db_backup','set_row','set_rows');
|
||||
// Does not return unless user is authorized
|
||||
|
||||
$setup_tpl->set_var('stage_title',$stage_title = lang('DB backup and restore'));
|
||||
$setup_tpl->set_var('stage_desc',lang('This program lets you backup your database, schedule a backup or restore it.'));
|
||||
$setup_tpl->set_var('error_msg','');
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
|
||||
$bgcolor = array('#DDDDDD','#EEEEEE');
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$self = 'db_backup.php';
|
||||
}
|
||||
$db_backup = CreateObject('phpgwapi.db_backup');
|
||||
$asyncservice = CreateObject('phpgwapi.asyncservice');
|
||||
|
||||
if (is_object($GLOBALS['egw_setup']->html))
|
||||
// download a backup, has to be before any output !!!
|
||||
if ($_POST['download'])
|
||||
{
|
||||
list($file) = each($_POST['download']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to now allow to change the dir
|
||||
|
||||
$browser = CreateObject('phpgwapi.browser');
|
||||
$browser->content_header(basename($file));
|
||||
fpassthru($f = fopen($file,'rb'));
|
||||
fclose($f);
|
||||
exit;
|
||||
}
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_db_backup' => 'db_backup.tpl',
|
||||
));
|
||||
$setup_tpl->set_block('T_db_backup','schedule_row','schedule_rows');
|
||||
$setup_tpl->set_block('T_db_backup','set_row','set_rows');
|
||||
|
||||
$setup_tpl->set_var('stage_title',$stage_title = lang('DB backup and restore'));
|
||||
$setup_tpl->set_var('stage_desc',lang('This program lets you backup your database, schedule a backup or restore it.'));
|
||||
$setup_tpl->set_var('error_msg','');
|
||||
|
||||
$bgcolor = array('#DDDDDD','#EEEEEE');
|
||||
|
||||
if (is_object($GLOBALS['egw_setup']->html))
|
||||
{
|
||||
$GLOBALS['egw_setup']->html->show_header($stage_title,False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_block('T_db_backup','setup_header');
|
||||
$setup_tpl->set_var('setup_header','');
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = $stage_title;
|
||||
$GLOBALS['egw']->common->phpgw_header();
|
||||
parse_navbar();
|
||||
}
|
||||
// create a backup now
|
||||
if($_POST['backup'])
|
||||
{
|
||||
if (is_resource($f = $db_backup->fopen_backup()))
|
||||
{
|
||||
$GLOBALS['egw_setup']->html->show_header($stage_title,False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
echo '<p align="center">'.lang('backup started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096);
|
||||
$db_backup->backup($f);
|
||||
fclose($f);
|
||||
$setup_tpl->set_var('error_msg',lang('backup finished'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_block('T_db_backup','setup_header');
|
||||
$setup_tpl->set_var('setup_header','');
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = $stage_title;
|
||||
$GLOBALS['egw']->common->phpgw_header();
|
||||
parse_navbar();
|
||||
$setup_tpl->set_var('error_msg',$f);
|
||||
}
|
||||
// create a backup now
|
||||
if($_POST['backup'])
|
||||
{
|
||||
if (is_resource($f = $db_backup->fopen_backup()))
|
||||
{
|
||||
echo '<p align="center">'.lang('backup started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096);
|
||||
$db_backup->backup($f);
|
||||
fclose($f);
|
||||
$setup_tpl->set_var('error_msg',lang('backup finished'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_var('error_msg',$f);
|
||||
}
|
||||
}
|
||||
$setup_tpl->set_var('backup_now_button','<input type="submit" name="backup" title="'.htmlspecialchars(lang("back's up your DB now, this might take a few minutes")).'" value="'.htmlspecialchars(lang('backup now')).'" />');
|
||||
$setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '.
|
||||
'<input type="submit" name="upload" value="'.htmlspecialchars(lang('upload backup')).'" title="'.htmlspecialchars(lang("uploads a backup to the backup-dir, from where you can restore it")).'" />');
|
||||
}
|
||||
$setup_tpl->set_var('backup_now_button','<input type="submit" name="backup" title="'.htmlspecialchars(lang("back's up your DB now, this might take a few minutes")).'" value="'.htmlspecialchars(lang('backup now')).'" />');
|
||||
$setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '.
|
||||
'<input type="submit" name="upload" value="'.htmlspecialchars(lang('upload backup')).'" title="'.htmlspecialchars(lang("uploads a backup to the backup-dir, from where you can restore it")).'" />');
|
||||
|
||||
if ($_POST['upload'] && is_array($_FILES['uploaded']) && !$_FILES['uploaded']['error'] &&
|
||||
is_uploaded_file($_FILES['uploaded']['tmp_name']))
|
||||
{
|
||||
move_uploaded_file($_FILES['uploaded']['tmp_name'],$db_backup->backup_dir.'/'.$_FILES['uploaded']['name']);
|
||||
if ($_POST['upload'] && is_array($_FILES['uploaded']) && !$_FILES['uploaded']['error'] &&
|
||||
is_uploaded_file($_FILES['uploaded']['tmp_name']))
|
||||
{
|
||||
move_uploaded_file($_FILES['uploaded']['tmp_name'],$db_backup->backup_dir.'/'.$_FILES['uploaded']['name']);
|
||||
|
||||
if (function_exists('md5_file')) // php4.2+
|
||||
{
|
||||
$md5 = ', md5='.md5_file($db_backup->backup_dir.'/'.$_FILES['uploaded']['name']);
|
||||
}
|
||||
$setup_tpl->set_var('error_msg',lang("succesfully uploaded file %1",$_FILES['uploaded']['name'].', '.
|
||||
sprintf('%3.1lf MB (%d)',$_FILES['uploaded']['size']/(1024*1024),$_FILES['uploaded']['size']).$md5));
|
||||
}
|
||||
// delete a backup
|
||||
if ($_POST['delete'])
|
||||
if (function_exists('md5_file')) // php4.2+
|
||||
{
|
||||
$md5 = ', md5='.md5_file($db_backup->backup_dir.'/'.$_FILES['uploaded']['name']);
|
||||
}
|
||||
$setup_tpl->set_var('error_msg',lang("succesfully uploaded file %1",$_FILES['uploaded']['name'].', '.
|
||||
sprintf('%3.1lf MB (%d)',$_FILES['uploaded']['size']/(1024*1024),$_FILES['uploaded']['size']).$md5));
|
||||
}
|
||||
// delete a backup
|
||||
if ($_POST['delete'])
|
||||
{
|
||||
list($file) = each($_POST['delete']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
|
||||
if (unlink($file)) $setup_tpl->set_var('error_msg',lang("backup '%1' deleted",$file));
|
||||
}
|
||||
// rename a backup
|
||||
if ($_POST['rename'])
|
||||
{
|
||||
list($file) = each($_POST['rename']);
|
||||
$new_name = $_POST['new_name'][$file];
|
||||
if (!empty($new_name))
|
||||
{
|
||||
list($file) = each($_POST['delete']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
$ext = preg_match('/(\.gz|\.bz2)+$/i',$file,$matches) ? $matches[1] : '';
|
||||
$new_file = $db_backup->backup_dir.'/'.preg_replace('/(\.gz|\.bz2)+$/i','',basename($new_name)).$ext;
|
||||
if (rename($file,$new_file)) $setup_tpl->set_var('error_msg',lang("backup '%1' renamed to '%2'",basename($file),basename($new_file)));
|
||||
}
|
||||
}
|
||||
// restore a backup
|
||||
if ($_POST['restore'])
|
||||
{
|
||||
list($file) = each($_POST['restore']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
|
||||
if (unlink($file)) $setup_tpl->set_var('error_msg',lang("backup '%1' deleted",$file));
|
||||
}
|
||||
// rename a backup
|
||||
if ($_POST['rename'])
|
||||
if (is_resource($f = $db_backup->fopen_backup($file,true)))
|
||||
{
|
||||
list($file) = each($_POST['rename']);
|
||||
$new_name = $_POST['new_name'][$file];
|
||||
if (!empty($new_name))
|
||||
{
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
$ext = preg_match('/(\.gz|\.bz2)+$/i',$file,$matches) ? $matches[1] : '';
|
||||
$new_file = $db_backup->backup_dir.'/'.preg_replace('/(\.gz|\.bz2)+$/i','',basename($new_name)).$ext;
|
||||
if (rename($file,$new_file)) $setup_tpl->set_var('error_msg',lang("backup '%1' renamed to '%2'",basename($file),basename($new_file)));
|
||||
}
|
||||
echo '<p align="center">'.lang('restore started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096);
|
||||
$db_backup->restore($f);
|
||||
fclose($f);
|
||||
$setup_tpl->set_var('error_msg',lang("backup '%1' restored",$file));
|
||||
}
|
||||
// restore a backup
|
||||
if ($_POST['restore'])
|
||||
else
|
||||
{
|
||||
list($file) = each($_POST['restore']);
|
||||
$file = $db_backup->backup_dir.'/'.basename($file); // basename to not allow to change the dir
|
||||
$setup_tpl->set_var('error_msg',$f);
|
||||
}
|
||||
}
|
||||
// create a new scheduled backup
|
||||
if ($_POST['schedule'])
|
||||
{
|
||||
$asyncservice->set_timer($_POST['times'],'db_backup-'.implode(':',$_POST['times']),'admin.admin_db_backup.do_backup','');
|
||||
}
|
||||
// cancel a scheduled backup
|
||||
if (is_array($_POST['cancel']))
|
||||
{
|
||||
list($id) = each($_POST['cancel']);
|
||||
$asyncservice->cancel_timer($id);
|
||||
}
|
||||
// list scheduled backups
|
||||
if (($jobs = $asyncservice->read('db_backup-%')))
|
||||
{
|
||||
foreach($jobs as $job)
|
||||
{
|
||||
$setup_tpl->set_var($job['times']);
|
||||
$setup_tpl->set_var('next_run',date('Y-m-d H:i',$job['next']));
|
||||
$setup_tpl->set_var('actions','<input type="submit" name="cancel['.$job['id'].']" value="'.htmlspecialchars(lang('delete')).'" />');
|
||||
$setup_tpl->parse('schedule_rows','schedule_row',true);
|
||||
}
|
||||
}
|
||||
// input-fields to create a new scheduled backup
|
||||
foreach($times=array('year'=>'*','month'=>'*','day'=>'*','dow'=>'2-6','hour'=>3,'min'=>0) as $name => $default)
|
||||
{
|
||||
$setup_tpl->set_var($name,'<input name="times['.$name.']" size="5" value="'.$default.'" />');
|
||||
}
|
||||
$setup_tpl->set_var('next_run',' ');
|
||||
$setup_tpl->set_var('actions','<input type="submit" name="schedule" value="'.htmlspecialchars(lang('schedule')).'" />');
|
||||
$setup_tpl->parse('schedule_rows','schedule_row',true);
|
||||
|
||||
if (is_resource($f = $db_backup->fopen_backup($file,true)))
|
||||
{
|
||||
echo '<p align="center">'.lang('restore started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096);
|
||||
$db_backup->restore($f);
|
||||
fclose($f);
|
||||
$setup_tpl->set_var('error_msg',lang("backup '%1' restored",$file));
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_var('error_msg',$f);
|
||||
}
|
||||
}
|
||||
// create a new scheduled backup
|
||||
if ($_POST['schedule'])
|
||||
// listing the availible backup sets
|
||||
$setup_tpl->set_var('backup_dir',$db_backup->backup_dir);
|
||||
$setup_tpl->set_var('set_rows','');
|
||||
$handle = @opendir($db_backup->backup_dir);
|
||||
$files = array();
|
||||
while($handle && ($file = readdir($handle)))
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
$asyncservice->set_timer($_POST['times'],'db_backup-'.implode(':',$_POST['times']),'admin.admin_db_backup.do_backup','');
|
||||
}
|
||||
// cancel a scheduled backup
|
||||
if (is_array($_POST['cancel']))
|
||||
{
|
||||
list($id) = each($_POST['cancel']);
|
||||
$asyncservice->cancel_timer($id);
|
||||
}
|
||||
// list scheduled backups
|
||||
if (($jobs = $asyncservice->read('db_backup-%')))
|
||||
{
|
||||
foreach($jobs as $job)
|
||||
{
|
||||
$setup_tpl->set_var($job['times']);
|
||||
$setup_tpl->set_var('next_run',date('Y-m-d H:i',$job['next']));
|
||||
$setup_tpl->set_var('actions','<input type="submit" name="cancel['.$job['id'].']" value="'.htmlspecialchars(lang('delete')).'" />');
|
||||
$setup_tpl->parse('schedule_rows','schedule_row',true);
|
||||
}
|
||||
}
|
||||
// input-fields to create a new scheduled backup
|
||||
foreach($times=array('year'=>'*','month'=>'*','day'=>'*','dow'=>'2-6','hour'=>3,'min'=>0) as $name => $default)
|
||||
{
|
||||
$setup_tpl->set_var($name,'<input name="times['.$name.']" size="5" value="'.$default.'" />');
|
||||
}
|
||||
$setup_tpl->set_var('next_run',' ');
|
||||
$setup_tpl->set_var('actions','<input type="submit" name="schedule" value="'.htmlspecialchars(lang('schedule')).'" />');
|
||||
$setup_tpl->parse('schedule_rows','schedule_row',true);
|
||||
|
||||
// listing the availible backup sets
|
||||
$setup_tpl->set_var('backup_dir',$db_backup->backup_dir);
|
||||
$setup_tpl->set_var('set_rows','');
|
||||
$handle = @opendir($db_backup->backup_dir);
|
||||
$files = array();
|
||||
while($handle && ($file = readdir($handle)))
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
$files[filectime($db_backup->backup_dir.'/'.$file)] = $file;
|
||||
}
|
||||
}
|
||||
if ($handle) closedir($handle);
|
||||
|
||||
krsort($files);
|
||||
foreach($files as $ctime => $file)
|
||||
{
|
||||
$size = filesize($db_backup->backup_dir.'/'.$file);
|
||||
$setup_tpl->set_var(array(
|
||||
'filename' => $file,
|
||||
'date' => date('Y-m-d H:i',$ctime),
|
||||
'size' => sprintf('%3.1lf MB (%d)',$size/(1024*1024),$size),
|
||||
'actions' => '<input type="submit" name="download['.$file.']" value="'.htmlspecialchars(lang('download')).'" /> '."\n".
|
||||
'<input type="submit" name="delete['.$file.']" value="'.htmlspecialchars(lang('delete')).'" onclick="return confirm(\''.
|
||||
htmlspecialchars(lang('Confirm to delete this backup?')).'\');" /> '."\n".
|
||||
'<input name="new_name['.$file.']" value="" size="15" /><input type="submit" name="rename['.$file.']" value="'.htmlspecialchars(lang('rename')).'" /> '."\n".
|
||||
'<input type="submit" name="restore['.$file.']" value="'.htmlspecialchars(lang('restore')).'" onclick="return confirm(\''.
|
||||
htmlspecialchars(lang('Restoring a backup will delete/replace all content in your database. Are you sure?')).'\');" />',
|
||||
));
|
||||
$setup_tpl->parse('set_rows','set_row',true);
|
||||
$files[filectime($db_backup->backup_dir.'/'.$file)] = $file;
|
||||
}
|
||||
}
|
||||
if ($handle) closedir($handle);
|
||||
|
||||
krsort($files);
|
||||
foreach($files as $ctime => $file)
|
||||
{
|
||||
$size = filesize($db_backup->backup_dir.'/'.$file);
|
||||
$setup_tpl->set_var(array(
|
||||
'lang_scheduled_backups'=> lang('scheduled backups'),
|
||||
'lang_year' => lang('year'),
|
||||
'lang_month' => lang('month'),
|
||||
'lang_day' => lang('day'),
|
||||
'lang_dow' => lang('day of week<br />(0-6, 0=sunday)'),
|
||||
'lang_hour' => lang('hour (0-24)'),
|
||||
'lang_minute' => lang('minute'),
|
||||
'lang_next_run' => lang('next run'),
|
||||
'lang_actions' => lang('actions'),
|
||||
'lang_backup_sets' => lang('backup sets'),
|
||||
'lang_filename' => lang('filename'),
|
||||
'lang_date' => lang('created'),
|
||||
'lang_size' => lang('size'),
|
||||
'filename' => $file,
|
||||
'date' => date('Y-m-d H:i',$ctime),
|
||||
'size' => sprintf('%3.1lf MB (%d)',$size/(1024*1024),$size),
|
||||
'actions' => '<input type="submit" name="download['.$file.']" value="'.htmlspecialchars(lang('download')).'" /> '."\n".
|
||||
'<input type="submit" name="delete['.$file.']" value="'.htmlspecialchars(lang('delete')).'" onclick="return confirm(\''.
|
||||
htmlspecialchars(lang('Confirm to delete this backup?')).'\');" /> '."\n".
|
||||
'<input name="new_name['.$file.']" value="" size="15" /><input type="submit" name="rename['.$file.']" value="'.htmlspecialchars(lang('rename')).'" /> '."\n".
|
||||
'<input type="submit" name="restore['.$file.']" value="'.htmlspecialchars(lang('restore')).'" onclick="return confirm(\''.
|
||||
htmlspecialchars(lang('Restoring a backup will delete/replace all content in your database. Are you sure?')).'\');" />',
|
||||
));
|
||||
$setup_tpl->parse('set_rows','set_row',true);
|
||||
}
|
||||
|
||||
$setup_tpl->set_var('self',$self);
|
||||
$setup_tpl->pparse('out','T_db_backup');
|
||||
$setup_tpl->set_var(array(
|
||||
'lang_scheduled_backups'=> lang('scheduled backups'),
|
||||
'lang_year' => lang('year'),
|
||||
'lang_month' => lang('month'),
|
||||
'lang_day' => lang('day'),
|
||||
'lang_dow' => lang('day of week<br />(0-6, 0=sunday)'),
|
||||
'lang_hour' => lang('hour (0-24)'),
|
||||
'lang_minute' => lang('minute'),
|
||||
'lang_next_run' => lang('next run'),
|
||||
'lang_actions' => lang('actions'),
|
||||
'lang_backup_sets' => lang('backup sets'),
|
||||
'lang_filename' => lang('filename'),
|
||||
'lang_date' => lang('created'),
|
||||
'lang_size' => lang('size'),
|
||||
));
|
||||
|
||||
if (is_object($GLOBALS['egw_setup']->html))
|
||||
{
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
}
|
||||
?>
|
||||
$setup_tpl->set_var('self',$self);
|
||||
$setup_tpl->pparse('out','T_db_backup');
|
||||
|
||||
if (is_object($GLOBALS['egw_setup']->html))
|
||||
{
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
}
|
||||
|
@ -1,29 +1,19 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - Setup - fixes a mysql DB to match our system_charset *
|
||||
* http://www.eGroupWare.org *
|
||||
* Written by RalfBecker@outdoor-training.de *
|
||||
* -------------------------------------------- *
|
||||
* 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$ */
|
||||
/**
|
||||
* eGroupWare Setup - fixes a mysql DB to match our system_charset
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
// if we are NOT called as part of an update script, behave like a regular setup script
|
||||
if (!isset($GLOBALS['egw_setup']) || !is_object($GLOBALS['egw_setup']))
|
||||
if (!isset($GLOBALS['egw_setup']) || !is_object($GLOBALS['egw_setup']))
|
||||
{
|
||||
$diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all
|
||||
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
@ -53,7 +43,7 @@ $db_version = (float) $ServerInfo['version'];
|
||||
|
||||
if ($running_standalone || $_REQUEST['debug']) echo "<p>DB-Type='<b>{$GLOBALS['egw_setup']->db->Type}</b>', DB-Version=<b>$db_version</b> ($ServerInfo[description]), eGroupWare system_charset='<b>{$GLOBALS['egw_setup']->system_charset}</b>', DB-connection charset was '<b>{$GLOBALS['egw_setup']->db_charset_was}</b>'</p>\n";
|
||||
|
||||
$mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ?
|
||||
$mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ?
|
||||
$charset2mysql[$GLOBALS['egw_setup']->system_charset] : $GLOBALS['egw_setup']->system_charset;
|
||||
|
||||
if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was &&
|
||||
@ -85,7 +75,7 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
$fulltext[$row['Column_name']] = $row['Key_name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$alter_table = $alter_table_back = array();
|
||||
foreach($columns as $column)
|
||||
{
|
||||
@ -93,13 +83,13 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
{
|
||||
list(,$type,$size) = $matches;
|
||||
list($charset) = explode('_',$column['Collation']);
|
||||
|
||||
|
||||
if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset];
|
||||
|
||||
|
||||
if ($charset != $GLOBALS['egw_setup']->system_charset)
|
||||
{
|
||||
$col = $column['Field'];
|
||||
|
||||
|
||||
if ($type == 'varchar' || $type == 'char') // old schema_proc (pre 1.0.1) used also char
|
||||
{
|
||||
$type = 'varchar('.$size.')';
|
||||
@ -110,10 +100,10 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
$bintype = str_replace('text','blob',$type);
|
||||
}
|
||||
//echo "<p>$table.$col $type CHARACTER SET $charset $default $null</p>\n";
|
||||
|
||||
|
||||
$default = !is_null($column['Default']) ? "DEFAULT '".$column['Default']."'" : '';
|
||||
$null = $column['Null'] ? 'NULL' : 'NOT NULL';
|
||||
|
||||
|
||||
if (isset($fulltext[$col]))
|
||||
{
|
||||
$idx_name = $fulltext[$col];
|
||||
@ -127,13 +117,13 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
}
|
||||
}
|
||||
$fulltext_back[$idx_name] = $idx_cols;
|
||||
$alter_table[] = " DROP INDEX `$idx_name`";
|
||||
$alter_table[] = " DROP INDEX `$idx_name`";
|
||||
}
|
||||
$alter_table[] = " CHANGE `$col` `$col` $bintype $default $null";
|
||||
$alter_table_back[] = " CHANGE `$col` `$col` $type CHARACTER SET $mysql_system_charset $default $null";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list($charset) = explode('_',$collation);
|
||||
if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset];
|
||||
if ($charset != $GLOBALS['egw_setup']->system_charset)
|
||||
@ -143,7 +133,7 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
if (count($alter_table))
|
||||
{
|
||||
$alter_table = "ALTER TABLE $table\n".implode(",\n",$alter_table);
|
||||
|
||||
|
||||
if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table)."</p>\n";
|
||||
if (!$db->query($alter_table,__LINE__,__FILE__))
|
||||
{
|
||||
@ -159,7 +149,7 @@ if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setu
|
||||
if (count($alter_table_back))
|
||||
{
|
||||
$alter_table_back = "ALTER TABLE $table\n".implode(",\n",$alter_table_back);
|
||||
|
||||
|
||||
if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table_back)."</p>\n";
|
||||
if (!$db->query($alter_table_back,__LINE__,__FILE__))
|
||||
{
|
||||
|
1025
setup/index.php
1025
setup/index.php
File diff suppressed because it is too large
Load Diff
227
setup/lang.php
227
setup/lang.php
@ -1,133 +1,124 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - Setup *
|
||||
* 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. *
|
||||
\**************************************************************************/
|
||||
/**
|
||||
* eGroupWare Setup - Install & remove languages
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Miles Lott <milos@groupwhere.org>
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
include('./inc/functions.inc.php');
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if (!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
// Authorize the user to use setup app and load the database
|
||||
// Does not return unless user is authorized
|
||||
if (!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
|
||||
if (@$_POST['submit'])
|
||||
{
|
||||
$GLOBALS['egw_setup']->translation->setup_translation_sql();
|
||||
$GLOBALS['egw_setup']->translation->sql->install_langs(@$_POST['lang_selected'],@$_POST['upgrademethod']);
|
||||
|
||||
|
||||
if( !$GLOBALS['egw_setup']->translation->sql->line_rejected )
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$GLOBALS['egw_setup']->loaddb();
|
||||
}
|
||||
|
||||
if (@$_POST['submit'])
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl',
|
||||
'T_lang_main' => 'lang_main.tpl'
|
||||
));
|
||||
|
||||
$setup_tpl->set_block('T_lang_main','B_choose_method','V_choose_method');
|
||||
|
||||
$stage_title = lang('Multi-Language support setup');
|
||||
$stage_desc = lang('This program will help you upgrade or install different languages for eGroupWare');
|
||||
$tbl_width = @$newinstall ? '60%' : '80%';
|
||||
$td_colspan = @$newinstall ? '1' : '2';
|
||||
$td_align = @$newinstall ? ' align="center"' : '';
|
||||
$hidden_var1 = @$newinstall ? '<input type="hidden" name="newinstall" value="True" />' : '';
|
||||
|
||||
if (!@$newinstall && !isset($GLOBALS['egw_info']['setup']['installed_langs']))
|
||||
{
|
||||
$GLOBALS['egw_setup']->detection->check_lang(false); // get installed langs
|
||||
}
|
||||
$select_box_desc = lang('Select which languages you would like to use');
|
||||
$select_box = '';
|
||||
$languages = get_langs();
|
||||
uasort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);'));
|
||||
foreach($languages as $id => $data)
|
||||
{
|
||||
$select_box_langs =
|
||||
@$select_box_langs
|
||||
.'<option value="' . $id . '"'
|
||||
.(@$GLOBALS['egw_info']['setup']['installed_langs'][$id]?' selected="selected"':'').'>'
|
||||
. $data['descr'] . '</option>'
|
||||
."\n";
|
||||
}
|
||||
|
||||
if (!@$newinstall)
|
||||
{
|
||||
$meth_desc = lang('Select which method of upgrade you would like to do');
|
||||
$blurb_addonlynew = lang('Only add languages that are not in the database already');
|
||||
$blurb_addmissing = lang('Only add new phrases');
|
||||
$blurb_dumpold = lang('Delete all old languages and install new ones');
|
||||
|
||||
$setup_tpl->set_var('meth_desc',$meth_desc);
|
||||
$setup_tpl->set_var('blurb_addonlynew',$blurb_addonlynew);
|
||||
$setup_tpl->set_var('blurb_addmissing',$blurb_addmissing);
|
||||
$setup_tpl->set_var('blurb_dumpold',$blurb_dumpold);
|
||||
$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
|
||||
$setup_tpl->parse('V_choose_method','B_choose_method');
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_var('V_choose_method','');
|
||||
}
|
||||
|
||||
// Rejected Lines
|
||||
if($_POST['debug'] && count($GLOBALS['egw_setup']->translation->sql->line_rejected))
|
||||
{
|
||||
$str = '';
|
||||
foreach($GLOBALS['egw_setup']->translation->sql->line_rejected as $badline)
|
||||
{
|
||||
$GLOBALS['egw_setup']->translation->setup_translation_sql();
|
||||
$GLOBALS['egw_setup']->translation->sql->install_langs(@$_POST['lang_selected'],@$_POST['upgrademethod']);
|
||||
|
||||
|
||||
if( !$GLOBALS['egw_setup']->translation->sql->line_rejected )
|
||||
{
|
||||
Header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
$_f_buffer = split("[/\\]", $badline['appfile']);
|
||||
$str .= lang('Application: %1, File: %2, Line: "%3"','<b>'.$_f_buffer[count($_f_buffer)-3].'</b>',
|
||||
'<b>'.$_f_buffer[count($_f_buffer)-1].'</b>',$badline['line'])."<br />\n";
|
||||
}
|
||||
$setup_tpl->set_var('V_alert_word', lang('Rejected lines'));
|
||||
$setup_tpl->set_var('V_alert_msg', $str);
|
||||
$alert = TRUE;
|
||||
}
|
||||
|
||||
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
|
||||
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
|
||||
$setup_tpl->set_file(array(
|
||||
'T_head' => 'head.tpl',
|
||||
'T_footer' => 'footer.tpl',
|
||||
'T_alert_msg' => 'msg_alert_msg.tpl',
|
||||
'T_lang_main' => 'lang_main.tpl'
|
||||
));
|
||||
$setup_tpl->set_var('stage_title',$stage_title);
|
||||
$setup_tpl->set_var('stage_desc',$stage_desc);
|
||||
$setup_tpl->set_var('tbl_width',$tbl_width);
|
||||
$setup_tpl->set_var('td_colspan',$td_colspan);
|
||||
$setup_tpl->set_var('td_align',$td_align);
|
||||
$setup_tpl->set_var('hidden_var1',$hidden_var1);
|
||||
$setup_tpl->set_var('select_box_desc',$select_box_desc);
|
||||
$setup_tpl->set_var('select_box_langs',$select_box_langs);
|
||||
|
||||
$setup_tpl->set_block('T_lang_main','B_choose_method','V_choose_method');
|
||||
$setup_tpl->set_var('lang_install',lang('install'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('cancel'));
|
||||
|
||||
$stage_title = lang('Multi-Language support setup');
|
||||
$stage_desc = lang('This program will help you upgrade or install different languages for eGroupWare');
|
||||
$tbl_width = @$newinstall ? '60%' : '80%';
|
||||
$td_colspan = @$newinstall ? '1' : '2';
|
||||
$td_align = @$newinstall ? ' align="center"' : '';
|
||||
$hidden_var1 = @$newinstall ? '<input type="hidden" name="newinstall" value="True" />' : '';
|
||||
$GLOBALS['egw_setup']->html->show_header("$stage_title",False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
$setup_tpl->pparse('out','T_lang_main');
|
||||
|
||||
if (!@$newinstall && !isset($GLOBALS['egw_info']['setup']['installed_langs']))
|
||||
{
|
||||
$GLOBALS['egw_setup']->detection->check_lang(false); // get installed langs
|
||||
}
|
||||
$select_box_desc = lang('Select which languages you would like to use');
|
||||
$select_box = '';
|
||||
$languages = get_langs();
|
||||
uasort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);'));
|
||||
foreach($languages as $id => $data)
|
||||
{
|
||||
$select_box_langs =
|
||||
@$select_box_langs
|
||||
.'<option value="' . $id . '"'
|
||||
.(@$GLOBALS['egw_info']['setup']['installed_langs'][$id]?' selected="selected"':'').'>'
|
||||
. $data['descr'] . '</option>'
|
||||
."\n";
|
||||
}
|
||||
if($alert)
|
||||
$setup_tpl->pparse('out','T_alert_msg');
|
||||
|
||||
if (!@$newinstall)
|
||||
{
|
||||
$meth_desc = lang('Select which method of upgrade you would like to do');
|
||||
$blurb_addonlynew = lang('Only add languages that are not in the database already');
|
||||
$blurb_addmissing = lang('Only add new phrases');
|
||||
$blurb_dumpold = lang('Delete all old languages and install new ones');
|
||||
|
||||
$setup_tpl->set_var('meth_desc',$meth_desc);
|
||||
$setup_tpl->set_var('blurb_addonlynew',$blurb_addonlynew);
|
||||
$setup_tpl->set_var('blurb_addmissing',$blurb_addmissing);
|
||||
$setup_tpl->set_var('blurb_dumpold',$blurb_dumpold);
|
||||
$setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
|
||||
$setup_tpl->parse('V_choose_method','B_choose_method');
|
||||
}
|
||||
else
|
||||
{
|
||||
$setup_tpl->set_var('V_choose_method','');
|
||||
}
|
||||
|
||||
// Rejected Lines
|
||||
if($_POST['debug'] && count($GLOBALS['egw_setup']->translation->sql->line_rejected))
|
||||
{
|
||||
$str = '';
|
||||
foreach($GLOBALS['egw_setup']->translation->sql->line_rejected as $badline)
|
||||
{
|
||||
$_f_buffer = split("[/\\]", $badline['appfile']);
|
||||
$str .= lang('Application: %1, File: %2, Line: "%3"','<b>'.$_f_buffer[count($_f_buffer)-3].'</b>',
|
||||
'<b>'.$_f_buffer[count($_f_buffer)-1].'</b>',$badline['line'])."<br />\n";
|
||||
}
|
||||
$setup_tpl->set_var('V_alert_word', lang('Rejected lines'));
|
||||
$setup_tpl->set_var('V_alert_msg', $str);
|
||||
$alert = TRUE;
|
||||
}
|
||||
|
||||
$setup_tpl->set_var('stage_title',$stage_title);
|
||||
$setup_tpl->set_var('stage_desc',$stage_desc);
|
||||
$setup_tpl->set_var('tbl_width',$tbl_width);
|
||||
$setup_tpl->set_var('td_colspan',$td_colspan);
|
||||
$setup_tpl->set_var('td_align',$td_align);
|
||||
$setup_tpl->set_var('hidden_var1',$hidden_var1);
|
||||
$setup_tpl->set_var('select_box_desc',$select_box_desc);
|
||||
$setup_tpl->set_var('select_box_langs',$select_box_langs);
|
||||
|
||||
$setup_tpl->set_var('lang_install',lang('install'));
|
||||
$setup_tpl->set_var('lang_cancel',lang('cancel'));
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_header("$stage_title",False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
|
||||
$setup_tpl->pparse('out','T_lang_main');
|
||||
|
||||
if($alert)
|
||||
$setup_tpl->pparse('out','T_alert_msg');
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
?>
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
|
@ -10,18 +10,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
$GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'nocachecontrol' => True,
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'currentapp' => 'home',
|
||||
'noapi' => True
|
||||
));
|
||||
include('./inc/functions.inc.php');
|
||||
|
||||
require_once('./inc/class.setup_header.inc.php');
|
||||
$GLOBALS['egw_setup']->header =& new setup_header();
|
||||
$GLOBALS['egw_setup']->header =& new setup_header();
|
||||
|
||||
$setup_tpl = CreateObject('phpgwapi.Template','./templates/default');
|
||||
$setup_tpl->set_file(array(
|
||||
@ -54,16 +46,16 @@ switch($GLOBALS['egw_info']['setup']['stage']['header'])
|
||||
$GLOBALS['egw_info']['setup']['PageMSG'] = lang('You have not created your header.inc.php yet!<br /> You can create it now.');
|
||||
break;
|
||||
case '2':
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['PageMSG'] =
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['PageMSG'] =
|
||||
lang('Your header admin password is NOT set. Please set it now!');
|
||||
break;
|
||||
case '3':
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['PageMSG'] =
|
||||
$GLOBALS['egw_info']['setup']['HeaderLoginMSG'] =
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['PageMSG'] =
|
||||
$GLOBALS['egw_info']['setup']['HeaderLoginMSG'] =
|
||||
lang('You need to add at least one eGroupWare domain / database instance.');
|
||||
break;
|
||||
case '4':
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] =
|
||||
$GLOBALS['egw_info']['setup']['HeaderFormMSG'] = $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] =
|
||||
lang('Your header.inc.php needs upgrading.');
|
||||
$GLOBALS['egw_info']['setup']['PageMSG'] = lang('Your header.inc.php needs upgrading.<br /><blink><b class="msg">WARNING!</b></blink><br /><b>MAKE BACKUPS!</b>');
|
||||
break;
|
||||
@ -75,7 +67,7 @@ switch($GLOBALS['egw_info']['setup']['stage']['header'])
|
||||
|
||||
if (!file_exists('../header.inc.php') || !is_readable('../header.inc.php'))
|
||||
{
|
||||
$GLOBALS['egw_setup']->header->defaults();
|
||||
$GLOBALS['egw_setup']->header->defaults();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -174,7 +166,7 @@ function check_header_form()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// setting the domain settings from the posted content
|
||||
foreach($_POST['domains'] as $key => $domain)
|
||||
{
|
||||
@ -192,22 +184,22 @@ function check_header_form()
|
||||
$GLOBALS['egw_domain'][$domain][$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// validate the input and return errors
|
||||
$validation_errors = $GLOBALS['egw_setup']->header->validation_errors(
|
||||
$GLOBALS['egw_info']['server']['server_root'],
|
||||
$GLOBALS['egw_info']['server']['include_root']);
|
||||
|
||||
|
||||
//echo "egw_info[server]=<pre>".print_r($GLOBALS['egw_info']['server'],true)."</pre>\n";
|
||||
//echo "egw_domain=<pre>".print_r($GLOBALS['egw_domain'],true)."</pre>\n";
|
||||
//if ($validation_errors) echo "validation_errors=<pre>".print_r($validation_errors,true)."</pre>\n";
|
||||
|
||||
|
||||
return $validation_errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form to edit the configuration
|
||||
*
|
||||
*
|
||||
* @param array $validation_errors to display
|
||||
*/
|
||||
function show_header_form($validation_errors)
|
||||
@ -278,11 +270,11 @@ function show_header_form($validation_errors)
|
||||
if(!isset($GLOBALS['egw_domain']))
|
||||
{
|
||||
$detected[] = lang('You need to add some domains to your header.inc.php.');
|
||||
|
||||
|
||||
$GLOBALS['egw_domain']['default'] = $GLOBALS['egw_setup']->header->domain_defaults(
|
||||
$GLOBALS['egw_info']['server']['header_admin_user'],
|
||||
$GLOBALS['egw_info']['server']['header_admin_password'],$supported_db);
|
||||
}
|
||||
}
|
||||
elseif(@$GLOBALS['egw_info']['server']['header_version'] != @$GLOBALS['egw_info']['server']['current_header_version'])
|
||||
{
|
||||
$detected[] = lang("You're using an old header.inc.php version...");
|
||||
@ -324,7 +316,7 @@ function show_header_form($validation_errors)
|
||||
$options = array();
|
||||
foreach($supported_sessions_type as $type => $label)
|
||||
{
|
||||
$options[] = '<option ' . ($type == $GLOBALS['egw_info']['server']['sessions_type'] ?
|
||||
$options[] = '<option ' . ($type == $GLOBALS['egw_info']['server']['sessions_type'] ?
|
||||
'selected="selected" ' : '') . 'value="' . $type . '">' . $label . '</option>';
|
||||
}
|
||||
$setup_tpl->set_var('session_options',implode("\n",$options));
|
||||
@ -431,4 +423,4 @@ function show_header_form($validation_errors)
|
||||
$setup_tpl->pfp('out','manageheader');
|
||||
|
||||
$GLOBALS['egw_setup']->html->show_footer();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @link http://www.egroupware.org
|
||||
* @package setup
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright (c) 2006 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
@ -73,18 +73,18 @@ switch($action)
|
||||
case '--check':
|
||||
setup_cmd::check_installed($arguments[0],0,true);
|
||||
break;
|
||||
|
||||
|
||||
case '--create-header':
|
||||
case '--edit-header':
|
||||
case '--upgrade-header':
|
||||
case '--update-header':
|
||||
do_header($action == '--create-header',$arguments);
|
||||
break;
|
||||
|
||||
|
||||
case '--install':
|
||||
do_install($arguments[0]);
|
||||
break;
|
||||
|
||||
|
||||
case '--config':
|
||||
do_config($arguments);
|
||||
break;
|
||||
@ -96,11 +96,11 @@ switch($action)
|
||||
case '--language':
|
||||
do_lang($arguments[0]);
|
||||
break;
|
||||
|
||||
|
||||
case '--update':
|
||||
do_update($arguments[0]);
|
||||
break;
|
||||
|
||||
|
||||
case '--backup':
|
||||
do_backup($arguments[0]);
|
||||
break;
|
||||
@ -112,11 +112,11 @@ switch($action)
|
||||
case '--charsets':
|
||||
echo html_entity_decode(implode("\n",$GLOBALS['egw_setup']->translation->get_charsets(false)),ENT_COMPAT,'utf-8')."\n";
|
||||
break;
|
||||
|
||||
|
||||
case '--exit-codes':
|
||||
list_exit_codes();
|
||||
break;
|
||||
|
||||
|
||||
case '--help':
|
||||
case '--usage':
|
||||
do_usage($arguments[0]);
|
||||
@ -159,16 +159,16 @@ function do_config($args)
|
||||
$user = @array_shift($arg0);
|
||||
$password = @array_shift($arg0);
|
||||
_fetch_user_password($user,$password);
|
||||
|
||||
|
||||
if ($arg0) // direct assignments (name=value,...) left
|
||||
{
|
||||
array_unshift($args,implode(',',$arg0));
|
||||
array_unshift($args,'--config');
|
||||
}
|
||||
|
||||
|
||||
$cmd = new setup_cmd_config($domain,$user,$password,$args,true);
|
||||
echo $cmd->run()."\n\n";
|
||||
|
||||
|
||||
$cmd->get_config(true);
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ function do_emailadmin()
|
||||
|
||||
$emailadmin = new emailadmin_bo(-1,false); // false=no session stuff
|
||||
$emailadmin->setDefaultProfile($config);
|
||||
|
||||
|
||||
echo "\n".lang('EMailAdmin profile updated:')."\n";
|
||||
foreach($config as $name => $value)
|
||||
{
|
||||
@ -208,7 +208,7 @@ function do_admin($arg)
|
||||
{
|
||||
list($domain,$user,$password,$admin,$pw,$first,$last,$email) = explode(',',$arg);
|
||||
_fetch_user_password($user,$password);
|
||||
|
||||
|
||||
$cmd = new setup_cmd_admin($domain,$user,$password,$admin,$pw,$first,$last,$email);
|
||||
echo $cmd->run()."\n";
|
||||
}
|
||||
@ -231,11 +231,11 @@ function do_backup($arg,$quite_check=false)
|
||||
foreach($domains as $domain => $data)
|
||||
{
|
||||
$options[0] = $domain;
|
||||
|
||||
|
||||
if ($quite_check) ob_start();
|
||||
_check_auth_config(implode(',',$options),14);
|
||||
if ($quite_check) ob_end_clean();
|
||||
|
||||
|
||||
if ($backup == 'no')
|
||||
{
|
||||
echo lang('Backup skipped!')."\n";
|
||||
@ -278,9 +278,9 @@ function do_update($arg)
|
||||
{
|
||||
$options[0] = $domain;
|
||||
$arg = implode(',',$options);
|
||||
|
||||
|
||||
_check_auth_config($arg,14);
|
||||
|
||||
|
||||
if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4)
|
||||
{
|
||||
echo lang('No update necessary, domain %1(%2) is up to date.',$domain,$data['db_type'])."\n";
|
||||
@ -288,16 +288,16 @@ function do_update($arg)
|
||||
else
|
||||
{
|
||||
echo lang('Start updating the database ...')."\n";
|
||||
|
||||
|
||||
do_backup($arg,true);
|
||||
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['egw_setup']->process->init_process(); // we need a new schema-proc instance for each new domain
|
||||
$GLOBALS['egw_setup']->process->pass($setup_info,'upgrade',false);
|
||||
$messages = ob_get_contents();
|
||||
ob_end_clean();
|
||||
if ($messages) echo strip_tags($messages)."\n";
|
||||
|
||||
|
||||
echo lang('Update finished.')."\n";
|
||||
}
|
||||
}
|
||||
@ -323,9 +323,9 @@ function do_lang($arg)
|
||||
{
|
||||
$options[0] = $domain;
|
||||
$arg = implode(',',$options);
|
||||
|
||||
|
||||
$langs = _check_auth_config($arg,15,false); // false = leave eGW's charset, dont set ours!!!
|
||||
|
||||
|
||||
$GLOBALS['egw_setup']->translation->setup_translation_sql();
|
||||
|
||||
if ($langs[0]{0} === '+' || !count($langs)) // update / add to existing languages
|
||||
@ -352,14 +352,14 @@ function do_lang($arg)
|
||||
$GLOBALS['egw_setup']->translation->sql->install_langs($langs);
|
||||
echo lang('Languages updated.')."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if eGW is installed according to $stop and we have the necessary authorization for config
|
||||
*
|
||||
*
|
||||
* The password can be specified as parameter, via the enviroment variable EGW_CLI_PASSWORD or
|
||||
* querier from the user. Specifying it as parameter can be security problem!
|
||||
*
|
||||
*
|
||||
* We allow the config user/pw of the domain OR the header admin user/pw!
|
||||
*
|
||||
* @param string $arg [domain(default)],[user(admin)],password
|
||||
@ -394,7 +394,7 @@ function do_install($args)
|
||||
{
|
||||
list($domain,$user,$password,$backup,$charset) = explode(',',$args);
|
||||
_fetch_user_password($user,$password);
|
||||
|
||||
|
||||
$cmd = new setup_cmd_install($domain,$user,$password,$backup,$charset,true);
|
||||
echo $cmd->run()."\n";
|
||||
}
|
||||
@ -457,7 +457,7 @@ function get_lang(&$charset)
|
||||
if (isset($languages[$lang.'-'.$nation])) return $lang.'-'.$nation;
|
||||
|
||||
if (isset($languages[$lang])) return $lang;
|
||||
|
||||
|
||||
return 'en';
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ function create_http_enviroment()
|
||||
function do_usage($what='')
|
||||
{
|
||||
echo lang('Usage: %1 command [additional options]',basename($_SERVER['argv'][0]))."\n\n";
|
||||
|
||||
|
||||
if (!$what)
|
||||
{
|
||||
echo '--check '.lang('checks eGroupWare\'s installed, it\'s versions and necessary upgrads (return values see --exit-codes)')."\n";
|
||||
@ -534,7 +534,7 @@ function do_usage($what='')
|
||||
echo '--mcrypt '.lang('use mcrypt to crypt session-data: {off(default) | on},[mcrypt-init-vector(default randomly generated)],[mcrypt-version]')."\n";
|
||||
echo '--db-persistent '.lang('use persistent db connections: {on(default) | off}')."\n";
|
||||
echo '--domain-selectbox '.lang('{off(default) | on}')."\n";
|
||||
|
||||
|
||||
echo "\n".lang('Adding, editing or deleting an eGroupWare domain / database instance:')."\n";
|
||||
echo '--domain '.lang('add or edit a domain: [domain-name(default)],[db-name(egroupware)],[db-user(egroupware)],db-password,[db-type(mysql)],[db-host(localhost)],[db-port(db specific)],[config-user(as header)],[config-passwd(as header)]')."\n";
|
||||
echo '--delete-domain '.lang('domain-name')."\n";
|
||||
@ -565,9 +565,9 @@ function fail($exit_code,$message)
|
||||
/**
|
||||
* List all exit codes used by the command line interface
|
||||
*
|
||||
* The list is generated by "greping" this file for calls to the fail() function.
|
||||
* The list is generated by "greping" this file for calls to the fail() function.
|
||||
* Calls to fail() have to be in one line, to be recogniced!
|
||||
*
|
||||
*
|
||||
* @todo we need to grep for the exceptions too!
|
||||
*/
|
||||
function list_exit_codes()
|
||||
|
Loading…
Reference in New Issue
Block a user