phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] setup/ldapmodify.php, 1.10.2.3


From: nomail
Subject: [Phpgroupware-cvs] setup/ldapmodify.php, 1.10.2.3
Date: Thu, 15 Jul 2004 02:21:13 +0200

Update of /setup
Modified Files:
        Branch: Version-0_9_16-branch
          ldapmodify.php

date: 2004/07/15 00:21:13;  author: skwashd;  state: Exp;  lines: +79 -65

Log Message:
fixes bug #9599
=====================================================================
Index: setup/ldapmodify.php
diff -u setup/ldapmodify.php:1.10.2.2 setup/ldapmodify.php:1.10.2.3
--- setup/ldapmodify.php:1.10.2.2       Tue Sep  9 05:49:06 2003
+++ setup/ldapmodify.php        Thu Jul 15 00:21:13 2004
@@ -11,13 +11,14 @@
 
   /* $Id$ */
 
-       $phpgw_info = array();
-       $phpgw_info["flags"] = array(
-               'noheader'   => True,
-               'nonavbar'   => True,
-               'currentapp' => 'home',
-               'noapi'      => True
-       );
+       $GLOBALS['phpgw_info'] = array();
+       $GLOBALS['phpgw_info']['flags'] = array(
+                       'noheader'   => True,
+                       'nonavbar'   => True,
+                       'currentapp' => 'home',
+                       'noapi'      => True
+               );
+
        include('./inc/functions.inc.php');
 
        /* Authorize the user to use setup app and load the database */
@@ -26,6 +27,7 @@
                Header('Location: index.php');
                exit;
        }
+
        /* Does not return unless user is authorized */
 
        class phpgw
@@ -35,12 +37,12 @@
                var $applications;
                var $db;
        }
-       $phpgw = new phpgw;
-       $phpgw->common = CreateObject('phpgwapi.common');
+       $GLOBALS['phpgw'] = new phpgw;
+       $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
 
-       $common = $phpgw->common;
+       $common =& $GLOBALS['phpgw']->common;
        $GLOBALS['phpgw_setup']->loaddb();
-       $phpgw->db = $GLOBALS['phpgw_setup']->db;
+       $GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
 
        $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
        $setup_tpl = CreateObject('setup.Template',$tpl_root);
@@ -56,15 +58,14 @@
        {
                $config[$GLOBALS['phpgw_setup']->db->f('config_name')] = 
$GLOBALS['phpgw_setup']->db->f('config_value');
        }
-       $phpgw_info['server']['ldap_host']          = $config['ldap_host'];
-       $phpgw_info['server']['ldap_context']       = $config['ldap_context'];
-       $phpgw_info['server']['ldap_group_context'] = 
$config['ldap_group_context'];
-       $phpgw_info['server']['ldap_root_dn']       = $config['ldap_root_dn'];
-       $phpgw_info['server']['ldap_root_pw']       = $config['ldap_root_pw'];
-       $phpgw_info['server']['account_repository'] = 
$config['account_repository'];
+       $GLOBALS['phpgw_info']['server']['ldap_host']          = 
$config['ldap_host'];
+       $GLOBALS['phpgw_info']['server']['ldap_context']       = 
$config['ldap_context'];
+       $GLOBALS['phpgw_info']['server']['ldap_group_context'] = 
$config['ldap_group_context'];
+       $GLOBALS['phpgw_info']['server']['ldap_root_dn']       = 
$config['ldap_root_dn'];
+       $GLOBALS['phpgw_info']['server']['ldap_root_pw']       = 
$config['ldap_root_pw'];
+       $GLOBALS['phpgw_info']['server']['account_repository'] = 
$config['account_repository'];
 
-       $phpgw->accounts     = CreateObject('phpgwapi.accounts');
-       $acct                = $phpgw->accounts;
+       $acct   = $GLOBALS['phpgw']->accounts   = 
CreateObject('phpgwapi.accounts');
 
        /* connect to ldap server */
        if (! $ldap = $common->ldapConnect())
@@ -82,15 +83,15 @@
        $info = ldap_get_entries($ldap, $sr);
        $tmp = '';
 
