78 $this->ctrl = $DIC->ctrl();
79 $this->tpl = $DIC->ui()->mainTemplate();
80 $this->tabs = $DIC->tabs();
81 $this->
http = $DIC->http();
82 $this->lng = $DIC->language();
83 $this->ref_id = (int) $this->
http->request()->getQueryParams()[
'ref_id'];
84 $this->toolbar = $DIC->toolbar();
85 $this->access = $DIC->access();
95 $this->ctrl->returnToParent($this);
97 $cmd = $this->ctrl->getCmd(self::CMD_DEFAULT);
100 case self::CMD_DEFAULT:
103 case self::CMD_DOWNLOAD_VERSION:
106 case self::CMD_DELETE_VERSIONS:
109 case self::CMD_ROLLBACK_VERSION:
112 case self::CMD_ADD_NEW_VERSION:
115 case self::CMD_ADD_REPLACING_VERSION:
118 case self::CMD_CREATE_NEW_VERSION:
121 case self::CMD_CREATE_REPLACING_VERSION:
124 case self::CMD_CONFIRMED_DELETE_VERSIONS:
127 case self::CMD_CONFIRMED_DELETE_FILE:
130 case self::CMD_MIGRATE:
139 if ($this->has_been_migrated) {
141 $add_version->setCaption(
'file_new_version');
142 $add_version->setUrl($this->ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION));
143 $this->toolbar->addButtonInstance($add_version);
146 $replace_version->setCaption(
'replace_file');
147 $replace_version->setUrl($this->ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION));
148 $this->toolbar->addButtonInstance($replace_version);
151 $migrate->setCaption(
'migrate');
152 $migrate->setUrl($this->ctrl->getLinkTarget($this, self::CMD_MIGRATE));
158 $this->tpl->setContent($table->getHTML());
166 if (!$this->has_been_migrated) {
169 $this->tabs->clearTargets();
170 $this->tabs->setBackTarget($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT));
174 $this->tpl->setContent($form->getHTML());
184 if (!$this->has_been_migrated) {
188 if ($form->saveObject()) {
189 ilUtil::sendSuccess($this->lng->txt(
'msg_obj_modified'),
true);
190 $this->ctrl->redirect($this, self::CMD_DEFAULT);
192 $form->setValuesByPost();
193 $this->tpl->setContent($form->getHTML());
198 $version = (int)
$_GET[self::HIST_ID];
199 $this->file->sendFile($version);
207 if (!$this->has_been_migrated) {
212 $existing_versions = $this->file->getVersions();
213 $remaining_versions = array_udiff(
216 static function (
$a,
$b) {
218 $a =
$a->getHistEntryId();
220 if (
$b instanceof ilObjFileVersion) {
221 $b =
$b->getHistEntryId();
227 if (count($version_ids) < 1) {
229 $this->ctrl->redirect($this, self::CMD_DEFAULT);
232 $conf_gui->setFormAction($this->ctrl->getFormAction($this, self::CMD_DEFAULT));
233 $conf_gui->setCancel($this->lng->txt(
"cancel"), self::CMD_DEFAULT);
236 $alt = $this->lng->txt(
"icon") .
" " . $this->lng->txt(
"obj_" . $this->file->getType());
238 if (count($remaining_versions) < 1) {
242 $conf_gui->setConfirm($this->lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_FILE);
246 $this->file->getTitle(),
254 $conf_gui->setConfirm($this->lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
256 foreach ($this->file->getVersions($version_ids) as $version) {
257 $a_text = $version[
'filename'] ?? $version->getFilename() ?? $this->file->getTitle();
258 $version_string = $version[
'hist_id'] ?? $version->getVersion();
259 $a_text .=
" (v" . $version_string .
")";
262 $version[
'hist_entry_id'],
270 $this->tpl->setContent($conf_gui->getHTML());
276 if (!$this->has_been_migrated) {
282 if (count($version_ids) != 1) {
284 $this->ctrl->redirect($this, self::CMD_DEFAULT);
288 $new_version = $this->file->rollback($version_ids[0]);
290 ilUtil::sendSuccess(sprintf($this->lng->txt(
"file_rollback_done"), $new_version[
"rollback_version"]),
true);
291 $this->ctrl->redirect($this, self::CMD_DEFAULT);
296 if (!$this->has_been_migrated) {
301 if (is_array($versions_to_delete) && count($versions_to_delete) > 0) {
302 $this->file->deleteVersions($versions_to_delete);
303 ilUtil::sendSuccess($this->lng->txt(
"file_versions_deleted"),
true);
306 $this->ctrl->setParameter($this, self::HIST_ID,
"");
307 $this->ctrl->redirect($this, self::CMD_DEFAULT);
312 if (!$this->has_been_migrated) {
317 $parent_id = $DIC->repositoryTree()->getParentId($this->ref_id);
320 $ru->deleteObjects($parent_id, array($this->ref_id));
323 $this->ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id", $parent_id);
324 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
331 $DIC->fileSystem()->storage(),
336 $this->ctrl->redirect($this, self::CMD_DEFAULT);
354 $request = $this->
http->request();
357 if (isset($request->getQueryParams()[self::HIST_ID])) {
358 $version_ids = [$request->getQueryParams()[self::HIST_ID]];
359 } elseif (isset($request->getParsedBody()[self::HIST_ID])) {
360 $version_ids = (array) $request->getParsedBody()[self::HIST_ID];
363 array_walk($version_ids,
static function (&
$i) {
376 $versions_to_keep = $this->file->getVersions();
377 array_udiff($versions_to_keep, $version_ids,
static function ($v1, $v2) {
379 $v1 = (int) $v1[
"hist_entry_id"];
381 if (!is_numeric($v1)) {
386 if (is_array($v2) || $v2 instanceof ilObjFileVersion) {
387 $v2 = (int) $v2[
"hist_entry_id"];
389 if (!is_numeric($v2)) {
397 return $versions_to_keep;
410 if (isset(
$_GET[
'wsp_id'])) {
412 if ($this->wsp_access->checkAccess($a_permission,
"", $this->ref_id)) {
417 if ($this->access->checkAccess($a_permission,
'', $this->ref_id)) {
getVersionIdsFromRequest()
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
const CMD_DELETE_VERSIONS
Class ilFileObjectToStorageDirectory.
Access handler for personal workspace.
const CMD_DOWNLOAD_VERSION
const CMD_CONFIRMED_DELETE_VERSIONS
saveVersion($mode=ilFileVersionFormGUI::MODE_ADD)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static http()
Fetches the global http state from ILIAS.
Class ilFileVersionsTableGUI.
Repository GUI Utilities.
const CMD_CONFIRMED_DELETE_FILE
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
addVersion($mode=ilFileVersionFormGUI::MODE_ADD)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct(ilObjFile $file)
ilFileVersionsGUI constructor.
const CMD_ADD_REPLACING_VERSION
getVersionsToKeep(array $version_ids)
const CMD_ADD_NEW_VERSION
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Class FileNotFoundException Indicates that a file is missing or not found.
migrate(ilFileObjectToStorageDirectory $item)
hasPermission($a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
const CMD_ROLLBACK_VERSION
const CMD_CREATE_REPLACING_VERSION
const CMD_CREATE_NEW_VERSION
Confirmation screen class.