New feature: Copy a DN and edit values before creation
This commit is contained in:
parent
2e8e9625d6
commit
1c467a6115
@ -63,16 +63,43 @@ if ($request['recursive']) {
|
|||||||
print '</small>';
|
print '</small>';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']);
|
if ($_SESSION[APPCONFIG]->getValue('confirm','copy')) {
|
||||||
|
$request['pageSRC'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
|
||||||
|
$request['pageSRC']->setDN($request['dnSRC']);
|
||||||
|
$request['pageSRC']->accept(true);
|
||||||
|
|
||||||
if ($copy_result)
|
$request['pageDST'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
|
||||||
$copy_message = sprintf('%s %s: <b>%s</b> %s',
|
$request['pageDST']->setContainer($app['server']->getContainer($request['dnDST']));
|
||||||
$request['remove'] ? _('Move successful') : _('Copy successful'),
|
$request['pageDST']->accept(true);
|
||||||
_('DN'),$request['dnDST'],_('has been created.'));
|
|
||||||
else
|
$request['templateSRC'] = $request['pageSRC']->getTemplate();
|
||||||
$copy_message = sprintf('%s %s: <b>%s</b> %s',
|
$request['templateDST'] = $request['pageDST']->getTemplate();
|
||||||
$request['remove'] ? _('Move NOT successful') : _('Copy NOT successful'),
|
|
||||||
_('DN'),$request['dnDST'],_('has NOT been created.'));
|
$request['templateDST']->copy($request['templateSRC'],get_rdn($request['dnDST']),true);
|
||||||
|
|
||||||
|
# Set all attributes with a values as shown, and remove the add value options
|
||||||
|
foreach ($request['templateDST']->getAttributes(true) as $sattribute)
|
||||||
|
if ($sattribute->getValues() && ! $sattribute->isInternal()) {
|
||||||
|
$sattribute->show();
|
||||||
|
$sattribute->setMaxValueCount(count($sattribute->getValues()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$request['pageDST']->accept();
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$copy_result = copy_dn($ldap['SRC'],$ldap['DST'],$request['dnSRC'],$request['dnDST'],$request['remove']);
|
||||||
|
|
||||||
|
if ($copy_result)
|
||||||
|
$copy_message = sprintf('%s %s: <b>%s</b> %s',
|
||||||
|
$request['remove'] ? _('Move successful') : _('Copy successful'),
|
||||||
|
_('DN'),$request['dnDST'],_('has been created.'));
|
||||||
|
else
|
||||||
|
$copy_message = sprintf('%s %s: <b>%s</b> %s',
|
||||||
|
$request['remove'] ? _('Move NOT successful') : _('Copy NOT successful'),
|
||||||
|
_('DN'),$request['dnDST'],_('has NOT been created.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($copy_result) {
|
if ($copy_result) {
|
||||||
|
@ -656,7 +656,7 @@ class Template extends xmlTemplate {
|
|||||||
/**
|
/**
|
||||||
* Copy a DN
|
* Copy a DN
|
||||||
*/
|
*/
|
||||||
public function copy($template,$rdn) {
|
public function copy($template,$rdn,$asnew=false) {
|
||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||||
|
|
||||||
@ -709,6 +709,11 @@ class Template extends xmlTemplate {
|
|||||||
else
|
else
|
||||||
$attribute->setRDN($counter++);
|
$attribute->setRDN($counter++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If we are copying into a new entry, we need to discard all the "old values"
|
||||||
|
if ($asnew)
|
||||||
|
foreach ($this->getAttributes(true) as $sattribute)
|
||||||
|
$sattribute->setOldValue(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -854,7 +859,9 @@ class Template extends xmlTemplate {
|
|||||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||||
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||||
|
|
||||||
if ($this->getContainer())
|
if ($this->getContainer() && get_request('cmd','REQUEST') == 'copy')
|
||||||
|
return 'copyasnew';
|
||||||
|
elseif ($this->getContainer() || get_request('create_base'))
|
||||||
return 'create';
|
return 'create';
|
||||||
elseif ($this->getDN())
|
elseif ($this->getDN())
|
||||||
return 'edit';
|
return 'edit';
|
||||||
|
@ -49,7 +49,8 @@ class TemplateRender extends PageRender {
|
|||||||
$this->page = get_request('page','REQUEST',false,1);
|
$this->page = get_request('page','REQUEST',false,1);
|
||||||
|
|
||||||
if ($this->template_id) {
|
if ($this->template_id) {
|
||||||
parent::accept();
|
if (! $this->template)
|
||||||
|
parent::accept();
|
||||||
|
|
||||||
$this->url_base = sprintf('server_id=%s&dn=%s',
|
$this->url_base = sprintf('server_id=%s&dn=%s',
|
||||||
$this->getServerID(),rawurlencode($this->template->getDN()));
|
$this->getServerID(),rawurlencode($this->template->getDN()));
|
||||||
@ -611,11 +612,11 @@ class TemplateRender extends PageRender {
|
|||||||
|
|
||||||
# If we have a DN, then we are an editing template
|
# If we have a DN, then we are an editing template
|
||||||
if ($this->dn)
|
if ($this->dn)
|
||||||
$this->template->setDN(get_request('dn','REQUEST'));
|
$this->template->setDN($this->dn);
|
||||||
|
|
||||||
# Else if we have a container, we are a creating template
|
# Else if we have a container, we are a creating template
|
||||||
elseif ($this->container)
|
elseif ($this->container || get_request('create_base'))
|
||||||
$this->template->setContainer(get_request('container','REQUEST'));
|
$this->template->setContainer($this->container);
|
||||||
|
|
||||||
else
|
else
|
||||||
debug_dump_backtrace('Dont know what type of template we are - no DN or CONTAINER?',1);
|
debug_dump_backtrace('Dont know what type of template we are - no DN or CONTAINER?',1);
|
||||||
@ -641,6 +642,15 @@ class TemplateRender extends PageRender {
|
|||||||
$this->drawStepForm($this->page);
|
$this->drawStepForm($this->page);
|
||||||
$this->drawStepFormEnd();
|
$this->drawStepFormEnd();
|
||||||
|
|
||||||
|
} elseif ($this->template->getContext() == 'copyasnew') {
|
||||||
|
$this->drawStepFormStart($this->page);
|
||||||
|
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($this->template->getContainer()));
|
||||||
|
echo '<div><table>';
|
||||||
|
$this->drawRDNChooser();
|
||||||
|
echo '</table></div>';
|
||||||
|
$this->drawForm(true);
|
||||||
|
$this->drawStepFormSubmitButton($this->page);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
# Draw internal attributes
|
# Draw internal attributes
|
||||||
if (get_request('show_internal_attrs','REQUEST')) {
|
if (get_request('show_internal_attrs','REQUEST')) {
|
||||||
@ -1360,7 +1370,7 @@ class TemplateRender extends PageRender {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function drawForm() {
|
protected function drawForm($nosubmit=false) {
|
||||||
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__);
|
if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__);
|
||||||
|
|
||||||
echo '<div>';
|
echo '<div>';
|
||||||
@ -1372,7 +1382,8 @@ class TemplateRender extends PageRender {
|
|||||||
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">';
|
echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">';
|
||||||
|
|
||||||
$this->drawShownAttributes();
|
$this->drawShownAttributes();
|
||||||
$this->drawFormSubmitButton();
|
if (! $nosubmit)
|
||||||
|
$this->drawFormSubmitButton();
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
|
@ -284,6 +284,10 @@ class Config {
|
|||||||
|
|
||||||
/** Confirm actions
|
/** Confirm actions
|
||||||
*/
|
*/
|
||||||
|
$this->default->confirm['copy'] = array(
|
||||||
|
'desc'=>'Confirm copy actions',
|
||||||
|
'default'=>true);
|
||||||
|
|
||||||
$this->default->confirm['create'] = array(
|
$this->default->confirm['create'] = array(
|
||||||
'desc'=>'Confirm creation actions',
|
'desc'=>'Confirm creation actions',
|
||||||
'default'=>true);
|
'default'=>true);
|
||||||
|
Loading…
Reference in New Issue
Block a user