/**
  * Override the default method to handle the specific things of the download module and
  * update the database after file was successful uploaded.
  * This method has the same parameters as the default.
  * @param  $uploaded_file
  * @param  $name
  * @param  $size
  * @param  $type
  * @param  $error
  * @param  $index
  * @param  $content_range
  * @return stdClass
  */
 protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
 {
     global $gPreferences, $gL10n, $gDb, $getId, $gCurrentOrganization, $gCurrentUser;
     $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
     if (!isset($file->error)) {
         try {
             // check filesize against module settings
             if ($file->size > $gPreferences['max_file_upload_size'] * 1024 * 1024) {
                 throw new AdmException('DOW_FILE_TO_LARGE', $gPreferences['max_file_upload_size']);
             }
             // check filename and throw exception if something is wrong
             admStrIsValidFileName($file->name, true);
             // get recordset of current folder from database and throw exception if necessary
             $targetFolder = new TableFolder($gDb);
             $targetFolder->getFolderForDownload($getId);
             // now add new file to database
             $newFile = new TableFile($gDb);
             $newFile->setValue('fil_fol_id', $targetFolder->getValue('fol_id'));
             $newFile->setValue('fil_name', $file->name);
             $newFile->setValue('fil_locked', $targetFolder->getValue('fol_locked'));
             $newFile->setValue('fil_counter', '0');
             $newFile->save();
             // Benachrichtigungs-Email für neue Einträge
             $message = $gL10n->get('DOW_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $file->name, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
             $notification = new Email();
             $notification->adminNotfication($gL10n->get('DOW_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
         } catch (AdmException $e) {
             $file->error = $e->getText();
             unlink($this->options['upload_dir'] . $file->name);
             return $file;
         }
     }
     return $file;
 }
Beispiel #2
0
    if ($getFileId) {
        // get recordset of current file from databse
        $file = new TableFile($gDb);
        $file->getFileForDownload($getFileId);
        $originalName = $file->getValue('fil_name');
        if ($form_values['new_name'] == null) {
            $form_values['new_name'] = admFuncGetFilenameWithoutExtension($originalName);
        }
        if ($form_values['new_description'] == null) {
            $form_values['new_description'] = $file->getValue('fil_description');
        }
    } else {
        // get recordset of current folder from databses
        $folder = new TableFolder($gDb);
        $folder->getFolderForDownload($getFolderId);
        $originalName = $folder->getValue('fol_name');
        if ($form_values['new_name'] == null) {
            $form_values['new_name'] = $originalName;
        }
        if ($form_values['new_description'] == null) {
            $form_values['new_description'] = $folder->getValue('fol_description');
        }
    }
} catch (AdmException $e) {
    $e->showHtml();
}
// create html page object
$page = new HtmlPage($headline);
// add back link to module menu
$downloadRenameMenu = $page->getMenu();
$downloadRenameMenu->addItem('menu_item_back', $gNavigation->getPreviousUrl(), $gL10n->get('SYS_BACK'), 'back.png');
Beispiel #3
0
    $gMessage->show($gL10n->get('SYS_MODULE_DISABLED'));
}
// Only available from master organization
if (strcasecmp($gCurrentOrganization->getValue('org_shortname'), $g_organization) != 0) {
    // is not master organization
    $gMessage->show($gL10n->get('SYS_MODULE_ACCESS_FROM_HOMEPAGE_ONLY', $g_organization));
}
try {
    // get recordset of current folder from databse
    $currentFolder = new TableFolder($gDb);
    $currentFolder->getFolderForDownload($getFolderId);
} catch (AdmException $e) {
    $e->showHtml();
}
// 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);
// get module menu
$DownloadsMenu = $page->getMenu();
}
// erst prüfen, ob der User auch die entsprechenden Rechte hat
if (!$gCurrentUser->editDownloadRight()) {
    $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
}
$gNavigation->addUrl(CURRENT_URL, $headline);
try {
    // get recordset of current folder from database
    $folder = new TableFolder($gDb);
    $folder->getFolderForDownload($getFolderId);
} catch (AdmException $e) {
    $e->showHtml();
}
// Parentordner holen
$parentRoleSet = array();
if ($folder->getValue('fol_fol_id_parent')) {
    try {
        // get recordset of parent folder from database
        $parentFolder = new TableFolder($gDb);
        $parentFolder->getFolderForDownload($folder->getValue('fol_fol_id_parent'));
    } catch (AdmException $e) {
        $e->showHtml();
    }
    // get assigned roles of the parent folder
    $parentRoleSet = $parentFolder->getRoleArrayOfFolder(true);
}
if (count($parentRoleSet) === 0) {
    // wenn der uebergeordnete Ordner keine Rollen gesetzt hat sind alle erlaubt
    // alle aus der DB aus lesen
    $sql_roles = 'SELECT *
                    FROM ' . TBL_ROLES . '
$gNavigation->addUrl(CURRENT_URL, $headline);
if (isset($_SESSION['download_request'])) {
    $form_values = strStripSlashesDeep($_SESSION['download_request']);
    unset($_SESSION['download_request']);
} else {
    $form_values['new_folder'] = null;
    $form_values['new_description'] = null;
}
try {
    // get recordset of current folder from database
    $folder = new TableFolder($gDb);
    $folder->getFolderForDownload($getFolderId);
} catch (AdmException $e) {
    $e->showHtml();
}
$parentFolderName = $folder->getValue('fol_name');
// create html page object
$page = new HtmlPage($headline);
// add back link to module menu
// @ptabaden: Changed icon of back button
$folderNewMenu = $page->getMenu();
$folderNewMenu->addItem('menu_item_back', $gNavigation->getPreviousUrl(), '<i class="fa fa-arrow-left" alt="' . $gL10n->get('SYS_BACK') . '" title="' . $gL10n->get('SYS_BACK') . '"></i><div class="iconDescription">' . $gL10n->get('SYS_BACK') . '</div>', '');
$page->addHtml('<p class="lead">' . $gL10n->get('DOW_CREATE_FOLDER_DESC', $parentFolderName) . '</p>');
// show form
$form = new HtmlForm('new_folder_form', $g_root_path . '/adm_program/modules/downloads/download_function.php?mode=3&amp;folder_id=' . $getFolderId, $page);
$form->addInput('new_folder', $gL10n->get('SYS_NAME'), $form_values['new_folder'], array('maxLength' => 255, 'property' => FIELD_REQUIRED));
$form->addMultilineTextInput('new_description', $gL10n->get('SYS_DESCRIPTION'), $form_values['new_description'], 4, array('maxLength' => 4000));
$form->addSubmitButton('btn_create', $gL10n->get('DOW_CREATE_FOLDER'), array('icon' => THEME_PATH . '/icons/folder_create.png', 'class' => ' col-sm-offset-3'));
// add form to html page and show page
$page->addHtml($form->show(false));
$page->show();
Beispiel #6
0
        $gMessage->show($gL10n->get('SYS_NO_RIGHTS'));
    }
    // download module can only be used from organization set in config.php
    if (strcasecmp($gCurrentOrganization->getValue('org_shortname'), $g_organization) !== 0) {
        $gMessage->show($gL10n->get('SYS_MODULE_ACCESS_FROM_HOMEPAGE_ONLY', $g_organization));
    }
    // upload only possible if upload filesize > 0
    if ($gPreferences['max_file_upload_size'] == 0) {
        $gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
    }
    try {
        // get recordset of current folder from database
        $folder = new TableFolder($gDb);
        $folder->getFolderForDownload($getId);
        $uploadDir = $folder->getCompletePathOfFolder() . '/';
        $uploadUrl = $g_root_path . $folder->getValue('fol_path') . '/' . $folder->getValue('fol_name') . '/';
    } catch (AdmException $e) {
        $e->showHtml();
    }
    $headline = $gL10n->get('DOW_UPLOAD_FILES');
    $textFileUploaded = $gL10n->get('DOW_FILE_UPLOADED');
    $textUploadSuccessful = $gL10n->get('DOW_FILES_UPLOAD_SUCCESSFUL');
    $textUploadNotSuccessful = $gL10n->get('DOW_FILES_UPLOAD_NOT_SUCCESSFUL');
    $textUploadDescription = $gL10n->get('DOW_FILES_UPLOAD_DESC', $folder->getValue('fol_name'));
    $textSelectFiles = $gL10n->get('DOW_SELECT_FILES');
    $iconUploadPath = THEME_PATH . '/icons/page_white_upload.png';
}
// check if the server allow file uploads
if (ini_get('file_uploads') !== '1') {
    $gMessage->show($gL10n->get('SYS_SERVER_NO_UPLOAD'));
}
Beispiel #7
0
} elseif ($getMode == 7) {
    if ($getFolderId == 0) {
        //FolderId ist zum hinzufuegen erforderlich
        $gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
    }
    try {
        // get recordset of current folder from databse
        $targetFolder = new TableFolder($gDb);
        $targetFolder->getFolderForDownload($getFolderId);
        if ($targetFolder->getValue('fol_fol_id_parent')) {
            // get recordset of parent folder from databse
            $parentFolder = new TableFolder($gDb);
            $parentFolder->getFolderForDownload($targetFolder->getValue('fol_fol_id_parent'));
        }
        //Formularinhalt aufbereiten
        if ($targetFolder->getValue('fol_fol_id_parent') && $parentFolder->getValue('fol_public') == 0) {
            $publicFlag = $targetFolder->getValue('fol_public');
        } else {
            if (isset($_POST['fol_public']) == false || $_POST['fol_public'] == 0) {
                $publicFlag = 1;
            } else {
                $publicFlag = 0;
            }
        }
        //setze schon einmal das Public_Flag
        $targetFolder->editPublicFlagOnFolder($publicFlag);
        $rolesArray = null;
        //Nur wenn der Ordner oeffentlich nicht zugaenglich ist
        //werden die Rollenbrechtigungen gespeichert.
        //Ansonsten wird ein leeres Rollenset gespeichert...
        if ($publicFlag == 0) {
Beispiel #8
0
        header($location);
        exit;
    }
} elseif ($getMode === 7) {
    if (!isset($_POST['adm_allowed_roles'])) {
        $gMessage->show($gL10n->get('SYS_FIELD_EMPTY', $gL10n->get('DAT_VISIBLE_TO')));
    }
    if ($getFolderId == 0 || !is_array($_POST['adm_allowed_roles'])) {
        // FolderId ist zum hinzufuegen erforderlich
        $gMessage->show($gL10n->get('SYS_INVALID_PAGE_VIEW'));
    }
    try {
        // get recordset of current folder from database
        $targetFolder = new TableFolder($gDb);
        $targetFolder->getFolderForDownload($getFolderId);
        if ($targetFolder->getValue('fol_fol_id_parent')) {
            // get recordset of parent folder from databse
            $parentFolder = new TableFolder($gDb);
            $parentFolder->getFolderForDownload($targetFolder->getValue('fol_fol_id_parent'));
        }
        if (in_array(0, $_POST['adm_allowed_roles'], true)) {
            $public = 1;
        } else {
            $public = 0;
        }
        // set flag public for this folder and all child folders
        $targetFolder->editPublicFlagOnFolder($public);
        // now set all rol
        if ($public === 0) {
            // save all set roles in the database
            $targetFolder->setRolesOnFolder($_POST['adm_allowed_roles']);