From f66d70ad6dfb06ce644ae7a12fb996095a0b57ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A0=D1=83=D0=B4?=
 =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=86?= <andrey.rudenets@gmail.com>
Date: Sat, 23 Aug 2014 12:35:44 +0400
Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2,=20vo?=
 =?UTF-8?q?l.=203:=20=D0=B8=D1=81=D0=BA=D1=83=D0=BF=D0=BB=D0=B5=D0=BD?=
 =?UTF-8?q?=D0=B8=D0=B5=20=D0=B3=D1=80=D0=B5=D1=85=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 db/Structure.sql                              | 17 +++++++++++
 ~dev_rating/application/bootstrap.php         | 26 ++++++++--------
 .../classes/Controller/Teacher/Map.php        | 30 ++++++++-----------
 .../classes/Controller/UserEnvi.php           |  8 ++---
 .../application/classes/Model/Teacher/Map.php |  2 +-
 5 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/db/Structure.sql b/db/Structure.sql
index 329f4449b..5002db4fa 100644
--- a/db/Structure.sql
+++ b/db/Structure.sql
@@ -380,6 +380,23 @@ INSERT INTO `user_roles` (`ID`, `Type`, `RoleName`, `Mark`) VALUES
 (2, 'teacher', 'Преподаватель', 2),
 (3, 'teacher', 'Преподаватель-Администратор', 4);
 
+--
+-- Дамп данных таблицы `user_roles`
+--
+
+INSERT INTO `page_access` (`ID`, `Pagename`, `Bitmask`) VALUES
+(NULL, 'common:index', 7),
+(NULL, 'common:settings', 7),
+(NULL, 'teacher:index', 6),
+(NULL, 'teacher:settings', 6),
+(NULL, 'teacher:map:create', 6),
+(NULL, 'teacher:map:edit', 6),
+(NULL, 'teacher:rating', 6),
+(NULL, 'admin:common', 4),
+(NULL, 'student:index', 1),
+(NULL, 'student:settings', 1),
+(NULL, 'student:subject', 1);
+
 --
 -- Ограничения внешнего ключа сохраненных таблиц
 --
diff --git a/~dev_rating/application/bootstrap.php b/~dev_rating/application/bootstrap.php
index 726fa28a6..6b3e6cb50 100644
--- a/~dev_rating/application/bootstrap.php
+++ b/~dev_rating/application/bootstrap.php
@@ -179,19 +179,19 @@ Route::set('twig:show', 'twig(/<id>)')
                 
 /* --------------- Общие ссылки ---------------- */
 
-Route::set('index', 'index')
+Route::set('common:index', 'index')
         ->defaults(array(
             'controller' => 'UserEnvi',
             'action' => 'index'
         ));
 
-Route::set('settings', 'settings')
+Route::set('common:settings', 'settings')
         ->defaults(array(
             'controller' => 'UserEnvi',
             'action' => 'settings'
         ));
 		
-Route::set('profile', 'profile(/<type>(/<id>))', array('type' => '(teacher|student)'))
+Route::set('common:profile', 'profile(/<type>(/<id>))', array('type' => '(teacher|student)'))
         ->defaults(array(
             'controller' => 'UserEnvi',
             'action' => 'profile'
@@ -199,7 +199,7 @@ Route::set('profile', 'profile(/<type>(/<id>))', array('type' => '(teacher|stude
 
 /* --------------- Студенты ---------------- */
 
-Route::set('subject', 'subject/<id>', array('id' => '[0-9]+'))
+Route::set('student:subject', 'subject/<id>', array('id' => '[0-9]+'))
         ->defaults(array(
             'directory' => 'student',
             'controller' => 'subject',
@@ -207,7 +207,7 @@ Route::set('subject', 'subject/<id>', array('id' => '[0-9]+'))
         ));
 
         // Внутренние вызовы!
-Route::set('stdnt:index', 'student/index')
+Route::set('student:index', 'student/index')
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
@@ -218,7 +218,7 @@ Route::set('stdnt:index', 'student/index')
             'action' => 'index'
         ));
 
-Route::set('stdnt:settings', 'student/settings')
+Route::set('student:settings', 'student/settings')
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
@@ -229,7 +229,7 @@ Route::set('stdnt:settings', 'student/settings')
             'action' => 'settings'
         ));
 		
-Route::set('stdnt:profile', 'student/profile')
+Route::set('student:profile', 'student/profile')
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
@@ -242,21 +242,21 @@ Route::set('stdnt:profile', 'student/profile')
         
 /* --------------- Преподаватели ---------------- */
 
-Route::set('map:create', 'map/create')
+Route::set('teacher:map:create', 'map/create')
         ->defaults(array(
             'directory' => 'teacher',
             'controller' => 'map',
 			'action' => 'create'
         ));
 
-Route::set('map:edit', 'map/<id>', array('id' => '[0-9]+'))
+Route::set('teacher:map:edit', 'map/<id>', array('id' => '[0-9]+'))
         ->defaults(array(
             'directory' => 'teacher',
             'controller' => 'map',
 			'action' => 'edit'
         ));
 
-Route::set('rating', 'rating/<id>', array('id' => '[0-9]+'))
+Route::set('teacher:rating', 'rating/<id>', array('id' => '[0-9]+'))
         ->defaults(array(
             'directory' => 'teacher',
             'controller' => 'rating',
@@ -264,7 +264,7 @@ Route::set('rating', 'rating/<id>', array('id' => '[0-9]+'))
         ));
 
         // Внутренние вызовы!
-Route::set('tchr:index', 'teacher/index')
+Route::set('teacher:index', 'teacher/index')
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
@@ -275,7 +275,7 @@ Route::set('tchr:index', 'teacher/index')
             'action' => 'index'
         ));
 		
