From 26323875171b836aaccc6fcaaf2ca8bc7fe99b88 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Thu, 8 Aug 2013 18:01:05 +0300 Subject: [PATCH] Respond to session-list --- ajax/otpoll.php | 21 +++++++++------------ ajax/session.php | 36 ------------------------------------ lib/download/range.php | 1 - lib/download/simple.php | 1 - lib/op.php | 2 +- 5 files changed, 10 insertions(+), 51 deletions(-) delete mode 100644 ajax/session.php diff --git a/ajax/otpoll.php b/ajax/otpoll.php index 180ead6f..940ea253 100644 --- a/ajax/otpoll.php +++ b/ajax/otpoll.php @@ -38,24 +38,21 @@ // OCP\JSON::checkAppEnabled('office'); // session_write_close(); -function bogusSession($i){ - $bs = array(); - $bs["denomination"] = "[$i] bogus session"; - $bs["id"] = "$i"; - $bs["title"] = "bogus.odt"; - $bs["mimetype"] = "application/vnd.oasis.opendocument.text"; - $bs["members"] = $bs["cursors"] = array("bob_10002", "alice_10001"); - $bs["creation_date"] = "2013-07-16T18:52:50.120Z"; - return $bs; -} - $response = array(); try{ $request = new OCA\Office\Request(); $command = $request->getParam('command'); switch ($command){ case 'session-list': - $response["session_list"] = array(bogusSession(0), bogusSession(1)); + $sessions = OCA\Office\Session::getAllSessions(); + if (!is_array($sessions)){ + $sessions = array(); + } + + $response["session_list"] = array_map( + function($x){return ($x['es_id']);}, + $sessions + ); break; case 'join-session': $response = "true"; // should fail when session is non-existent diff --git a/ajax/session.php b/ajax/session.php deleted file mode 100644 index 92d62b9d..00000000 --- a/ajax/session.php +++ /dev/null @@ -1,36 +0,0 @@ -file_exists($genesis)){ - $genesisPath = View::storeDocument($uid, $genesis); -} else { - $genesisPath = $genesis; -} - -if ($genesisPath){ - $session = Session::getSessionByPath($genesisPath); - if (!$session){ - $hash = View::getHashByGenesis($uid, $genesisPath); - $session = Session::addSession($genesisPath, $hash); - } - \OCP\JSON::success($session); - exit(); -} -\OCP\JSON::error(); \ No newline at end of file diff --git a/lib/download/range.php b/lib/download/range.php index 57c0a282..6016e7bc 100644 --- a/lib/download/range.php +++ b/lib/download/range.php @@ -24,7 +24,6 @@ class Range extends \OCA\Office\Download { } public function sendResponse(){ - $this->view = View::initOfficeView(\OCP\User::getUser()); if (!preg_match('/^bytes=\d*-\d*(,\d*-\d*)*$/', $_SERVER['HTTP_RANGE'])){ $this->sendNotSatisfiable(); } diff --git a/lib/download/simple.php b/lib/download/simple.php index 277f52ae..4d7d6414 100644 --- a/lib/download/simple.php +++ b/lib/download/simple.php @@ -20,7 +20,6 @@ class Simple extends \OCA\Office\Download { } public function sendResponse(){ - $this->view = View::initOfficeView(\OCP\User::getUser()); header( 'Content-Type:' . $this->getMimeType() ); $encodedName = rawurlencode($this->getFilename()); diff --git a/lib/op.php b/lib/op.php index 151b3d89..b8abba47 100644 --- a/lib/op.php +++ b/lib/op.php @@ -48,7 +48,7 @@ class Op { } public static function getOpsAfterJson($esId, $seq){ - $ops =self::getOpsAfter($esId, $seq); + $ops = self::getOpsAfter($esId, $seq); $ops = array_map( function($x){return json_decode($x['opspec']);}, $ops