forked from extern/egroupware
Update for proposed accounts class changes
This commit is contained in:
parent
1d97b2b433
commit
d7c287e6e4
@ -43,7 +43,7 @@
|
|||||||
'qmailr' => True, 'qmails' => True
|
'qmailr' => True, 'qmails' => True
|
||||||
);
|
);
|
||||||
|
|
||||||
$phpgw_info["server"]["global_excluded_groups"] = array(
|
$phpgw_info["server"]["global_denied_groups"] = array(
|
||||||
'root' => True, 'bin' => True, 'daemon' => True,
|
'root' => True, 'bin' => True, 'daemon' => True,
|
||||||
'sys' => True, 'adm' => True, 'tty' => True,
|
'sys' => True, 'adm' => True, 'tty' => True,
|
||||||
'disk' => True, 'lp' => True, 'mem' => True,
|
'disk' => True, 'lp' => True, 'mem' => True,
|
||||||
@ -107,7 +107,8 @@
|
|||||||
$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 ($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];
|
||||||
}
|
}
|
||||||
@ -145,7 +146,8 @@
|
|||||||
$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 ($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"];
|
||||||
}
|
}
|
||||||
@ -187,10 +189,10 @@
|
|||||||
// Groups
|
// Groups
|
||||||
if ($this->data["account_type"] == "g" && $phpgw_info["server"]["ldap_group_context"] )
|
if ($this->data["account_type"] == "g" && $phpgw_info["server"]["ldap_group_context"] )
|
||||||
{
|
{
|
||||||
$dn = 'uid='.$this->data["account_lid"].','.$phpgw_info["server"]["ldap_group_context"];
|
$dn = 'cn='.$this->data["account_lid"].','.$phpgw_info["server"]["ldap_group_context"];
|
||||||
$entry["cn"] = $this->data["account_lid"];
|
$entry["cn"] = $this->data["account_lid"];
|
||||||
$entry["gidnumber"] = $this->data["account_id"];
|
$entry["gidnumber"] = $this->data["account_id"];
|
||||||
$entry["objectclass"] = "";
|
//$entry["objectclass"] = "";
|
||||||
$entry["objectclass"][0] = 'top';
|
$entry["objectclass"][0] = 'top';
|
||||||
$entry["objectclass"][1] = 'posixGroup';
|
$entry["objectclass"][1] = 'posixGroup';
|
||||||
$members = $this->members($this->data["account_id"]);
|
$members = $this->members($this->data["account_id"]);
|
||||||
@ -292,12 +294,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->query("update phpgw_accounts set account_lid='" . $this->data['account_lid']
|
$this->db->query("UPDATE phpgw_accounts SET account_lid='" . $this->data['account_lid']
|
||||||
. "', account_firstname='" . $this->data['firstname']
|
. "', account_firstname='" . $this->data['firstname']
|
||||||
. "', account_lastname='" . $this->data['lastname']
|
. "', account_lastname='" . $this->data['lastname']
|
||||||
. "', account_status='" . $this->data['status']
|
. "', account_status='" . $this->data['status']
|
||||||
. "' where account_id='" . $this->account_id . "'",__LINE__,__FILE__);
|
. "' where account_id='" . $this->account_id . "'",__LINE__,__FILE__);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isin_array($needle,$haystack=array())
|
function isin_array($needle,$haystack=array())
|
||||||
@ -325,6 +326,16 @@
|
|||||||
{
|
{
|
||||||
$del = ldap_delete($ds, $allValues[0]['dn']);
|
$del = ldap_delete($ds, $allValues[0]['dn']);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sri = ldap_search($ds, $phpgw_info['server']['ldap_group_context'], 'cn='.$account_lid);
|
||||||
|
$allValues = ldap_get_entries($ds, $sri);
|
||||||
|
|
||||||
|
if ($allValues[0]['dn'])
|
||||||
|
{
|
||||||
|
$del = ldap_delete($ds, $allValues[0]['dn']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
$tables_array = Array('phpgw_accounts');
|
$tables_array = Array('phpgw_accounts');
|
||||||
@ -551,37 +562,9 @@
|
|||||||
$this->acct_type = $account_type;
|
$this->acct_type = $account_type;
|
||||||
|
|
||||||
//echo '<br>in create for account_lid: "'.$account_lid.'"';
|
//echo '<br>in create for account_lid: "'.$account_lid.'"';
|
||||||
if (empty($account_id) || !$account_id) {
|
if (empty($account_id) || !$account_id)
|
||||||
if ($phpgw_info["server"]["account_min_id"]) { $min = $phpgw_info["server"]["account_min_id"]; }
|
{
|
||||||
if ($phpgw_info["server"]["account_max_id"]) { $max = $phpgw_info["server"]["account_max_id"]; }
|
$account_id = $this->get_nextid();
|
||||||
|
|
||||||
$nextid = $phpgw->common->last_id("accounts",$min,$max);
|
|
||||||
|
|
||||||
// Loop until we find a free id
|
|
||||||
$free = 0;
|
|
||||||
while (!$free) {
|
|
||||||
//echo '<br>calling search for id: '.$nextid;
|
|
||||||
if ($this->exists($nextid))
|
|
||||||
{
|
|
||||||
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//echo '<br>calling search for lid: '.$account_lid;
|
|
||||||
if ($this->exists($account_lid))
|
|
||||||
{
|
|
||||||
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$free = True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($phpgw_info["server"]["account_max_id"] && ($nextid > $phpgw_info["server"]["account_max_id"])) {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
$account_id = $nextid;
|
|
||||||
//echo '<br>using'.$account_id;exit;
|
//echo '<br>using'.$account_id;exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,32 +583,32 @@
|
|||||||
}
|
}
|
||||||
$allValues = ldap_get_entries($ds, $sri);
|
$allValues = ldap_get_entries($ds, $sri);
|
||||||
|
|
||||||
$entry["gidnumber"] = $account_id;
|
if ($phpgw_info["server"]["ldap_extra_attributes"] && $account_type != 'g')
|
||||||
$entry["userpassword"] = $phpgw->common->encrypt_password($account_pwd);
|
{
|
||||||
|
|
||||||
if ($phpgw_info["server"]["ldap_extra_attributes"] && $account_type != 'g') {
|
|
||||||
if ($account_home)
|
if ($account_home)
|
||||||
{
|
{
|
||||||
$entry["homedirectory"] = $account_home;
|
$entry["homedirectory"] = $account_home;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$entry["homedirectory"] = $phpgw_info["server"]["ldap_account_home"].SEP.$account_lid;
|
$entry["homedirectory"] = $phpgw_info["server"]["ldap_account_home"].SEP.$account_lid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($account_shell)
|
if ($account_shell)
|
||||||
{
|
{
|
||||||
$entry["loginshell"] = $account_shell;
|
$entry["loginshell"] = $account_shell;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$entry["loginshell"] = $phpgw_info["server"]["ldap_account_shell"];
|
$entry["loginshell"] = $phpgw_info["server"]["ldap_account_shell"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($allValues[0]["dn"]) {
|
if ($allValues[0]["dn"])
|
||||||
|
{
|
||||||
// This should keep the password from being overwritten here on ldap import
|
// This should keep the password from being overwritten here on ldap import
|
||||||
unset($entry["userpassword"]);
|
unset($entry["userpassword"]);
|
||||||
|
$entry["gidnumber"] = $account_id;
|
||||||
|
|
||||||
while (list($key,$val) = each($entry))
|
while (list($key,$val) = each($entry))
|
||||||
{
|
{
|
||||||
@ -659,41 +642,45 @@
|
|||||||
$tmpentry["objectclass"][1] = 'person';
|
$tmpentry["objectclass"][1] = 'person';
|
||||||
$tmpentry["objectclass"][2] = 'organizationalPerson';
|
$tmpentry["objectclass"][2] = 'organizationalPerson';
|
||||||
$tmpentry["objectclass"][3] = 'inetOrgPerson';
|
$tmpentry["objectclass"][3] = 'inetOrgPerson';
|
||||||
|
$tmpentry["userpassword"] = $phpgw->common->encrypt_password($account_pwd);
|
||||||
//$tmpentry["objectclass"][4] = 'account'; Causes problems with some LDAP servers
|
//$tmpentry["objectclass"][4] = 'account'; Causes problems with some LDAP servers
|
||||||
$tmpentry["objectclass"][5] = 'posixAccount';
|
$tmpentry["objectclass"][5] = 'posixAccount';
|
||||||
$tmpentry["objectclass"][6] = 'shadowAccount';
|
$tmpentry["objectclass"][6] = 'shadowAccount';
|
||||||
}
|
}
|
||||||
ldap_modify($ds, $allValues[0]["dn"], $tmpentry);
|
ldap_modify($ds, $allValues[0]["dn"], $tmpentry);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Not already there, we will add it
|
// Not already there, we will add it
|
||||||
if ($account_type == "g")
|
if ($account_type == "g")
|
||||||
{
|
{
|
||||||
$dn = 'cn='.$account_lid.','.$phpgw_info["server"]["ldap_group_context"];
|
$dn = 'cn='.$account_lid.','.$phpgw_info["server"]["ldap_group_context"];
|
||||||
unset($entry["homedirectory"]);
|
unset($entry["homedirectory"]);
|
||||||
unset($entry["loginshell"]);
|
unset($entry["loginshell"]);
|
||||||
$entry["cn"] = $account_lid;
|
|
||||||
$entry["objectclass"][0] = 'top';
|
$entry["objectclass"][0] = 'top';
|
||||||
$entry["objectclass"][1] = 'posixGroup';
|
$entry["objectclass"][1] = 'posixGroup';
|
||||||
|
$entry["cn"] = $account_lid;
|
||||||
$members = $this->members($account_id);
|
$entry["gidnumber"] = $account_id;
|
||||||
$entry["memberuid"] = array();
|
$entry["userpassword"] = $phpgw->common->encrypt_password($account_pwd);
|
||||||
for ($i=0;$i<count($members);$i++)
|
$entry["description"] = 'phpgw-created group';
|
||||||
{
|
|
||||||
$currname = $this->id2name($members[$i]['account_id']);
|
|
||||||
if (!$this->isin_array($currname,$entry["memberuid"]))
|
|
||||||
{
|
|
||||||
$entry["memberuid"][] = $currname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$dn = 'uid=' . $account_lid . ',' . $phpgw_info["server"]["ldap_context"];
|
$dn = 'uid=' . $account_lid . ',' . $phpgw_info["server"]["ldap_context"];
|
||||||
$entry["cn"] = sprintf("%s %s", $account_firstname, $account_lastname);
|
$entry["cn"] = sprintf("%s %s", $account_firstname, $account_lastname);
|
||||||
$entry["sn"] = $account_lastname;
|
$entry["sn"] = $account_lastname;
|
||||||
$entry["givenname"] = $account_firstname;
|
$entry["givenname"] = $account_firstname;
|
||||||
$entry["uid"] = $account_lid;
|
$entry["uid"] = $account_lid;
|
||||||
$entry["uidnumber"] = $account_id;
|
$entry["uidnumber"] = $account_id;
|
||||||
|
if ($phpgw_info["server"]["ldap_group_id"])
|
||||||
|
{
|
||||||
|
$entry["gidnumber"] = $phpgw_info["server"]["ldap_group_id"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$entry["gidnumber"] = $account_id;
|
||||||
|
}
|
||||||
|
$entry["userpassword"] = $phpgw->common->encrypt_password($account_pwd);
|
||||||
$entry["objectclass"][0] = 'top';
|
$entry["objectclass"][0] = 'top';
|
||||||
$entry["objectclass"][1] = 'person';
|
$entry["objectclass"][1] = 'person';
|
||||||
$entry["objectclass"][2] = 'organizationalPerson';
|
$entry["objectclass"][2] = 'organizationalPerson';
|
||||||
@ -702,7 +689,19 @@
|
|||||||
$entry["objectclass"][4] = 'posixAccount';
|
$entry["objectclass"][4] = 'posixAccount';
|
||||||
$entry["objectclass"][5] = 'shadowAccount';
|
$entry["objectclass"][5] = 'shadowAccount';
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
echo '<br>dn: '.$dn;
|
||||||
|
while (list($key,$val) = each($entry)) {
|
||||||
|
if (is_array($val)) {
|
||||||
|
for ($i=0;$i<count($val);$i++) {
|
||||||
|
if ($val[$i]) { echo "<br>\nline ".$key.': '.$val[$i]; }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($val) { echo '<br>line '.$key.': '.$val; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//exit;
|
||||||
|
*/
|
||||||
ldap_add($ds, $dn, $entry);
|
ldap_add($ds, $dn, $entry);
|
||||||
}
|
}
|
||||||
//print ldap_error($ds);
|
//print ldap_error($ds);
|
||||||
@ -714,26 +713,7 @@
|
|||||||
exit();
|
exit();
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
if ($phpgw_info["server"]["account_min_id"]) { $min = $phpgw_info["server"]["account_min_id"]; }
|
$accountid = $this->get_nextid();
|
||||||
if ($phpgw_info["server"]["account_max_id"]) { $max = $phpgw_info["server"]["account_max_id"]; }
|
|
||||||
|
|
||||||
$nextid = $phpgw->common->last_id("accounts",$min,$max);
|
|
||||||
|
|
||||||
// Loop until we find a free id
|
|
||||||
$free = 0;
|
|
||||||
while (!$free) {
|
|
||||||
if ($this->exists($nextid))
|
|
||||||
{
|
|
||||||
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
|
||||||
} else {
|
|
||||||
$free = True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($phpgw_info["server"]["account_max_id"] && ($nextid > $phpgw_info["server"]["account_max_id"])) {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
$account_id = $nextid;
|
|
||||||
//echo $account_id;exit;
|
|
||||||
|
|
||||||
if ($defaultprefs =="") {
|
if ($defaultprefs =="") {
|
||||||
$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";}}';
|
||||||
|
157
phpgwapi/inc/class.accounts_shared_wip.inc.php
Normal file
157
phpgwapi/inc/class.accounts_shared_wip.inc.php
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* phpGroupWare API - Accounts manager shared functions *
|
||||||
|
* This file written by Joseph Engo <jengo@phpgroupware.org> *
|
||||||
|
* shared functions for other account repository managers *
|
||||||
|
* Copyright (C) 2000, 2001 Joseph Engo *
|
||||||
|
* -------------------------------------------------------------------------*
|
||||||
|
* This library is part of the phpGroupWare API *
|
||||||
|
* http://www.phpgroupware.org/api *
|
||||||
|
* ------------------------------------------------------------------------ *
|
||||||
|
* This library is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2.1 of the License, *
|
||||||
|
* or any later version. *
|
||||||
|
* This library is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU Lesser General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License *
|
||||||
|
* along with this library; if not, write to the Free Software Foundation, *
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
class accounts extends accounts_
|
||||||
|
{
|
||||||
|
|
||||||
|
var $memberships = Array();
|
||||||
|
var $members = Array();
|
||||||
|
|
||||||
|
/**************************************************************************\
|
||||||
|
* Standard constructor for setting $this->account_id *
|
||||||
|
* This constructor sets the account id, if string is sent, converts to id *
|
||||||
|
* I might move this to the accounts_shared if it stays around *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
function accounts($account_id = '')
|
||||||
|
{
|
||||||
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
|
$this->db = $phpgw->db;
|
||||||
|
|
||||||
|
if($account_id != '')
|
||||||
|
{
|
||||||
|
$this->account_id = get_account_id($account_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function read()
|
||||||
|
{
|
||||||
|
if (count($this->data) == 0)
|
||||||
|
{
|
||||||
|
$this->read_repository();
|
||||||
|
}
|
||||||
|
|
||||||
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_data($data)
|
||||||
|
{
|
||||||
|
reset($data);
|
||||||
|
$this->data = Array();
|
||||||
|
$this->data = $data;
|
||||||
|
|
||||||
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function memberships($accountid = '')
|
||||||
|
{
|
||||||
|
global $phpgw_info, $phpgw;
|
||||||
|
$account_id = get_account_id($accountid);
|
||||||
|
|
||||||
|
$security_equals = Array();
|
||||||
|
$security_equals = $phpgw->acl->get_location_list_for_id('phpgw_group', 1, $account_id);
|
||||||
|
|
||||||
|
if ($security_equals == False)
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->memberships = Array();
|
||||||
|
|
||||||
|
for ($idx=0; $idx<count($security_equals); $idx++)
|
||||||
|
{
|
||||||
|
$groups = intval($security_equals[$idx]);
|
||||||
|
$this->memberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->memberships;
|
||||||
|
}
|
||||||
|
|
||||||
|
function members ($accountid = '')
|
||||||
|
{
|
||||||
|
global $phpgw_info, $phpgw;
|
||||||
|
$account_id = get_account_id($accountid);
|
||||||
|
|
||||||
|
$security_equals = Array();
|
||||||
|
$acl = CreateObject('phpgwapi.acl');
|
||||||
|
$security_equals = $acl->get_ids_for_location($account_id, 1, 'phpgw_group');
|
||||||
|
unset($acl);
|
||||||
|
|
||||||
|
if ($security_equals == False)
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($idx=0; $idx<count($security_equals); $idx++)
|
||||||
|
{
|
||||||
|
$name = $this->id2name(intval($security_equals[$idx]));
|
||||||
|
$this->members[] = Array('account_id' => intval($security_equals[$idx]), 'account_name' => $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->members;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_nextid()
|
||||||
|
{
|
||||||
|
global $phpgw,$phpgw_info;
|
||||||
|
|
||||||
|
if ($phpgw_info["server"]["account_min_id"]) { $min = $phpgw_info["server"]["account_min_id"]; }
|
||||||
|
if ($phpgw_info["server"]["account_max_id"]) { $max = $phpgw_info["server"]["account_max_id"]; }
|
||||||
|
|
||||||
|
$nextid = $phpgw->common->last_id("accounts",$min,$max);
|
||||||
|
|
||||||
|
// Loop until we find a free id
|
||||||
|
$free = 0;
|
||||||
|
while (!$free)
|
||||||
|
{
|
||||||
|
//echo '<br>calling search for id: '.$nextid;
|
||||||
|
if ($this->exists($nextid))
|
||||||
|
{
|
||||||
|
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//echo '<br>calling search for lid: '.$account_lid;
|
||||||
|
if ($this->exists($account_lid))
|
||||||
|
{
|
||||||
|
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$free = True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($phpgw_info["server"]["account_max_id"] && ($nextid > $phpgw_info["server"]["account_max_id"])) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
//echo '<br>using'.$nextid;exit;
|
||||||
|
return $nextid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -25,6 +25,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
$phpgw_info["server"]["global_denied_users"] = array();
|
$phpgw_info["server"]["global_denied_users"] = array();
|
||||||
|
$phpgw_info["server"]["global_denied_groups"] = array();
|
||||||
|
|
||||||
class accounts_
|
class accounts_
|
||||||
{
|
{
|
||||||
@ -211,39 +212,26 @@
|
|||||||
|
|
||||||
function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status, $account_id='', $account_home='',$account_shell='')
|
function create($account_type, $account_lid, $account_pwd, $account_firstname, $account_lastname, $account_status, $account_id='', $account_home='',$account_shell='')
|
||||||
{
|
{
|
||||||
// $account_home and $account_shell not used here
|
//echo '<br>in create for account_lid: "'.$account_lid.'"';
|
||||||
$this->db->query("insert into phpgw_accounts (account_lid, account_type, account_pwd, "
|
if (empty($account_id) || !$account_id)
|
||||||
. "account_firstname, account_lastname, account_status) values ('" . $account_lid
|
{
|
||||||
. "','" . $account_type . "','" . md5($account_pwd) . "', '" . $account_firstname
|
$account_id = $this->get_nextid();
|
||||||
. "','" . $account_lastname . "','" . $account_status . "')",__LINE__,__FILE__);
|
//echo '<br>using'.$account_id;exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $account_home and $account_shell not used here
|
||||||
|
$this->db->query("insert into phpgw_accounts (account_id, account_lid, account_type, account_pwd, "
|
||||||
|
. "account_firstname, account_lastname, account_status) values ("
|
||||||
|
. $account_id . ",'" . $account_lid . "','"
|
||||||
|
. $account_type . "','" . md5($account_pwd) . "', '" . $account_firstname . "','"
|
||||||
|
. $account_lastname . "','" . $account_status . "')",__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False)
|
function auto_add($accountname, $passwd, $default_prefs = False, $default_acls = False)
|
||||||
{
|
{
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
if ($phpgw_info["server"]["account_min_id"]) { $min = $phpgw_info["server"]["account_min_id"]; }
|
$account_id = $this->get_nextid();
|
||||||
if ($phpgw_info["server"]["account_max_id"]) { $max = $phpgw_info["server"]["account_max_id"]; }
|
|
||||||
|
|
||||||
$nextid = $phpgw->common->last_id("accounts",$min,$max);
|
|
||||||
|
|
||||||
// Loop until we find a free id
|
|
||||||
$free = 0;
|
|
||||||
while (!$free) {
|
|
||||||
if ($this->exists($nextid))
|
|
||||||
{
|
|
||||||
$nextid = $phpgw->common->next_id("accounts",$min,$max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$free = True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($phpgw_info["server"]["account_max_id"] && ($nextid > $phpgw_info["server"]["account_max_id"])) {
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
$account_id = $nextid;
|
|
||||||
//echo $account_id;exit;
|
|
||||||
|
|
||||||
if ($default_prefs == False) {
|
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";}}';
|
||||||
|
Loading…
Reference in New Issue
Block a user