[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] setup/setup_demo.php, 1.32
From: |
nomail |
Subject: |
[Phpgroupware-cvs] setup/setup_demo.php, 1.32 |
Date: |
Thu, 30 Dec 2004 09:43:15 +0100 |
Update of /setup
Modified Files:
Branch:
setup_demo.php
date: 2004/12/30 08:43:15; author: skwashd; state: Exp; lines: +72 -19
Log Message:
adding missing files to new HEAD
=====================================================================
Index: setup/setup_demo.php
diff -u setup/setup_demo.php:1.31 setup/setup_demo.php:1.32
--- setup/setup_demo.php:1.31 Sun May 18 16:51:45 2003
+++ setup/setup_demo.php Thu Dec 30 08:43:15 2004
@@ -29,8 +29,20 @@
exit;
}
- function add_account($username,$first,$last,$passwd,$type='u')
+ function add_account($username, $first, $last, $passwd, $type='u')
{
+ if($type=='u')
+ {
+ $addressmaster_id = -3;
+ $contacts = CreateObject('phpgwapi.contacts');
+ $principal = array('per_prefix' => $username,
+ 'per_first_name' => $first,
+ 'per_last_name' => $last,
+ 'access' => 'public',
+ 'owner' =>
$addressmaster_id);
+ $contact_type =
$contacts->search_contact_type('Persons');
+ $person_id = $contacts->add_contact($contact_type,
$principal);
+ }
$account_info = array(
'account_type' => $type,
'account_lid' => $username,
@@ -38,13 +50,18 @@
'account_firstname' => $first,
'account_lastname' => $last,
'account_status' => 'A',
- 'account_expires' => -1
+ 'account_expires' => -1,
+ 'person_id' => $person_id
);
+
$GLOBALS['phpgw']->accounts->create($account_info);
- return $GLOBALS['phpgw']->accounts->name2id($username);
+ $account_id = $GLOBALS['phpgw']->accounts->name2id($username);
+
+ return $account_id;
}
+ $GLOBALS['phpgw_setup']->loaddb();
if(!get_var('submit',Array('POST')))
{
$tpl_root =
$GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
@@ -63,9 +80,24 @@
$GLOBALS['phpgw_setup']->html->show_header(lang('Demo Server
Setup'));
$setup_tpl->set_var('action_url','setup_demo.php');
- $setup_tpl->set_var('description',lang('This will create 1
admin account and 3 demo accounts<br>The username/passwords are: demo/guest,
demo2/guest and demo3/guest.<br><b>!!!THIS WILL DELETE ALL EXISTING
ACCOUNTS!!!</b><br>')
- . ' '. lang('(account deletion in SQL only)'
- ));
+
+ /* detect whether anything will be deleted before alerting */
+ $phpgw_setup->db->query("select config_value FROM phpgw_config
WHERE config_name='account_repository'");
+ $phpgw_setup->db->next_record();
+ $account_repository = $phpgw_setup->db->f(0);
+
+ $account_creation_notice = lang('This will create an admin
account and (optionally) 3 demo accounts.<br>The username/passwords are:
demo/guest, demo2/guest and demo3/guest.<br>');
+ if ($account_repository == 'sql')
+ {
+ $phpgw_setup->db->query("select count(*) from
phpgw_accounts");
+ $phpgw_setup->db->next_record();
+ $number_of_accounts = (int) $phpgw_setup->db->f(0);
+ if ($number_of_accounts>0)
+ {
+ $account_creation_notice .= lang('<b>!!!THIS
WILL DELETE ALL EXISTING ACCOUNTS!!!</b><br>');
+ }
+ }
+ $setup_tpl->set_var('description', $account_creation_notice);
$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'));
@@ -74,8 +106,8 @@
$setup_tpl->set_var('adminpassword2',lang('Re-enter password'));
$setup_tpl->set_var('create_demo_accounts',lang('Create demo
accounts'));
- $setup_tpl->set_var('lang_submit',lang('submit'));
- $setup_tpl->set_var('lang_cancel',lang('cancel'));
+ $setup_tpl->set_var('lang_submit',lang('Save'));
+ $setup_tpl->set_var('lang_cancel',lang('Cancel'));
$setup_tpl->pparse('out','T_setup_demo');
$GLOBALS['phpgw_setup']->html->show_footer();
}
@@ -99,9 +131,9 @@
exit;
}
- $GLOBALS['phpgw_setup']->loaddb();
/* Load up some configured values */
- $GLOBALS['phpgw_setup']->db->query("SELECT
config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR
config_name='account_repository'",__LINE__,__FILE__);
+ // fips added 'group_min_id', 'group_max_id', 'account_min_id'
, 'account_max_id'
+ $GLOBALS['phpgw_setup']->db->query("SELECT
config_name,config_value FROM phpgw_config WHERE config_name LIKE 'ldap%' OR
config_name='account_repository' OR config_name='group_min_id' OR
config_name='group_max_id' OR config_name='account_min_id' OR
config_name='account_max_id'",__LINE__,__FILE__);
while ($GLOBALS['phpgw_setup']->db->next_record())
{
$config[$GLOBALS['phpgw_setup']->db->f('config_name')]
= $GLOBALS['phpgw_setup']->db->f('config_value');
@@ -112,10 +144,14 @@
$GLOBALS['phpgw_info']['server']['ldap_root_dn'] =
$config['ldap_root_dn'];
$GLOBALS['phpgw_info']['server']['ldap_root_pw'] =
$config['ldap_root_pw'];
$GLOBALS['phpgw_info']['server']['ldap_extra_attributes'] =
$config['ldap_extra_attributes'];
- $GLOBALS['phpgw_info']['server']['ldap_account_home'] =
$config['ldap_account_home'];
- $GLOBALS['phpgw_info']['server']['ldap_account_shell'] =
$config['ldap_account_shell'];
- $GLOBALS['phpgw_info']['server']['ldap_encryption_type'] =
$config['ldap_encryption_type'];
- $GLOBALS['phpgw_info']['server']['account_repository'] =
$config['account_repository'];
+ $GLOBALS['phpgw_info']['server']['ldap_account_home'] =
$config['ldap_account_home'];
+ $GLOBALS['phpgw_info']['server']['ldap_account_shell'] =
$config['ldap_account_shell'];
+ $GLOBALS['phpgw_info']['server']['ldap_encryption_type'] =
$config['ldap_encryption_type'];
+ $GLOBALS['phpgw_info']['server']['account_repository'] =
$config['account_repository'];
+ $GLOBALS['phpgw_info']['server']['account_min_id'] =
$config['account_min_id'];
+ $GLOBALS['phpgw_info']['server']['account_max_id'] =
$config['account_max_id'];
+ $GLOBALS['phpgw_info']['server']['group_min_id'] =
$config['group_min_id'];
+ $GLOBALS['phpgw_info']['server']['group_max_id'] =
$config['group_max_id'];
unset($config);
/* Create dummy class, then accounts object */
@@ -140,13 +176,31 @@
$GLOBALS['phpgw_setup']->db->transaction_begin();
/* Now, clear out existing tables */
+ $contacts_to_delete =
$GLOBALS['phpgw']->accounts->get_account_with_contact();
+// $GLOBALS['phpgw_setup']->db->query('SELECT person_id from
phpgw_accounts WHERE person_id is not null');
+// $contacts_to_delete=array();
+// while ($GLOBALS['phpgw_setup']->db->next_record())
+// {
+// $contacts_to_delete[] =
$GLOBALS['phpgw_setup']->db->f('person_id');
+// }
$GLOBALS['phpgw_setup']->db->query('DELETE FROM
phpgw_accounts');
$GLOBALS['phpgw_setup']->db->query('DELETE FROM
phpgw_preferences');
$GLOBALS['phpgw_setup']->db->query('DELETE FROM phpgw_acl');
-
+ $contacts = CreateObject('phpgwapi.contacts');
+ if(is_array($contacts_to_delete))
+ {
+ foreach(@$contacts_to_delete as $contact_id)
+ {
+ $contacts->delete($contact_id, '', False);
+ }
+ }
+ unset($contacts_to_delete);
/* Create the demo groups */
- $defaultgroupid =
add_account('Default','Default','Group',$passwd,'g');
- $admingroupid = add_account('Admins','Admin',
'Group',$passwd,'g');
+ $defaultgroupid =
intval(add_account('Default','Default','Group',$passwd,'g'));
+ $admingroupid = intval(add_account('Admins','Admin',
'Group',$passwd,'g'));
+
+ /* Create the addressmaster record */
+
//add_account('addressmaster','addressmaster','addressmaster','addressmaster');
/* Group perms for the default group */
$GLOBALS['phpgw_setup']->db->query("INSERT INTO
phpgw_acl(acl_appname,acl_location,acl_account,acl_rights)
VALUES('addressbook','run'," . $defaultgroupid . ", 1)");
@@ -216,7 +270,6 @@
$GLOBALS['phpgw_setup']->db->query("INSERT INTO
phpgw_acl(acl_appname,acl_location,acl_account,acl_rights)
VALUES('todo','run'," . $accountid . ", 1)");
$GLOBALS['phpgw_setup']->db->query("INSERT INTO
phpgw_acl(acl_appname,acl_location,acl_account,acl_rights)
VALUES('manual','run'," . $accountid . ", 1)");
$GLOBALS['phpgw_setup']->db->query("INSERT INTO
phpgw_acl(acl_appname,acl_location,acl_account,acl_rights)
VALUES('infolog','run'," . $accountid . ", 1)");
-
$GLOBALS['phpgw_setup']->db->transaction_commit();
Header('Location: index.php');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] setup/setup_demo.php, 1.32,
nomail <=