Exemplo n.º 1
0
function insert_link_db($range_id, $the_file_size, $refresh = FALSE) {
    global $the_file_name, $user;
    $the_link = Request::get('the_link');
    $date = time();             //Systemzeit
    $user_id = $user->id;           // user_id erfragen...
    $range_id = trim($range_id);        // laestige white spaces loswerden
    $description = trim(Request::get('description'));      // laestige white spaces loswerden
    $name = trim(Request::get('name'));            // laestige white spaces loswerden

    $url_parts = parse_url($the_link);
    $the_file_name = $the_file_name ?: basename($url_parts['path']);

    if (!$name) {
        $name = $the_file_name;
    }
    if (!$refresh) {
        $doc = new StudipDocument();
        $doc->description = remove_magic_quotes($description);
        $doc->name = $name;
        $doc->range_id = $range_id;
        $doc->user_id = $user_id;
        $doc->filename = $the_file_name;
        $doc->seminar_id = Request::option('upload_seminar_id');
        $doc->filesize = $the_file_size;
        $doc->url = $the_link;
        $doc->protected = Request::int('protect');
        $doc->autor_host = $_SERVER['REMOTE_ADDR'];
        $doc->author_name = get_fullname($user_id);

    } else {
        $doc = StudipDocument::find($refresh);
        $doc->user_id = $user_id;
        $doc->filename = $the_file_name;
        $doc->filesize = $the_file_size;
        $doc->autor_host = $_SERVER['REMOTE_ADDR'];
        $doc->author_name = get_fullname($user_id);
    }
    return $doc->store();
}
Exemplo n.º 2
0
 public function delete_attachment_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     $doc = StudipDocument::find(Request::option('document_id'));
     if ($doc && $doc->range_id == 'provisional' && $doc->description == Request::option('message_id')) {
         @unlink(get_upload_file_path($doc->id));
         $doc->delete();
     }
     $this->render_nothing();
 }
Exemplo n.º 3
0
    }
    for ($i=0; $i < count($path); $i++) {
        if ($path[$i] != 'root') {
            $folder_system_data['open'][$path[$i]] = true;
        }
    }
}
//wurde ein Objekt zugeklappt?
if ($close) {
    unset($folder_system_data["open"][$close]);
    $folder_system_data["open"]['anker'] = $close;
}
if ($rechte && Request::submitted('delete_selected')) {
    $download_ids = Request::optionArray('download_ids');
    if (count($download_ids) > 0) {
        $files_to_delete = array_map(function($f) {return htmlReady(StudipDocument::find($f)->filename) . '<input type="hidden" name="download_ids[]" value="' . $f . '">';}, $download_ids);
        $template = $template_factory->open('usermanagement/question_form.php');
        $template->set_attribute('question', _('Möchten Sie die ausgewählten Dateien wirklich löschen?'));
        $template->set_attribute('elements', array('<ul><li>' . join('</li><li>', $files_to_delete) . '</li></ul>'));
        $template->set_attribute('approvalbutton', Button::createAccept(_('JA!'), 'delete'));
        $template->set_attribute('disapprovalbutton', Button::createCancel(_('NEIN!')));
        $template->set_attribute('action', URLHelper::getLink());
        $question = $template->render();
    }
}

if ($rechte && Request::submitted('delete') && count(Request::optionArray('download_ids'))) {
    CSRFProtection::verifyUnsafeRequest();
    $deleted = 0;
    foreach (Request::optionArray('download_ids') as $one) {
        $deleted += delete_document($one);
Exemplo n.º 4
0
 static function find_files($id, $user_id)
 {
     $db = \DBManager::get();
     $query = "       SELECT *\n\t\t\t\t\t\tFROM dokumente\n\t\t\t\t\t\tWHERE seminar_id =  '{$id}'\n\t\t\t\t\t\tORDER BY mkdate DESC\n\t\t\tLIMIT 0,30\n\t\t\t";
     $result = $db->query($query);
     $files = array();
     foreach ($result as $row) {
         // getLink
         $link = $row['url'];
         if ($row['url'] == "" or !$row['url']) {
             $link = GetDownloadLink($row['dokument_id'], $row['filename'], 0, 'force_download');
         }
         // get file extension
         $path_parts = pathinfo($row['filename']);
         $extension = strtoupper($path_parts['extension']);
         //get extension icon
         switch ($extension) {
             case "PDF":
                 $icon_link = "/public/images/icons/files32/pdf.png";
                 break;
             case "XLS":
                 $icon_link = "/public/images/icons/files32/xls.png";
                 break;
             case "PPT":
                 $icon_link = "/public/images/icons/files32/ppt.png";
                 break;
             case "ZIP":
                 $icon_link = "/public/images/icons/files32/zip.png";
                 break;
             case "RTF":
                 $icon_link = "/public/images/icons/files32/rtf.png";
                 break;
             case "TXT":
                 $icon_link = "/public/images/icons/files32/txt.png";
                 break;
             case "TGZ":
                 $icon_link = "/public/images/icons/files32/tgz.png";
                 break;
             default:
                 $icon_link = "/public/images/icons/files32/_blank.png";
         }
         //check access
         $file_object = \StudipDocument::find($row['dokument_id']);
         // Falls $file_oject vorhanden ab in den Array
         if (isset($file_object) && $file_object->checkAccess($user_id)) {
             $files[] = array('id' => $row['dokument_id'], 'name' => $row['name'], 'Seminar_id' => $row['seminar_id'], 'author' => $row['author_name'], 'author_id' => $row['user_id'], 'description' => $row['description'], 'mkdate' => $row['mkdate'], 'filesize' => $row['filesize'], 'link' => $link, 'filename' => $row['filename'], 'icon_link' => $icon_link, 'extension' => $extension);
         }
     }
     return $files;
 }