getBool('enable_download_module'))
{
$gMessage->show($gL10n->get('SYS_MODULE_DISABLED'));
// => EXIT
}
try
{
// get recordset of current folder from database
$currentFolder = new TableFolder($gDb);
$currentFolder->getFolderForDownload($getFolderId);
}
catch(AdmException $e)
{
$e->showHtml();
// => EXIT
}
// set headline of the script
if($currentFolder->getValue('fol_fol_id_parent') == null)
{
$headline = $gL10n->get('DOW_DOWNLOADS');
}
else
{
$headline = $gL10n->get('DOW_DOWNLOADS').' - '.$currentFolder->getValue('fol_name');
}
// Navigation of the module starts here
$gNavigation->addStartUrl(CURRENT_URL, $headline);
$getFolderId = $currentFolder->getValue('fol_id');
// Get folder content for style
$folderContent = $currentFolder->getFolderContentsForDownload();
// Keep navigation link
$navigationBar = $currentFolder->getNavigationForDownload();
// create html page object
$page = new HtmlPage($headline);
$page->enableModal();
$page->addJavascript('
$("body").on("hidden.bs.modal", ".modal", function() {
$(this).removeData("bs.modal");
location.reload();
});
$("#menu_item_upload_files").attr("data-toggle", "modal");
$("#menu_item_upload_files").attr("data-target", "#admidio_modal");
',
true
);
// get module menu
$downloadsMenu = $page->getMenu();
if ($currentFolder->hasUploadRight())
{
// upload only possible if upload filesize > 0
if ($gSettingsManager->getInt('max_file_upload_size') > 0)
{
// show links for upload, create folder and folder configuration
$downloadsMenu->addItem(
'menu_item_create_folder', safeUrl(ADMIDIO_URL.FOLDER_MODULES.'/downloads/folder_new.php', array('folder_id' => $getFolderId)),
$gL10n->get('DOW_CREATE_FOLDER'), 'folder_create.png'
);
$downloadsMenu->addItem(
'menu_item_upload_files', safeUrl(ADMIDIO_URL.'/adm_program/system/file_upload.php', array('module' => 'downloads', 'id' => $getFolderId)),
$gL10n->get('DOW_UPLOAD_FILES'), 'page_white_upload.png'
);
}
if($gCurrentUser->editDownloadRight())
{
$downloadsMenu->addItem(
'menu_item_config_folder', safeUrl(ADMIDIO_URL.FOLDER_MODULES.'/downloads/folder_config.php', array('folder_id' => $getFolderId)),
$gL10n->get('SYS_PERMISSIONS'), 'lock.png'
);
}
}
if($gCurrentUser->isAdministrator())
{
// show link to system preferences of weblinks
$downloadsMenu->addItem(
'admMenuItemPreferencesLinks', safeUrl(ADMIDIO_URL.FOLDER_MODULES.'/preferences/preferences.php', array('show_option' => 'downloads')),
$gL10n->get('SYS_MODULE_PREFERENCES'), 'options.png', 'right'
);
}
// Create table object
$downloadOverview = new HtmlTable('tbl_downloads', $page, true, true);
// create array with all column heading values
$columnHeading = array(
$gL10n->get('SYS_TYPE'),
'
',
$gL10n->get('SYS_NAME'),
$gL10n->get('SYS_DATE_MODIFIED'),
$gL10n->get('SYS_SIZE'),
$gL10n->get('DOW_COUNTER')
);
if ($currentFolder->hasUploadRight())
{
$columnHeading[] = ' ';
$downloadOverview->disableDatatablesColumnsSort(array(7));
}
$downloadOverview->setColumnAlignByArray(array('left', 'left', 'left', 'left', 'right', 'right', 'right'));
$downloadOverview->addRowHeadingByArray($columnHeading);
$downloadOverview->setMessageIfNoRowsFound('DOW_FOLDER_NO_FILES', 'warning');
// Get folder content
if (isset($folderContent['folders']))
{
// First get possible sub folders
foreach ($folderContent['folders'] as $nextFolder)
{
$folderDescription = '';
if($nextFolder['fol_description'] !== null)
{
$folderDescription = '
';
}
// create array with all column values
$columnValues = array(
1, // Type folder
'
',
''. $nextFolder['fol_name']. ''.$folderDescription,
'',
'',
''
);
if ($currentFolder->hasUploadRight())
{
// Links for change and delete
$additionalFolderFunctions = '';
if($nextFolder['fol_exists'] === true)
{
$additionalFolderFunctions = '
';
}
elseif($gCurrentUser->editDownloadRight())
{
$additionalFolderFunctions = '
';
}
$columnValues[] = $additionalFolderFunctions.'
';
}
$downloadOverview->addRowByArray($columnValues, 'row_folder_'.$nextFolder['fol_id']);
}
}
// Get contained files
if (isset($folderContent['files']))
{
foreach ($folderContent['files'] as $nextFile)
{
// Check filetyp
$fileExtension = admStrToLower(substr($nextFile['fil_name'], strrpos($nextFile['fil_name'], '.') + 1));
// Choose icon for the file
$iconFile = 'page_white_question.png';
if(array_key_exists($fileExtension, $iconFileExtension))
{
$iconFile = $iconFileExtension[$fileExtension];
}
// Format timestamp
$timestamp = \DateTime::createFromFormat('Y-m-d H:i:s', $nextFile['fil_timestamp']);
$fileDescription = '';
if($nextFile['fil_description'] !== null)
{
$fileDescription = '
';
}
// create array with all column values
$columnValues = array(
2, // Type file
'
',
''. $nextFile['fil_name']. ''.$fileDescription,
$timestamp->format($gSettingsManager->getString('system_date').' '.$gSettingsManager->getString('system_time')),
round($nextFile['fil_size'] / 1024). ' kB ',
($nextFile['fil_counter'] !== '') ? $nextFile['fil_counter'] : 0
);
if ($currentFolder->hasUploadRight())
{
// Links for change and delete
$additionalFileFunctions = '';
if($nextFile['fil_exists'] === true)
{
$additionalFileFunctions = '
';
}
elseif($gCurrentUser->editDownloadRight())
{
$additionalFileFunctions = '
';
}
$columnValues[] = $additionalFileFunctions.'
';
}
$downloadOverview->addRowByArray($columnValues, 'row_file_'.$nextFile['fil_id']);
}
}
// Create download table
$downloadOverview->setDatatablesColumnsHide(array(1));
$downloadOverview->setDatatablesOrderColumns(array(1, 3));
$htmlDownloadOverview = $downloadOverview->show();
/**************************************************************************/
// Add Admin table to html page
/**************************************************************************/
// If user is download Admin show further files contained in this folder.
if ($gCurrentUser->editDownloadRight())
{
// Check whether additional content was found in the folder
if (isset($folderContent['additionalFolders']) || isset($folderContent['additionalFiles']))
{
$htmlAdminTableHeadline = '