Newer
Older
class Controller_Api_Discipline extends Controller_Handler
/** @var Model_User_Teacher */
protected $user;
public function action_index() {
$id = $this->request->param('id', 0);
return Model_Discipline::load($id);
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
->author ($this->user->TeacherID)
->semester($this->user->SemesterID)
->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();
Model_Map::AddModuleBonus($this->user->TeacherID, $discipline->ID);
# PUT: /handler/discipline/update/723
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
$id = $this->request->param('id', 0);
if ($id <= 0)
throw new InvalidArgumentException(Error::ID_IS_INCORRECT);
throw new LogicException('Not implemented yet');
}
# DELETE: /handler/discipline/delete/723
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
$id = (int) $this->request->param('id', 0);
$discipline = Model_Discipline::load($id);
// delete only if discipline cleared (doesn't exists related rating's records)
if ($discipline->AuthorID != $this->user->TeacherID)
throw new LogicException(Error::DISCIPLINE_IS_LOCKED);
if (Model_Rating::count($discipline) > 0)
throw new LogicException(Error::DISCIPLINE_IS_LOCKED);
$discipline->delete();
public function action_delegate() {
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
$id = (int) $this->request->param('id', 0);
$discipline = Model_Discipline::load($id);
if ($discipline->AuthorID != $this->user->TeacherID)
throw new LogicException(Error::ACCESS_DENIED);
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->delegateTo($teacher);
}
public function action_bind() {
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
$id = (int) $this->request->param('id', 0);
$discipline = Model_Discipline::load($id);
if ($discipline->AuthorID != $this->user->TeacherID)
throw new LogicException(Error::ACCESS_DENIED);
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->bind($teacher);
}
public function action_unbind() {
$role = $this->user->RoleMark;
Access::instance($role)->checkAccess(Access::RIGHTS_TEACHER);
$id = (int) $this->request->param('id', 0);
$discipline = Model_Discipline::load($id);
if ($discipline->AuthorID != $this->user->TeacherID)
throw new LogicException(Error::ACCESS_DENIED);
$teacherID = (int) $this->request->post('teacherID');
$teacher = Model_Teacher::with($teacherID);
$discipline->unbind($teacher);
}