Inheritance: extends OCA\Richdocuments\Db
 protected function loadSession($esId)
 {
     if (!$esId) {
         throw new \Exception('Session id can not be empty');
     }
     $session = new Db\Session();
     $session->load($esId);
     if (!$session->getEsId()) {
         throw new \Exception('Session does not exist');
     }
     return $session;
 }
 /**
  * @NoAdminRequired
  * lists the documents the user has access to (including shared files, once the code in core has been fixed)
  * also adds session and member info for these files
  */
 public function listAll()
 {
     $found = Storage::getDocuments();
     $fileIds = array();
     $documents = array();
     foreach ($found as $key => $document) {
         if (is_object($document)) {
             $documents[] = $document->getData();
         } else {
             $documents[$key] = $document;
         }
         $documents[$key]['icon'] = preg_replace('/\\.png$/', '.svg', \OCP\Template::mimetype_icon($document['mimetype']));
         $documents[$key]['hasPreview'] = \OC::$server->getPreviewManager()->isMimeSupported($document['mimetype']);
         $fileIds[] = $document['fileid'];
     }
     usort($documents, function ($a, $b) {
         return @$b['mtime'] - @$a['mtime'];
     });
     $session = new Db\Session();
     $sessions = $session->getCollectionBy('file_id', $fileIds);
     $members = array();
     $member = new Db\Member();
     foreach ($sessions as $session) {
         $members[$session['es_id']] = $member->getActiveCollection($session['es_id']);
     }
     return array('status' => 'success', 'documents' => $documents, 'sessions' => $sessions, 'members' => $members);
 }
Example #3
0
 protected function getUniqueSessionId()
 {
     $testSession = new Session();
     do {
         $id = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(30, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
     } while ($testSession->load($id)->hasData());
     return $id;
 }
 /**
  * @NoAdminRequired
  * @PublicPage
  * Process partial/complete file download
  */
 public function serve($esId)
 {
     $session = new Db\Session();
     $session->load($esId);
     $filename = $session->getGenesisUrl() ? $session->getGenesisUrl() : '';
     return new DownloadResponse($this->request, $session->getOwner(), $filename);
 }