Joining session works
This commit is contained in:
parent
0247677108
commit
9658890600
65
ajax/controller.php
Normal file
65
ajax/controller.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ownCloud - Office App
|
||||||
|
*
|
||||||
|
* @author Victor Dubiniuk
|
||||||
|
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Office;
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
|
||||||
|
public static function serve($args){
|
||||||
|
\OCP\JSON::checkLoggedIn();
|
||||||
|
|
||||||
|
$session = Session::getSession(@$args['es_id']);
|
||||||
|
$filename = isset($session['genesis_url']) ? $session['genesis_url'] : '';
|
||||||
|
$officeView = View::initOfficeView($session['owner']);
|
||||||
|
$download = new Download($officeView, $filename);
|
||||||
|
$download->sendResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function startSession($args){
|
||||||
|
$path = @$_POST['path'];
|
||||||
|
|
||||||
|
\OCP\JSON::checkLoggedIn();
|
||||||
|
$uid = \OCP\User::getUser();
|
||||||
|
$officeView = View::initOfficeView($uid);
|
||||||
|
|
||||||
|
if (!$officeView->file_exists($path)){
|
||||||
|
$genesisPath = View::storeDocument($uid, $path);
|
||||||
|
} else {
|
||||||
|
$genesisPath = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($genesisPath){
|
||||||
|
$session = Session::getSessionByPath($uid, $genesisPath);
|
||||||
|
if (!$session){
|
||||||
|
$hash = View::getHashByGenesis($uid, $genesisPath);
|
||||||
|
$session = Session::addSession($genesisPath, $hash);
|
||||||
|
}
|
||||||
|
\OCP\JSON::success($session);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
\OCP\JSON::error();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function joinSession($args){
|
||||||
|
$esId = @$args['es_id'];
|
||||||
|
|
||||||
|
\OCP\JSON::checkLoggedIn();
|
||||||
|
|
||||||
|
if ($esId){
|
||||||
|
$session = Session::getSession($esId);
|
||||||
|
\OCP\JSON::success($session);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
\OCP\JSON::error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,6 @@ OCP\App::addNavigationEntry(array(
|
|||||||
'name' => 'Office')
|
'name' => 'Office')
|
||||||
);
|
);
|
||||||
|
|
||||||
OC::$CLASSPATH['OCA\Office\Genesis'] = 'office/lib/genesis.php';
|
OC::$CLASSPATH['OCA\Office\Controller'] = 'office/ajax/controller.php';
|
||||||
OC::$CLASSPATH['OCA\Office\Download\Simple'] = 'office/lib/download/simple.php';
|
OC::$CLASSPATH['OCA\Office\Download\Simple'] = 'office/lib/download/simple.php';
|
||||||
OC::$CLASSPATH['OCA\Office\Download\Range'] = 'office/lib/download/range.php';
|
OC::$CLASSPATH['OCA\Office\Download\Range'] = 'office/lib/download/range.php';
|
||||||
|
@ -11,9 +11,27 @@
|
|||||||
|
|
||||||
$this->create('office_genesis', 'ajax/genesis/{es_id}')
|
$this->create('office_genesis', 'ajax/genesis/{es_id}')
|
||||||
->post()
|
->post()
|
||||||
->action('\OCA\Office\Genesis', 'serve')
|
->action('\OCA\Office\Controller', 'serve')
|
||||||
;
|
;
|
||||||
$this->create('office_genesis', 'ajax/genesis/{es_id}')
|
$this->create('office_genesis', 'ajax/genesis/{es_id}')
|
||||||
->get()
|
->get()
|
||||||
->action('\OCA\Office\Genesis', 'serve')
|
->action('\OCA\Office\Controller', 'serve')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$this->create('office_session_start', 'ajax/session/start')
|
||||||
|
->get()
|
||||||
|
->action('\OCA\Office\Controller', 'startSession')
|
||||||
|
;
|
||||||
|
$this->create('office_session_start', 'ajax/session/start')
|
||||||
|
->post()
|
||||||
|
->action('\OCA\Office\Controller', 'startSession')
|
||||||
|
;
|
||||||
|
|
||||||
|
$this->create('office_session_join', 'ajax/session/join/{es_id}')
|
||||||
|
->get()
|
||||||
|
->action('\OCA\Office\Controller', 'joinSession')
|
||||||
|
;
|
||||||
|
$this->create('office_session_join', 'ajax/session/join/{es_id}')
|
||||||
|
->post()
|
||||||
|
->action('\OCA\Office\Controller', 'joinSession')
|
||||||
|
;
|
@ -89,8 +89,8 @@ var officeMain = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(OC.filePath('office', 'ajax', 'session.php'),
|
$.post(OC.Router.generate('office_session_start'),
|
||||||
{ 'genesis' : filepath },
|
{ 'path' : filepath },
|
||||||
officeMain.onView
|
officeMain.onView
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* ownCloud - Office App
|
|
||||||
*
|
|
||||||
* @author Victor Dubiniuk
|
|
||||||
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Office;
|
|
||||||
|
|
||||||
class Genesis {
|
|
||||||
|
|
||||||
public static function serve($args){
|
|
||||||
\OCP\JSON::checkLoggedIn();
|
|
||||||
|
|
||||||
$session = Session::getSession(@$args['es_id']);
|
|
||||||
|
|
||||||
$filename = isset($session['genesis_url']) ? $session['genesis_url'] : '';
|
|
||||||
|
|
||||||
$officeView = View::initOfficeView($session['owner']);
|
|
||||||
|
|
||||||
$download = new Download($officeView, $filename);
|
|
||||||
$download->sendResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -25,9 +25,9 @@ class Session {
|
|||||||
return $result->fetchRow();
|
return $result->fetchRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSessionByPath($url){
|
public static function getSessionByPath($uid, $url){
|
||||||
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `genesis_url`= ?');
|
$query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*office_session` WHERE `genesis_url`= ? AND `owner`= ? ');
|
||||||
$result = $query->execute(array($url));
|
$result = $query->execute(array($url, $uid));
|
||||||
return $result->fetchRow();
|
return $result->fetchRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user