You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
richdocuments/ajax/controller.php

75 lines
5.8 KiB
PHP

<?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){
$uid = self::getUser();
$path = @$_POST['path'];
$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 sendAvatar(){
$uid = self::getUser();
$image = new \OC_Image('R0lGODlhUABQAPcAAAQCBIGCUYgFBDNERe7EOr2ECEoFBZxCBHljKSIjGbeXackJBIykp9dKBKfGyUgmBGdFCYyEVJNkBycIBdSiFPzqoI+EZJRiRDozHsgkCIQrBFFiYoySfL+sgz9WVWkHBWglBhIUE2BSO9fEn6VvBNyjCjAkDkpDK25oW7SwqqiUbkk1E6kIBbSWNOkLBOkmBPzfYUQUDIh1T+PTsklFPIt1Nebk4eu0FLyTJoyytCcVCyoyMRIbGy8mIRUFBWpUJqkiCYV9cehgBF5cT2oTEHx2VEkzL+k2BOLDXKmjl6ySPKiNY5Z7TjU1MmiEhMwTBtG8mbegfYhrMJSUkmk3MUpMQty1R4QWD3h6TKyDF9S6aKSUfu3bwPdFBPz0pGB0eKcYBFgUE8yVDDcWCX+an3FlQ8DEwHxOBFgGBahGBBwkJF9LJr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gRncLUMgXFGAWwziDAgow1RLlp2CYAAJriCGKq6RijpQ4BZKYIUrICCRHSQhChFABxIIIAZQrgMOseK1TaolER2YAwGRgAMBwl0HGLDiBrf/yLRA3BALQ7ACBgGHw7WXkYx/DIJX/B4LHU5wjkJkQQIFuAEBFL6MAvzAJudIxQ0osAxVwIEPUliDFq5x8UsUqCmVcbcMUmEFTdADA49QhRhyoYks6HsiPKjBOnKxDhwUowjM2Pk5GIGEXMDhAW7ykN47sgZqQEMTyfDHphJwgjLUoAzgWI0JdCHhBPBEF+hIRiEikQV6IPs3TelBJqDxD1fU4ASILTFHQhCMQ8QjFwXgAw1yHuUQhCMQbEjHLaSw7TZx+igJsQksGHELEsAhAIglcFYYkgRDuAIHAdCF6LvyiIr7HvhoSYinWaEJOBSj3T4GQD0kwAc+sKEK3k2Ld0FQgA+lZgH6wY/KYNQfkhXowkkdEr1DEjCNOiwDHfnIvv4NYoJaRAD++4cvGtdv1iF+7HeAlrF+AbiAOseA2nOAHAKBBrh+FEiADniBGOhjFSiBHLiBHmiBGRiCIggWH9iBE3iCJmgZI7iCLNiCLviCMBiDAxEQADs=');
\OC_Util::obEnd();
echo $image->show();
}
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();
}
protected static function getUser(){
\OCP\JSON::checkLoggedIn();
return \OCP\User::getUser();
}
}