diff --git a/htdocs/mass_delete.php b/htdocs/mass_delete.php index cc87010..4956d36 100644 --- a/htdocs/mass_delete.php +++ b/htdocs/mass_delete.php @@ -17,6 +17,12 @@ require './common.php'; $request = array(); $request['dn'] = get_request('dn','REQUEST'); +if (! $request['dn']) + system_message(array( + 'title'=>_('No entry selected'), + 'body'=>_('No entry was selected to delete'), + 'type'=>'warn'),'index.php'); + if (! is_array($request['dn'])) $request['dn'] = array($request['dn']); diff --git a/htdocs/mass_edit.php b/htdocs/mass_edit.php new file mode 100644 index 0000000..beb2b5b --- /dev/null +++ b/htdocs/mass_edit.php @@ -0,0 +1,128 @@ +dnExists($dn)) { + system_message(array( + 'title'=>_('Entry does not exist'), + 'body'=>sprintf('%s (%s/%s)',_('The entry does not exist and will be ignored'),$dn), + 'type'=>'error')); + + continue; + } + + $request['page'][$counter] = new MassRender($app['server']->getIndex(),'none'); + $request['page'][$counter]->setDN($dn); + $request['page'][$counter]->accept(true); + + $template = $request['page'][$counter]->getTemplate(); + + # Mark our attributes to edit as shown. + foreach ($template->getAttributes(true) as $attribute) { + if ($attribute->isInternal()) + continue; + + if (in_array_ignore_case($attribute->getName(),$request['attrs']) || in_array('*',$request['attrs'])) { + $attribute->show(); + + # Get a list of our columns (we are not interested in these attribute values) + if (! isset($attrcols[$attribute->getName()])) + $attrcols[$attribute->getName()] = $attribute; + } + } + + $counter++; +} + +usort($attrcols,'sortAttrs'); + +if (! count($request['page'])) + header('Location: index.php'); + +# We'll render this forms Title with the first DN's object. +$request['page'][0]->drawTitle(_('Bulk edit the following DNs')); +$request['page'][0]->drawSubTitle(sprintf('%s: %s',_('Server'),$app['server']->getName())); + +echo '
'; +?> diff --git a/htdocs/mass_update.php b/htdocs/mass_update.php new file mode 100644 index 0000000..0d489e8 --- /dev/null +++ b/htdocs/mass_update.php @@ -0,0 +1,175 @@ + $dn) { + # Check if the entry exists. + if (! $dn || ! $app['server']->dnExists($dn)) { + system_message(array( + 'title'=>_('Entry does not exist'), + 'body'=>sprintf('%s (%s/%s)',_('The entry does not exist and will be ignored'),$dn), + 'type'=>'error')); + + continue; + } + + # Simulate the requirements for *Render->accept() + if (! isset($request['mass_values'][$index])) + continue; + + $_REQUEST['new_values'] = $request['mass_values'][$index]; + + $render = new MassRender($app['server']->getIndex(),'none'); + $render->setDN($dn); + $render->accept(true); + + if ($render->getTemplate()->getLDAPmodify(false,$index)) + $request['update'][$index] = $render; +} + +# We can use the $render to give us a title +$render->drawTitle(_('Bulk update the following DNs')); +$render->drawSubTitle(sprintf('%s: %s',_('Server'),$app['server']->getName())); + +if (count($request['update'])) { + if (get_request('confirm','REQUEST')) { + foreach ($request['update'] as $index => $page) { + $template = $page->getTemplate(); + + # Perform the modification + $result = $app['server']->modify($template->getDN(),$template->getLDAPmodify(false,$index)); + + if ($result) + printf('%s: %s'; + + printf('', + $j,htmlspecialchars($attribute->getName()),$i, + $j,htmlspecialchars($attribute->getName()),$i, + htmlspecialchars($val), + $attribute->needJS('focus') ? sprintf('onFocus="focus_%s(this);" ',$attribute->getName()) : '', + $attribute->needJS('blur') ? sprintf('onBlur="blur_%s(this);" ',$attribute->getName()) : '', + ($attribute->getSize() > 0) ? sprintf('size="%s"',$attribute->getSize()) : '', + ($attribute->getMaxLength() > 0) ? sprintf('maxlength="%s"',$attribute->getMaxLength()) : ''); + + if ($attribute->getHelper()) { + echo ' | '; + $this->draw('AttributeHelper',$attribute,$i); + echo ' |