diff --git a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php index 6f210c34b10638ceba09e05b958f6f7dd61aa795..f667341bcdc349687d6f9d3b9541e53cc92e0b6d 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmTeachers.php @@ -80,6 +80,6 @@ class Controller_Handler_AdmTeachers extends Controller_Handler { public function action_getDepartmentsList() { $facultyID = $this->post->offsetGet('facultyID'); - $this->response->body(DataArray::factory('Departments')->byFaculty($facultyID)->asJSON()); + $this->response->body(Model_Departments::factory()->byFaculty($facultyID)->asJSON()); } } \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/Handler/Map.php b/~dev_rating/application/classes/Controller/Handler/Map.php index da4e3b66f75569b7059e3dedc4899fc8135c64e1..c6433699674f6ec143f0d1a36a17ebaa78cc1050 100644 --- a/~dev_rating/application/classes/Controller/Handler/Map.php +++ b/~dev_rating/application/classes/Controller/Handler/Map.php @@ -516,7 +516,7 @@ class Controller_Handler_Map extends Controller_Handler { $this->post -> rule('FacultyID', 'not_empty') -> rule('FacultyID', 'digit'); if($this->post->check()) { - $DepList = DataArray::factory('Departments')->byFaculty($this->post->offsetGet('FacultyID'))->asJSON(); + $DepList = Model_Departments::factory()->byFaculty($this->post->offsetGet('FacultyID'))->asJSON(); } $this->response->body($DepList); } diff --git a/~dev_rating/application/classes/Controller/Handler/Settings.php b/~dev_rating/application/classes/Controller/Handler/Settings.php index aa184f91ca8683453aee132fa6b37cc5cc53451c..60e4a94445e47a35e74ce6b0c9c77e9d31020578 100644 --- a/~dev_rating/application/classes/Controller/Handler/Settings.php +++ b/~dev_rating/application/classes/Controller/Handler/Settings.php @@ -80,7 +80,7 @@ class Controller_Handler_Settings extends Controller_Handler { public function action_getDepartmentsList() { $facultyID = $this->post->offsetGet('facultyID'); - $deps = DataArray::factory('Departments')->byFaculty($facultyID)->asArray(); + $deps = Model_Departments::factory()->byFaculty($facultyID)->asArray(); $this->response->body(json_encode($deps)); } diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php index a30cc2c9f2d37255e115484adcbaeb659a6bed4b..cd99179d0b9b4ca2f23ca0b1d5c621cff2677ff0 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php @@ -146,7 +146,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvi { $twig->Discipline = $this->getDisciplineInfo($db, $id); $twig->BindTeachersList = Model_Teachers::factory()->forDiscipline($id)->asArray(); $twig->FacultiesList = Model_Faculties::factory()->common()->asArray(); - $twig->Departments = DataArray::factory('Departments')->byFaculty($this->UserInfo['FacultyID'])->asArray(); + $twig->Departments = Model_Departments::factory()->byFaculty($this->UserInfo['FacultyID'])->asArray(); $this->response->body($twig); } diff --git a/~dev_rating/application/classes/Controller/Teacher/Profile.php b/~dev_rating/application/classes/Controller/Teacher/Profile.php index 587a234a516f16481e58eea22c747ec6b35210e4..fc2cb84ae5c3bcbc03d7c697233d4932cf4ed819 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Profile.php +++ b/~dev_rating/application/classes/Controller/Teacher/Profile.php @@ -6,7 +6,7 @@ class Controller_Teacher_Profile extends Controller_UserEnvi { $twig = Twig::factory('profile/settings'); $twig->JobPositions = $this->getJobPositions(); $twig->Faculties = $this->getFaculties(); - $twig->Departments = DataArray::factory('Departments')->byFaculty($this->UserInfo['FacultyID'])->asArray(); + $twig->Departments = Model_Departments::factory()->byFaculty($this->UserInfo['FacultyID'])->asArray(); $twig->User = $this->UserInfo; $this->response->body($twig); } diff --git a/~dev_rating/application/classes/DataArr/Departments.php b/~dev_rating/application/classes/DataArr/Departments.php index ca529798b7cd53985b32ffaa506468f78405559f..b4447bf45c8855e4eb5a54eed3b3503340af52d0 100644 --- a/~dev_rating/application/classes/DataArr/Departments.php +++ b/~dev_rating/application/classes/DataArr/Departments.php @@ -1,12 +1,14 @@ <?php +/** @deprecated use Model_Departments instead. */ class DataArr_Departments { protected $model; public function __construct() { $this->model = new Model_DataArr_Departments; } - + + /** @deprecated */ public function byFaculty($facultyID) { if($facultyID != 0) diff --git a/~dev_rating/application/classes/Model/DataArr/Departments.php b/~dev_rating/application/classes/Model/DataArr/Departments.php index 6d0007605b8b821fa4f6341f0e805ee47ef45389..8f372f19ab49f05a42e4b08820237c1304051edf 100644 --- a/~dev_rating/application/classes/Model/DataArr/Departments.php +++ b/~dev_rating/application/classes/Model/DataArr/Departments.php @@ -1,7 +1,9 @@ <?php defined('SYSPATH') or die('No direct script access.'); - + +/** @deprecated use Model_Departments instead. */ class Model_DataArr_Departments extends Model { + /** @deprecated */ public function getDepartmentsByFaculty($facultyID) { $sql = "CALL `GetDepartments`('$facultyID'); "; diff --git a/~dev_rating/application/classes/Model/Departments.php b/~dev_rating/application/classes/Model/Departments.php new file mode 100644 index 0000000000000000000000000000000000000000..de4f86b6d26380189aed7402dec22690929e85fc --- /dev/null +++ b/~dev_rating/application/classes/Model/Departments.php @@ -0,0 +1,26 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Model_Departments extends Model +{ + public static function factory() { + return new self(); + } + + public function getDepartmentsByFaculty($facultyID) { + $sql = "CALL `GetDepartments`('$facultyID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function byFaculty($facultyID) { + if ($facultyID != 0) { + $departments = $this->getDepartmentsByFaculty($facultyID); + $list = array(); + foreach ($departments as $row) { + if ($row['Name'] == null) + $row['Name'] = '<служебная кафедра>'; + $list = $row; + } + return new DataArray_Result($list); + } + } +}