public function processPrepareGetShare($id, $share)
 {
     $ic = $this->dao()->getItemCollection($id);
     if (!$ic) {
         Logging::logDebug("Invalid share request, no item collection found with id " . $id);
         throw new ServiceException("INVALID_REQUEST");
     }
     $this->env->filesystem()->allowFilesystems = TRUE;
     $items = $this->getItems($ic["items"]);
     foreach ($items as $item) {
         $this->env->permissions()->temporaryFilesystemPermission("filesystem_item_access", $item, FilesystemController::PERMISSION_LEVEL_READ);
     }
     $ap = $this->env->plugins()->getPlugin("Archiver");
     if (!$ap) {
         throw new ServiceException("INVALID_REQUEST", "No archiver plugin");
     }
     $am = $ap->getArchiveManager();
     $af = $am->compress($items);
     $this->env->events()->onEvent(MultiFileEvent::download($items));
     return $af;
 }
 public function processPrepareGetShare($id, $share)
 {
     $ic = $this->dao()->getItemCollection($id);
     if (!$ic) {
         Logging::logDebug("Invalid share request, no item collection found with id " . $id);
         throw new ServiceException("INVALID_REQUEST");
     }
     foreach ($ic["items"] as $item) {
         $this->env->permissions()->temporaryFilesystemPermission("filesystem_item_access", $item, FilesystemController::PERMISSION_LEVEL_READ);
     }
     $ap = $this->env->plugins()->getPlugin("Archiver");
     if (!$ap) {
         throw new ServiceException("INVALID_REQUEST", "No archiver plugin");
     }
     $am = $ap->getArchiveManager();
     $items = $ic["items"];
     $af = $am->compress($items);
     $key = str_replace(".", "", uniqid('', true));
     $this->env->events()->onEvent(MultiFileEvent::download($items));
     Logging::logDebug("Storing prepared package " . $key . ":" . $af);
     $this->env->session()->param($key, $af);
     return array("key" => $key);
 }
 private function onDownloadCompressed()
 {
     $data = $this->request->data;
     if (!array_key_exists("items", $data)) {
         throw $this->invalidRequestException();
     }
     if (!is_array($data['items']) || count($data['items']) < 1) {
         throw $this->invalidRequestException();
     }
     $items = array();
     $name = FALSE;
     foreach ($data['items'] as $i) {
         $items[] = $this->item($i);
     }
     if (count($items) == 0) {
         throw $this->invalidRequestException();
     }
     if (count($items) == 1) {
         $name = $items[0]->name();
     }
     $this->env->filesystem()->assertRights($items, FilesystemController::PERMISSION_LEVEL_READ, "download compressed");
     $a = $this->archiveManager()->compress($items);
     $id = uniqid();
     $this->env->session()->param("archive_" . $id, $a);
     if ($name) {
         $this->env->session()->param("archive_" . $id . "_name", $name);
     }
     if (is_array($items)) {
         $this->env->events()->onEvent(MultiFileEvent::download($items));
     } else {
         $this->env->events()->onEvent(FileEvent::download($items));
     }
     $this->response()->success(array("id" => $id));
 }
 public function deleteItems($items)
 {
     Logging::logDebug('deleting ' . count($items) . ' items');
     foreach ($items as $item) {
         if ($item->isRoot()) {
             throw new ServiceException("INVALID_REQUEST", "Cannot delete root folder:" . $item->id());
         }
     }
     $this->assertRights($items, self::PERMISSION_LEVEL_READWRITEDELETE, "delete");
     $this->validateAction(FileEvent::DELETE, $items);
     if ($this->triggerActionInterceptor(FileEvent::DELETE, $items)) {
         return;
     }
     foreach ($items as $item) {
         $this->doDeleteItem($item, FALSE, FALSE);
     }
     $this->env->events()->onEvent(MultiFileEvent::delete($items));
     foreach ($items as $item) {
         $this->idProvider->delete($item);
     }
 }
 private function onDownloadCompressed()
 {
     $data = $this->request->data;
     if (!array_key_exists("items", $data)) {
         throw $this->invalidRequestException();
     }
     if (!is_array($data['items']) || count($data['items']) < 1) {
         throw $this->invalidRequestException();
     }
     $items = array();
     foreach ($data['items'] as $i) {
         $items[] = $this->item($i);
     }
     if (count($items) == 0) {
         throw $this->invalidRequestException();
     }
     $this->env->filesystem()->assertRights($items, Authentication::RIGHTS_READ, "download compressed");
     $a = $this->archiveManager()->compress($items);
     $id = uniqid();
     $this->env->session()->param("archive_" . $id, $a);
     if (is_array($items)) {
         $this->env->events()->onEvent(MultiFileEvent::download($items));
     } else {
         $this->env->events()->onEvent(FileEvent::download($items));
     }
     $this->response()->success(array("id" => $id));
 }