Commit d150390d authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(management) Add new object from template action to template...

 feat(management) Add new object from template action to template objects in management list

issue #5881
parent ba1cbd8c
......@@ -30,6 +30,9 @@ class Action
/* 0, 1, ?, + or * */
protected $targets;
/* Object types this action is present on */
protected $validTypes;
protected $acl;
/* Booleans */
......@@ -46,20 +49,21 @@ class Action
protected $parent;
function __construct($name, $label, $icon, $targets, $callable, array $acls = array(), $inmenu = TRUE, $inline = TRUE)
function __construct($name, $label, $icon, $targets, $callable, array $acls = array(), $inmenu = TRUE, $inline = TRUE, array $validTypes = array())
{
if ($targets == '0') {
$inline = FALSE;
}
$this->name = $name;
$this->label = $label;
$this->icon = $icon;
$this->targets = $targets;
$this->callable = $callable;
$this->inmenu = $inmenu;
$this->inline = $inline;
$this->acl = array();
$this->name = $name;
$this->label = $label;
$this->icon = $icon;
$this->targets = $targets;
$this->callable = $callable;
$this->inmenu = $inmenu;
$this->inline = $inline;
$this->validTypes = $validTypes;
$this->acl = array();
/*
* acl may be of the form:
* acl (ex: 'd')
......@@ -190,6 +194,10 @@ class Action
return '';
}
if (!empty($this->validTypes) && !($entry->isTemplate() && in_array('template', $this->validTypes)) && !in_array($entry->type, $this->validTypes)) {
return '';
}
// Skip the entry completely if there's no permission to execute it
if (!$this->hasPermission($entry->dn, $entry->getTemplatedType(), $entry->isTemplate())) {
return '<img src="images/empty.png" alt=" " class="optional"/>';
......
......@@ -174,7 +174,7 @@ class management
);
$fromTemplateMenu[] = new Action(
'template_apply_'.$type, $infos['name'], $img,
'?', 'newEntryFromTemplate',
'0', 'newEntryFromTemplate',
array($infos['aclCategory'].'/template/r', $infos['aclCategory'].'/'.$infos['mainTab'].'/c')
);
}
......@@ -279,6 +279,19 @@ class management
$this->actions['restore']->setEnableFunction(array($this, 'enableSnapshotRestore'));
}
if (!static::$skipTemplates) {
$this->registerAction(
new Action(
'template_apply', _('Create an object from this template'), 'geticon.php?context=actions&icon=document-new&size=16',
'1', 'newEntryFromTemplate',
array('/template/r', 'c'),
FALSE,
TRUE,
array('template')
)
);
}
/* Actions from footer are not in any menus and do not need a label */
$this->registerAction(new HiddenAction('apply', 'applyChanges'));
$this->registerAction(new HiddenAction('save', 'saveChanges'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment