Skip to content

Commit

Permalink
Merge branch 'v4.1' of https://github.com/Admidio/admidio into v4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Mar 12, 2022
2 parents d8bb0d3 + 27fb62b commit c9b08f0
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions adm_program/modules/documents-files/documents_files_function.php
Expand Up @@ -36,10 +36,10 @@

$_SESSION['documents_files_request'] = $_POST;

// Pfad in adm_my_files pruefen und ggf. anlegen
// Check path in adm_my_files and create if necessary
try {
FileSystemUtils::createDirectoryIfNotExists(ADMIDIO_PATH . FOLDER_DATA . '/' . TableFolder::getRootFolderName());
} catch (\RuntimeException $exception) {
} catch (RuntimeException $exception) {
$gMessage->show($exception->getMessage());
// => EXIT
}
Expand Down Expand Up @@ -86,7 +86,7 @@
}

if ($file->delete()) {
// Loeschen erfolgreich -> Rueckgabe fuer XMLHttpRequest
// Delete successful -> return for XMLHttpRequest
echo 'done';
}
} else {
Expand Down Expand Up @@ -121,7 +121,7 @@
if ($error === null) {
$folId = (int) $folder->getValue('fol_id');

// Jetzt noch den Ordner der DB hinzufuegen...
// add folder to database
$newFolder = new TableFolder($gDb);

$newFolder->setValue('fol_fol_id_parent', $folId);
Expand Down Expand Up @@ -151,7 +151,7 @@
}
} catch (AdmException $e) {
if ($e->getMessage() === 'SYS_FILENAME_EMPTY') {
$e->setNewMessage('SYS_FIELD_EMPTY', $gL10n->get('SYS_NAME'));
$e->setNewMessage('SYS_FIELD_EMPTY', array($gL10n->get('SYS_NAME')));
}
if ($e->getMessage() === 'SYS_FILENAME_INVALID') {
$e->setNewMessage('SYS_FOLDER_NAME_INVALID');
Expand Down Expand Up @@ -193,7 +193,7 @@
// rename file in filesystem and database
try {
FileSystemUtils::moveFile($oldFile, $newPath . $newFile);
} catch (\RuntimeException $exception) {
} catch (RuntimeException $exception) {
$gMessage->setForwardUrl(ADMIDIO_URL.'/adm_program/system/back.php');
$gMessage->show($gL10n->get('SYS_FILE_RENAME_ERROR', array($oldName)));
// => EXIT
Expand Down Expand Up @@ -232,7 +232,7 @@
FileSystemUtils::moveDirectory($oldFolder, ADMIDIO_PATH. $folder->getValue('fol_path'). '/'.$newFolder);

$folder->rename($newFolder, $folder->getValue('fol_path'));
} catch (\RuntimeException $exception) {
} catch (RuntimeException $exception) {
$gMessage->setForwardUrl(ADMIDIO_URL.'/adm_program/system/back.php');
$gMessage->show($gL10n->get('SYS_FOLDER_RENAME_ERROR', array($oldName)));
// => EXIT
Expand All @@ -251,7 +251,7 @@
// exception handling; replace some exception strings with better descriptions
catch (AdmException $e) {
if ($e->getMessage() === 'SYS_FILENAME_EMPTY') {
$e->setNewMessage('SYS_FIELD_EMPTY', $gL10n->get('SYS_NEW_NAME'));
$e->setNewMessage('SYS_FIELD_EMPTY', array($gL10n->get('SYS_NEW_NAME')));
}
if ($e->getMessage() === 'SYS_FILENAME_INVALID' && $getFolderUuid !== '') {
$e->setNewMessage('SYS_FOLDER_NAME_INVALID');
Expand All @@ -261,26 +261,26 @@
}
}

// Folder loeschen
// delete folder
elseif ($getMode === 5) {
if ($getFolderUuid === '') {
// Es muss eine FolderId uebergeben werden
// the uuid of the current folder must be set
$gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
// => EXIT
} elseif ($getFolderUuid !== '') {
} else {
if ($folder->delete()) {
// Loeschen erfolgreich -> Rueckgabe fuer XMLHttpRequest
// Delete successful -> return for XMLHttpRequest
echo 'done';
}
}

unset($_SESSION['documents_files_request']);
}

// Datei / Ordner zur DB hinzufeuegen
// add file / folder to database
elseif ($getMode === 6) {
if ($getFolderUuid === '') {
// FolderId ist zum hinzufuegen erforderlich
// the uuid of the current folder must be set
$gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
// => EXIT
}
Expand All @@ -295,24 +295,24 @@
$newObjectPath = $folder->getFullFolderPath() . '/' . $getName;
$folId = (int) $folder->getValue('fol_id');

// Pruefen ob das neue Element eine Datei order ein Ordner ist.
// check if a file or folder should be created
if (is_file($newObjectPath)) {
// Datei hinzufuegen
// add file to database
$newFile = new TableFile($gDb);
$newFile->setValue('fil_fol_id', $folId);
$newFile->setValue('fil_name', $getName);
$newFile->setValue('fil_locked', $folder->getValue('fol_locked'));
$newFile->setValue('fil_counter', 0);
$newFile->save();

// Zurueck zur letzten Seite
// back to previous page
$gNavigation->addUrl(CURRENT_URL);

admRedirect(ADMIDIO_URL . '/adm_program/system/back.php');
// => EXIT
} elseif (is_dir($newObjectPath)) {

// Ordner der DB hinzufuegen
// add folder to database
$newFolder = new TableFolder($gDb);
$newFolder->setValue('fol_fol_id_parent', $folId);
$newFolder->setValue('fol_type', 'DOCUMENTS');
Expand All @@ -328,7 +328,7 @@
$rightParentFolderUpload = new RolesRights($gDb, 'folder_upload', $folId);
$newFolder->addRolesOnFolder('folder_upload', $rightParentFolderUpload->getRolesIds());

// Zurueck zur letzten Seite
// back to previous page
$gNavigation->addUrl(CURRENT_URL);

admRedirect(ADMIDIO_URL . '/adm_program/system/back.php');
Expand All @@ -343,13 +343,13 @@
// => EXIT
}
if (!isset($_POST['adm_roles_upload_right'])) {
// upload right need not to be set because documents & files module administrators still
// upload right does not need to be set because documents & files module administrators still
// have the right, so initialize the parameter
$_POST['adm_roles_upload_right'] = array();
}

if ($getFolderUuid === '' || !is_array($_POST['adm_roles_view_right']) || !is_array($_POST['adm_roles_upload_right'])) {
// FolderId ist zum hinzufuegen erforderlich
// the uuid of the current folder must be set
$gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
// => EXIT
}
Expand All @@ -364,12 +364,6 @@
$postIntRolesViewRight = array_map('intval', $_POST['adm_roles_view_right']);
$postIntRolesUploadRight = array_map('intval', $_POST['adm_roles_upload_right']);

if ($folder->getValue('fol_fol_id_parent')) {
// get recordset of parent folder from database
$parentFolder = new TableFolder($gDb, (int) $folder->getValue('fol_fol_id_parent'));
$parentFolder->getFolderForDownload($parentFolder->getValue('fol_uuid'));
}

// Read current view roles rights of the folder
$rightFolderView = new RolesRights($gDb, 'folder_view', $folder->getValue('fol_id'));
$rolesFolderView = $rightFolderView->getRolesIds();
Expand Down

0 comments on commit c9b08f0

Please sign in to comment.