/**
  * 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;
 }
Example #2
0
try {
    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();
Example #3
0
// Initialize and check the parameters
$getFolderId = admFuncVariableIsValid($_GET, 'folder_id', 'numeric');
// Check if module is activated
if ($gPreferences['enable_download_module'] != 1) {
    // Module is not activated
    $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
}
$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 . '
              INNER JOIN ' . TBL_CATEGORIES . '
                      ON cat_id = rol_cat_id
                   WHERE rol_valid  = 1
                     AND rol_system = 0