Skip to content
Snippets Groups Projects
Commit fb0de4ce authored by xamgore's avatar xamgore
Browse files

@SemesterID fix, but nothing works now

parent 12caeafe
Branches
Tags
No related merge requests found
...@@ -62,7 +62,7 @@ class Kohana_User implements ArrayAccess ...@@ -62,7 +62,7 @@ class Kohana_User implements ArrayAccess
if ($isSignedIn) { if ($isSignedIn) {
$id = $this->_session->get('ID'); $id = $this->_session->get('ID');
$this->_userInfo = $this->getInfoFromDB($id); $this->_userInfo = $this->getInfoFromDB($id, $this->_model->getCurSemesterID());
if (self::$_flag != true) { if (self::$_flag != true) {
$this->_session->regenerate(); $this->_session->regenerate();
...@@ -130,14 +130,16 @@ class Kohana_User implements ArrayAccess ...@@ -130,14 +130,16 @@ class Kohana_User implements ArrayAccess
$userHash = $this->hash($source) . $this->_config['hash_key']; $userHash = $this->hash($source) . $this->_config['hash_key'];
$passwordHash = $this->hash($passhash . $this->_config['hash_key']); $passwordHash = $this->hash($passhash . $this->_config['hash_key']);
Cookie::set('userhash', $passwordHash); Cookie::set('userhash', $passwordHash);
$this->_userInfo = $this->getInfoFromDB($id);
$semester = $this->_model->getCurSemesterID();
$this->_userInfo = $this->getInfoFromDB($id, $semester);
$this->_session->regenerate(); $this->_session->regenerate();
$this->_session->set('ID', $id); $this->_session->set('ID', $id);
$this->_session->set('LoggedIn', true); $this->_session->set('LoggedIn', true);
$this->_session->set('UserHash', $this->hash($userHash)); $this->_session->set('UserHash', $this->hash($userHash));
$this->_session->set('PasswordHash', $passwordHash); $this->_session->set('PasswordHash', $passwordHash);
$this->_session->set('start_time', time()); $this->_session->set('start_time', time());
$this->_session->set("SemesterID", $this->_model->getCurSemesterID()); $this->_session->set("SemesterID", $semester);
return true; return true;
} }
...@@ -265,8 +267,8 @@ class Kohana_User implements ArrayAccess ...@@ -265,8 +267,8 @@ class Kohana_User implements ArrayAccess
} }
} }
private function getInfoFromDB($id) { private function getInfoFromDB($id, $semesterID) {
$info = $this->_model->getPersonalInfo($id); $info = $this->_model->getPersonalInfo($id, $semesterID);
$info += $this->_model->getAccountInfo($id); $info += $this->_model->getAccountInfo($id);
return $info; return $info;
} }
...@@ -286,9 +288,9 @@ class Kohana_User implements ArrayAccess ...@@ -286,9 +288,9 @@ class Kohana_User implements ArrayAccess
$this->_userInfo[$offset] = $value; $this->_userInfo[$offset] = $value;
} elseif (isset($offset, $this->_session)) { } elseif (isset($offset, $this->_session)) {
$this->_session[$offset] = $value; $this->_session[$offset] = $value;
} else {
$this->_userInfo[$offset] = $value;
} }
$this->_userInfo[$offset] = $value;
} }
public function offsetGet($offset) { public function offsetGet($offset) {
......
...@@ -117,9 +117,8 @@ class Model_Kohana_Account extends Model ...@@ -117,9 +117,8 @@ class Model_Kohana_Account extends Model
return $response->get('Num'); return $response->get('Num');
} }
public static function getPersonalInfo($id) public static function getPersonalInfo($id, $semesterID = null) {
{ $semesterID = $semesterID ? $semesterID : User::instance()->SemesterID;
$semesterID = User::instance()->se;
$sql = "CALL `GetPersonalInfo`('$id', $semesterID);"; $sql = "CALL `GetPersonalInfo`('$id', $semesterID);";
$query = DB::query(Database::SELECT, $sql)->execute(); $query = DB::query(Database::SELECT, $sql)->execute();
return $query[0]; return $query[0];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment