Skip to content
Snippets Groups Projects
AdmTeachers.php 3.16 KiB
Newer Older
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Handler_AdmTeachers extends Controller_Handler {
            $this->user->checkAccess(User::RIGHTS_ADMIN);
                    // ->rule('firstName', 'alpha_dash', array(':value', TRUE))
                    // ->rule('secondName', 'not_empty')
                    // ->rule('secondName', 'alpha_dash', array(':value', TRUE))
                    // ->rule('lastName', 'alpha_dash', array(':value', TRUE))
                    ->rule('jobPositionID', 'not_empty')
                    ->rule('jobPositionID', 'digit')
                    ->rule('departmentID', 'not_empty')
                    ->rule('departmentID', 'digit');
            if($this->post['jobPositionID'] == 0)
            if($this->post['departmentID'] == 0)
xamgore's avatar
xamgore committed
                $code = Model_Account::createTeacher(
                        $this->post['lastName'],
                        $this->post['firstName'],
                        $this->post['secondName'],
                        $this->post['jobPositionID'],
                        $this->post['departmentID']
                    );
                if($code != -1)
                {
                    $response['success'] = true;
                    $response['messages'][1] = 'Всё ОК! Вот код активации: '.$code;
                }
                else {
                    $response['success'] = false;
                    $response['messages'][1] = 'Неверные входные данные.';
                }
            }
            else
            {
                $response['success'] = false;
                $response['messages'] = $this->post->errors();
            }
            $this->response->body(json_encode($response));
        }
        
            $departmentID = $this->post['departmentID'];
            $facultyID = $this->post['facultyID'];
xamgore's avatar
xamgore committed
                $teachers = Model_Teachers::ofDepartment($departmentID);
xamgore's avatar
xamgore committed
                $teachers = Model_Teachers::ofFaculty($facultyID);
        public function action_getDepartmentsList() {
            $faculty = Model_Faculty::with($this->post['facultyID']);
            $departments = $faculty->getDepartments();
            $this->response->body(json_encode($departments));