Example #1
0
 public static function GetDirectoryTree($folder_id)
 {
     // TODO Top level?
     $result = array();
     $folder = new StudipDirectory($folder_id);
     foreach ($folder->listFiles() as $entry) {
         $file = $entry->file;
         if ($file instanceof StudipDirectory) {
             $result[$file->file_id] = array('ref_id' => $entry->id, 'filename' => $file->filename, 'description' => $entry->description, 'children' => self::getDirectoryTree($file->file_id));
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Create a new sub directory with the given name in this
  * directory. It inherits the backend storage of its parent.
  *
  * @param string $name  directory name
  * @param int $parent_id place in folder hierarchy
  *
  */
 public function mkdir($name, $description = '', $user_id = null)
 {
     $dir = new StudipDirectory();
     $dir->user_id = $user_id ?: $GLOBALS['user']->id;
     $dir->filename = $name;
     $dir->mime_type = '';
     $dir->size = 0;
     $dir->restricted = false;
     $dir->storage = $this->storage;
     $dir->storage_id = '';
     $dir->store();
     return $this->link($dir, $name, $description);
 }
Example #3
0
 /**
  * Defines the elements in the sidebar.
  *
  * @param String $current_entry Directory entry id of the current folder
  * @param String $current_dir   File id of the current folder
  */
 private function setupSidebar($current_entry, $current_dir, $page = 1)
 {
     $root_dir = RootDirectory::find($this->context_id);
     $root_count = $root_dir->countFiles(true, false);
     $sidebar = Sidebar::get();
     $sidebar->setImage('sidebar/files-sidebar.png');
     if (Config::get()->PERSONALDOCUMENT_OPEN_ACCESS && $GLOBALS['user']->id !== $this->context_id) {
         $title = sprintf(_('Dateien von %s'), $this->owner->getFullname());
         $sidebar->setTitle($title);
     }
     if ($this->full_access) {
         $widget = new ActionsWidget();
         $widget->addLink(_('Datei hochladen'), $this->url_for('document/files/upload/' . $current_entry . '/' . $page), Icon::create('upload', 'clickable'), $this->userConfig['forbidden'] ? array('disabled' => '', 'title' => _('Ihre Upload-Funktion wurde gesperrt.')) : array())->asDialog('size=auto');
         $widget->addLink(_('Neuen Ordner erstellen'), $this->url_for('document/folder/create/' . $current_entry), Icon::create('folder-empty+add', 'clickable'))->asDialog('size=auto');
         $attributes = $root_count > 0 ? array() : array('disabled' => true, 'title' => _('Ihr Dateibereich enthält keine Dateien'));
         $widget->addLink(_('Dateibereich leeren'), $this->url_for('document/folder/delete/all'), Icon::create('trash', 'clickable'), $attributes);
         $sidebar->addWidget($widget);
     }
     $widget = new OptionsWidget();
     $widget->setTitle(_('Darstellung anpassen'));
     foreach (self::$possible_limits as $limit) {
         $widget->addRadioButton(sprintf(_('%u Einträge pro Seite anzeigen'), $limit), $this->url_for('document/files/settings/' . $limit . '/' . $page . '/' . $current_entry), $limit == $this->limit);
     }
     $sidebar->addWidget($widget);
     // Show export options only if zip extension is loaded
     // TODO: Implement fallback
     if (extension_loaded('zip')) {
         $widget = new ExportWidget();
         $this_dir = $current_dir === $this->context_id ? $root_dir : StudipDirectory::find($current_dir);
         $attributes = $this_dir->countFiles(true, false) > 0 ? array() : array('disabled' => true, 'title' => _('Dieser Ordner enthält keine Dateien'));
         $widget->addLink(_('Inhalt dieses Ordners herunterladen'), $this->url_for('document/download/' . $current_dir), Icon::create('file-archive', 'clickable'), $attributes);
         $attributes = $root_count > 0 ? array() : array('disabled' => true, 'title' => _('Ihr Dateibereich enthält keine Dateien'));
         $widget->addLink(_('Alle Dateien herunterladen'), $this->url_for('document/download/' . $this->context_id), Icon::create('download', 'clickable'), $attributes);
         $sidebar->addWidget($widget);
     }
 }
Example #4
0
 /**
  * Initialize a new root directory object for the given id.
  *
  * @param string $id  context id
  *
  * @return RootDirectory  directory object
  */
 public function __construct($id = null)
 {
     parent::__construct($id);
     // default is to use DiskFileStorage
     $this->storage = 'DiskFileStorage';
 }