From 32016d8381268b152512f22e1bbbb9420b5eeacb Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Sat, 10 Aug 2013 01:00:25 +0300 Subject: [PATCH] Introducing memberId --- ajax/controller.php | 18 +++++++++++++----- ajax/otpoll.php | 1 + js/office.js | 2 +- lib/member.php | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ajax/controller.php b/ajax/controller.php index 56069b44..dc0a2880 100644 --- a/ajax/controller.php +++ b/ajax/controller.php @@ -37,14 +37,22 @@ class Controller { if ($genesisPath){ $session = Session::getSessionByOwnerAndGenesis($uid, $genesisPath); - if (!$session){ - $hash = View::getHashByGenesis($uid, $genesisPath); - $session = Session::add($genesisPath, $hash, $path); + try { + if (!$session){ + $hash = View::getHashByGenesis($uid, $genesisPath); + $session = Session::add($genesisPath, $hash, $path); + } + + $session['member_id'] = Member::add($session['es_id'], \OCP\User::getDisplayName(), '#00f000'); + + \OCP\JSON::success($session); + exit(); + } catch (\Exception $e){ + throw $e; } - \OCP\JSON::success($session); - exit(); } \OCP\JSON::error(); + exit(); } public static function sendAvatar(){ diff --git a/ajax/otpoll.php b/ajax/otpoll.php index f7002e51..f9638cf8 100644 --- a/ajax/otpoll.php +++ b/ajax/otpoll.php @@ -75,6 +75,7 @@ try{ ); break; case 'sync-ops': + case 'sync_ops': $seqHead = $request->getParam('args/seq_head'); if (!is_null($seqHead)){ $esId = $request->getParam('args/es_id'); diff --git a/js/office.js b/js/office.js index 6ad3ac2a..1962830c 100644 --- a/js/office.js +++ b/js/office.js @@ -61,7 +61,7 @@ var officeMain = { $('#preview').html(canvashtml); runtime.assert(response.es_id, "invalid session id."); - memberId = response.es_id + "member"; + memberId = response.member_id; webodfEditor.boot( { collaborative: "owncloud", diff --git a/lib/member.php b/lib/member.php index cb13e62c..8eb2be7d 100644 --- a/lib/member.php +++ b/lib/member.php @@ -17,7 +17,7 @@ class Member { const DEFAULT_ACTIVITY_THRESHOLD = 600; // 10 Minutes public static function add($esId, $displayname, $color){ - $query = \OCP\DB::prepare('INSERT INTO `*PREFIX*office_member` (`es_id`, `uid`, `color`, `lastactivity`) VALUES (?, ?, ?, ?) '); + $query = \OCP\DB::prepare('INSERT INTO `*PREFIX*office_member` (`es_id`, `uid`, `color`, `last_activity`) VALUES (?, ?, ?, ?) '); $query->execute(array( $esId, \OCP\User::getUser(), @@ -54,7 +54,7 @@ class Member { $activeSince = $lastActivity; } - $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_member` WHERE `es_id`= ? and lastactivity > ?'); + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_member` WHERE `es_id`= ? and last_activity > ?'); $result = $query->execute(array($esId, $activeSince)); return $result->fetchAll(); }