From 63b8bbc67b7dd901fa4e74560b7a4ed82345cdf9 Mon Sep 17 00:00:00 2001
From: Artem Konenko <yadummer@gmail.com>
Date: Sat, 16 Jul 2016 15:00:50 +0300
Subject: [PATCH] Close #83 Move curator's interface to all teachers

* Eliminate redundant  role
* A little refactor in base.twig around officeTitle ifs
* Eliminate redundant db tables
---
 db/migrations/data/V2_1__userRoles.sql        |  4 +--
 .../structure/V10__curators_groups.sql        | 33 -------------------
 db/structure/curators_groups.sql              | 33 -------------------
 .../phpConfig/sidePanel/teacher.json          |  0
 .../classes/Controller/Environment/Office.php |  6 ++--
 ~dev_rating/application/classes/User.php      |  6 ----
 ~dev_rating/application/views/base.twig       | 11 ++++---
 7 files changed, 11 insertions(+), 82 deletions(-)
 delete mode 100644 db/migrations/structure/V10__curators_groups.sql
 delete mode 100644 db/structure/curators_groups.sql
 rename ~dev_rating/application/config/sidePanel/curator.json => deploy/phpConfig/sidePanel/teacher.json (100%)

diff --git a/db/migrations/data/V2_1__userRoles.sql b/db/migrations/data/V2_1__userRoles.sql
index b17694776..a04e4c313 100644
--- a/db/migrations/data/V2_1__userRoles.sql
+++ b/db/migrations/data/V2_1__userRoles.sql
@@ -16,12 +16,10 @@ SET time_zone = "+00:00";
 -- 4 - teacher
 -- 8 - admin
 -- 16 - deans
--- 32 - curator
 INSERT INTO `user_roles` (`ID`, `Type`, `RoleName`, `Mark`) VALUES
 (1, 'student', 'Студент', 3),
 (2, 'teacher', 'Преподаватель', 5),
 (3, 'teacher', 'Преподаватель-Администратор', 31),
-(4, 'teacher', 'Работник деканата', 21),
-(5, 'teacher', 'Преподаватель-Куратор', 37);
+(4, 'teacher', 'Работник деканата', 21);
 
 -- --------------------------------------------------------
