Ejemplo n.º 1
0
 /**
  * Edits a folder.
  *
  * @param String $folder_id Directory entry id of the folder
  */
 public function edit_action($folder_id)
 {
     if (!$this->full_access) {
         throw new AccessDeniedException();
     }
     PageLayout::setTitle(_('Ordner bearbeiten'));
     $folder = new DirectoryEntry($folder_id);
     $folder->checkAccess();
     if (Request::isPost()) {
         $name = Request::get('name');
         $name = $folder->directory->ensureUniqueFilename($name, $folder->file);
         $folder->name = $name;
         $folder->description = Request::get('description');
         if ($folder->isDirty()) {
             $folder->store();
             $message = sprintf(_('Der Ordner "%s" wurde gespeichert.'), $folder->name);
             PageLayout::postMessage(MessageBox::success($message));
         }
         $this->redirect($this->url_for_parent_directory($folder));
         return;
     }
     $this->setDialogLayout(Icon::create('folder-' . ($folder->file->isEmpty() ? 'empty' : 'full'), 'navigation'));
     $this->folder = $folder;
 }
Ejemplo n.º 2
0
 /**
  * Downloads a single file.
  *
  * @param DirectoryEntry $entry  Directory entry to download
  * @param bool           $inline Download as inline
  */
 protected function download_file(DirectoryEntry $entry, $inline)
 {
     $file = $entry->file;
     $storage = $file->getStorageObject();
     if (!$storage->exists() || !$storage->isReadable()) {
         throw new Exception('Cannot access file "' . $storage->getPath() . '"');
     }
     $entry->downloads += 1;
     $entry->store();
     Metrics::increment('core.personal_files.downloads');
     $this->initiateDownload($inline, $file->filename, $file->mime_type, $file->size, $storage->open('r'));
 }
Ejemplo n.º 3
0
 /**
  * Edits a file.
  *
  * @param String $entry_id Directory entry id of the file
  */
 public function edit_action($entry_id)
 {
     if (!$this->full_access) {
         throw new AccessDeniedException();
     }
     PageLayout::setTitle(_('Datei bearbeiten'));
     $entry = new DirectoryEntry($entry_id);
     $entry->checkAccess();
     if (Request::isPost()) {
         $name = Request::get('filename');
         $name = $entry->directory->ensureUniqueFilename($name, $entry->file);
         $entry->file->filename = $name;
         $entry->file->restricted = Request::int('restricted', 0);
         $entry->name = $name;
         $entry->description = Request::get('description');
         if ($entry->file->isDirty() || $entry->isDirty()) {
             $entry->store();
             $entry->file->store();
             $message = sprintf(_('Die Datei "%s" wurde bearbeitet.'), $entry->name);
             PageLayout::postMessage(MessageBox::success($message));
         }
         $this->redirect($this->url_for_parent_directory($entry));
         return;
     }
     $this->setDialogLayout(Icon::create(get_icon_for_mimetype($entry->file->mime_type), 'navigation'));
     $this->entry = $entry;
 }
Ejemplo n.º 4
0
 /**
  * Create a new entry in this directory for the given file
  * under the given name. This will increase the link count
  * of the file by one.
  *
  * @param File $file    file to link
  * @param string $name  new file name
  * @param string $description optional description
  *
  * @return DirectoryEntry  created DirectoryEntry object
  */
 public function link(File $file, $name, $description = '')
 {
     $name = FileHelper::CompressFilename($name);
     $name = $this->ensureUniqueFilename($name, $file);
     $entry = new DirectoryEntry();
     $entry->file_id = $file->id;
     $entry->parent_id = $this->file_id;
     $entry->name = $name;
     $entry->description = $description;
     $entry->store();
     return $entry;
 }