mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-02 03:19:56 +01:00
added email-address to the accounts-data (ldap untested so far!)
This commit is contained in:
parent
7fbc1c9248
commit
8bfb6cfb07
@ -218,9 +218,9 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$serial2 = $serial;
|
$serial2 = $serial;
|
||||||
if (is_numeric($param['type']) || $param[$app] || $param['type'] == 'owngroups') // do we need to limit the search on a group or app?
|
if (is_numeric($param['type']) || $param['app'] || $param['type'] == 'owngroups') // do we need to limit the search on a group or app?
|
||||||
{
|
{
|
||||||
$app = $param[$app];
|
$app = $param['app'];
|
||||||
unset($param['app']);
|
unset($param['app']);
|
||||||
if (is_numeric($param['type']))
|
if (is_numeric($param['type']))
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@
|
|||||||
if (!isset($account_search[$serial2])) // check if we already did this general search
|
if (!isset($account_search[$serial2])) // check if we already did this general search
|
||||||
{
|
{
|
||||||
$account_search[$serial2]['data'] = array();
|
$account_search[$serial2]['data'] = array();
|
||||||
$accounts = accounts_::get_list($param['type'],'',$param['sort'],$param['order'],$param['query'],'',$param['query_type']);
|
$accounts = accounts_::get_list($param['type'],$param['start'],$param['sort'],$param['order'],$param['query'],$param['offset'],$param['query_type']);
|
||||||
if (!$accounts) $accounts = array();
|
if (!$accounts) $accounts = array();
|
||||||
foreach($accounts as $data)
|
foreach($accounts as $data)
|
||||||
{
|
{
|
||||||
@ -290,7 +290,7 @@
|
|||||||
$account_search[$serial]['total'] = $this->total;
|
$account_search[$serial]['total'] = $this->total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//echo "<p>accounts::search(...)=<pre>".print_r($account_search[$serial]['data'],True).")</pre>\n";
|
//echo "<p>accounts::search('$serial')=<pre>".print_r($account_search[$serial]['data'],True).")</pre>\n";
|
||||||
return $account_search[$serial]['data'];
|
return $account_search[$serial]['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,25 +598,25 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function name2id($account_lid)
|
function name2id($name,$which='account_lid')
|
||||||
{
|
{
|
||||||
$this->setup_cache();
|
$this->setup_cache();
|
||||||
$name_list = &$this->cache['name_list'];
|
$name_list = &$this->cache['name_list'];
|
||||||
|
|
||||||
if(@isset($name_list[$account_lid]) && $name_list[$account_lid])
|
if(@isset($name_list[$which][$name]) && $name_list[$which][$name])
|
||||||
{
|
{
|
||||||
return $name_list[$account_lid];
|
return $name_list[$which][$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't bother searching for empty account_lid */
|
/* Don't bother searching for empty account_lid */
|
||||||
if(empty($account_lid))
|
if(empty($name))
|
||||||
{
|
{
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
return $name_list[$account_lid] = accounts_::name2id($account_lid);
|
return $name_list[$which][$name] = accounts_::name2id($name,$which);
|
||||||
}
|
}
|
||||||
|
|
||||||
function id2name($account_id)
|
function id2name($account_id,$which='account_lid')
|
||||||
{
|
{
|
||||||
$this->setup_cache();
|
$this->setup_cache();
|
||||||
$id_list = &$this->cache['id_list'];
|
$id_list = &$this->cache['id_list'];
|
||||||
@ -626,11 +626,11 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($id_list[$account_id])
|
if($id_list[$account_id][$which])
|
||||||
{
|
{
|
||||||
return $id_list[$account_id];
|
return $id_list[$account_id][$which];
|
||||||
}
|
}
|
||||||
return $id_list[$account_id] = accounts_::id2name($account_id);
|
return $id_list[$account_id][$which] = accounts_::id2name($account_id,$which);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_type($accountid)
|
function get_type($accountid)
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
$this->data['lastname'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['sn'][0],'utf-8');
|
$this->data['lastname'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['sn'][0],'utf-8');
|
||||||
if(isset($allValues[0]['mail'][0]))
|
if(isset($allValues[0]['mail'][0]))
|
||||||
{
|
{
|
||||||
$this->data['mailaddress'] = $allValues[0]['mail'][0];
|
$this->data['email'] = $allValues[0]['mail'][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->data['account_dn'] = $allValues[0]['dn'];
|
$this->data['account_dn'] = $allValues[0]['dn'];
|
||||||
@ -184,6 +184,10 @@
|
|||||||
{
|
{
|
||||||
$newData['phpgwaccountexpires'] = $this->data['expires'];
|
$newData['phpgwaccountexpires'] = $this->data['expires'];
|
||||||
}
|
}
|
||||||
|
if($this->data['email'])
|
||||||
|
{
|
||||||
|
$newData['mail'] = $this->data['email'];
|
||||||
|
}
|
||||||
|
|
||||||
$newAccountID = $newData['uid'];
|
$newAccountID = $newData['uid'];
|
||||||
$oldAccountID = $newData['uid'];
|
$oldAccountID = $newData['uid'];
|
||||||
@ -259,7 +263,7 @@
|
|||||||
for($i=0;$i<count($members);$i++)
|
for($i=0;$i<count($members);$i++)
|
||||||
{
|
{
|
||||||
$currname = $this->id2name($members[$i]['account_id']);
|
$currname = $this->id2name($members[$i]['account_id']);
|
||||||
if(!$this->isin_array($currname,$entry['memberuid']))
|
if(!in_array($currname,$entry['memberuid']))
|
||||||
{
|
{
|
||||||
$newData['memberuid'][] = $currname;
|
$newData['memberuid'][] = $currname;
|
||||||
}
|
}
|
||||||
@ -290,7 +294,7 @@
|
|||||||
for($i=0;$i<count($members);$i++)
|
for($i=0;$i<count($members);$i++)
|
||||||
{
|
{
|
||||||
$currname = $this->id2name($members[$i]['account_id']);
|
$currname = $this->id2name($members[$i]['account_id']);
|
||||||
if(!$this->isin_array($currname,$newData['memberuid']))
|
if(!in_array($currname,$newData['memberuid']))
|
||||||
{
|
{
|
||||||
$newData['memberuid'][] = $currname;
|
$newData['memberuid'][] = $currname;
|
||||||
}
|
}
|
||||||
@ -392,16 +396,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isin_array($needle,$haystack='')
|
|
||||||
{
|
|
||||||
if(!@is_array($haystack))
|
|
||||||
{
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
for($i=0;$i<count($haystack) && $haystack[$i] !=$needle;$i++);
|
|
||||||
return ($i!=count($haystack));
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete($accountid = '')
|
function delete($accountid = '')
|
||||||
{
|
{
|
||||||
$account_id = get_account_id($accountid);
|
$account_id = get_account_id($accountid);
|
||||||
@ -502,7 +496,7 @@
|
|||||||
'firstname' => 'sn',
|
'firstname' => 'sn',
|
||||||
'lastname' => 'givenname',
|
'lastname' => 'givenname',
|
||||||
'lid' => 'uid',
|
'lid' => 'uid',
|
||||||
'email' => 'email',
|
'email' => 'mail',
|
||||||
);
|
);
|
||||||
$filter .= '('.$to_ldap[$query_type].'=*'.$query.'*)';
|
$filter .= '('.$to_ldap[$query_type].'=*'.$query.'*)';
|
||||||
break;
|
break;
|
||||||
@ -524,7 +518,8 @@
|
|||||||
'account_type' => $allVals['phpgwaccounttype'][0],
|
'account_type' => $allVals['phpgwaccounttype'][0],
|
||||||
'account_firstname' => $GLOBALS['phpgw']->translation->convert($allVals['givenname'][0],'utf-8'),
|
'account_firstname' => $GLOBALS['phpgw']->translation->convert($allVals['givenname'][0],'utf-8'),
|
||||||
'account_lastname' => $GLOBALS['phpgw']->translation->convert($allVals['sn'][0],'utf-8'),
|
'account_lastname' => $GLOBALS['phpgw']->translation->convert($allVals['sn'][0],'utf-8'),
|
||||||
'account_status' => $allVals['phpgwaccountstatus'][0]
|
'account_status' => $allVals['phpgwaccountstatus'][0],
|
||||||
|
'account_email' => $allVals['mail'][0],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -553,7 +548,8 @@
|
|||||||
'account_type' => $allVals['phpgwaccounttype'][0],
|
'account_type' => $allVals['phpgwaccounttype'][0],
|
||||||
'account_firstname' => $GLOBALS['phpgw']->translation->convert($allVals['givenname'][0],'utf-8'),
|
'account_firstname' => $GLOBALS['phpgw']->translation->convert($allVals['givenname'][0],'utf-8'),
|
||||||
'account_lastname' => $GLOBALS['phpgw']->translation->convert($allVals['sn'][0],'utf-8'),
|
'account_lastname' => $GLOBALS['phpgw']->translation->convert($allVals['sn'][0],'utf-8'),
|
||||||
'account_status' => $allVals['phpgwaccountstatus'][0]
|
'account_status' => $allVals['phpgwaccountstatus'][0],
|
||||||
|
'account_email' => $allVals['mail'][0],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -566,7 +562,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$filter = "(&(gidnumber=*)(phpgwaccounttype=*)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)))";
|
$filter = "(&(gidnumber=*)(phpgwaccounttype=*)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)(mail=*$query*)))";
|
||||||
}
|
}
|
||||||
$sri = ldap_search($this->ds, $this->group_context, $filter);
|
$sri = ldap_search($this->ds, $this->group_context, $filter);
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
@ -591,7 +587,8 @@
|
|||||||
'account_type' => $allVals['phpgwaccounttype'][0],
|
'account_type' => $allVals['phpgwaccounttype'][0],
|
||||||
'account_firstname' => $allVals['givenname'][0],
|
'account_firstname' => $allVals['givenname'][0],
|
||||||
'account_lastname' => $allVals['sn'][0],
|
'account_lastname' => $allVals['sn'][0],
|
||||||
'account_status' => $allVals['phpgwaccountstatus'][0]
|
'account_status' => $allVals['phpgwaccountstatus'][0],
|
||||||
|
'account_email' => $allVals['mail'][0],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,7 +624,7 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
function name2id($account_lid)
|
function name2id($name,$which='account_lid')
|
||||||
{
|
{
|
||||||
$sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$account_lid . ')(phpgwaccounttype=g))');
|
$sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$account_lid . ')(phpgwaccounttype=g))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
@ -637,7 +634,13 @@
|
|||||||
return (int)$allValues[0]['gidnumber'][0];
|
return (int)$allValues[0]['gidnumber'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sri = ldap_search($this->ds, $this->user_context, '(&(uid=' . (string)$account_lid . ')(phpgwaccounttype=u))');
|
$to_ldap = array(
|
||||||
|
'account_lid' => 'uid',
|
||||||
|
'account_email' => 'mail',
|
||||||
|
);
|
||||||
|
if (!isset($to_ldap[$which])) return False;
|
||||||
|
|
||||||
|
$sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'=' . (string)$name . ')(phpgwaccounttype=u))');
|
||||||
|
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
@ -649,7 +652,7 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
function id2name($account_id)
|
function id2name($account_id,$which='account_lid')
|
||||||
{
|
{
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||||
@ -660,13 +663,22 @@
|
|||||||
return $allValues[0]['cn'][0];
|
return $allValues[0]['cn'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$to_ldap = array(
|
||||||
|
'account_lid' => 'uid',
|
||||||
|
'account_email' => 'mail',
|
||||||
|
'account_firstname' => 'surname',
|
||||||
|
'account_lastname' => 'cn',
|
||||||
|
'account_type' => 'phpgwaccounttype',
|
||||||
|
);
|
||||||
|
if (!isset($to_ldap[$which])) return False;
|
||||||
|
|
||||||
$allValues = array();
|
$allValues = array();
|
||||||
$sri = ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))');
|
$sri = ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))');
|
||||||
$allValues = ldap_get_entries($this->ds, $sri);
|
$allValues = ldap_get_entries($this->ds, $sri);
|
||||||
|
|
||||||
if (@$allValues[0]['uid'][0])
|
if (@$allValues[0][$to_ldap[$which]][0])
|
||||||
{
|
{
|
||||||
return $allValues[0]['uid'][0];
|
return $allValues[0][$to_ldap[$which]][0];
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
@ -890,6 +902,14 @@
|
|||||||
'utf-8'
|
'utf-8'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if($account_info['account_email'])
|
||||||
|
{
|
||||||
|
$entry['mail'] = $GLOBALS['phpgw']->translation->convert(
|
||||||
|
$account_info['account_email'],
|
||||||
|
$GLOBALS['phpgw']->translation->charset(),
|
||||||
|
'utf-8'
|
||||||
|
);
|
||||||
|
}
|
||||||
$entry['uid'] = $account_info['account_lid'];
|
$entry['uid'] = $account_info['account_lid'];
|
||||||
$entry['uidnumber'] = $account_id;
|
$entry['uidnumber'] = $account_id;
|
||||||
$entry['gidnumber'] = $account_info['account_primary_group'];
|
$entry['gidnumber'] = $account_info['account_primary_group'];
|
||||||
|
@ -38,9 +38,11 @@
|
|||||||
|
|
||||||
function accounts_()
|
function accounts_()
|
||||||
{
|
{
|
||||||
copyobj($GLOBALS['phpgw']->db,$this->db);
|
//copyobj($GLOBALS['phpgw']->db,$this->db);
|
||||||
|
$this->db = is_object($GLOBALS['phpgw']->db) ? $GLOBALS['phpgw']->db : $GLOBALS['phpgw_setup']->db;
|
||||||
|
|
||||||
unset($this->query_types['email']);
|
$this->table = 'phpgw_accounts';
|
||||||
|
$this->db->set_app('phpgwapi'); // to load the right table-definitions for insert, select, update, ...
|
||||||
}
|
}
|
||||||
|
|
||||||
function list_methods($_type='xmlrpc')
|
function list_methods($_type='xmlrpc')
|
||||||
@ -82,7 +84,7 @@
|
|||||||
*/
|
*/
|
||||||
function read_repository()
|
function read_repository()
|
||||||
{
|
{
|
||||||
$this->db->query('SELECT * FROM phpgw_accounts WHERE account_id=' . (int)$this->account_id,__LINE__,__FILE__);
|
$this->db->select($this->table,'*',array('account_id'=>$this->account_id),__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
|
|
||||||
$this->data['userid'] = $this->db->f('account_lid');
|
$this->data['userid'] = $this->db->f('account_lid');
|
||||||
@ -98,6 +100,7 @@
|
|||||||
$this->data['expires'] = $this->db->f('account_expires');
|
$this->data['expires'] = $this->db->f('account_expires');
|
||||||
$this->data['person_id'] = $this->db->f('person_id');
|
$this->data['person_id'] = $this->db->f('person_id');
|
||||||
$this->data['account_primary_group'] = $this->db->f('account_primary_group');
|
$this->data['account_primary_group'] = $this->db->f('account_primary_group');
|
||||||
|
$this->data['email'] = $this->db->f('account_email');
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
@ -108,15 +111,18 @@
|
|||||||
*/
|
*/
|
||||||
function save_repository()
|
function save_repository()
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE phpgw_accounts SET'
|
$this->db->update($this->table,array(
|
||||||
. " account_firstname='" . $this->db->db_addslashes($this->data['firstname'])
|
'account_firstname' => $this->data['firstname'],
|
||||||
. "', account_lastname='" . $this->db->db_addslashes($this->data['lastname'])
|
'account_lastname' => $this->data['lastname'],
|
||||||
. "', account_status='". $this->db->db_addslashes($this->data['status'])
|
'account_status' => $this->data['status'],
|
||||||
. "', account_expires=" . (int)$this->data['expires']
|
'account_expires' => $this->data['expires'],
|
||||||
. ($this->data['account_lid']?", account_lid='".$this->db->db_addslashes($this->data['account_lid'])."'":'')
|
'account_lid' => $this->data['account_lid'],
|
||||||
. ', person_id='.(int)$this->data['person_id']
|
'person_id' => $this->data['person_id'],
|
||||||
. ', account_primary_group='.(int)$this->data['account_primary_group']
|
'account_primary_group' => $this->data['account_primary_group'],
|
||||||
. ' WHERE account_id=' . (int)$this->account_id,__LINE__,__FILE__);
|
'account_email' => $this->data['email'],
|
||||||
|
),array(
|
||||||
|
'account_id' => $this->account_id
|
||||||
|
),__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($accountid = '')
|
function delete($accountid = '')
|
||||||
@ -124,9 +130,8 @@
|
|||||||
$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 */
|
||||||
$tables_array = Array('phpgw_accounts');
|
$this->db->lock(Array($this->table));
|
||||||
$this->db->lock($tables_array);
|
$this->db->delete($this->table,array('account_id'=>$account_id),__LINE__,__FILE__);
|
||||||
$this->db->query('DELETE FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
|
||||||
$this->db->unlock();
|
$this->db->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,18 +189,19 @@
|
|||||||
case 'firstname':
|
case 'firstname':
|
||||||
case 'lastname':
|
case 'lastname':
|
||||||
case 'lid':
|
case 'lid':
|
||||||
|
case 'email':
|
||||||
$query = $this->db->quote('%'.$query.'%');
|
$query = $this->db->quote('%'.$query.'%');
|
||||||
$whereclause .= " account_$query_type LIKE $query )";
|
$whereclause .= " account_$query_type LIKE $query )";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM phpgw_accounts $whereclause $orderclause";
|
$sql = "SELECT * FROM $this->table $whereclause $orderclause";
|
||||||
if ($offset)
|
if ($offset)
|
||||||
{
|
{
|
||||||
$this->db->limit_query($sql,$start,__LINE__,__FILE__,$offset);
|
$this->db->limit_query($sql,$start,__LINE__,__FILE__,$offset);
|
||||||
}
|
}
|
||||||
elseif ($start !== '')
|
elseif (is_numeric($start))
|
||||||
{
|
{
|
||||||
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
|
$this->db->limit_query($sql,$start,__LINE__,__FILE__);
|
||||||
}
|
}
|
||||||
@ -214,61 +220,60 @@
|
|||||||
'account_status' => $this->db->f('account_status'),
|
'account_status' => $this->db->f('account_status'),
|
||||||
'account_expires' => $this->db->f('account_expires'),
|
'account_expires' => $this->db->f('account_expires'),
|
||||||
'person_id' => $this->db->f('person_id'),
|
'person_id' => $this->db->f('person_id'),
|
||||||
'account_primary_group' => $this->db->f('account_primary_group')
|
'account_primary_group' => $this->db->f('account_primary_group'),
|
||||||
|
'account_email' => $this->db->f('account_email'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->db->query("SELECT count(*) FROM phpgw_accounts $whereclause");
|
$this->db->query("SELECT count(*) FROM $this->table $whereclause");
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
$this->total = $this->db->f(0);
|
$this->total = $this->db->f(0);
|
||||||
|
|
||||||
return $accounts;
|
return $accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function name2id($account_lid)
|
/**
|
||||||
|
* converts a name / unique value from the accounts-table (account_lid,account_email) to an id
|
||||||
|
*/
|
||||||
|
function name2id($name,$which='account_lid')
|
||||||
{
|
{
|
||||||
$this->db->query("SELECT account_id FROM phpgw_accounts WHERE account_lid='".$this->db->db_addslashes($account_lid)."'",__LINE__,__FILE__);
|
$this->db->select($this->table,'account_id',array($which=>$name),__LINE__,__FILE__);
|
||||||
if($this->db->num_rows())
|
if($this->db->next_record())
|
||||||
{
|
{
|
||||||
$this->db->next_record();
|
|
||||||
return (int)$this->db->f('account_id');
|
return (int)$this->db->f('account_id');
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
function id2name($account_id)
|
/**
|
||||||
|
* converts an id to the corresponding value of the accounts-table (account_lid,account_email,account_firstname,...)
|
||||||
|
*/
|
||||||
|
function id2name($account_id,$which='account_lid')
|
||||||
{
|
{
|
||||||
$this->db->query('SELECT account_lid FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
$this->db->select($this->table,$this->db->name_quote($which),array('account_id'=>$account_id),__LINE__,__FILE__);
|
||||||
if($this->db->num_rows())
|
if($this->db->next_record())
|
||||||
{
|
{
|
||||||
$this->db->next_record();
|
return $this->db->f(0);
|
||||||
return $this->db->f('account_lid');
|
|
||||||
}
|
}
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_type($account_id)
|
function get_type($account_id)
|
||||||
{
|
{
|
||||||
$this->db->query('SELECT account_type FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
return $this->id2name($account_id,'account_type');
|
||||||
if ($this->db->num_rows())
|
|
||||||
{
|
|
||||||
$this->db->next_record();
|
|
||||||
return $this->db->f('account_type');
|
|
||||||
}
|
|
||||||
return False;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists($account_lid)
|
function exists($account_lid)
|
||||||
{
|
{
|
||||||
static $by_id, $by_lid;
|
static $by_id, $by_lid;
|
||||||
|
|
||||||
$sql = 'SELECT count(account_id) FROM phpgw_accounts WHERE ';
|
$where = array();
|
||||||
if(is_numeric($account_lid))
|
if(is_numeric($account_lid))
|
||||||
{
|
{
|
||||||
if(@isset($by_id[$account_lid]) && $by_id[$account_lid] != '')
|
if(@isset($by_id[$account_lid]) && $by_id[$account_lid] != '')
|
||||||
{
|
{
|
||||||
return $by_id[$account_lid];
|
return $by_id[$account_lid];
|
||||||
}
|
}
|
||||||
$sql .= 'account_id=' . $account_lid;
|
$where['account_id'] = $account_lid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -276,10 +281,10 @@
|
|||||||
{
|
{
|
||||||
return $by_lid[$account_lid];
|
return $by_lid[$account_lid];
|
||||||
}
|
}
|
||||||
$sql .= "account_lid = '".$this->db->db_addslashes($account_lid)."'";
|
$where['account_lid'] = $account_lid;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->query($sql,__LINE__,__FILE__);
|
$this->db->select($this->table,'count(*)',$where,__LINE__,__FILE__);
|
||||||
$this->db->next_record();
|
$this->db->next_record();
|
||||||
$ret_val = $this->db->f(0) > 0;
|
$ret_val = $this->db->f(0) > 0;
|
||||||
if(is_numeric($account_lid))
|
if(is_numeric($account_lid))
|
||||||
@ -302,24 +307,9 @@
|
|||||||
// account_id already used => discard it
|
// account_id already used => discard it
|
||||||
unset($account_info['account_id']);
|
unset($account_info['account_id']);
|
||||||
}
|
}
|
||||||
$this->db->query('INSERT INTO phpgw_accounts ('.(isset($account_info['account_id'])?'account_id,':'')
|
$this->db->insert($this->table,$account_info,False,__LINE__,__FILE__);
|
||||||
. 'account_lid,account_type,account_pwd,'
|
|
||||||
. 'account_firstname,account_lastname,account_status,account_expires,person_id,'
|
|
||||||
. 'account_primary_group) VALUES ('
|
|
||||||
. (isset($account_info['account_id'])?(int)$account_info['account_id'].',':'')
|
|
||||||
. "'" . $this->db->db_addslashes($account_info['account_lid'])
|
|
||||||
. "','" . $this->db->db_addslashes($account_info['account_type'])
|
|
||||||
. "','" . $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd'], True)
|
|
||||||
. "', '" . $this->db->db_addslashes($account_info['account_firstname'])
|
|
||||||
. "','" . $this->db->db_addslashes($account_info['account_lastname'])
|
|
||||||
. "','" . $this->db->db_addslashes($account_info['account_status'])
|
|
||||||
. "'," . (int)$account_info['account_expires']
|
|
||||||
. ',' . (int)$account_info['person_id']
|
|
||||||
. ',' . (int)$account_info['account_primary_group'] . ')',__LINE__,__FILE__);
|
|
||||||
|
|
||||||
$accountid = $this->db->get_last_insert_id('phpgw_accounts','account_id');
|
return $this->db->get_last_insert_id($this->table,'account_id');
|
||||||
|
|
||||||
return $accountid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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')
|
||||||
@ -363,6 +353,7 @@
|
|||||||
'account_status' => $account_status,
|
'account_status' => $account_status,
|
||||||
'account_expires' => $expires,
|
'account_expires' => $expires,
|
||||||
'account_primary_group' => $primary_group,
|
'account_primary_group' => $primary_group,
|
||||||
|
'account_email' => $GLOBALS['auto_create_acct']['email'],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->db->transaction_begin();
|
$this->db->transaction_begin();
|
||||||
@ -420,6 +411,7 @@
|
|||||||
$GLOBALS['hook_values']['account_status'] = $acct_info['account_status'];
|
$GLOBALS['hook_values']['account_status'] = $acct_info['account_status'];
|
||||||
$GLOBALS['hook_values']['account_firstname'] = $acct_info['account_lid'];
|
$GLOBALS['hook_values']['account_firstname'] = $acct_info['account_lid'];
|
||||||
$GLOBALS['hook_values']['account_lastname'] = 'eGW Account';
|
$GLOBALS['hook_values']['account_lastname'] = 'eGW Account';
|
||||||
|
$GLOBALS['hook_values']['account_email'] = $acct_info['account_passwd'];
|
||||||
$GLOBALS['phpgw']->hooks->process($GLOBALS['hook_values']+array(
|
$GLOBALS['phpgw']->hooks->process($GLOBALS['hook_values']+array(
|
||||||
'location' => 'addaccount'
|
'location' => 'addaccount'
|
||||||
),False,True); // called for every app now, not only enabled ones
|
),False,True); // called for every app now, not only enabled ones
|
||||||
@ -429,15 +421,14 @@
|
|||||||
|
|
||||||
function get_account_name($accountid,&$lid,&$fname,&$lname)
|
function get_account_name($accountid,&$lid,&$fname,&$lname)
|
||||||
{
|
{
|
||||||
$db = $GLOBALS['phpgw']->db;
|
$this->db->select($this->table,'account_lid,account_firstname,account_lastname',array('account_id'=>$accountid),__LINE__,__FILE__);
|
||||||
$db->query('SELECT account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_id=' . (int)$accountid,__LINE__,__FILE__);
|
if (!$this->db->next_record())
|
||||||
if (!$db->next_record())
|
|
||||||
{
|
{
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
$lid = $db->f('account_lid');
|
$lid = $this->db->f('account_lid');
|
||||||
$fname = $db->f('account_firstname');
|
$fname = $this->db->f('account_firstname');
|
||||||
$lname = $db->f('account_lastname');
|
$lname = $this->db->f('account_lastname');
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
@ -806,6 +806,11 @@
|
|||||||
{
|
{
|
||||||
return $this->data['email']['address'];
|
return $this->data['email']['address'];
|
||||||
}
|
}
|
||||||
|
// if email-address is set in the account, return it
|
||||||
|
if ($email = $GLOBALS['phpgw']->accounts->id2name($account_id,'account_email'))
|
||||||
|
{
|
||||||
|
return $email;
|
||||||
|
}
|
||||||
$prefs_email_address = $GLOBALS['phpgw']->accounts->id2name($account_id);
|
$prefs_email_address = $GLOBALS['phpgw']->accounts->id2name($account_id);
|
||||||
if (strstr($prefs_email_address,'@') === False)
|
if (strstr($prefs_email_address,'@') === False)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
/* Basic information about this app */
|
/* Basic information about this app */
|
||||||
$setup_info['phpgwapi']['name'] = 'phpgwapi';
|
$setup_info['phpgwapi']['name'] = 'phpgwapi';
|
||||||
$setup_info['phpgwapi']['title'] = 'phpgwapi';
|
$setup_info['phpgwapi']['title'] = 'phpgwapi';
|
||||||
$setup_info['phpgwapi']['version'] = '1.0.0';
|
$setup_info['phpgwapi']['version'] = '1.0.0.000';
|
||||||
$setup_info['phpgwapi']['versions']['current_header'] = '1.27';
|
$setup_info['phpgwapi']['versions']['current_header'] = '1.27';
|
||||||
$setup_info['phpgwapi']['enable'] = 3;
|
$setup_info['phpgwapi']['enable'] = 3;
|
||||||
$setup_info['phpgwapi']['app_order'] = 1;
|
$setup_info['phpgwapi']['app_order'] = 1;
|
||||||
@ -54,3 +54,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@
|
|||||||
'account_expires' => array('type' => 'int','precision' => '4'),
|
'account_expires' => array('type' => 'int','precision' => '4'),
|
||||||
'account_type' => array('type' => 'char','precision' => '1'),
|
'account_type' => array('type' => 'char','precision' => '1'),
|
||||||
'person_id' => array('type' => 'int','precision' => '4'),
|
'person_id' => array('type' => 'int','precision' => '4'),
|
||||||
'account_primary_group' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0')
|
'account_primary_group' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'),
|
||||||
|
'account_email' => array('type' => 'varchar','precision' => '100')
|
||||||
),
|
),
|
||||||
'pk' => array('account_id'),
|
'pk' => array('account_id'),
|
||||||
'fk' => array(),
|
'fk' => array(),
|
||||||
|
@ -1268,14 +1268,6 @@
|
|||||||
$test[] = '0.9.99.024';
|
$test[] = '0.9.99.024';
|
||||||
function phpgwapi_upgrade0_9_99_024()
|
function phpgwapi_upgrade0_9_99_024()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
$sql = "SELECT ae1.contact_id,ae1.contact_name,ae1.contact_value,ae2.contact_value FROM phpgw_addressbook_extra ae1 LEFT JOIN phpgw_addressbook_extra ae2 ON ae1.contact_id==ae2.contact_id AND ae1.contact_name == ae2.contact_name WHERE ae1.contact_value != ae2.contact_vaue";
|
|
||||||
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
|
|
||||||
while ($GLOBALS['phpgw_setup']->oProc->next_record())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_addressbook_extra',array(
|
$GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_addressbook_extra',array(
|
||||||
'fd' => array(
|
'fd' => array(
|
||||||
'contact_id' => array('type' => 'int','precision' => '4','nullable' => False),
|
'contact_id' => array('type' => 'int','precision' => '4','nullable' => False),
|
||||||
@ -1378,4 +1370,34 @@
|
|||||||
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0';
|
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0';
|
||||||
return $GLOBALS['setup_info']['calendar']['currentver'];
|
return $GLOBALS['setup_info']['calendar']['currentver'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$test[] = '1.0.0';
|
||||||
|
function phpgwapi_upgrade1_0_0()
|
||||||
|
{
|
||||||
|
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_accounts','account_email',array(
|
||||||
|
'type' => 'varchar',
|
||||||
|
'precision' => '100'
|
||||||
|
));
|
||||||
|
|
||||||
|
$GLOBALS['phpgw_setup']->oProc->query("SELECT config_value FROM phpgw_config WHERE config_app='phpgwapi' AND config_name='mail_suffix'",__LINE__,__FILE__);
|
||||||
|
$mail_domain = $GLOBALS['phpgw_setup']->oProc->next_record() ? $GLOBALS['phpgw_setup']->oProc->f(0) : '';
|
||||||
|
|
||||||
|
// copy the email-addresses from the preferences of the mail-app (if set) to the new field
|
||||||
|
$db2 = $GLOBALS['phpgw_setup']->oProc->m_odb;
|
||||||
|
$sql = "SELECT account_id,account_lid,preference_value FROM phpgw_accounts LEFT JOIN phpgw_preferences ON account_id=preference_owner AND preference_app='email' WHERE account_type = 'u'";
|
||||||
|
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
|
||||||
|
while ($GLOBALS['phpgw_setup']->oProc->next_record())
|
||||||
|
{
|
||||||
|
$email_prefs = unserialize($GLOBALS['phpgw_setup']->oProc->f('preference_value'));
|
||||||
|
$account_lid = $GLOBALS['phpgw_setup']->oProc->f('account_lid');
|
||||||
|
$db2->update('phpgw_accounts',array(
|
||||||
|
'account_email' => $email_prefs['address'] ? $email_prefs['address'] : $account_lid.(strstr($account_lid,'@')===False?'@'.$mail_domain:''),
|
||||||
|
),array(
|
||||||
|
'account_id' => $GLOBALS['phpgw_setup']->oProc->f('account_id')
|
||||||
|
),__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.000';
|
||||||
|
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user