diff --git a/ajax/controller.php b/ajax/controller.php index 51417746..15ede426 100644 --- a/ajax/controller.php +++ b/ajax/controller.php @@ -74,6 +74,26 @@ class Controller { \OCP\JSON::error(); } + public static function save(){ + $uid = self::getUser(); + $esId = @$_POST['es_id']; + $memberId = @$_POST['member_id']; + $content = @$_POST['content']; + if ($esId && $content){ + $session = Session::getSession($esId); + $fileInfo = \OC\Files\Cache\Cache::getById($session['file_id']); + $path = $fileInfo[1]; + $view = new \OC\Files\View('/' . $session['owner']); + + $canWrite = ($view->file_exists($path) && $view->isUpdatable($path)) || $view->isCreatable($path); + if ($canWrite){ + $view->file_put_contents($path, $content); + } else { + // TODO: report an error + } + } + } + public static function listSessions(){ self::getUser(); $sessions = Session::getAll(); diff --git a/appinfo/routes.php b/appinfo/routes.php index 3638c35f..e90aa859 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -59,6 +59,11 @@ $this->create('office_session_join', 'ajax/session/join/{es_id}') ->action('\OCA\Office\Controller', 'joinSession') ; +$this->create('office_session_save', 'ajax/session/save') + ->post() + ->action('\OCA\Office\Controller', 'save') +; + $this->create('office_user_avatar', 'ajax/user/avatar') ->get()