getIndex(),'LDIF');
$request['import'] = $request['importer']->getTemplate();
$request['continuous_mode'] = get_request('continuous_mode') ? true : false;
$type = $request['import']->getType();
# Set our timelimit in case we have a lot of importing to do
@set_time_limit(0);
# String associated to the operation on the ldap server
$actionString = array(
'add' => _('Adding'),
'delete' => _('Deleting'),
'modrdn' => _('Renaming'),
'moddn' => _('Renaming'),
'modify' => _('Modifying')
);
# String associated with error
$actionErrorMsg = array(
'add' => _('Could not add object'),
'delete' => _('Could not delete object'),
'modrdn' => _('Could not rename the entry.'),
'moddn' => _('Could not rename the entry.'),
'modify' => _('Could not modify object')
);
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->drawTitle(sprintf('%s',_('Import')));
$request['page']->drawSubTitle(sprintf('%s: %s %s: %s %s %s (%s)',
_('Server'),$app['server']->getName(),
_('File'),$request['import']->getSource('name'),number_format($request['import']->getSource('size')),_('bytes'),$type['description']));
echo '
';
# @todo When renaming DNs, the hotlink should point to the new entry on success, or the old entry on failure.
while (! $request['import']->eof()) {
while ($request['template'] = $request['import']->readEntry()) {
$edit_href = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s',$app['server']->getIndex(),
rawurlencode($request['template']->getDN()));
$changetype = $request['template']->getType();
printf('%s %s',$actionString[$changetype],$edit_href,$request['template']->getDN());
if ($request['import']->LDAPimport())
printf(' %s
',_('Success'));
else {
printf(' %s
',_('Failed'));
$errormsg = sprintf('%s %s',$actionErrorMsg[$changetype],$request['template']->getDN());
$errormsg .= ldap_error_msg($app['server']->getErrorMessage(null),$app['server']->getErrorNum(null));
system_message(array(
'title'=>_('LDIF import'),
'body'=>$errormsg,
'type'=>'warn'));
}
}
if ($request['import']->error) {
printf('%s: %s
',
_('Error'),$request['import']->error['message']);
echo '
';
display_pla_parse_error($request['import']);
}
if (! $request['continuous_mode'])
break;
}
function display_pla_parse_error($request) {
$type = $request->getType();
echo '
',IMGDIR,'error-big.png'); printf(' | %s %s | ',$type['description'],_('Parse error'));
echo '
%s: | %s |
%s: | %s |
%s: | |
%s |