<?php
  /**************************************************************************\
  * phpGroupWare - eLDAPtir - LDAP Administration                            *
  * http://www.phpgroupware.org                                              *
  * Written by Miles Lott <milosch@phpgroupware.org>                         *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

	/* $Id: addobj.php,v 1.1.1.1.18.1 2004/09/26 11:15:52 kazuyan Exp $ */

	$GLOBALS['phpgw_info']['flags']['currentapp'] = 'eldaptir';
	include('../header.inc.php');

	foreach($_POST as $key => $val)
	{
		$$key = get_var($key, array('POST'));
	}
	foreach($_GET as $key => $val)
	{
		$$key = $$key ? $$key : get_var($key, array('GET'));
	}
	
	$GLOBALS['phpgw']->common->check_code($cd);

	$servers = servers();
	$dn = $HTTP_GET_VARS['dn'];
	$ou = $HTTP_GET_VARS['ou'];
	$dn = urldecode($dn);
	
	$ldapobj = CreateObject('eldaptir.ldap', $servers[$server_id]);
	$codecv = CreateObject('phpgwapi.codecv');
	$tmpdata = $ldapobj->read($dn);

	echo "<table width=\"100%\">\n<form method=\"GET\" action=\"".$GLOBALS['phpgw']->link('/eldaptir/edit.php')."\">\n";
	echo "<br>".lang('Add').' '.lang('objectclasses')." ".lang('to')." ".$codecv->utf8toeuc($dn);
	while(list($key,$oc) = each($ldapobj->schema->objectclasses))
	{
		if (in_array(strtolower($oc), $tmpdata[0]['objectclass']))
			continue;
		echo '<tr><td><input type="checkbox" name="' . $oc . '">' . $oc
			. '</td></tr>'."\n";
	}
	echo '<tr><td>'."\n";
	echo '<input type="hidden" name="ou" value="'.$ou.'">'."\n";
	echo '<input type="hidden" name="dn" value="'.urlencode($dn).'">'."\n";
	echo '<input type="hidden" name="server_id" value="'.$server_id.'">'."\n";
	echo '<input type="submit" name="addobj" value="'.lang('Add').'">'."\n";
	echo '</td></tr>'."\n";
	echo "</form>\n</table>\n";

	$GLOBALS['phpgw']->common->phpgw_footer();
?>
