Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Api_Discipline extends Controller_Handler {
public $data;
public function before() {
// todo: var $user should be defined here
// either by GET param (token),
// or on the session variables.
$this->setAccessLevel(self::ACCESS_USER);
parent::before();
}
public function after() {
$this->response->body(json_encode($this->data));
}
public function action_create() {
try {
$discipline = Model_Discipline::make()
->author ($this->user['TeacherID'])
->faculty ($this->post['facultyID'])
->subject ($this->post['subjectID'])
->grade ($this->post['gradeID'])
->lectures($this->post['lectures'])
->practice($this->post['practice'])
->labs ($this->post['labs'])
->type ($this->post['type'])
->create();
if ($this->post['bonus'] == "true")
Model_Map::AddModuleBonus($this->user['TeacherID'], $discipline->ID);
$this->data = ['success' => true, 'ID' => $discipline->ID];
} catch (Exception $e) {
$this->data = ['success' => false, 'message' => $e->getMessage()];
}
}
}