diff --git a/~dev_rating/application/classes/Controller/Admin/Accounts.php b/~dev_rating/application/classes/Controller/Admin/Accounts.php index 1c100dedde4aca6f74ab375bff63b1697f2cf043..f5b86240541b8945df78870dd8a6f0be7f6046d0 100644 --- a/~dev_rating/application/classes/Controller/Admin/Accounts.php +++ b/~dev_rating/application/classes/Controller/Admin/Accounts.php @@ -12,10 +12,9 @@ class Controller_Admin_Accounts extends Controller_UserEnvironment { public function action_getActivationCodes() { - $model = new Model_Students(); Cookie::set('fD', 'true'); $twig = Twig::factory('admin/accounts/codes'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->user; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/Admin/Students.php b/~dev_rating/application/classes/Controller/Admin/Students.php index ecbd1cb3ed6ae8955914e3e94d346015a7708f9d..158ab9bae614a90c1a518447aa53bec5ff7c20c7 100644 --- a/~dev_rating/application/classes/Controller/Admin/Students.php +++ b/~dev_rating/application/classes/Controller/Admin/Students.php @@ -6,7 +6,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment { { // VIEW $twig = Twig::factory('admin/students/index'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->user; $this->response->body($twig); @@ -15,7 +15,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment { public function action_add() { $twig = Twig::factory('admin/students/add'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->user; $this->response->body($twig); @@ -29,7 +29,7 @@ class Controller_Admin_Students extends Controller_UserEnvironment { } // VIEW $twig = Twig::factory('admin/students/upload'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->UploadingResult = $result; $twig->User = $this->user; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/Admin/Subjects.php b/~dev_rating/application/classes/Controller/Admin/Subjects.php index b14d43a2df4316944f35437c6a6c709a127aa106..d96b8eca335d4a0cf62fa5fb9cfd43cbce53cde5 100644 --- a/~dev_rating/application/classes/Controller/Admin/Subjects.php +++ b/~dev_rating/application/classes/Controller/Admin/Subjects.php @@ -13,7 +13,7 @@ class Controller_Admin_Subjects extends Controller_UserEnvironment { } // VIEW $twig = Twig::factory('admin/subjects/upload'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->UploadingResult = $result; $twig->User = $this->user; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/Admin/Teachers.php b/~dev_rating/application/classes/Controller/Admin/Teachers.php index cab950ed5e593126e092b3116bd905d56ef17a65..f0ccd5046d19a57551a1e3a587498a73b97bd716 100644 --- a/~dev_rating/application/classes/Controller/Admin/Teachers.php +++ b/~dev_rating/application/classes/Controller/Admin/Teachers.php @@ -6,7 +6,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment { { // VIEW $twig = Twig::factory('admin/teachers/index'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->User = $this->user; $this->response->body($twig); } @@ -15,7 +15,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment { { $twig = Twig::factory('admin/teachers/add'); $twig->JobPositions = $this->getJobPositions(); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->User = $this->user; $this->response->body($twig); } @@ -28,7 +28,7 @@ class Controller_Admin_Teachers extends Controller_UserEnvironment { } // VIEW $twig = Twig::factory('admin/teachers/upload'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->UploadingResult = $result; $twig->User = $this->user; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/DeanOffice/Students.php b/~dev_rating/application/classes/Controller/DeanOffice/Students.php index f49edd24ece3564097cba80e1eea7457de0c8703..2ce11d2bf4b533045c7f3017d8657283caff0b03 100644 --- a/~dev_rating/application/classes/Controller/DeanOffice/Students.php +++ b/~dev_rating/application/classes/Controller/DeanOffice/Students.php @@ -4,7 +4,7 @@ class Controller_DeanOffice_Students extends Controller_UserEnvironment { public function action_index() { $twig = Twig::factory('dean_office/students/index'); - $twig->Faculties = Model_Faculties::toArray(); + $twig->Faculties = Model_Faculties::load(); $twig->Grades = Model_Grades::toStructuredArray(); $twig->User = $this->user; $this->response->body($twig); diff --git a/~dev_rating/application/classes/Controller/Teacher/Discipline.php b/~dev_rating/application/classes/Controller/Teacher/Discipline.php index 20948c0faf9716252ac8206849d1312eddd573c5..3fc9753f770ff07c7ebaf59cc514adcf4fa9b841 100644 --- a/~dev_rating/application/classes/Controller/Teacher/Discipline.php +++ b/~dev_rating/application/classes/Controller/Teacher/Discipline.php @@ -7,7 +7,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment { $twig = Twig::factory('teacher/discipline/CreateDiscipline'); $twig->User = $this->user; - $twig->FacultiesList = Model_Faculties::toArray(); + $twig->FacultiesList = Model_Faculties::load(); $twig->SubjectsList = Model_Subjects::byFaculty($this->user['FacultyID']); $twig->GradesList = Model_Grades::toArray(); @@ -19,7 +19,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment { $twig = Twig::factory('teacher/discipline/CreateCoursework'); $twig->User = $this->user; - $twig->FacultiesList = Model_Faculties::toArray(); + $twig->FacultiesList = Model_Faculties::load(); $twig->SubjectsList = Model_Subjects::byFaculty($this->user['FacultyID']); $twig->GradesList = Model_Grades::toArray(); @@ -144,7 +144,7 @@ class Controller_Teacher_Discipline extends Controller_UserEnvironment { $twig->User = $this->user; $twig->Discipline = $this->getDisciplineInfo($id); $twig->BindTeachersList = Model_Teachers::getNamesForDiscipline($id); - $twig->FacultiesList = Model_Faculties::toArray(); + $twig->FacultiesList = Model_Faculties::load(); $twig->Departments = Model_Departments::byFaculty($this->user['FacultyID']); $twig->Author = Model_Account::getPersonalInfo($twig->Discipline['AuthorID']); diff --git a/~dev_rating/application/classes/Model/Faculties.php b/~dev_rating/application/classes/Model/Faculties.php index 83ad3a47ca7646d6ddb46d58b934f716ceae19dd..82ecb8d433162628c08025b3a64670a5311f6869 100644 --- a/~dev_rating/application/classes/Model/Faculties.php +++ b/~dev_rating/application/classes/Model/Faculties.php @@ -2,17 +2,9 @@ class Model_Faculties extends Model { - public static function getFaculties() { + public static function load() { $sql = "CALL `GetFaculties`(); "; - return DB::query(Database::SELECT, $sql)->execute(); - } - - public static function toArray() { - $faculties = self::getFaculties(); - - $list = array(); - foreach ($faculties as $row) - $list[] = $row; - return $list; + return DB::query(Database::SELECT, $sql) + ->execute()->as_array(); } }