From 013bf8eb6e3923ee491ba5ce3665883f13aefe2c Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 7 Aug 2013 18:02:20 +0300 Subject: [PATCH] Initial session list --- ajax/genesis.php | 1 - ajax/otpoll.php | 2 +- ajax/sessions.php | 9 +++++++++ css/style.css | 11 +++++++++++ js/office.js | 21 +++++++++++++++++++++ lib/op.php | 4 ++-- lib/session.php | 7 +++++++ templates/documents.php | 2 +- 8 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 ajax/sessions.php diff --git a/ajax/genesis.php b/ajax/genesis.php index c2d33bee..fdebb1e2 100644 --- a/ajax/genesis.php +++ b/ajax/genesis.php @@ -11,7 +11,6 @@ namespace OCA\Office; -// Check if we are a user \OCP\User::checkLoggedIn(); $session = Session::getSession($_SERVER['QUERY_STRING']); diff --git a/ajax/otpoll.php b/ajax/otpoll.php index e7be378d..5de6e0ab 100644 --- a/ajax/otpoll.php +++ b/ajax/otpoll.php @@ -66,7 +66,7 @@ try{ $esId = $request->getParam('args/es_id'); $memberId = $request->getParam('args/member_id'); $ops = $request->getParam('args/client_ops'); - $hasOps = is_array($ops) && count($ops>0); + $hasOps = is_array($ops) && count($ops)>0; $currentHead = OCA\Office\Op::getHeadSeq($esId); diff --git a/ajax/sessions.php b/ajax/sessions.php new file mode 100644 index 00000000..1ade18d0 --- /dev/null +++ b/ajax/sessions.php @@ -0,0 +1,9 @@ + Session::getAllSessions() +)); \ No newline at end of file diff --git a/css/style.css b/css/style.css index e7e2150e..737c98da 100755 --- a/css/style.css +++ b/css/style.css @@ -4,3 +4,14 @@ .documentslist tr:hover { backgound-color:#aaa; } .documentslist tr td { padding:5px; } +#allsessions{ + position: absolute; + z-index: 100500; + top : 40px; + padding: 10px; + background: #ccc; +} + +#allsessions div{ + margin:5px 0; +} \ No newline at end of file diff --git a/js/office.js b/js/office.js index 4c0b58e4..7a529b0c 100644 --- a/js/office.js +++ b/js/office.js @@ -95,6 +95,26 @@ var officeMain = { officeMain.onView ); }, + + showSessions : function(){ + if ($('#allsessions').length){ + $('#allsessions').remove(); + return; + } + $.post(OC.filePath('office', 'ajax', 'sessions.php'), {}, officeMain.onSessions); + }, + onSessions : function(response){ + if (response && response.sessions){ + $(response.sessions).each( function(i, s){ officeMain.addSession(s) } ); + } + }, + addSession : function(s){ + if (!$('#allsessions').length){ + $(document.body).append('
'); + } + $('#allsessions').append('
'+s.es_id+ '
'); + }, + onClose: function() { "use strict"; var bodyelement = document.getElementsByTagName('body')[0]; @@ -119,4 +139,5 @@ $(document).ready(function() { }); $('#odf_close').live('click', officeMain.onClose); OC.addScript('office', 'dojo-amalgamation', officeMain.onStartup); + $('#session-list').click(officeMain.showSessions); }); diff --git a/lib/op.php b/lib/op.php index 774e67c9..65e0d7f9 100644 --- a/lib/op.php +++ b/lib/op.php @@ -17,7 +17,7 @@ class Op { } public static function addOpsArray($esId, $memberId, $ops){ - $lastSeq = false; + $lastSeq = ""; foreach ($ops as $op) { $lastSeq = self::add($esId, $memberId, json_encode($op)); } @@ -52,7 +52,7 @@ class Op { $oplist = array(); $query = \OCP\DB::prepare('SELECT `opspec` FROM `*PREFIX*office_op` WHERE `es_id`=? AND `seq`>? ORDER BY `seq` ASC'); $result = $query->execute(array($esId, $seq)); - return $result; + return $result->fetchAll(); } } diff --git a/lib/session.php b/lib/session.php index 9d5c321b..145d1ddf 100644 --- a/lib/session.php +++ b/lib/session.php @@ -3,6 +3,13 @@ namespace OCA\Office; class Session { + + public static function getAllSessions(){ + $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session`'); + $result = $query->execute(); + return $result->fetchAll(); + } + public static function getSession($id){ $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `es_id`= ?'); $result = $query->execute(array($id)); diff --git a/templates/documents.php b/templates/documents.php index 95c036ec..64f187e2 100755 --- a/templates/documents.php +++ b/templates/documents.php @@ -1,4 +1,4 @@ -
+