phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.arrayfunctions.inc.php,1.1,1.


From: Bettina Gille <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.arrayfunctions.inc.php,1.1,1.2 class.accounts_ldap.inc.php,1.112,1.113
Date: Tue, 17 Dec 2002 19:17:53 -0500

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv2822

Modified Files:
        class.accounts_ldap.inc.php 
Added Files:
        class.arrayfunctions.inc.php 
Log Message:
update accounts_ldap


Index: class.accounts_ldap.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.accounts_ldap.inc.php,v
retrieving revision 1.112
retrieving revision 1.113
diff -C2 -r1.112 -r1.113
*** class.accounts_ldap.inc.php 21 Sep 2002 05:15:32 -0000      1.112
--- class.accounts_ldap.inc.php 18 Dec 2002 00:17:50 -0000      1.113
***************
*** 1,27 ****
  <?php
!   /**************************************************************************\
!   * phpGroupWare API - Accounts manager for LDAP                             *
!   * This file written by Joseph Engo <address@hidden>                *
!   * and Lars Kneschke <address@hidden>                            *
!   * View and manipulate account records using LDAP                           *
!   * 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_
--- 1,26 ----
  <?php
!       
/**************************************************************************\
!       * phpGroupWare API - Accounts manager for LDAP                          
   *
!       * This file written by Joseph Engo <address@hidden>                *
!       * and Lars Kneschke <address@hidden>                                   *
!       * View and manipulate account records using LDAP                        
   *
!       * Copyright (C) 2000 - 2002 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_
***************
*** 109,132 ****
                        if($acct_type == 'u')
                        {
!                               $entry['cn']                = sprintf("%s %s", 
$this->data['firstname'], $this->data['lastname']);
                        }
                        else
                        {
!                               $entry['cn']                = 
$this->data['firstname'];
                        }
  
!                       $entry['sn']                    = 
$this->data['lastname'];
!                       $entry['givenname']             = 
$this->data['firstname'];
!                       $entry['phpgwaccountlastlogin']     = 
$this->data['lastlogin'];
!                       $entry['phpgwaccountlastloginfrom'] = 
$this->data['lastloginfrom'];
!                       $entry['phpgwlastpasswdchange'] = 
$this->data['lastpasswd_change'];
!                       $entry['phpgwaccountstatus']    = $this->data['status'];
!                       $entry['phpgwaccounttype']      = $this->data['type'];
!                       $entry['phpgwaccountexpires']   = 
$this->data['expires'];
  
                        
if($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
                        {
!                               $entry['homedirectory'] = 
$this->data['homedirectory'];
!                               $entry['loginshell']    = 
$this->data['loginshell'];
                        }
  
--- 108,131 ----
                        if($acct_type == 'u')
                        {
!                               $entry['cn'] = sprintf("%s %s", 
$this->data['firstname'], $this->data['lastname']);
                        }
                        else
                        {
!                               $entry['cn'] = $this->data['firstname'];
                        }
  
!                       $entry['sn']                                            
= $this->data['lastname'];
!                       $entry['givenname']                                     
= $this->data['firstname'];
!                       $entry['phpgwaccountlastlogin']         = 
$this->data['lastlogin'];
!                       $entry['phpgwaccountlastloginfrom']     = 
$this->data['lastloginfrom'];
!                       $entry['phpgwlastpasswdchange']         = 
$this->data['lastpasswd_change'];
!                       $entry['phpgwaccountstatus']            = 
$this->data['status'];
!                       $entry['phpgwaccounttype']                      = 
$this->data['type'];
!                       $entry['phpgwaccountexpires']           = 
$this->data['expires'];
  
                        
if($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
                        {
!                               $entry['homedirectory'] = 
$this->data['homedirectory'];
!                               $entry['loginshell']    = 
$this->data['loginshell'];
                        }
  
***************
*** 202,225 ****
                                else
                                {
!                                       $dn = 
'uid='.$this->data['account_lid'].','.$this->user_context;
!                                       $entry['uidnumber']      = 
$this->data['account_id'];
!                                       $entry['cn'] = sprintf("%s %s", 
$this->data['firstname'], $this->data['lastname']);
!                                       $entry['uid']       = 
$this->data['account_lid'];
!                                       $entry['givenname']      = 
$this->data['firstname'];
!                                       $entry['sn']             = 
$this->data['lastname'];
!                                       $entry['objectclass']    = '';
!                                       $entry['objectclass'][0] = 'top';
!                                       $entry['objectclass'][1] = 'person';
!                                       $entry['objectclass'][2] = 
'organizationalPerson';
!                                       $entry['objectclass'][3] = 
'inetOrgPerson';
!                                       /* $entry['objectclass'][4] = 
'account'; Causes problems with some LDAP servers */
!                                       $entry['objectclass'][4] = 
'posixAccount';
!                                       $entry['objectclass'][5] = 
'shadowAccount';
!                                       $entry['objectclass'][6] = 
'phpgwAccount';
  
                                        
if($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
                                        {
!                                               $entry['homedirectory'] = 
$this->data['homedirectory'];
!                                               $entry['loginshell']    = 
$this->data['loginshell'];
                                        }
                                }
