Adjust auto_add() - sql now uses a default group config in setup, or does

not configure a group at all - old behavior was to add them to account_id 1.
Some more register_globals tweaks.
This commit is contained in:
Miles Lott 2001-08-31 22:50:30 +00:00
parent aedcd42f81
commit 45f2ca1616
2 changed files with 99 additions and 100 deletions

View File

@ -29,7 +29,7 @@
This is where it ended up (milosch) This is where it ended up (milosch)
Since LDAP will return system accounts, there are a few we don't want to login. Since LDAP will return system accounts, there are a few we don't want to login.
*/ */
$phpgw_info['server']['global_denied_users'] = array( $GLOBALS['phpgw_info']['server']['global_denied_users'] = array(
'root' => True, 'bin' => True, 'daemon' => True, 'root' => True, 'bin' => True, 'daemon' => True,
'adm' => True, 'lp' => True, 'sync' => True, 'adm' => True, 'lp' => True, 'sync' => True,
'shutdown' => True, 'halt' => True, 'ldap' => True, 'shutdown' => True, 'halt' => True, 'ldap' => True,
@ -55,19 +55,16 @@
function accounts_() function accounts_()
{ {
global $phpgw; $this->db = $GLOBALS['phpgw']->db;
$this->db = $phpgw->db;
} }
function read_repository() function read_repository()
{ {
global $phpgw, $phpgw_info;
/* get an ldap connection handle */ /* get an ldap connection handle */
$ds = $phpgw->common->ldapConnect(); $ds = $GLOBALS['phpgw']->common->ldapConnect();
// search the dn for the given uid // search the dn for the given uid
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], 'uidnumber='.$this->account_id); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uidnumber='.$this->account_id);
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
/* Now dump it into the array; take first entry found */ /* Now dump it into the array; take first entry found */
@ -77,10 +74,10 @@
$this->data['firstname'] = $allValues[0]['givenname'][0]; $this->data['firstname'] = $allValues[0]['givenname'][0];
$this->data['lastname'] = $allValues[0]['sn'][0]; $this->data['lastname'] = $allValues[0]['sn'][0];
$this->data['fullname'] = $allValues[0]['cn'][0]; $this->data['fullname'] = $allValues[0]['cn'][0];
if ($phpgw_info['server']['ldap_extra_attributes']) if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
{ {
$this->data['homedirectory'] = $allValues[0]['homedirectory'][0]; $this->data['homedirectory'] = $allValues[0]['homedirectory'][0];
$this->data['loginshell'] = $allValues[0]['loginshell'][0]; $this->data['loginshell'] = $allValues[0]['loginshell'][0];
} }
$this->db->query("SELECT * FROM phpgw_accounts WHERE account_id='" . $this->data['account_id'] . "'",__LINE__,__FILE__); $this->db->query("SELECT * FROM phpgw_accounts WHERE account_id='" . $this->data['account_id'] . "'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
@ -96,19 +93,17 @@
function save_repository() function save_repository()
{ {
global $phpgw_info, $phpgw; $ds = $GLOBALS['phpgw']->common->ldapConnect();
$ds = $phpgw->common->ldapConnect();
/* search the dn for the given uid */ /* search the dn for the given uid */
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], 'uidnumber='.$this->account_id); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uidnumber='.$this->account_id);
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
$entry['cn'] = sprintf("%s %s", $this->data['firstname'], $this->data['lastname']); $entry['cn'] = sprintf("%s %s", $this->data['firstname'], $this->data['lastname']);
$entry['sn'] = $this->data['lastname']; $entry['sn'] = $this->data['lastname'];
$entry['givenname'] = $this->data['firstname']; $entry['givenname'] = $this->data['firstname'];
if ($phpgw_info['server']['ldap_extra_attributes']) if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
{ {
$entry['homedirectory'] = $this->data['homedirectory']; $entry['homedirectory'] = $this->data['homedirectory'];
$entry['loginshell'] = $this->data['loginshell']; $entry['loginshell'] = $this->data['loginshell'];
@ -143,12 +138,10 @@
function delete($accountid = '') function delete($accountid = '')
{ {
global $phpgw, $phpgw_info;
$account_id = get_account_id($accountid); $account_id = get_account_id($accountid);
$account_lid = $this->id2name($account_id); $account_lid = $this->id2name($account_id);
$ds = $phpgw->common->ldapConnect(); $ds = $GLOBALS['phpgw']->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], 'uid='.$account_lid); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uid='.$account_lid);
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
if ($allValues[0]['dn']) if ($allValues[0]['dn'])
@ -165,15 +158,13 @@
function get_list($_type='both', $start = '',$sort = '', $order = '', $query = '', $offset = '') function get_list($_type='both', $start = '',$sort = '', $order = '', $query = '', $offset = '')
{ {
global $phpgw,$phpgw_info;
if ($offset) if ($offset)
{ {
$limitclause = $phpgw->db->limit($start,$offset); $limitclause = $GLOBALS['phpgw']->db->limit($start,$offset);
} }
elseif ($start && !$offset) elseif ($start && !$offset)
{ {
$limitclause = $phpgw->db->limit($start); $limitclause = $GLOBALS['phpgw']->db->limit($start);
} }
if (! $sort) if (! $sort)
@ -190,7 +181,7 @@
$orderclause = 'ORDER BY account_lid,account_lastname,account_firstname ASC'; $orderclause = 'ORDER BY account_lid,account_lastname,account_firstname ASC';
} }
$ds = $phpgw->common->ldapConnect(); $ds = $GLOBALS['phpgw']->common->ldapConnect();
switch($_type) switch($_type)
{ {
@ -211,7 +202,7 @@
// get user information from ldap only, if it's a user, not a group // get user information from ldap only, if it's a user, not a group
if ($this->db->f('account_type') == 'u') if ($this->db->f('account_type') == 'u')
{ {
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], 'uidnumber='.$this->db->f('account_id')); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], 'uidnumber='.$this->db->f('account_id'));
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
$accounts[] = Array( $accounts[] = Array(
'account_id' => $allValues[0]['uidnumber'][0], 'account_id' => $allValues[0]['uidnumber'][0],
@ -240,7 +231,6 @@
function name2id($account_lid) function name2id($account_lid)
{ {
global $phpgw, $phpgw_info;
static $name_list; static $name_list;
if(@isset($name_list[$account_lid])) if(@isset($name_list[$account_lid]))
@ -263,7 +253,6 @@
function id2name($account_id) function id2name($account_id)
{ {
global $phpgw, $phpgw_info;
static $id_list; static $id_list;
if(isset($id_list[$account_id])) if(isset($id_list[$account_id]))
@ -286,7 +275,6 @@
function get_type($accountid = '') function get_type($accountid = '')
{ {
global $phpgw, $phpgw_info;
static $account_type; static $account_type;
$account_id = get_account_id($accountid); $account_id = get_account_id($accountid);
@ -313,7 +301,6 @@
*/ */
function exists($account) function exists($account)
{ {
global $phpgw, $phpgw_info;
/* This sets up internal caching variables for this functon */ /* This sets up internal caching variables for this functon */
static $by_id, $by_lid; static $by_id, $by_lid;
@ -344,8 +331,8 @@
$in += 1; $in += 1;
} }
$ds = $phpgw->common->ldapConnect(); $ds = $GLOBALS['phpgw']->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], "$ldap_name=$account"); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], "$ldap_name=$account");
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
if ($allValues[0]['dn']) if ($allValues[0]['dn'])
@ -371,27 +358,31 @@
function create($account_info) function create($account_info)
{ {
global $phpgw_info, $phpgw; $ds = $GLOBALS['phpgw']->common->ldapConnect();
$ds = $phpgw->common->ldapConnect();
if (!($account_id = $account_info['account_id'])) if (!($account_id = $account_info['account_id']))
{ {
if ($phpgw_info['server']['account_min_id']) { $min = $phpgw_info['server']['account_min_id']; } if ($GLOBALS['phpgw_info']['server']['account_min_id'])
if ($phpgw_info['server']['account_max_id']) { $max = $phpgw_info['server']['account_max_id']; } {
$min = $GLOBALS['phpgw_info']['server']['account_min_id'];
}
if ($GLOBALS['phpgw_info']['server']['account_max_id'])
{
$max = $GLOBALS['phpgw_info']['server']['account_max_id'];
}
$nextid = $phpgw->common->last_id('accounts_ldap',$min,$max); $nextid = $GLOBALS['phpgw']->common->last_id('accounts_ldap',$min,$max);
/* Loop until we find a free id */ /* Loop until we find a free id */
$free = 0; $free = 0;
while (!$free) while (!$free)
{ {
$ldap_fields = ''; $ldap_fields = '';
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'],'uidnumber='.$nextid); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'],'uidnumber='.$nextid);
$ldap_test = ldap_get_entries($ds, $sri); $ldap_test = ldap_get_entries($ds, $sri);
if ($ldap_test[0]['dn'][0]) if ($ldap_test[0]['dn'][0])
{ {
$nextid = $phpgw->common->next_id('accounts_ldap',$min,$max); $nextid = $GLOBALS['phpgw']->common->next_id('accounts_ldap',$min,$max);
} }
else else
{ {
@ -399,7 +390,8 @@
} }
} }
if ($phpgw_info['server']['account_max_id'] && ($nextid > $phpgw_info['server']['account_max_id'])) if ($GLOBALS['phpgw_info']['server']['account_max_id'] &&
($nextid > $GLOBALS['phpgw_info']['server']['account_max_id']))
{ {
return False; return False;
} }
@ -413,7 +405,7 @@
. "','" . $account_info['account_lastname'] . "','" . $account_info['account_status'] . "'," . $account_info['account_expires'] . ")",__LINE__,__FILE__); . "','" . $account_info['account_lastname'] . "','" . $account_info['account_status'] . "'," . $account_info['account_expires'] . ")",__LINE__,__FILE__);
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'],'uid=' . $account_info['account_lid']); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'],'uid=' . $account_info['account_lid']);
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
$entry['uidnumber'] = $account_id; $entry['uidnumber'] = $account_id;
@ -421,27 +413,13 @@
$entry['cn'] = sprintf('%s %s', $account_info['account_firstname'], $account_info['account_lastname']); $entry['cn'] = sprintf('%s %s', $account_info['account_firstname'], $account_info['account_lastname']);
$entry['sn'] = $account_info['account_lastname']; $entry['sn'] = $account_info['account_lastname'];
$entry['givenname'] = $account_info['account_firstname']; $entry['givenname'] = $account_info['account_firstname'];
$entry['userpassword'] = $phpgw->common->encrypt_password($account_info['account_passwd']); $entry['userpassword'] = $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd']);
if ($phpgw_info['server']['ldap_extra_attributes'] && $account_info['account_type'] != 'g') if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'] && $account_info['account_type'] == 'u')
{ {
if ($account_home) $entry['homedirectory'] = $account_info['homedirectory'] ? $account_info['homedirectory'] : $GLOBALS['phpgw_info']['server']['ldap_account_home'].SEP.$account_info['account_lid'];
{
$entry['homedirectory'] = $account_info['homedirectory'];
}
else
{
$entry['homedirectory'] = $phpgw_info['server']['ldap_account_home'].SEP.$account_info['account_lid'];
}
if ($account_shell) $entry['loginshell'] = $account_info['loginshell'] ? $account_info['loginshell'] : $GLOBALS['phpgw_info']['server']['ldap_account_shell'];
{
$entry['loginshell'] = $account_info['loginshell'];
}
else
{
$entry['loginshell'] = $phpgw_info['server']['ldap_account_shell'];
}
} }
if ($allValues[0]['dn']) if ($allValues[0]['dn'])
@ -501,7 +479,7 @@
*/ */
if ($account_info['account_type'] == 'u') if ($account_info['account_type'] == 'u')
{ {
$dn = 'uid=' . $account_info['account_lid'] . ',' . $phpgw_info['server']['ldap_context']; $dn = 'uid=' . $account_info['account_lid'] . ',' . $GLOBALS['phpgw_info']['server']['ldap_context'];
$entry['objectclass'][0] = 'top'; $entry['objectclass'][0] = 'top';
$entry['objectclass'][1] = 'person'; $entry['objectclass'][1] = 'person';
$entry['objectclass'][2] = 'organizationalPerson'; $entry['objectclass'][2] = 'organizationalPerson';
@ -517,42 +495,66 @@
/* print ldap_error($ds); */ /* print ldap_error($ds); */
} }
function auto_add($account_name, $passwd, $default_prefs=False, $default_acls= False) function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False, $expiredate = 0, $account_status = 'A')
{ {
print "not done until now auto_generate class.accounts_ldap.inc.php<br>"; echo 'not yet implemented - auto_generate class.accounts_ldap.inc.php<br>';
exit(); exit;
global $phpgw, $phpgw_info;
$accountid = mt_rand (100, 600000); if (!$expiredate)
if ($defaultprefs =='') {
/* expire in 30 days by default */
$expiredate = time() + ( ( 60 * 60 ) * (30 * 24) );
}
$acct_info = array(
'account_lid' => $accountname,
'account_type' => 'u',
'account_passwd' => $passwd,
'account_firstname' => '',
'account_lastname' => '',
'account_status' => $account_status,
'account_expires' => mktime(2,0,0,date('n',$expiredate), intval(date('d',$expiredate)), date('Y',$expiredate))
);
$this->create($acct_info);
$accountid = $this->name2id($accountname);
$this->db->transaction_begin();
if ($default_prefs == False)
{ {
$defaultprefs = 'a:5:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";N;s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";N;s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}:s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}'; $defaultprefs = 'a:5:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";N;s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";N;s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}:s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}';
/* $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; */ /* $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; */
$this->db->query("insert into phpgw_preferences (preference_owner, preference_value) values ('".$accountid."', '$defaultprefs')");
} }
$sql = "insert into phpgw_accounts";
$sql .= "(account_id, account_lid, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status, account_type, account_file_space)"; if ($default_acls == False)
$sql .= "values (".$accountid.", '".$accountname."', '".md5($passwd)."', '".$accountname."', 'AutoCreated', ".time().", 'A','u','" . $phpgw_info['server']['vfs_default_account_size_number'] . "-" . $phpgw_info['server']['vfs_default_account_size_type'] . "')"; {
$this->db->query($sql); $default_group_lid = $GLOBALS['phpgw_info']['server']['default_group_lid'];
$this->db->query("insert into phpgw_preferences (preference_owner, preference_value) values ('".$accountid."', '$defaultprefs')"); $default_group_id = $this->name2id($default_group_lid);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)values('preferences', 'changepassword', ".$accountid.", 'u', 1)",__LINE__,__FILE__); $defaultgroupid = $default_group_id ? $default_group_id : $this->name2id('Default');
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '1', ".$accountid.", 'u', 1)",__LINE__,__FILE__); if($defaultgroupid)
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('addressbook', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); {
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('filemanager', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', "
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('calendar', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); . $defaultgroupid . ", " . $accountid . ", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('email', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); }
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('notes', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)values('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('todo', 'run', ".$accountid.", 'u', 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('addressbook', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('filemanager', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('calendar', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('email', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('notes', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('todo', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
}
$this->db->transaction_commit();
return $accountid; return $accountid;
} }
function getDNforID($_accountid = '') function getDNforID($_accountid = '')
{ {
global $phpgw;
$_account_id = get_account_id($_accountid); $_account_id = get_account_id($_accountid);
$ds = $phpgw->common->ldapConnect(); $ds = $GLOBALS['phpgw']->common->ldapConnect();
$sri = ldap_search($ds, $phpgw_info['server']['ldap_context'], "uidnumber=$_account_id"); $sri = ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], "uidnumber=$_account_id");
$allValues = ldap_get_entries($ds, $sri); $allValues = ldap_get_entries($ds, $sri);
return $allValues[0]['dn']; return $allValues[0]['dn'];

View File

@ -24,7 +24,7 @@
/* $Id$ */ /* $Id$ */
$phpgw_info['server']['global_denied_users'] = array(); $GLOBALS['phpgw_info']['server']['global_denied_users'] = array();
class accounts_ class accounts_
{ {
@ -34,13 +34,11 @@
function accounts_() function accounts_()
{ {
global $phpgw; $this->db = $GLOBALS['phpgw']->db;
$this->db = $phpgw->db;
} }
function read_repository() function read_repository()
{ {
global $phpgw, $phpgw_info;
$this->db->query("SELECT * FROM phpgw_accounts WHERE account_id='" . $this->account_id . "'",__LINE__,__FILE__); $this->db->query("SELECT * FROM phpgw_accounts WHERE account_id='" . $this->account_id . "'",__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
@ -55,6 +53,7 @@
$this->data['lastpasswd_change'] = $this->db->f('account_lastpwd_change'); $this->data['lastpasswd_change'] = $this->db->f('account_lastpwd_change');
$this->data['status'] = $this->db->f('account_status'); $this->data['status'] = $this->db->f('account_status');
$this->data['expires'] = $this->db->f('account_expires'); $this->data['expires'] = $this->db->f('account_expires');
return $this->data; return $this->data;
} }
@ -69,8 +68,6 @@
function delete($accountid = '') function delete($accountid = '')
{ {
global $phpgw, $phpgw_info;
$account_id = get_account_id($accountid); $account_id = get_account_id($accountid);
/* Do this last since we are depending upon this record to get the account_lid above */ /* Do this last since we are depending upon this record to get the account_lid above */
@ -82,8 +79,6 @@
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '') function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '')
{ {
global $phpgw, $phpgw_info;
if (! $sort) if (! $sort)
{ {
$sort = "DESC"; $sort = "DESC";
@ -160,7 +155,6 @@
function name2id($account_lid) function name2id($account_lid)
{ {
global $phpgw, $phpgw_info;
static $name_list; static $name_list;
if($name_list[$account_lid] && $name_list[$account_lid] != '') if($name_list[$account_lid] && $name_list[$account_lid] != '')
@ -183,7 +177,6 @@
function id2name($account_id) function id2name($account_id)
{ {
global $phpgw, $phpgw_info;
static $id_list; static $id_list;
if($id_list[$account_id]) if($id_list[$account_id])
@ -206,7 +199,6 @@
function get_type($accountid) function get_type($accountid)
{ {
global $phpgw, $phpgw_info;
static $account_type; static $account_type;
$account_id = get_account_id($accountid); $account_id = get_account_id($accountid);
@ -276,8 +268,6 @@
function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False, $expiredate = 0, $account_status = 'A') function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False, $expiredate = 0, $account_status = 'A')
{ {
global $phpgw;
if (!$expiredate) if (!$expiredate)
{ {
/* expire in 30 days by default */ /* expire in 30 days by default */
@ -299,15 +289,22 @@
$this->db->transaction_begin(); $this->db->transaction_begin();
if ($default_prefs == False) if ($default_prefs == False)
{ {
$default_prefs = 'a:5:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";N;s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";N;s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}:s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}'; $defaultprefs = 'a:5:{s:6:"common";a:10:{s:9:"maxmatchs";s:2:"15";s:12:"template_set";s:8:"verdilak";s:5:"theme";s:6:"purple";s:13:"navbar_format";s:5:"icons";s:9:"tz_offset";N;s:10:"dateformat";s:5:"m/d/Y";s:10:"timeformat";s:2:"12";s:4:"lang";s:2:"en";s:11:"default_app";N;s:8:"currency";s:1:"$";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}:s:8:"calendar";a:4:{s:13:"workdaystarts";s:1:"7";s:11:"workdayends";s:2:"15";s:13:"weekdaystarts";s:6:"Monday";s:15:"defaultcalendar";s:9:"month.php";}}';
/* $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; */ /* $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}s:8:"calendar";a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; */
$this->db->query("insert into phpgw_preferences (preference_owner, preference_value) values ('".$accountid."', '$default_prefs')"); $this->db->query("insert into phpgw_preferences (preference_owner, preference_value) values ('".$accountid."', '$defaultprefs')");
} }
if ($default_acls == False) if ($default_acls == False)
{ {
$default_group_lid = $GLOBALS['phpgw_info']['server']['default_group_lid'];
$default_group_id = $this->name2id($default_group_lid);
$defaultgroupid = $default_group_id ? $default_group_id : $this->name2id('Default');
if($defaultgroupid)
{
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', "
. $defaultgroupid . ", " . $accountid . ", 1)",__LINE__,__FILE__);
}
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)values('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)values('preferences', 'changepassword', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('phpgw_group', '1', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('addressbook', 'run', ".$accountid.", 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('addressbook', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('filemanager', 'run', ".$accountid.", 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('filemanager', 'run', ".$accountid.", 1)",__LINE__,__FILE__);
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('calendar', 'run', ".$accountid.", 1)",__LINE__,__FILE__); $this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights) values('calendar', 'run', ".$accountid.", 1)",__LINE__,__FILE__);