diff --git a/ajax/otpoll.php b/ajax/otpoll.php index 86a991da..51150875 100644 --- a/ajax/otpoll.php +++ b/ajax/otpoll.php @@ -34,6 +34,7 @@ * @source: http://www.webodf.org/ * @source: http://gitorious.org/webodf/webodf/ */ + // OCP\JSON::checkLoggedIn(); // OCP\JSON::checkAppEnabled('office'); // session_write_close(); @@ -51,21 +52,37 @@ function bogusSession($i){ $command = isset($_POST['command']) ? $_POST['command'] : ''; -header('Content-Type: application/json'); - +$response = array(); switch ($command){ case 'session-list': - $bogusSessionList = array(); - $bogusSessionList["session_list"] = array(bogusSession(0), bogusSession(1)); - print json_encode($bogusSessionList, JSON_PRETTY_PRINT) . "\n"; + $response["session_list"] = array(bogusSession(0), bogusSession(1)); break; case 'join-session': - print "true"; + break; case 'sync-ops': // completely bogus - print '{"result":"newOps","ops":[],"headSeq":-1}'; + /* + * try { + * OCA\Office\Op::add( + * array( + * 'es_id' => ES_ID, + * 'seq' => SEQ, + * 'member' => MEMBER, + * 'opspec' => OPSPEC + * ) + * ); + * } catch (Exception $e) { + * + * } + */ + $response['result'] = 'newOps'; + $response['ops'] = array(); + $response['headSeq'] = -1; break; default: - print "unknown command"; // TODO send HTTP 400 response + header('HTTP/1.1 400: BAD REQUEST'); + exit(); } + +\OCP\JSON::success($response); diff --git a/ajax/thumbnail.php b/ajax/thumbnail.php index 7ef85707..24f1ba45 100644 --- a/ajax/thumbnail.php +++ b/ajax/thumbnail.php @@ -25,5 +25,8 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('office'); session_write_close(); +// TODO: short-circuit or fix the http 500 that happens on ajax/thumbnail.php +// or just wait unit preview is merged to core ;) + $file = $_GET['filepath']; -\OCP\Preview::show($file,120,120); +\OCP\Preview::show($file, 120, 120); diff --git a/lib/op.php b/lib/op.php index 01e7dbb9..04a918ad 100644 --- a/lib/op.php +++ b/lib/op.php @@ -3,5 +3,15 @@ namespace OCA\Office; class Op { - + + public function add($op){ + $query = \OCP\DB::prepare('INSERT INTO `*PREFIX*office_op` (`es_id`, `seq`, `member`, `opspec`) VALUES (?, ?, ?, ?) '); + $result = $query->execute(array( + $op['es_id'], + $op['seq'], + $op['member'], + $op['opspec'], + )); + } + }