diff --git a/db/migrations/structure/V10__curators_groups.sql b/db/migrations/structure/V10__curators_groups.sql
deleted file mode 100644
index 1368f4765..000000000
--- a/db/migrations/structure/V10__curators_groups.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-SET time_zone = "+00:00";
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `curators_groups`
---
-
-CREATE TABLE IF NOT EXISTS `curators_groups` (
-  `ID` int(11) NOT NULL AUTO_INCREMENT,
-  `TeacherID` int(11) NOT NULL,
-  `GroupID` int(11) NOT NULL,
-  PRIMARY KEY (`ID`),
-  KEY `TeacherID` (`TeacherID`),
-  KEY `GroupID` (`GroupID`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-
---
--- Ограничения внешнего ключа таблицы `curators_groups`
---
-ALTER TABLE `curators_groups`
-  ADD CONSTRAINT `curators_groups_ibfk_1` FOREIGN KEY (`TeacherID`) REFERENCES `teachers` (`ID`),
-  ADD CONSTRAINT `curators_groups_ibfk_2` FOREIGN KEY (`GroupID`) REFERENCES `study_groups` (`ID`);
-
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
diff --git a/db/structure/curators_groups.sql b/db/structure/curators_groups.sql
deleted file mode 100644
index 1368f4765..000000000
--- a/db/structure/curators_groups.sql
+++ /dev/null
@@ -1,33 +0,0 @@
-SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-SET time_zone = "+00:00";
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-
--- --------------------------------------------------------
-
---
--- Структура таблицы `curators_groups`
---
-
-CREATE TABLE IF NOT EXISTS `curators_groups` (
-  `ID` int(11) NOT NULL AUTO_INCREMENT,
-  `TeacherID` int(11) NOT NULL,
-  `GroupID` int(11) NOT NULL,
-  PRIMARY KEY (`ID`),
-  KEY `TeacherID` (`TeacherID`),
-  KEY `GroupID` (`GroupID`)
-) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-
---
--- Ограничения внешнего ключа таблицы `curators_groups`
---
-ALTER TABLE `curators_groups`
-  ADD CONSTRAINT `curators_groups_ibfk_1` FOREIGN KEY (`TeacherID`) REFERENCES `teachers` (`ID`),
-  ADD CONSTRAINT `curators_groups_ibfk_2` FOREIGN KEY (`GroupID`) REFERENCES `study_groups` (`ID`);
-
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
diff --git a/~dev_rating/application/config/sidePanel/curator.json b/deploy/phpConfig/sidePanel/teacher.json
similarity index 100%
rename from ~dev_rating/application/config/sidePanel/curator.json
rename to deploy/phpConfig/sidePanel/teacher.json
diff --git a/~dev_rating/application/classes/Controller/Environment/Office.php b/~dev_rating/application/classes/Controller/Environment/Office.php
index 6cef045a5..830bc2ba0 100644
--- a/~dev_rating/application/classes/Controller/Environment/Office.php
+++ b/~dev_rating/application/classes/Controller/Environment/Office.php
@@ -11,7 +11,7 @@ class Controller_Environment_Office extends Controller_Environment_User
     public function before() {
         parent::before();
 
-        $this->user->checkAccess(User::RIGHTS_DEAN | User::RIGHTS_ADMIN | User::RIGHTS_CURATOR);
+        $this->user->checkAccess(User::RIGHTS_DEAN | User::RIGHTS_ADMIN | User::RIGHTS_TEACHER);
 
         if ($this->user->isAdmin()) {
             $str='sidePanel/admin.json';
@@ -19,8 +19,8 @@ class Controller_Environment_Office extends Controller_Environment_User
         elseif ($this->user->isDean()) {
             $str='sidePanel/dean.json';
         }
-        elseif ($this->user->isCurator()) {
-            $str='sidePanel/curator.json';
+        elseif ($this->user->isTeacher()) {
+            $str='sidePanel/teacher.json';
         }
 
         // todo: move to twig
diff --git a/~dev_rating/application/classes/User.php b/~dev_rating/application/classes/User.php
index daec1a940..67cf33c39 100644
--- a/~dev_rating/application/classes/User.php
+++ b/~dev_rating/application/classes/User.php
@@ -36,8 +36,6 @@ class User implements ArrayAccess
     const RIGHTS_TEACHER = 4;
     const RIGHTS_ADMIN = 8;
     const RIGHTS_DEAN = 16;
-    const RIGHTS_CURATOR = 32;
-
 
     /** @var Session */
     protected $_session;
@@ -109,10 +107,6 @@ class User implements ArrayAccess
         return (bool) ($this->RoleMark & self::RIGHTS_TEACHER);
     }
 
-    public function isCurator() {
-        return (bool) ($this->RoleMark & self::RIGHTS_CURATOR);
-    }
-
     public function isStudent() {
         return (bool) ($this->RoleMark & self::RIGHTS_DEAN);
     }
diff --git a/~dev_rating/application/views/base.twig b/~dev_rating/application/views/base.twig
index 9358e4f4c..bb31e9a06 100644
--- a/~dev_rating/application/views/base.twig
+++ b/~dev_rating/application/views/base.twig
@@ -110,14 +110,17 @@
                 {# see media/js/profile.js, views/profile/*.twig #}
 				<div id="username">{{ User.FirstName }} {{ User.LastName }}</div>
 
+				{% set officeTitle = '' %}
+
 				{% if User.isAdmin %}
 					{% set officeTitle = 'Администрирование' %}
-					{{ HTML.anchor('/office', '<i class="fa fa-university fa-md fa-fw"></i>', {'title': officeTitle })|raw }}
 				{% elseif User.isDean %}
 					{% set officeTitle = 'Деканат' %}
-					{{ HTML.anchor('/office', '<i class="fa fa-university fa-md fa-fw"></i>', {'title': officeTitle })|raw }}
-				{% elseif User.isCurator %}
-					{% set officeTitle = 'Куратор' %}
+				{% elseif User.isTeacher %}
+					{% set officeTitle = 'Сводные ведомости' %}
+				{% endif %}
+
+				{% if officeTitle != '' %}
 					{{ HTML.anchor('/office', '<i class="fa fa-university fa-md fa-fw"></i>', {'title': officeTitle })|raw }}
 				{% endif %}
 
-- 
GitLab