]> jfr.im git - z_archive/KronOS.git/blame - application/controllers/control.php
Changing javascript return stryle
[z_archive/KronOS.git] / application / controllers / control.php
CommitLineData
3cf8917d
JR
1<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3/* TODO: error handling */
c1828c8b 4/* TODO: check that requesting user == app-session user */
3cf8917d
JR
5
6class Control extends CI_Controller {
7
8 public function __construct() {
9 parent::__construct();
10 $this->load->model('user');
536db703 11 $this->load->model('msession');
3cf8917d
JR
12 }
13
14 public function index() {
15 }
16
c1828c8b 17 public function open($aid, $core=NULL) {
3cf8917d 18 if ($this->user->is_logged_in()) {
c1828c8b
JR
19 if ($aid == -1) {
20 // core app!
21 $instance = $this->msession->openCoreApp($core);
22 $repl = array('id' => $instance->iid(), 'name' => $instance->appName(), 'title' => $instance->windowTitle(), 'interior' => $instance->windowContents());
23 $this->json->reply($repl);
24 } else {
25 $instance = $this->msession->openApp($aid);
26 $repl = array('id' => $instance->iid(), 'name' => $instance->appName(), 'title' => $instance->windowTitle(), 'interior' => $instance->windowContents());
27 $this->json->reply($repl);
28 }
3cf8917d
JR
29 } else {
30 $this->json->error('Not logged in.');
31 }
32 }
33
34 public function act($iid, $action) {
906f0f92
JR
35 $this->json->reply($this->msession->getAppInst($iid)->act($action));
36 }
37
38 public function scripts($aid) {
7014db39 39 $this->output->set_output('wos.appscripts['.(int)$aid.'] = new function(){'.call_user_func(array($this->msession->getAppClass($aid), 'scripts'), $aid).'}();');
3cf8917d
JR
40 }
41
42 public function close($iid) {
536db703 43 $this->msession->closeApp($iid);
3cf8917d
JR
44 }
45}
46?>