From fb0de4ce1ee7fc0fd8a1578788bd55b4fe242873 Mon Sep 17 00:00:00 2001 From: xamgore <xamgore@ya.ru> Date: Tue, 9 Jun 2015 11:01:05 +0300 Subject: [PATCH] @SemesterID fix, but nothing works now --- .../modules/account/classes/Kohana/User.php | 16 +++++++++------- .../account/classes/Model/Kohana/Account.php | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/~dev_rating/modules/account/classes/Kohana/User.php b/~dev_rating/modules/account/classes/Kohana/User.php index a4de5646e..823579b1b 100644 --- a/~dev_rating/modules/account/classes/Kohana/User.php +++ b/~dev_rating/modules/account/classes/Kohana/User.php @@ -62,7 +62,7 @@ class Kohana_User implements ArrayAccess if ($isSignedIn) { $id = $this->_session->get('ID'); - $this->_userInfo = $this->getInfoFromDB($id); + $this->_userInfo = $this->getInfoFromDB($id, $this->_model->getCurSemesterID()); if (self::$_flag != true) { $this->_session->regenerate(); @@ -130,14 +130,16 @@ class Kohana_User implements ArrayAccess $userHash = $this->hash($source) . $this->_config['hash_key']; $passwordHash = $this->hash($passhash . $this->_config['hash_key']); Cookie::set('userhash', $passwordHash); - $this->_userInfo = $this->getInfoFromDB($id); + + $semester = $this->_model->getCurSemesterID(); + $this->_userInfo = $this->getInfoFromDB($id, $semester); $this->_session->regenerate(); $this->_session->set('ID', $id); $this->_session->set('LoggedIn', true); $this->_session->set('UserHash', $this->hash($userHash)); $this->_session->set('PasswordHash', $passwordHash); $this->_session->set('start_time', time()); - $this->_session->set("SemesterID", $this->_model->getCurSemesterID()); + $this->_session->set("SemesterID", $semester); return true; } @@ -265,8 +267,8 @@ class Kohana_User implements ArrayAccess } } - private function getInfoFromDB($id) { - $info = $this->_model->getPersonalInfo($id); + private function getInfoFromDB($id, $semesterID) { + $info = $this->_model->getPersonalInfo($id, $semesterID); $info += $this->_model->getAccountInfo($id); return $info; } @@ -286,9 +288,9 @@ class Kohana_User implements ArrayAccess $this->_userInfo[$offset] = $value; } elseif (isset($offset, $this->_session)) { $this->_session[$offset] = $value; + } else { + $this->_userInfo[$offset] = $value; } - - $this->_userInfo[$offset] = $value; } public function offsetGet($offset) { diff --git a/~dev_rating/modules/account/classes/Model/Kohana/Account.php b/~dev_rating/modules/account/classes/Model/Kohana/Account.php index 9b3030995..ff183b7d6 100644 --- a/~dev_rating/modules/account/classes/Model/Kohana/Account.php +++ b/~dev_rating/modules/account/classes/Model/Kohana/Account.php @@ -117,9 +117,8 @@ class Model_Kohana_Account extends Model return $response->get('Num'); } - public static function getPersonalInfo($id) - { - $semesterID = User::instance()->se; + public static function getPersonalInfo($id, $semesterID = null) { + $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID; $sql = "CALL `GetPersonalInfo`('$id', $semesterID);"; $query = DB::query(Database::SELECT, $sql)->execute(); return $query[0]; -- GitLab