Unverified Commit 8cf70243 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(core) Add archive ACL and action if plugin is installed

issue #6119
Showing with 68 additions and 0 deletions
+68 -0
...@@ -1141,6 +1141,10 @@ class config ...@@ -1141,6 +1141,10 @@ class config
$this->data['OBJECTS'][$obj]['snapshotActive'] = TRUE; $this->data['OBJECTS'][$obj]['snapshotActive'] = TRUE;
$this->data['CATEGORIES'][$cat]['classes'][] = 'SnapshotHandler'; $this->data['CATEGORIES'][$cat]['classes'][] = 'SnapshotHandler';
} }
if (class_available('archivedObject') && archivedObject::isArchiveActive($obj)) {
$this->data['OBJECTS'][$obj]['archiveActive'] = TRUE;
$this->data['CATEGORIES'][$cat]['classes'][] = 'archive';
}
} }
} }
} }
......
...@@ -280,6 +280,13 @@ class management implements FusionDirectoryDialog ...@@ -280,6 +280,13 @@ class management implements FusionDirectoryDialog
); );
} }
if (class_available('archivedObject')) {
$action = archivedObject::getManagementAction($this->objectTypes, 'archiveEntry');
if ($action !== NULL) {
$this->registerAction($action);
}
}
$this->registerAction( $this->registerAction(
new Action( new Action(
'remove', _('Remove'), 'geticon.php?context=actions&icon=edit-delete&size=16', 'remove', _('Remove'), 'geticon.php?context=actions&icon=edit-delete&size=16',
...@@ -834,6 +841,63 @@ class management implements FusionDirectoryDialog ...@@ -834,6 +841,63 @@ class management implements FusionDirectoryDialog
$this->dialogObject = new templateDialog($this, $type, NULL, $this->currentDn); $this->dialogObject = new templateDialog($this, $type, NULL, $this->currentDn);
} }
public function archiveEntry (array $action)
{
global $ui;
if (empty($action['targets'])) {
return;
}
$this->currentDns = $action['targets'];
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->currentDns, 'Archiving');
// check locks
if ($locks = get_locks($this->currentDns)) {
return gen_locked_message($locks, $this->currentDns);
}
// Add locks
add_lock($this->currentDns, $ui->dn);
$success = 0;
foreach ($this->currentDns as $dn) {
$entry = $this->listing->getEntry($dn);
if ($entry === NULL) {
trigger_error('Could not find '.$dn.', action canceled');
$this->remove_lock();
$this->currentDns = [];
return;
}
if ($entry->isTemplate()) {
$error = new FusionDirectoryError(htmlescape(_('Archiving a template is not possible')));
$error->display();
$this->remove_lock();
$this->currentDns = [];
return;
}
$errors = archivedObject::archiveObject($entry->type, $dn);
if (empty($errors)) {
$success++;
} else {
msg_dialog::displayChecks($errors);
}
del_lock($dn);
}
if ($success > 0) {
msg_dialog::display(
_('Archive success'),
htmlescape(sprintf(_('%d entries were successfully archived'), $success)),
INFO_DIALOG
);
}
$this->currentDns = [];
}
/*! /*!
* \brief This method opens an existing object to be edited. * \brief This method opens an existing object to be edited.
......
Supports Markdown
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