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); $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 = '
'.lang('Passwords did not match, please re-enter') . ".
\n"; } if(!$username) { $error = ''.lang('You must enter a username for the admin') . ".
\n"; } } if(!$_POST['submit'] || $error) { $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); $setup_tpl = CreateObject('setup.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, )); $setup_tpl->set_var('action_url','admin_account.php'); $setup_tpl->set_var('description',lang('This will create 1 admin account and 3 demo accounts'.lang('Error in group-creation !!!')."
\n"; echo ''.lang('click here to return to setup.')."
\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); // give admin access to all apps, to save us some support requests $all_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()) { $all_apps[] = $GLOBALS['egw_setup']->db->f('app_name'); } $GLOBALS['egw_setup']->add_acl($all_apps,'run',$admingroupid); 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( '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); // set some 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); if (!$accountid) { echo ''.lang('Error in admin-creation !!!')."
\n"; echo ''.lang('click here to return to setup.')."
\n"; $GLOBALS['egw_setup']->db->transaction_abort(); exit; } $GLOBALS['egw_setup']->add_acl('phpgw_group',$admingroupid,$accountid); $GLOBALS['egw_setup']->add_acl('phpgw_group',$defaultgroupid,$accountid); $GLOBALS['egw_setup']->db->transaction_commit(); Header('Location: index.php'); exit; } ?>