diff --git a/include/class_config.inc b/include/class_config.inc index 47bb3ff79d07f6e1c0ad555884df45c1e5fd3ca0..40cb70773fc9123b06a3c31254ceff87b2ce6738 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -1141,6 +1141,10 @@ class config $this->data['OBJECTS'][$obj]['snapshotActive'] = TRUE; $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'; + } } } } diff --git a/include/management/class_management.inc b/include/management/class_management.inc index 72dfcdc96a1c88c2bb15b924b85309e0b83c2d93..2f011da0d5c4be545a790a19115209907fd11964 100644 --- a/include/management/class_management.inc +++ b/include/management/class_management.inc @@ -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( new Action( 'remove', _('Remove'), 'geticon.php?context=actions&icon=edit-delete&size=16', @@ -834,6 +841,63 @@ class management implements FusionDirectoryDialog $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.