-Route::set('tchr:settings', 'teacher/settings')
+Route::set('teacher:settings', 'teacher/settings')
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
@@ -286,7 +286,7 @@ Route::set('tchr:settings', 'teacher/settings')
             'action' => 'settings'
         ));
 
-Route::set('tchr:profile', 'teacher/profile(/<action>(/<id>))', array('action' => '(student)', 'id' => '[0-9]+'))
+Route::set('teacher:profile', 'teacher/profile(/<action>(/<id>))', array('action' => '(student)', 'id' => '[0-9]+'))
         ->filter(function($route, $params, $request){
             if($request->is_initial())
                 return FALSE;
diff --git a/~dev_rating/application/classes/Controller/Teacher/Map.php b/~dev_rating/application/classes/Controller/Teacher/Map.php
index 89d4e06ac..e7e7a75fd 100644
--- a/~dev_rating/application/classes/Controller/Teacher/Map.php
+++ b/~dev_rating/application/classes/Controller/Teacher/Map.php
@@ -52,30 +52,26 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
     public function action_create()
     {
         $twig = Twig::factory('teacher/map/create');
-		$db = new Model_Teacher_Map;
+        $db = new Model_Teacher_Map;
         $twig->User = $this->UserInfo;
         $twig->SubjectsList = $this->GetSubjectsList($db);
-		$twig->GradesList = $this->GradesList;
-		
-		echo Debug::vars($this->UserInfo);
-		
+        $twig->GradesList = $this->GradesList;		
         $this->response->body($twig);
     }
     
     public function action_edit()
     {
-		$twig = Twig::factory('teacher/map/edit');
         $id = $this->request->param('id');
         $db = new Model_Teacher_Map;
         $map = $db->getMapForDiscipline($this->UserInfo['TeacherID'], $id);
-		
-		$twig->User = $this->UserInfo;
-		$twig->Map = $this->getMapInfo($map);
-		$twig->Discipline = $this->getSubjectInfo($db, $id);
-		$twig->SubjectsList = $this->GetSubjectsList($db);
-		$twig->GradesList = $this->GradesList;
-			
-		$this->response->body($twig);
+
+        $twig = Twig::factory('teacher/map/edit');
+        $twig->User = $this->UserInfo;
+        $twig->Map = $this->getMapInfo($map);
+        $twig->Discipline = $this->getSubjectInfo($db, $id);
+        $twig->SubjectsList = $this->GetSubjectsList($db);
+        $twig->GradesList = $this->GradesList;
+        $this->response->body($twig);
     }
 	
     private function getMapInfo($map) {
@@ -167,9 +163,9 @@ class Controller_Teacher_Map extends Controller_UserEnvi {
 		
 		foreach ($list as $row) {
 			$i++;
-			$SubjectsList[$i]['ID'] = $row['ID'];
-			$SubjectsList[$i]['Title'] = $row['Name'];
-			$SubjectsList[$i]['Abbr'] = $row['Abbr'];
+			$SubjectsList[$i]['ID'] = $row['SubjectID'];
+			$SubjectsList[$i]['Title'] = $row['SubjectName'];
+			$SubjectsList[$i]['Abbr'] = $row['SubjectAbbr'];
 		}
 		
 		return $SubjectsList;
diff --git a/~dev_rating/application/classes/Controller/UserEnvi.php b/~dev_rating/application/classes/Controller/UserEnvi.php
index e162be9be..8392d5fb6 100644
--- a/~dev_rating/application/classes/Controller/UserEnvi.php
+++ b/~dev_rating/application/classes/Controller/UserEnvi.php
@@ -21,20 +21,20 @@ class Controller_UserEnvi extends Controller {
             $bitmask = $sysModel->getBitmaskForRoute($route);
             if(!($bitmask & $userMark))
             {
-                throw HTTP_Exception::factory(403, 'Не пытайтесь попасть туда, куда попадать не следует: '.$bitmask);
+                throw HTTP_Exception::factory(403, 'Не пытайтесь попасть туда, куда попадать не следует: '.$route);
             }
         }
     }
     
     public function action_index()
     {
-        $page = Request::factory($this->UserInfo['Type'].'/index')->execute();
+        $page = Request::factory($this->UserInfo['AccType'].'/index')->execute();
         $this->response->body($page);
     }
     
     public function action_profile()
     {
-        $url = $this->UserInfo['Type']."/profile";
+        $url = $this->UserInfo['AccType']."/profile";
         if(!empty($type))
             $url .= '/'.$type;
         if(!empty($id))
@@ -45,7 +45,7 @@ class Controller_UserEnvi extends Controller {
 	
     public function action_settings()
     {
-        $page = Request::factory($this->UserInfo['Type'].'/settings')->execute();
+        $page = Request::factory($this->UserInfo['AccType'].'/settings')->execute();
         $this->response->body($page);
     }
 }
diff --git a/~dev_rating/application/classes/Model/Teacher/Map.php b/~dev_rating/application/classes/Model/Teacher/Map.php
index ca0b6f89c..3b646738e 100644
--- a/~dev_rating/application/classes/Model/Teacher/Map.php
+++ b/~dev_rating/application/classes/Model/Teacher/Map.php
@@ -106,7 +106,7 @@ class Model_Teacher_Map extends Model
 	
     public function GetSubjectList()
     {
-        $sql = "CALL `GetSubjectList`(); ";
+        $sql = "CALL `GetSubjects`(); ";
         return DB::query(Database::SELECT, $sql)->execute();
     }
 	
-- 
GitLab