-       for ($i=0; $i<$info['count']; $i++)
+       for ($i=0; $i<$info['count']; ++$i)
        {
-               if (! 
$phpgw_info['server']['global_denied_users'][$info[$i]['uid'][0]])
+               if (! 
$GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
                {
                        $account_info[$info[$i]['uidnumber'][0]] = $info[$i];
                }
        }
 
-       if ($phpgw_info['server']['ldap_group_context'])
+       if ($GLOBALS['phpgw_info']['server']['ldap_group_context'])
        {
                $srg = 
ldap_search($ldap,$config['ldap_group_context'],'(|(cn=*))',array('gidnumber','cn','memberuid'));
                $info = ldap_get_entries($ldap, $srg);
@@ -98,7 +99,7 @@
 
                for ($i=0; $i<$info['count']; $i++)
                {
-                       if (! 
$phpgw_info['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
+                       if (! 
$GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
                                ! $account_info[$i][$info[$i]['cn'][0]])
                        {
                                $group_info[$info[$i]['gidnumber'][0]] = 
$info[$i];
@@ -110,13 +111,15 @@
                $group_info = array();
        }
 
-       $GLOBALS['phpgw_setup']->db->query('SELECT app_name FROM 
phpgw_applications WHERE app_enabled !=0 AND app_enabled !=3 ORDER BY 
app_name',__LINE__,__FILE__);
+       $GLOBALS['phpgw_setup']->db->query('SELECT app_name FROM 
phpgw_applications'
+                                       . ' WHERE app_enabled !=0 '
+                                       . ' AND app_enabled !=3 ORDER BY 
app_name',__LINE__,__FILE__);
        while ($GLOBALS['phpgw_setup']->db->next_record())
        {
                $apps[$GLOBALS['phpgw_setup']->db->f('app_name')] = 
lang($GLOBALS['phpgw_setup']->db->f('app_name'));
        }
 
-       if ($cancel)
+       if ( isset($_POST['cancel']) )
        {
                Header("Location: ldap.php");
                exit;
@@ -124,15 +127,15 @@
 
        $GLOBALS['phpgw_setup']->html->show_header('LDAP 
Modify','','config',$ConfigDomain);
 
-       if ($submit)
+       if ($_POST['submit'])
        {
                $acl = CreateObject('phpgwapi.acl');
                $acl->db = $GLOBALS['phpgw_setup']->db;
-               if ($ldapgroups)
+               if ( isset($_POST['ldapgroups']) && count($_POST['ldapgroups']) 
)
                {
                        $groups = CreateObject('phpgwapi.accounts');
                        $groups->db = $GLOBALS['phpgw_setup']->db;
-                       while (list($key,$groupid) = each($ldapgroups))
+                       foreach($_POST['ldapgroups'] as $key => $groupid)
                        {
                                $id_exist = 0;
                                $entry = array();
@@ -153,39 +156,35 @@
 
                                        reset($entry[0]['objectclass']);
                                        $addclass = True;
-                                       while(list($key,$value) = 
each($entry[0]['objectclass']))
+                                       while(list($key,$value) = 
@each($entry[0]['objectclass']))
                                        {
-                                               if(strtolower($value) == 
'phpgwaccount')
+                                               if(strtolower($value) == 
'phpgwGroup')
                                                {
                                                        $addclass = False;
                                                }
                                        }
+                                       
                                        if($addclass)
                                        {
                                                reset($entry[0]['objectclass']);
                                                $replace['objectclass'] = 
$entry[0]['objectclass'];
-                                               $replace['objectclass'][]       
= 'phpgwAccount';
-                                               
ldap_mod_replace($ldap,$thisdn,$replace);
+                                               
unset($replace['objectclass']['count']);//breaks things
+                                               $replace['objectclass'][]       
= 'phpgwGroup';
+
+                                               //We add this here as it is 
mandatory
+                                               $replace['phpgwGroupID'] = 
$thisacctlid;
+
+                                               $ok = 
ldap_mod_replace($ldap,$thisdn,$replace);
+                                               if (!$ok)//give user some 
feedback
+                                               {
+                                                       echo lang('failed to 
modify: %1', $thisdn) . '<br />';
+                                               }
+                                               
                                                unset($replace);
                                                unset($addclass);
+                                               unset($ok);
                                        }
                                        unset($add);
-                                       
if(address@hidden($entry[0]['phpgwaccountstatus']))
-                                       {
-                                               $add['phpgwaccountstatus'][]    
= 'A';
-                                       }
-                                       
if(address@hidden($entry[0]['phpgwaccounttype']))
-                                       {
-                                               $add['phpgwaccounttype'][]      
= 'g';
-                                       }
-                                       
if(address@hidden($entry[0]['phpgwaccountexpires']))
-                                       {
-                                               $add['phpgwaccountexpires'][]   
= -1;
-                                       }
-                                       if(@isset($add))
-                                       {
-                                               
ldap_mod_add($ldap,$thisdn,$add);
-                                       }
 
                                        /* Now make the members a member of 
this group in phpgw. */
                                        while (list($key,$members) = 
each($thismembers))
@@ -224,7 +223,7 @@
                                                }
                                        }
                                        /* Now give this group some rights */
-                                       $phpgw_info['user']['account_id'] = 
$thisacctid;
+                                       
$GLOBALS['phpgw_info']['user']['account_id'] = $thisacctid;
                                        $acl->account_id = intval($thisacctid);
                                        $acl->read_repository();
                                        @reset($s_apps);
@@ -239,11 +238,11 @@
                        }
                }
 
-               if($users)
+               if( isset($_POST['users']) && count($_POST['users']) )
                {
                        $accounts = CreateObject('phpgwapi.accounts');
                        $accounts->db = $GLOBALS['phpgw_setup']->db;
-                       while (list($key,$id) = each($users))
+                       foreach($_POST['users'] as $key => $id)
                        {
                                $id_exist = 0;
                                $thisacctid  = 
$account_info[$id]['uidnumber'][0];
@@ -269,27 +268,42 @@
                                        if($addclass)
                                        {
                                                reset($entry[0]['objectclass']);
-                                               $replace['objectclass'] = 
$entry[0]['objectclass'];
-                                               $replace['objectclass'][]       
= 'phpgwAccount';
-                                               
ldap_mod_replace($ldap,$thisdn,$replace);
-                                               unset($replace);
-                                               unset($addclass);
+                                               $addmod['objectclass']          
= $entry[0]['objectclass'];
+                                               $addmod['objectclass'][]        
= 'phpgwAccount';
+                                               
unset($addmod['objectclass']['count']);
                                        }
-                                       unset($add);
+                                       
                                        
if(address@hidden($entry[0]['phpgwaccountstatus']))
                                        {
-                                               $add['phpgwaccountstatus'][]    
= 'A';
+                                               $addmod['phpgwaccountstatus'][] 
= 'A';
                                        }
-                                       
if(address@hidden($entry[0]['phpgwaccounttype']))
+                                       
+                                       
if(address@hidden($entry[0]['phpgwaccountexpires']))
                                        {
-                                               $add['phpgwaccounttype'][]      
= 'u';
+                                               
$addmod['phpgwaccountexpires'][] = -1;
                                        }
-                                       
if(address@hidden($entry[0]['phpgwaccountexpires']))
+
+                                       
if(address@hidden($entry[0]['phpgwAccountID']))
                                        {
-                                               $add['phpgwaccountexpires'][]   
= -1;
+                                               $addmod['phpgwAccountID'][]     
= $thisacctid;
+                                       }
+                                       
+                                       if($addmod)
+                                       {                                       
        
+                                               $ok = 
ldap_mod_replace($ldap,$thisdn,$addmod);
+                                               
+                                               if (!$ok)//give user some 
feedback
+                                               {
+                                                       echo lang('failed to 
modify: ', $thisdn) . '<br />';
+                                               }
+                                               
+                                               unset($replace);
+                                               unset($addclass);
                                        }
+                                       unset($addmod);
                                        if(@isset($add))
                                        {
+                                               echo 
"<pre>ldap_mod_add($ldap,$thisdn,"; print_r($add); echo '</pre>';
                                                
ldap_mod_add($ldap,$thisdn,$add);
                                        }
 
@@ -305,7 +319,7 @@
                                        However, if no groups were imported, we 
do need to give each user
                                        apps access
                                        */
-                                       if(!$ldapgroups)
+                                       if(! (isset($_POST['ldapgroups']) && 
count($_POST['ldapgroups']) ) )
                                        {
                                                @reset($s_apps);
                                                while (list($key,$app) = 
@each($s_apps))
@@ -376,7 +390,7 @@
                $group_list .= '<option value="' . $group['gidnumber'][0] . 
'">' . $group['cn'][0]  . '</option>';
        }
 
-       while(list($appname,$apptitle) = each($apps))
+       while(list($appname,$apptitle) = each($apps))//TODO: IMHO This needs to 
go - skwashd Jul-04
        {
                if($appname == 'admin' ||
                        $appname == 'skel' ||




reply via email to

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