--- 201,224 ----
                                else
                                {
!                                       $dn                                     
                = 'uid='.$this->data['account_lid'].','.$this->user_context;
!                                       $entry['uidnumber']                     
= $this->data['account_id'];
!                                       $entry['cn']                            
= sprintf("%s %s", $this->data['firstname'], $this->data['lastname']);
!                                       $entry['uid']                           
= $this->data['account_lid'];
!                                       $entry['givenname']                     
= $this->data['firstname'];
!                                       $entry['sn']                            
= $this->data['lastname'];
!                                       $entry['objectclass']           = '';
!                                       $entry['objectclass'][0]        = 'top';
!                                       $entry['objectclass'][1]        = 
'person';
!                                       $entry['objectclass'][2]        = 
'organizationalPerson';
!                                       $entry['objectclass'][3]        = 
'inetOrgPerson';
!                                       /* $entry['objectclass'][4]     = 
'account'; Causes problems with some LDAP servers */
!                                       $entry['objectclass'][4]        = 
'posixAccount';
!                                       $entry['objectclass'][5]        = 
'shadowAccount';
!                                       $entry['objectclass'][6]        = 
'phpgwAccount';
  
                                        
if($GLOBALS['phpgw_info']['server']['ldap_extra_attributes'])
                                        {
!                                               $entry['homedirectory'] = 
$this->data['homedirectory'];
!                                               $entry['loginshell']    = 
$this->data['loginshell'];
                                        }
                                }
