diff --git a/~dev_rating/application/classes/Controller/Admin/Accounts.php b/~dev_rating/application/classes/Controller/Admin/Accounts.php index 273da1b33e81472243f2aeb852911fed153cd9be..82c61bac856b03b32f8ec9e12a5a728981625aa0 100644 --- a/~dev_rating/application/classes/Controller/Admin/Accounts.php +++ b/~dev_rating/application/classes/Controller/Admin/Accounts.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/Departaments.php b/~dev_rating/application/classes/Controller/Admin/Departaments.php index 596fe35a65d4ea840b42422b0cc9a49bb49c2b71..77f3eacedd678e9335b57c52d6c0e7fb4bccd4fd 100644 --- a/~dev_rating/application/classes/Controller/Admin/Departaments.php +++ b/~dev_rating/application/classes/Controller/Admin/Departaments.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/Disciplines.php b/~dev_rating/application/classes/Controller/Admin/Disciplines.php index 5593a8c75327b2a71f95d9874dcaa9bfac343f1d..737552bfba606634ccd0ef3a941590ee6e6e414f 100644 --- a/~dev_rating/application/classes/Controller/Admin/Disciplines.php +++ b/~dev_rating/application/classes/Controller/Admin/Disciplines.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/Index.php b/~dev_rating/application/classes/Controller/Admin/Index.php index 5593a8c75327b2a71f95d9874dcaa9bfac343f1d..737552bfba606634ccd0ef3a941590ee6e6e414f 100644 --- a/~dev_rating/application/classes/Controller/Admin/Index.php +++ b/~dev_rating/application/classes/Controller/Admin/Index.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/Students.php b/~dev_rating/application/classes/Controller/Admin/Students.php index ee73bc98920ca4476bd2dd62b107935080089130..f1d4c364fa85bb5cf593b5cb676cdd28c0e3b892 100644 --- a/~dev_rating/application/classes/Controller/Admin/Students.php +++ b/~dev_rating/application/classes/Controller/Admin/Students.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/StudyGroups.php b/~dev_rating/application/classes/Controller/Admin/StudyGroups.php index 5593a8c75327b2a71f95d9874dcaa9bfac343f1d..737552bfba606634ccd0ef3a941590ee6e6e414f 100644 --- a/~dev_rating/application/classes/Controller/Admin/StudyGroups.php +++ b/~dev_rating/application/classes/Controller/Admin/StudyGroups.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Admin/Teachers.php b/~dev_rating/application/classes/Controller/Admin/Teachers.php index f170537456872e17bce7382d75feaa898143bf89..9a092d652e96b4286fbafa83f4ba0f6ade94737d 100644 --- a/~dev_rating/application/classes/Controller/Admin/Teachers.php +++ b/~dev_rating/application/classes/Controller/Admin/Teachers.php @@ -1,6 +1,6 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Teacher_Admin_Index extends Controller_UserEnvi { +class Controller_Admin_Index extends Controller_UserEnvi { public function action_index() { diff --git a/~dev_rating/application/classes/Controller/Handler.php b/~dev_rating/application/classes/Controller/Handler.php index 64d6ac953bcd13071f367801ebda2cce1ab8150d..39ee7a58f095647a72943f4d5642d3ad4be761a1 100644 --- a/~dev_rating/application/classes/Controller/Handler.php +++ b/~dev_rating/application/classes/Controller/Handler.php @@ -4,12 +4,9 @@ class Controller_Handler extends Controller { protected $user, $post, $model; private $access; - const ACCESS_ADMIN = 0; - const ACCESS_TEACHER = 1; - const ACCESS_STUDENT = 2; - const ACCESS_USER = 3; - const ACCESS_GUEST = 4; - const ACCESS_ANYBODY = 5; + const ACCESS_USER = 0; + const ACCESS_GUEST = 1; + const ACCESS_ANYBODY = 2; public function before() { @@ -29,11 +26,14 @@ class Controller_Handler extends Controller { $this->user = User::instance()->getInfoAsArray(); } + // Получаем имя маршрута + $route = Route::name($this->request->route()).':'.$this->request->controller(); + // Если запрос не прошел на проверку доступа - if(!$this->checkAccessLevel()) + if(!$this->checkAccessLevel() || !$this->checkBitmask($this->user['AccRoleMark'], $route)) { // Перенаправляем на ошибку доступа - throw HTTP_Exception::factory (403, $this->user['Type']); + throw HTTP_Exception::factory (403, $route); } } @@ -46,22 +46,19 @@ class Controller_Handler extends Controller { $this->access = (int) $level; } + protected function checkBitmask($userMark, $route) + { + $sysModel = new Model_System; + $bitmask = $sysModel->getBitmaskForRoute($route); + if(!$bitmask) + return true; + return $bitmask & $userMark != 0; + } + protected function checkAccessLevel() { switch($this->access) { - case self::ACCESS_ADMIN: - return User::instance()->isSignedIn() AND $this->user['Type'] == 'admin'; - break; - - case self::ACCESS_TEACHER: - return User::instance()->isSignedIn() AND $this->user['Type'] == 'teacher'; - break; - - case self::ACCESS_STUDENT: - return User::instance()->isSignedIn() AND $this->user['Type'] == 'student'; - break; - case self::ACCESS_USER: return User::instance()->isSignedIn(); break; diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index 059d1f175a04794348fecc16d40c4298e849ed7e..7e9739c175e1a9b8ec333062ccb2c2d5f84836ff 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -4,7 +4,7 @@ class Controller_Handler_Map extends Controller_Handler { public function before() { $this->model = new Model_Teacher_Map; - $this->setAccessLevel(self::ACCESS_TEACHER); + $this->setAccessLevel(self::ACCESS_USER); parent::before(); } diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php index 64a0fae487a9af072f9e7a0f61d92d5d9f51640c..8611b15c7a92fe734f0ef317e9cf213c9d1b2b68 100644 --- a/~dev_rating/application/classes/Controller/Handler/Rating.php +++ b/~dev_rating/application/classes/Controller/Handler/Rating.php @@ -4,7 +4,7 @@ class Controller_Handler_Rating extends Controller_Handler { public function before() { $this->model = new Model_Teacher_Rating; - $this->setAccessLevel(self::ACCESS_TEACHER); + $this->setAccessLevel(self::ACCESS_USER); parent::before(); } diff --git a/~dev_rating/application/views/admin/students/add.twig b/~dev_rating/application/views/admin/students/add.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/students/add.twig @@ -0,0 +1 @@ +{# empty Twig template #} diff --git a/~dev_rating/application/views/admin/students/index.twig b/~dev_rating/application/views/admin/students/index.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/students/index.twig @@ -0,0 +1 @@ +{# empty Twig template #} diff --git a/~dev_rating/application/views/admin/students/upload.twig b/~dev_rating/application/views/admin/students/upload.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/students/upload.twig @@ -0,0 +1 @@ +{# empty Twig template #} diff --git a/~dev_rating/application/views/admin/teachers/add.twig b/~dev_rating/application/views/admin/teachers/add.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/teachers/add.twig @@ -0,0 +1 @@ +{# empty Twig template #} diff --git a/~dev_rating/application/views/admin/teachers/index.twig b/~dev_rating/application/views/admin/teachers/index.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/teachers/index.twig @@ -0,0 +1 @@ +{# empty Twig template #} diff --git a/~dev_rating/application/views/admin/teachers/upload.twig b/~dev_rating/application/views/admin/teachers/upload.twig new file mode 100644 index 0000000000000000000000000000000000000000..aa3d5f102316dc80c9fc5250352cdbeb5ba95b51 --- /dev/null +++ b/~dev_rating/application/views/admin/teachers/upload.twig @@ -0,0 +1 @@ +{# empty Twig template #}