Index: ldapmodify.php
===================================================================
RCS file: /cvsroot/phpgroupware/setup/ldapmodify.php,v
retrieving revision 1.10.2.2
diff -r1.10.2.2 ldapmodify.php
14,20c14,21
< 	$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
> 		);
> 
28a30
> 
38,39c40,41
< 	$phpgw = new phpgw;
< 	$phpgw->common = CreateObject('phpgwapi.common');
---
> 	$GLOBALS['phpgw'] = new phpgw;
> 	$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
41c43
< 	$common = $phpgw->common;
---
> 	$common =& $GLOBALS['phpgw']->common;
43c45
< 	$phpgw->db = $GLOBALS['phpgw_setup']->db;
---
> 	$GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
59,64c61,66
< 	$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'];
66,67c68
< 	$phpgw->accounts     = CreateObject('phpgwapi.accounts');
< 	$acct                = $phpgw->accounts;
---
> 	$acct	= $GLOBALS['phpgw']->accounts	= CreateObject('phpgwapi.accounts');
85c86
< 	for ($i=0; $i<$info['count']; $i++)
---
> 	for ($i=0; $i<$info['count']; ++$i)
87c88
< 		if (! $phpgw_info['server']['global_denied_users'][$info[$i]['uid'][0]])
---
> 		if (! $GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
93c94
< 	if ($phpgw_info['server']['ldap_group_context'])
---
> 	if ($GLOBALS['phpgw_info']['server']['ldap_group_context'])
101c102
< 			if (! $phpgw_info['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
---
> 			if (! $GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
113c114,116
< 	$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__);
119c122
< 	if ($cancel)
---
> 	if ( isset($_POST['cancel']) )
127c130
< 	if ($submit)
---
> 	if ($_POST['submit'])
131c134
< 		if ($ldapgroups)
---
> 		if ( isset($_POST['ldapgroups']) && count($_POST['ldapgroups']) )
135c138
< 			while (list($key,$groupid) = each($ldapgroups))
---
> 			foreach($_POST['ldapgroups'] as $key => $groupid)
156c159
< 					while(list($key,$value) = each($entry[0]['objectclass']))
---
> 					while(list($key,$value) = @each($entry[0]['objectclass']))
158c161
< 						if(strtolower($value) == 'phpgwaccount')
---
> 						if(strtolower($value) == 'phpgwGroup')
162a166
> 					
167,168c171,182
< 						$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 />';
> 						}
> 						
170a185
> 						unset($ok);
173,188d187
< 					if(!@isset($entry[0]['phpgwaccountstatus']))
< 					{
< 						$add['phpgwaccountstatus'][]	= 'A';
< 					}
< 					if(!@isset($entry[0]['phpgwaccounttype']))
< 					{
< 						$add['phpgwaccounttype'][]	= 'g';
< 					}
< 					if(!@isset($entry[0]['phpgwaccountexpires']))
< 					{
< 						$add['phpgwaccountexpires'][]	= -1;
< 					}
< 					if(@isset($add))
< 					{
< 						ldap_mod_add($ldap,$thisdn,$add);
< 					}
227c226
< 					$phpgw_info['user']['account_id'] = $thisacctid;
---
> 					$GLOBALS['phpgw_info']['user']['account_id'] = $thisacctid;
242c241
< 		if($users)
---
> 		if( isset($_POST['users']) && count($_POST['users']) )
246c245
< 			while (list($key,$id) = each($users))
---
> 			foreach($_POST['users'] as $key => $id)
272,276c271,273
< 						$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']);
278c275
< 					unset($add);
---
> 					
281c278
< 						$add['phpgwaccountstatus'][]	= 'A';
---
> 						$addmod['phpgwaccountstatus'][]	= 'A';
283c280,281
< 					if(!@isset($entry[0]['phpgwaccounttype']))
---
> 					
> 					if(!@isset($entry[0]['phpgwaccountexpires']))
285c283
< 						$add['phpgwaccounttype'][]	= 'u';
---
> 						$addmod['phpgwaccountexpires'][] = -1;
287c285,286
< 					if(!@isset($entry[0]['phpgwaccountexpires']))
---
> 
> 					if(!@isset($entry[0]['phpgwAccountID']))
289c288,301
< 						$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);
290a303
> 					unset($addmod);
292a306
> 						echo "<pre>ldap_mod_add($ldap,$thisdn,"; print_r($add); echo '</pre>';
308c322
< 					if(!$ldapgroups)
---
> 					if(! (isset($_POST['ldapgroups']) && count($_POST['ldapgroups']) ) )
379c393
< 	while(list($appname,$apptitle) = each($apps))
---
> 	while(list($appname,$apptitle) = each($apps))//TODO: IMHO This needs to go - skwashd Jul-04