***************
*** 310,392 ****
                function get_list($_type='both', $start = '',$sort = '', $order 
= '', $query = '', $offset = '')
                {
!                       if($offset)
                        {
                                $limitclause = 
'';//$phpgw->db->limit($start,$offset);
                        }
!                       elseif($start && !$offset)
                        {
                                $limitclause = '';//$phpgw->db->limit($start);
                        }
  
!                       if(!$sort)
                        {
                                $sort = '';//"desc";
                        }
  
!                       if($order)
!                       {
!                               $orderclause = '';//"order by $order $sort";
!                       }
!                       else
!                       {
!                               $orderclause = '';//"order by 
account_lid,account_lastname,account_firstname asc";
!                       }
! 
!                       if($_type == 'both' || $_type == 'accounts')
                        {
!                               $sri = ldap_search($this->ds, 
$this->user_context, '(&(uidnumber=*)(phpgwaccounttype=u))');
                                $allValues = ldap_get_entries($this->ds, $sri);
!                               while(list($null,$allVals) = @each($allValues))
                                {
                                        settype($allVals,'array');
                                        $test = @$allVals['uid'][0];
!                                       
if(!$GLOBALS['phpgw_info']['server']['global_denied_users'][$test] && 
$allVals['uid'][0])
                                        {
!                                               if(!$query ||
!                                                       strpos(' ' . 
$allVals['cn'][0],$query) ||
!                                                       strpos(' ' . 
$allVals['givenname'][0],$query) ||
!                                                       strpos(' ' . 
$allVals['sn'][0],$query))
!                                               {
!                                                       $accounts[] = Array(
!                                                               'account_id'    
    => $allVals['uidnumber'][0],
!                                                               'account_lid'   
    => $allVals['uid'][0],
!                                                               'account_type'  
    => $allVals['phpgwaccounttype'][0],
!                                                               
'account_firstname' => $allVals['givenname'][0],
!                                                               
'account_lastname'  => $allVals['sn'][0],
!                                                               
'account_status'    => $allVals['phpgwaccountstatus'][0]
!                                                       );
!                                               }
                                        }
                                }
                        }
!                       elseif($_type == 'both' || $_type == 'groups')
                        {
!                               $sri = ldap_search($this->ds, 
$this->group_context, '(&(gidnumber=*)(phpgwaccounttype=g))');
                                $allValues = ldap_get_entries($this->ds, $sri);
!                               while(list($null,$allVals) = @each($allValues))
                                {
                                        settype($allVals,'array');
                                        $test = $allVals['cn'][0];
!                                       
if(!$GLOBALS['phpgw_info']['server']['global_denied_groups'][$test] && 
$allVals['cn'][0])
                                        {
!                                               if(!$query ||
!                                                       strpos(' ' . 
$allVals['cn'][0],$query) ||
!                                                       strpos(' ' . 
$allVals['givenname'][0],$query) ||
!                                                       strpos(' ' . 
$allVals['sn'][0],$query))
!                                               {
!                                                       $accounts[] = Array(
!                                                               'account_id'    
    => $allVals['gidnumber'][0],
!                                                               'account_lid'   
    => $allVals['cn'][0],
!                                                               'account_type'  
    => $allVals['phpgwaccounttype'][0],
!                                                               
'account_firstname' => $allVals['givenname'][0],
!                                                               
'account_lastname'  => $allVals['sn'][0],
!                                                               
'account_status'    => $allVals['phpgwaccountstatus'][0]
!                                                       );
!                                               }
                                        }
                                }
                        }
                        $this->total = count($accounts);
!                       return $accounts;
                }
  
