修正使用者帳號管理 取得群組名稱、班級名稱改由一開始擷取資料時一併擷取,不再透過群組物件另外擷取

This commit is contained in:
Yuan Chiu 2014-10-25 00:23:43 +08:00
parent f9df9edc9c
commit 3053541e3b
3 changed files with 42 additions and 40 deletions

View File

@ -170,8 +170,18 @@ class DBUser extends Database {
* @return array 查詢結果陣列 * @return array 查詢結果陣列
*/ */
protected function queryUserByWhere($where) { protected function queryUserByWhere($where) {
$sqlString = "SELECT * FROM ".$this->table('User').
" WHERE ".$where; $sqlString = "SELECT `UID`, `UPassword`, ".
"`group`.`GID`, `group`.`GName`, `class`.`CID`, `class`.`CName`, ".
"`UEnabled`, `UBuildTime`, `UModifyTime`, ".
"`LMode`, `MMode`, `UEnable_NoAppoint`, ".
"`UNickname`, `URealName`, `UEmail`, `UMemo` ".
"FROM `".$this->table('User')."` AS `user` ".
"LEFT JOIN `".$this->table('AGroup')."` as `group` ".
"ON `group`.`GID` = `user`.`GID`".
"LEFT JOIN `".$this->table('CGroup')."` as `class` ".
"ON `class`.`CID` = `user`.`CID`".
"WHERE ".$where;
$query = $this->connDB->prepare($sqlString); $query = $this->connDB->prepare($sqlString);
$query->execute(); $query->execute();
@ -197,7 +207,9 @@ class DBUser extends Database {
array( 'user_id' => $thisResult['UID'], array( 'user_id' => $thisResult['UID'],
'password' => $thisResult['UPassword'], 'password' => $thisResult['UPassword'],
'group_id' => $thisResult['GID'], 'group_id' => $thisResult['GID'],
'group_name' => $thisResult['GName'],
'class_id' => $thisResult['CID'], 'class_id' => $thisResult['CID'],
'class_name' => $thisResult['CName'],
'enable' => $output_enable, 'enable' => $output_enable,
'build_time' => $thisResult['UBuildTime'], 'build_time' => $thisResult['UBuildTime'],
'modify_time' => $thisResult['UModifyTime'], 'modify_time' => $thisResult['UModifyTime'],

View File

@ -170,6 +170,16 @@ class User {
public function getCreateTime(){ public function getCreateTime(){
return $this->queryResultArray['build_time']; return $this->queryResultArray['build_time'];
} }
/**
* 取得帳號資訊修改時間
*
* @return string 修改時間
* @since 2.0.0
*/
public function getModifyTime(){
return $this->queryResultArray['modify_time'];
}
// ======================================================================== // ========================================================================
/** /**
@ -178,7 +188,7 @@ class User {
* @return string 群組ID * @return string 群組ID
* @since 2.0.0 * @since 2.0.0
*/ */
public function getGroup(){ public function getGroupID(){
return $this->queryResultArray['group_id']; return $this->queryResultArray['group_id'];
} }
@ -191,17 +201,7 @@ class User {
*/ */
public function getGroupName(){ public function getGroupName(){
// 群組ID return $this->queryResultArray['group_name'];
$groupID = $this->queryResultArray['group_id'];
// 取得群組名稱
try {
$group = new User\UserGroup($groupID);
return $group->getName();
}
catch (Exception\GroupNoFoundException $e) {
throw $e;
}
} }
/** /**
@ -259,22 +259,7 @@ class User {
* @since 2.0.0 * @since 2.0.0
*/ */
public function getClassName(){ public function getClassName(){
// TODO: 取得所在群組顯示名稱 return $this->queryResultArray['class_name'];
// 群組ID
$classID = $this->queryResultArray['class_id'];
// 檢查有此群組
if(isset($classID)) {
// 取得群組名稱
try {
$group = new ClassGroup($classID);
return $group->getName();
}
catch (Exception\ClassNoFoundException $e) {
throw $e;
}
}
else return null;
} }
/** /**
@ -349,22 +334,27 @@ class User {
/** /**
* 取得這個人的學習導引風格 * 取得這個人的學習導引風格
* *
* @return string 學習導引風格 * @return int 將推薦幾個學習點
* @since 2.0.0 * @since 2.0.0
*/ */
public function getLearnStyle(){ public function getLearnStyle(){
// TODO: 取得這個人的學習導引風格 return $this->queryResultArray['learnStyle_mode'];
} }
/** /**
* 設定這個人的學習導引風格 * 設定這個人的學習導引風格
* *
* @param string $style 學習導引風格 * @param int $style 將推薦幾個學習點
* @since 2.0.0 * @since 2.0.0
*/ */
public function setLearnStyle($style){ public function setLearnStyle($style){
// TODO: 設定這個人的學習導引風格
if( $style >= 0 ) {
$this->setUpdate('learnStyle_mode', $style);
}
else {
throw new \UnexpectedValueException();
}
} }
@ -375,7 +365,7 @@ class User {
* @since 2.0.0 * @since 2.0.0
*/ */
public function getMaterialStyle(){ public function getMaterialStyle(){
// TODO: 取得這個人的教材風格 return $this->queryResultArray['material_mode'];
} }
/** /**
@ -385,9 +375,9 @@ class User {
* @since 2.0.0 * @since 2.0.0
*/ */
public function setMaterialStyle($style){ public function setMaterialStyle($style){
// TODO: 設定這個人的教材風格
// TODO: 防呆- 無此教材
$this->setUpdate('material_mode', $style);
} }
// ======================================================================== // ========================================================================

View File

@ -60,8 +60,8 @@ class UserAdmin {
* 'enable' => true, // (optional) 預設為true * 'enable' => true, // (optional) 預設為true
* 'learnStyle_mode' => 3, // (optional) * 'learnStyle_mode' => 3, // (optional)
* 'material_mode' => 'normal', // (optional) * 'material_mode' => 'normal', // (optional)
* 'material_mode' => 'normal', // (optional) * 'nickname' => '元兒~', // (optional)
* 'enable_noAppoint' => true, // (optional) * 'enable_noAppoint' => true, // (optional)
* 'realname' => 'Eric Chiu', // (optional) * 'realname' => 'Eric Chiu', // (optional)
* 'email' => 'eric@example.tw', // (optional) * 'email' => 'eric@example.tw', // (optional)
* 'memo' => '' ) // (optional) * 'memo' => '' ) // (optional)