mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-12 08:58:25 +01:00
Cleanup badfilter on empty values; cleanup formatting
This commit is contained in:
parent
286c8bf012
commit
0039d2a51c
@ -39,6 +39,10 @@
|
||||
function accounts_()
|
||||
{
|
||||
$this->ds = $GLOBALS['phpgw']->common->ldapConnect();
|
||||
if(!@is_object($GLOBALS['phpgw']->translation))
|
||||
{
|
||||
$GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
|
||||
}
|
||||
$this->user_context = $GLOBALS['phpgw_info']['server']['ldap_context'];
|
||||
$this->group_context = $GLOBALS['phpgw_info']['server']['ldap_group_context'];
|
||||
}
|
||||
@ -50,11 +54,11 @@
|
||||
/* search the dn for the given uid */
|
||||
if(($acct_type == 'g') && $this->group_context)
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$this->account_id);
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$this->account_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$this->account_id);
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$this->account_id);
|
||||
}
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
@ -101,11 +105,11 @@
|
||||
/* search the dn for the given u/gidnumber */
|
||||
if(($acct_type == 'g') && $this->group_context)
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$this->account_id);
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$this->account_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$this->account_id);
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$this->account_id);
|
||||
}
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
@ -116,19 +120,27 @@
|
||||
// data for posixaccount
|
||||
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(sprintf("%s %s",
|
||||
$this->data['firstname'],
|
||||
$this->data['lastname']),$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
||||
$this->data['lastname']),$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||
);
|
||||
$newData['uid'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$this->data['account_lid'],
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||
);
|
||||
if($this->data['lastname'])
|
||||
{
|
||||
$newData['sn'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$this->data['lastname'],
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||
);
|
||||
}
|
||||
|
||||
if($this->data['firstname'])
|
||||
{
|
||||
$newData['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$this->data['firstname'],
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
||||
$GLOBALS['phpgw']->translation->charset(),'utf-8'
|
||||
);
|
||||
}
|
||||
if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
|
||||
{
|
||||
$newData['homedirectory'] = $this->data['homedirectory'];
|
||||
@ -141,19 +153,33 @@
|
||||
$entry['loginshell'] = '/bin/false';
|
||||
}
|
||||
if($this->data['account_primary_group'])
|
||||
{
|
||||
$newData['gidnumber'] = $this->data['account_primary_group'];
|
||||
}
|
||||
if($this->data['lastlogin'])
|
||||
{
|
||||
$newData['phpgwaccountlastlogin'] = $this->data['lastlogin'];
|
||||
}
|
||||
if($this->data['lastloginfrom'])
|
||||
{
|
||||
$newData['phpgwaccountlastloginfrom'] = $this->data['lastloginfrom'];
|
||||
}
|
||||
if($this->data['lastpasswd_change'])
|
||||
{
|
||||
$newData['phpgwlastpasswdchange'] = $this->data['lastpasswd_change'];
|
||||
}
|
||||
if($this->data['status'])
|
||||
{
|
||||
$newData['phpgwaccountstatus'] = $this->data['status'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$newData['phpgwaccountstatus'] = array();
|
||||
}
|
||||
if($this->data['expires'])
|
||||
{
|
||||
$newData['phpgwaccountexpires'] = $this->data['expires'];
|
||||
}
|
||||
|
||||
$newAccountID = $newData['uid'];
|
||||
$oldAccountID = $newData['uid'];
|
||||
@ -163,15 +189,16 @@
|
||||
// data for posixgroup
|
||||
$newData['cn'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$this->data['account_lid'],
|
||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8'
|
||||
);
|
||||
$newData['gidnumber'] = $this->data['account_id'];
|
||||
$newGroupID = $newData['cn'];
|
||||
$oldGroupID = $newData['cn'];
|
||||
}
|
||||
if($this->data['type'])
|
||||
{
|
||||
$newData['phpgwaccounttype'] = $this->data['type'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Changing the uid: Need to delete and add new, since
|
||||
@ -267,7 +294,6 @@
|
||||
}
|
||||
// modify the DN
|
||||
ldap_modify($this->ds, $allValues[0]['dn'], $newData);
|
||||
|
||||
}
|
||||
|
||||
if ($this->data['account_type'] == 'u')
|
||||
@ -276,7 +302,7 @@
|
||||
|
||||
// first lets search for the groups, the user is currently member of
|
||||
// and from which he needs to be removed
|
||||
$filter = "(&(objectclass=posixgroup)(memberuid=$oldAccountID))";
|
||||
$filter = "(&(objectclass=posixgroup)(memberuid=" . (int)$oldAccountID . "))";
|
||||
$justThese = array('memberuid','gidnumber');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
@ -302,7 +328,6 @@
|
||||
$newData['memberuid'] = array_values(sort(array_flip($newData['memberuid'])));
|
||||
ldap_mod_replace($this->ds, $dn, $newData);
|
||||
#print ldap_error($this->ds);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -328,7 +353,7 @@
|
||||
foreach($this->data['account_groups'] as $key => $value)
|
||||
{
|
||||
// search for the group
|
||||
$filter = 'gidnumber='.$value;
|
||||
$filter = 'gidnumber=' . (int)$value;
|
||||
$justThese = array('memberuid');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
@ -375,9 +400,9 @@
|
||||
function delete($accountid = '')
|
||||
{
|
||||
$account_id = get_account_id($accountid);
|
||||
$account_lid = $this->id2name($account_id);
|
||||
$account_lid = $this->id2name((int)$account_id);
|
||||
|
||||
$filter = 'gidnumber='.$account_id;
|
||||
$filter = 'gidnumber=' . (int)$account_id;
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter);
|
||||
if($sri)
|
||||
{
|
||||
@ -386,7 +411,7 @@
|
||||
|
||||
if(!$allValues[0]['dn'])
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uid='.$account_lid);
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . (string)$account_lid);
|
||||
if($sri)
|
||||
{
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
@ -403,7 +428,7 @@
|
||||
if($wasAccount)
|
||||
{
|
||||
// remove the user from any group he is member of
|
||||
$filter = "(&(objectclass=posixgroup)(memberuid=$accountID))";
|
||||
$filter = "(&(objectclass=posixgroup)(memberuid=" . (int)$accountID . "))";
|
||||
$justThese = array('memberuid','gidnumber');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
@ -478,9 +503,9 @@
|
||||
}
|
||||
elseif ($_type == 'groups')
|
||||
{
|
||||
if(empty($query) || $query == "*")
|
||||
if(empty($query) || $query == '*')
|
||||
{
|
||||
$filter = "(&(gidnumber=*)(phpgwaccounttype=g))";
|
||||
$filter = '(&(gidnumber=*)(phpgwaccounttype=g))';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -583,7 +608,13 @@
|
||||
return $name_list[$account_lid];
|
||||
}
|
||||
|
||||
$sri = ldap_search($this->ds, $this->group_context, "(&(cn=$account_lid)(phpgwaccounttype=g))");
|
||||
/* Don't bother searching for empty account_lid */
|
||||
if(empty($account_lid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
$sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$account_lid . ')(phpgwaccounttype=g))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if (@$allValues[0]['gidnumber'][0])
|
||||
@ -591,7 +622,7 @@
|
||||
$name_list[$account_lid] = (int)$allValues[0]['gidnumber'][0];
|
||||
}
|
||||
|
||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uid=$account_lid)(phpgwaccounttype=u))");
|
||||
$sri = ldap_search($this->ds, $this->user_context, '(&(uid=' . (string)$account_lid . ')(phpgwaccounttype=u))');
|
||||
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
@ -613,7 +644,7 @@
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->group_context, "(&(gidnumber=$account_id)(phpgwaccounttype=g))");
|
||||
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if (@$allValues[0]['cn'][0])
|
||||
@ -623,7 +654,7 @@
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uidnumber=$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);
|
||||
|
||||
if (@$allValues[0]['uid'][0])
|
||||
@ -650,7 +681,7 @@
|
||||
return $account_type[$account_id];
|
||||
}
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->user_context, "(&(uidnumber=$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);
|
||||
|
||||
if ($allValues[0]['phpgwaccounttype'][0])
|
||||
@ -661,7 +692,7 @@
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->group_context, "(&(gidnumber=$account_id)(phpgwaccounttype=g))");
|
||||
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if ($allValues[0]['phpgwaccounttype'][0])
|
||||
@ -687,6 +718,7 @@
|
||||
{
|
||||
$ldapgroup = 'gidnumber';
|
||||
$ldapacct = 'uidnumber';
|
||||
$account = (int)$account;
|
||||
/* If data is cached, use it. */
|
||||
if(@isset($by_id[$account]) && @$by_id[$account])
|
||||
{
|
||||
@ -755,11 +787,11 @@
|
||||
|
||||
if($account_info['account_type'] == 'g')
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'cn=' . $account_info['account_lid']);
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'cn=' . (string)$account_info['account_lid']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . $account_info['account_lid']);
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uid=' . (string)$account_info['account_lid']);
|
||||
}
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
@ -813,7 +845,7 @@
|
||||
$tmpentry['objectclass'][1] = 'person';
|
||||
$tmpentry['objectclass'][2] = 'organizationalPerson';
|
||||
$tmpentry['objectclass'][3] = 'inetOrgPerson';
|
||||
$tmpentry['userpassword'] = $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd']);
|
||||
$tmpentry['userpassword'] = $GLOBALS['phpgw']->common->encrypt_password($account_info['account_passwd'],False);
|
||||
/* $tmpentry['objectclass'][4] = 'account'; Causes problems with some LDAP servers */
|
||||
$tmpentry['objectclass'][4] = 'posixAccount';
|
||||
$tmpentry['objectclass'][5] = 'shadowAccount';
|
||||
@ -844,20 +876,30 @@
|
||||
{
|
||||
$dn = 'uid=' . $account_info['account_lid'] . ',' . $this->user_context;
|
||||
|
||||
$entry['cn'] = $GLOBALS['phpgw']->translation->convert(sprintf("%s %s",
|
||||
$entry['cn'] = $GLOBALS['phpgw']->translation->convert(
|
||||
sprintf(
|
||||
"%s %s",
|
||||
$account_info['account_firstname'],
|
||||
$account_info['account_lastname']
|
||||
), $GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
||||
),
|
||||
$GLOBALS['phpgw']->translation->charset(),
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
$entry['sn'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$account_info['account_lastname'],
|
||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
||||
$GLOBALS['phpgw']->translation->charset(),
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
if($account_info['account_firstname'])
|
||||
{
|
||||
$entry['givenname'] = $GLOBALS['phpgw']->translation->convert(
|
||||
$account_info['account_firstname'],
|
||||
$GLOBALS['phpgw']->translation->charset(), 'utf-8');
|
||||
|
||||
$GLOBALS['phpgw']->translation->charset(),
|
||||
'utf-8'
|
||||
);
|
||||
}
|
||||
$entry['uid'] = $account_info['account_lid'];
|
||||
$entry['uidnumber'] = $account_id;
|
||||
$entry['gidnumber'] = $account_info['account_primary_group'];
|
||||
@ -870,7 +912,9 @@
|
||||
$entry['objectclass'][5] = 'shadowAccount';
|
||||
$entry['objectclass'][6] = 'phpgwAccount';
|
||||
if($account_info['account_status'])
|
||||
{
|
||||
$entry['phpgwaccountstatus'] = $account_info['account_status'];
|
||||
}
|
||||
$entry['phpgwaccounttype'] = $account_info['account_type'];
|
||||
$entry['phpgwaccountexpires'] = $account_info['account_expires'];
|
||||
}
|
||||
@ -888,10 +932,11 @@
|
||||
// lets check group the user needs to be added
|
||||
if($account_info['account_type'] == 'u')
|
||||
{
|
||||
@settype($account_info['account_groups'],'array');
|
||||
foreach($account_info['account_groups'] as $key => $value)
|
||||
{
|
||||
// search for the group
|
||||
$filter = 'gidnumber='.$value;
|
||||
$filter = 'gidnumber=' . (int)$value;
|
||||
$justThese = array('memberuid');
|
||||
$sri = ldap_search($this->ds, $this->group_context, $filter, $justThese);
|
||||
if($sri)
|
||||
@ -991,10 +1036,10 @@
|
||||
$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', "
|
||||
$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__);
|
||||
@reset($apps);
|
||||
while(list($key,$app) = each($apps))
|
||||
{
|
||||
@ -1022,11 +1067,11 @@
|
||||
/* search the dn for the given uid */
|
||||
if(($acct_type == 'g') && $this->group_context)
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber='.$account_id);
|
||||
$sri = ldap_search($this->ds, $this->group_context, 'gidnumber=' . (int)$account_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber='.$account_id);
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$account_id);
|
||||
}
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
@ -1066,7 +1111,7 @@
|
||||
{
|
||||
$_account_id = get_account_id($_accountid);
|
||||
|
||||
$sri = ldap_search($this->ds, $this->user_context, "uidnumber=$_account_id");
|
||||
$sri = ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$_account_id);
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
return $allValues[0]['dn'];
|
||||
|
Loading…
Reference in New Issue
Block a user