--- 309,453 ----
                function get_list($_type='both', $start = '',$sort = '', $order 
= '', $query = '', $offset = '')
                {
!                       #print "\$_type=$_type, \$start=$start , \$sort=$sort, 
\$order=$order, \$query=$query, \$offset=$offset<br>";
!                       $query = strtolower($query);
!                       if ($offset)
                        {
                                $limitclause = 
'';//$phpgw->db->limit($start,$offset);
                        }
!                       elseif ($start && !$offset)
                        {
                                $limitclause = '';//$phpgw->db->limit($start);
                        }
  
!                       if (! $sort)
                        {
                                $sort = '';//"desc";
                        }
  
!                       if ($_type == 'accounts')
                        {
!                               if(empty($query) || $query == "*")
!                               {
!                                       $filter = 
"(&(uidnumber=*)(phpgwaccounttype=u))";
!                               }
!                               else
!                               {
!                                       $filter = 
"(&(uidnumber=*)(phpgwaccounttype=u)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)))";
!                               }
!                               $sri = ldap_search($this->ds, 
$this->user_context, $filter);
                                $allValues = ldap_get_entries($this->ds, $sri);
!                               while (list($null,$allVals) = @each($allValues))
                                {
                                        settype($allVals,'array');
                                        $test = @$allVals['uid'][0];
!                                       if 
(!$GLOBALS['phpgw_info']['server']['global_denied_users'][$test] && 
$allVals['uid'][0])
                                        {
!                                               $accounts[] = Array(
!                                                       'account_id'        => 
$allVals['uidnumber'][0],
!                                                       'account_lid'       => 
$allVals['uid'][0],
!                                                       'account_type'      => 
$allVals['phpgwaccounttype'][0],
!                                                       'account_firstname' => 
$allVals['givenname'][0],
!                                                       'account_lastname'  => 
$allVals['sn'][0],
!                                                       'account_status'    => 
$allVals['phpgwaccountstatus'][0]
!                                               );
                                        }
                                }
                        }
!                       elseif ($_type == 'groups')
                        {
!                               if(empty($query) || $query == "*")
!                               {
!                                       $filter = 
"(&(gidnumber=*)(phpgwaccounttype=g))";
!                               }
!                               else
!                               {
!                                       $filter = 
"(&(gidnumber=*)(phpgwaccounttype=g)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)))";
!                               }
!                               $sri = ldap_search($this->ds, 
$this->group_context, $filter);
                                $allValues = ldap_get_entries($this->ds, $sri);
!                               while (list($null,$allVals) = @each($allValues))
                                {
                                        settype($allVals,'array');
                                        $test = $allVals['cn'][0];
!                                       if 
(!$GLOBALS['phpgw_info']['server']['global_denied_groups'][$test] && 
$allVals['cn'][0])
                                        {
!                                               $accounts[] = Array(
!                                                       'account_id'        => 
$allVals['gidnumber'][0],
!                                                       'account_lid'       => 
$allVals['cn'][0],
!                                                       'account_type'      => 
$allVals['phpgwaccounttype'][0],
!                                                       'account_firstname' => 
$allVals['givenname'][0],
!                                                       'account_lastname'  => 
$allVals['sn'][0],
!                                                       'account_status'    => 
$allVals['phpgwaccountstatus'][0]
!                                               );
                                        }
                                }
                        }
+                       else
+                       {
+                               if(empty($query) || $query == "*")
+                               {
+                                       $filter = 
"(&(gidnumber=*)(phpgwaccounttype=*))";
+                               }
+                               else
+                               {
+                                       $filter = 
"(&(gidnumber=*)(phpgwaccounttype=*)(|(uid=*$query*)(sn=*$query*)(cn=*$query*)(givenname=*$query*)))";
+                               }
+                               $sri = ldap_search($this->ds, 
$this->group_context, $filter);
+                               $allValues = ldap_get_entries($this->ds, $sri);
+                               while (list($null,$allVals) = @each($allValues))
+                               {
+                                       settype($allVals,'array');
+ 
+                                       if($allVals['phpgwaccounttype'][0] == 
'u')
+                                       {
+                                               $_uid = @$allVals['uid'][0];
+                                       }
+                                       else
+                                       {
+                                               $_uid = $allVals['cn'][0];
+                                       }
+ 
+                                       if 
(!$GLOBALS['phpgw_info']['server']['global_denied_groups'][$_uid] && $_uid)
+                                       {
+                                               $accounts[] = Array(
+                                                       'account_id'        => 
$allVals['gidnumber'][0],
+                                                       'account_lid'       => 
$_uid,
+                                                       'account_type'      => 
$allVals['phpgwaccounttype'][0],
+                                                       'account_firstname' => 
$allVals['givenname'][0],
+                                                       'account_lastname'  => 
$allVals['sn'][0],
+                                                       'account_status'    => 
$allVals['phpgwaccountstatus'][0]
+                                               );
+                                       }
+                               }
+                       }
+ 
+                       // sort the array
+                       $arrayFunctions = 
CreateObject('phpgwapi.arrayfunctions');
+                       if(empty($order))
+                       {
+                               $order = 'account_lid';
+                       }
+                       $sortedAccounts = 
$arrayFunctions->arfsort($accounts,array($order));
                        $this->total = count($accounts);
! 
!                       // return only the wanted accounts
! 
!                       if (is_array($sortedAccounts))
!                       {
!                               reset($sortedAccounts);
!                               if(is_int($start) && is_int($offset))
!                               {
!                                       return array_slice($sortedAccounts, 
$start, $offset);
!                               }
!                               elseif(is_int($start))
!                               {
!                                       return array_slice($sortedAccounts, 
$start, $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']);
!                               }
!                               else
!                               {
!                                       return $sortedAccounts;
!                               }
!                       }
!                       return False;
                }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]