修改資料庫架構,並更新相關類別。 & 改變資料庫類別的插入函式用法
This commit is contained in:
parent
a15274d97f
commit
f9df9edc9c
@ -41,11 +41,27 @@
|
||||
|
||||
/**
|
||||
* 資料庫內資料表前綴字串
|
||||
|
||||
*
|
||||
* 每一張表格名稱的起始字串,為了避開一些網頁空間只允許建立一個資料庫的限制。
|
||||
*/
|
||||
define('DB_PREFIX', 'uel__');
|
||||
|
||||
// 學習導引設定 =================================================================
|
||||
|
||||
/**
|
||||
* 預設導引模式
|
||||
*
|
||||
* 針對未個別設定過的使用者,採用預設的導引模式
|
||||
*/
|
||||
define('LMODE', '0');
|
||||
|
||||
/**
|
||||
* 預設教材模式
|
||||
*
|
||||
* 針對未個別設定過的使用者,採用預設的導引模式
|
||||
*/
|
||||
define('MMODE', 'normal');
|
||||
|
||||
// 網站設定 ===================================================================
|
||||
/**
|
||||
* 網站標題
|
||||
|
@ -39,7 +39,15 @@ class DBUser extends Database {
|
||||
* try {
|
||||
* $db = new Database\DBUser();
|
||||
*
|
||||
* $db->insertUser('eric', 'passwd', 'user', null, 1, 'harf-line-learn', '1', '偉人', 'Eric Chiou', 'eric@example.com', null);
|
||||
* $db->insertUser(
|
||||
* array(
|
||||
* 'user_id' => 'eric',
|
||||
* 'password' => 'passwd',
|
||||
* 'group_id' => 'user',
|
||||
* 'enable' => true,
|
||||
* 'enable_noAppoint' => true
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* echo 'Finish';
|
||||
* }
|
||||
@ -53,55 +61,93 @@ class DBUser extends Database {
|
||||
* echo '<h2>'. $e->getCode() .'</h2>';
|
||||
* }
|
||||
*
|
||||
* @param string $uId 使用者名稱
|
||||
* @param string $password 密碼
|
||||
* @param string $gId 群組
|
||||
* @param string $cId 班級
|
||||
* @param string $enable 啟用此帳號
|
||||
* @param string $l_mode 學習模式
|
||||
* @param string $m_mode 教材模式
|
||||
* @param string $nickName 暱稱
|
||||
* @param string $realName 姓名
|
||||
* @param string $email 電子郵件地址
|
||||
* @param string $memo 備註
|
||||
* @param array $array 使用者資料陣列,格式為:
|
||||
* array(
|
||||
* 'user_id' => <帳號名稱>,
|
||||
* 'password' => <密碼>,
|
||||
* 'group_id' => <群組>,
|
||||
* 'class_id' => <班級>,
|
||||
* 'enable' => <啟用>,
|
||||
* 'learnStyle_mode' => <偏好學習導引模式>,
|
||||
* 'material_mode' => <偏好教材模式>,
|
||||
* 'enable_noAppoint' => <是否允許非預約學習>,
|
||||
* 'nickname' => <暱稱>,
|
||||
* 'realname' => <真實姓名>,
|
||||
* 'email' => <電子郵件地址>,
|
||||
* 'memo' => <備註>
|
||||
* );
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function insertUser($uId, $password, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$nickName, $realName, $email, $memo){
|
||||
public function insertUser($array){
|
||||
|
||||
|
||||
// 檢查是否有支援所設定的DBMS
|
||||
//if($this->db_type == 'mysql') {
|
||||
|
||||
//紀錄使用者帳號進資料庫
|
||||
$sqlString = "INSERT INTO ".$this->table('User').
|
||||
" (`UID`, `UPassword`, `GID`, `CID`, `UEnabled`, `UBuild_Time`,
|
||||
`LMode`, `MMode`, `UNickname`, `UReal_Name`, `UEmail`, `UMemo`)
|
||||
VALUES ( :id , :passwd, :gid , :cid , :enable , NOW() ,
|
||||
:lmode , :mmode , :nickname , :realname , :email , :memo )";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(":id", $uId);
|
||||
$query->bindParam(":passwd", $password);
|
||||
$query->bindParam(":gid", $gId);
|
||||
$query->bindParam(":cid", $cId);
|
||||
$query->bindParam(":enable", $enable);
|
||||
$query->bindParam(":lmode", $l_mode);
|
||||
$query->bindParam(":mmode", $m_mode);
|
||||
$query->bindParam(":nickname", $nickName);
|
||||
$query->bindParam(":realname", $realName);
|
||||
$query->bindParam(":email", $email);
|
||||
$query->bindParam(":memo", $memo);
|
||||
$query->execute();
|
||||
//}
|
||||
//else {
|
||||
// throw new Exception\DatabaseNoSupportException($this->db_type);
|
||||
//}
|
||||
if( !isset($array['class_id']) ){
|
||||
$array['class_id'] = null;
|
||||
}
|
||||
if( !isset($array['learnStyle_mode']) ){
|
||||
$array['learnStyle_mode'] = null;
|
||||
}
|
||||
if( !isset($array['material_mode']) ){
|
||||
$array['material_mode'] = null;
|
||||
}
|
||||
if( !isset($array['nickname']) ){
|
||||
$array['nickname'] = null;
|
||||
}
|
||||
if( !isset($array['realname']) ){
|
||||
$array['realname'] = null;
|
||||
}
|
||||
if( !isset($array['email']) ){
|
||||
$array['email'] = null;
|
||||
}
|
||||
if( !isset($array['memo']) ){
|
||||
$array['memo'] = null;
|
||||
}
|
||||
// TODO: 不填enable, enable_noAppoint也要能操作
|
||||
|
||||
$uId = $array['user_id'];
|
||||
$password = $array['password'];
|
||||
$gId = $array['group_id'];
|
||||
$cId = $array['class_id'];
|
||||
$enable = $array['enable'];
|
||||
$l_mode = $array['learnStyle_mode'];
|
||||
$m_mode = $array['material_mode'];
|
||||
$enPublic = $array['enable_noAppoint'];
|
||||
$nickName = $array['nickname'];
|
||||
$realName = $array['realname'];
|
||||
$email = $array['email'];
|
||||
$memo = $array['memo'];
|
||||
|
||||
//紀錄使用者帳號進資料庫
|
||||
$sqlString = "INSERT INTO ".$this->table('User').
|
||||
" (`UID`, `UPassword`, `GID`, `CID`, `UEnabled`,
|
||||
`LMode`, `MMode`, `UEnable_NoAppoint`,
|
||||
`UNickname`, `URealName`, `UEmail`, `UMemo`)
|
||||
VALUES ( :id , :passwd, :gid , :cid , :enable ,
|
||||
:lmode , :mmode , :enpublic ,
|
||||
:nickname , :realname , :email , :memo )";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(":id", $uId);
|
||||
$query->bindParam(":passwd", $password);
|
||||
$query->bindParam(":gid", $gId);
|
||||
$query->bindParam(":cid", $cId);
|
||||
$query->bindParam(":enable", $enable);
|
||||
$query->bindParam(":lmode", $l_mode);
|
||||
$query->bindParam(":mmode", $m_mode);
|
||||
$query->bindParam(":enpublic", $enPublic);
|
||||
$query->bindParam(":nickname", $nickName);
|
||||
$query->bindParam(":realname", $realName);
|
||||
$query->bindParam(":email", $email);
|
||||
$query->bindParam(":memo", $memo);
|
||||
$query->execute();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除一位使用者
|
||||
* @param string $uId 使用者名稱
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function deleteUser($uId) {
|
||||
|
||||
@ -118,6 +164,59 @@ class DBUser extends Database {
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
* 內部使用的查詢動作
|
||||
* @param string $where 查詢語法
|
||||
* @return array 查詢結果陣列
|
||||
*/
|
||||
protected function queryUserByWhere($where) {
|
||||
$sqlString = "SELECT * FROM ".$this->table('User').
|
||||
" WHERE ".$where;
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
if($thisResult['UEnabled'] != '0') {
|
||||
$output_enable = true;
|
||||
}
|
||||
else { $output_enable = false; }
|
||||
|
||||
if($thisResult['UEnable_NoAppoint'] != '0') {
|
||||
$output_enable_noAppoint = true;
|
||||
}
|
||||
else { $output_enable_noAppoint = false; }
|
||||
|
||||
array_push($result,
|
||||
array( 'user_id' => $thisResult['UID'],
|
||||
'password' => $thisResult['UPassword'],
|
||||
'group_id' => $thisResult['GID'],
|
||||
'class_id' => $thisResult['CID'],
|
||||
'enable' => $output_enable,
|
||||
'build_time' => $thisResult['UBuildTime'],
|
||||
'modify_time' => $thisResult['UModifyTime'],
|
||||
'learnStyle_mode' => $thisResult['LMode'],
|
||||
'material_mode' => $thisResult['MMode'],
|
||||
'enable_noAppoint' => $output_enable_noAppoint,
|
||||
'nickname' => $thisResult['UNickname'],
|
||||
'realname' => $thisResult['URealName'],
|
||||
'email' => $thisResult['UEmail'],
|
||||
'memo' => $thisResult['UMemo'])
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢一位使用者帳號資料
|
||||
*
|
||||
@ -154,50 +253,25 @@ class DBUser extends Database {
|
||||
* 'class_id' => <班級>,
|
||||
* 'enable' => <啟用>,
|
||||
* 'build_time' => <建立日期>,
|
||||
* 'modify_time' => <修改日期>,
|
||||
* 'learnStyle_mode' => <偏好學習導引模式>,
|
||||
* 'material_mode' => <偏好教材模式>,
|
||||
* 'enable_noAppoint' => <是否允許非預約學習>,
|
||||
* 'nickname' => <暱稱>,
|
||||
* 'realname' => <真實姓名>,
|
||||
* 'email' => <電子郵件地址>,
|
||||
* 'memo' => <備註>
|
||||
* );
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function queryUser($uId) {
|
||||
|
||||
$sqlString = "SELECT * FROM ".$this->table('User').
|
||||
" WHERE `UID` = :uid";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(':uid', $uId);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
$queryResultAll = $this->queryUserByWhere("`UID`=".$this->connDB->quote($uId));
|
||||
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
$queryResult = $queryResultAll[0];
|
||||
|
||||
if($queryResult['UEnabled'] != '0') {
|
||||
$output_enable = true;
|
||||
}
|
||||
else { $output_enable = false; }
|
||||
|
||||
$result = array(
|
||||
'user_id' => $queryResult['UID'],
|
||||
'password' => $queryResult['UPassword'],
|
||||
'group_id' => $queryResult['GID'],
|
||||
'class_id' => $queryResult['CID'],
|
||||
'enable' => $output_enable,
|
||||
'build_time' => $queryResult['UBuild_Time'],
|
||||
'learnStyle_mode' => $queryResult['LMode'],
|
||||
'material_mode' => $queryResult['MMode'],
|
||||
'nickname' => $queryResult['UNickname'],
|
||||
'realname' => $queryResult['UReal_Name'],
|
||||
'email' => $queryResult['UEmail'],
|
||||
'memo' => $queryResult['UMemo']
|
||||
);
|
||||
|
||||
return $result;
|
||||
return $queryResultAll[0];
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
@ -218,8 +292,10 @@ class DBUser extends Database {
|
||||
* 'class_id' => <班級>,
|
||||
* 'enable' => <啟用>,
|
||||
* 'build_time' => <建立日期>,
|
||||
* 'modify_time' => <修改日期>,
|
||||
* 'learnStyle_mode' => <偏好學習導引模式>,
|
||||
* 'material_mode' => <偏好教材模式>,
|
||||
* 'enable_noAppoint' => <是否允許非預約學習>,
|
||||
* 'nickname' => <暱稱>,
|
||||
* 'realname' => <真實姓名>,
|
||||
* 'email' => <電子郵件地址>,
|
||||
@ -229,45 +305,7 @@ class DBUser extends Database {
|
||||
*
|
||||
*/
|
||||
public function queryAllUser() {
|
||||
|
||||
$sqlString = "SELECT * FROM ".$this->table('User');
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
if($thisResult['UEnabled'] != '0') {
|
||||
$output_enable = true;
|
||||
}
|
||||
else { $output_enable = false; }
|
||||
|
||||
array_push($result,
|
||||
array( 'user_id' => $thisResult['UID'],
|
||||
'password' => $thisResult['UPassword'],
|
||||
'group_id' => $thisResult['GID'],
|
||||
'class_id' => $thisResult['CID'],
|
||||
'enable' => $output_enable,
|
||||
'build_time' => $thisResult['UBuild_Time'],
|
||||
'learnStyle_mode' => $thisResult['LMode'],
|
||||
'material_mode' => $thisResult['MMode'],
|
||||
'nickname' => $thisResult['UNickname'],
|
||||
'realname' => $thisResult['UReal_Name'],
|
||||
'email' => $thisResult['UEmail'],
|
||||
'memo' => $thisResult['UMemo'])
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return $this->queryUserByWhere("1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,33 +321,36 @@ class DBUser extends Database {
|
||||
* @param string $value 內容
|
||||
*/
|
||||
public function changeUserData($uId, $field, $value) {
|
||||
// UPDATE `UElearning`.`chu__User` SET `UMemo` = '測試者' WHERE `chu__User`.`UID` = 'yuan';
|
||||
|
||||
$sqlField = null;
|
||||
switch($field) {
|
||||
case 'user_id': $sqlField = 'UID'; break;
|
||||
case 'password': $sqlField = 'UPassword'; break;
|
||||
case 'group_id': $sqlField = 'GID'; break;
|
||||
case 'class_id': $sqlField = 'CID'; break;
|
||||
case 'enable': $sqlField = 'UEnabled'; break;
|
||||
case 'build_time': $sqlField = 'UBuild_Time'; break;
|
||||
case 'learnStyle_mode': $sqlField = 'LMode'; break;
|
||||
case 'material_mode': $sqlField = 'MMode'; break;
|
||||
case 'nickname': $sqlField = 'UNickname'; break;
|
||||
case 'realname': $sqlField = 'UReal_Name'; break;
|
||||
case 'email': $sqlField = 'UEmail'; break;
|
||||
case 'memo': $sqlField = 'UMemo'; break;
|
||||
default: $sqlField = $field; break;
|
||||
case 'user_id': $sqlField = 'UID'; break;
|
||||
case 'password': $sqlField = 'UPassword'; break;
|
||||
case 'group_id': $sqlField = 'GID'; break;
|
||||
case 'class_id': $sqlField = 'CID'; break;
|
||||
case 'enable': $sqlField = 'UEnabled'; break;
|
||||
case 'build_time': $sqlField = 'UBuildTime'; break;
|
||||
case 'modify_time': $sqlField = 'UModifyTime'; break;
|
||||
case 'learnStyle_mode': $sqlField = 'LMode'; break;
|
||||
case 'material_mode': $sqlField = 'MMode'; break;
|
||||
case 'enable_noAppoint': $sqlField = 'UEnable_NoAppoint'; break;
|
||||
case 'nickname': $sqlField = 'UNickname'; break;
|
||||
case 'realname': $sqlField = 'URealName'; break;
|
||||
case 'email': $sqlField = 'UEmail'; break;
|
||||
case 'memo': $sqlField = 'UMemo'; break;
|
||||
default: $sqlField = $field; break;
|
||||
}
|
||||
|
||||
|
||||
$sqlString = "UPDATE ".$this->table('User').
|
||||
" SET `".$sqlField."` = :value".
|
||||
" , `UModifyTime` = NOW()".
|
||||
" WHERE `UID` = :uid";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(':uid', $uId);
|
||||
$query->bindParam(':value', $value);
|
||||
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
@ -318,18 +359,43 @@ class DBUser extends Database {
|
||||
/**
|
||||
* 插入群組資料
|
||||
*
|
||||
* @param string $gId 群組ID
|
||||
* @param string $name 群組顯示名稱
|
||||
* @param string $memo 備註
|
||||
* @param string $auth_admin Server端管理權
|
||||
* @param string $auth_clientAdmin Client端管理權
|
||||
* @param array $array 使用者群組資料陣列,格式為:
|
||||
*
|
||||
* array( 'group_id' => <群組ID>,
|
||||
* 'name' => <群組顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'auth_admin' => <Server端管理權>,
|
||||
* 'auth_clientAdmin' => <Client端管理權>
|
||||
* );
|
||||
*
|
||||
*/
|
||||
public function insertGroup($gId, $name, $memo, $auth_admin, $auth_clientAdmin) {
|
||||
public function insertGroup($array) {
|
||||
|
||||
// TODO: 不填以下欄位也能進行操作
|
||||
if( !isset($array['name']) ){
|
||||
$array['name'] = null;
|
||||
}
|
||||
if( !isset($array['memo']) ){
|
||||
$array['memo'] = null;
|
||||
}
|
||||
if( !isset($array['auth_admin']) ){
|
||||
$array['auth_admin'] = null;
|
||||
}
|
||||
if( !isset($array['auth_clientAdmin']) ){
|
||||
$array['auth_clientAdmin'] = null;
|
||||
}
|
||||
|
||||
|
||||
$gId = $array['group_id'];
|
||||
$name = $array['name'];
|
||||
$memo = $array['memo'];
|
||||
$auth_admin = $array['auth_admin'];
|
||||
$auth_clientAdmin = $array['auth_clientAdmin'];
|
||||
|
||||
// 紀錄使用者帳號進資料庫
|
||||
$sqlString = "INSERT INTO ".$this->table('AGroup').
|
||||
" (`GID`, `GName`, `GMemo`, `GBuild_Time`, `GAuth_Admin`, `GAuth_ClientAdmin`)
|
||||
VALUES ( :id , :name, :memo , NOW(), :auth_admin , :auth_clientAdmin )";
|
||||
" (`GID`, `GName`, `GMemo`, `GAuth_Admin`, `GAuth_ClientAdmin`)
|
||||
VALUES ( :id , :name, :memo , :auth_admin , :auth_clientAdmin )";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(":id", $gId);
|
||||
@ -354,14 +420,66 @@ class DBUser extends Database {
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 內部使用的查詢動作
|
||||
* @param string $where 查詢語法
|
||||
* @return array 查詢結果陣列
|
||||
*/
|
||||
protected function queryGroupByWhere($where) {
|
||||
$sqlString = "SELECT * FROM ".$this->table('AGroup').
|
||||
" WHERE ".$where;
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
// 轉換成boolean
|
||||
if($thisResult['GAuth_Admin'] != '0') {
|
||||
$output_auth_admin = true;
|
||||
} else { $output_auth_admin = false; }
|
||||
|
||||
if($thisResult['GAuth_ClientAdmin'] != '0') {
|
||||
$output_auth_clientAdmin = true;
|
||||
} else { $output_auth_clientAdmin = false; }
|
||||
|
||||
// 製作回傳結果陣列
|
||||
array_push($result,
|
||||
array('group_id' => $thisResult['GID'],
|
||||
'name' => $thisResult['GName'],
|
||||
'memo' => $thisResult['GMemo'],
|
||||
'build_time' => $thisResult['GBuildTime'],
|
||||
'modify_time' => $thisResult['GModifyTime'],
|
||||
'auth_admin' => $output_auth_admin,
|
||||
'auth_clientAdmin' => $output_auth_clientAdmin)
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢一個使用者群組資料
|
||||
*
|
||||
* @param string $gId 群組ID
|
||||
* @return array 使用者群組資料陣列,格式為:
|
||||
*
|
||||
* array( 'group_id' => <群組ID>,
|
||||
* 'name' => <群組顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'build_time' => <建立時間>,
|
||||
* 'modify_time' => <修改時間>,
|
||||
* 'auth_admin' => <Server端管理權>,
|
||||
* 'auth_clientAdmin' => <Client端管理權>
|
||||
* );
|
||||
@ -369,36 +487,11 @@ class DBUser extends Database {
|
||||
*/
|
||||
public function queryGroup($gId) {
|
||||
|
||||
$sqlString = "SELECT * FROM ".$this->table('AGroup').
|
||||
" WHERE `GID` = :gid";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(':gid', $gId);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
$queryResultAll = $this->queryGroupByWhere("`GID`=".$this->connDB->quote($gId));
|
||||
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
$thisResult = $queryResultAll[0];
|
||||
|
||||
// 轉換成boolean
|
||||
if($thisResult['GAuth_Admin'] != '0') {
|
||||
$output_auth_admin = true;
|
||||
} else { $output_auth_admin = false; }
|
||||
|
||||
if($thisResult['GAuth_ClientAdmin'] != '0') {
|
||||
$output_auth_clientAdmin = true;
|
||||
} else { $output_auth_clientAdmin = false; }
|
||||
|
||||
// 製作回傳結果陣列
|
||||
$result = array('group_id' => $thisResult['GID'],
|
||||
'name' => $thisResult['GName'],
|
||||
'memo' => $thisResult['GMemo'],
|
||||
'build_time' => $thisResult['GBuild_Time'],
|
||||
'auth_admin' => $output_auth_admin,
|
||||
'auth_clientAdmin' => $output_auth_clientAdmin
|
||||
);
|
||||
return $result;
|
||||
return $queryResultAll[0];
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
@ -416,6 +509,8 @@ class DBUser extends Database {
|
||||
* 'group_id' => <群組ID>,
|
||||
* 'name' => <群組顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'build_time' => <建立時間>,
|
||||
* 'modify_time' => <修改時間>,
|
||||
* 'auth_admin' => <Server端管理權>,
|
||||
* 'auth_clientAdmin' => <Client端管理權>
|
||||
* )
|
||||
@ -424,43 +519,7 @@ class DBUser extends Database {
|
||||
*/
|
||||
public function queryAllGroup() {
|
||||
|
||||
$sqlString = "SELECT * FROM ".$this->table('AGroup');
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
|
||||
// 轉換成boolean
|
||||
if($thisResult['GAuth_Admin'] != '0') {
|
||||
$output_auth_admin = true;
|
||||
} else { $output_auth_admin = false; }
|
||||
|
||||
if($thisResult['GAuth_ClientAdmin'] != '0') {
|
||||
$output_auth_clientAdmin = true;
|
||||
} else { $output_auth_clientAdmin = false; }
|
||||
|
||||
// 插入一筆資料
|
||||
array_push($result,
|
||||
array( 'group_id' => $thisResult['GID'],
|
||||
'name' => $thisResult['GName'],
|
||||
'memo' => $thisResult['GMemo'],
|
||||
'build_time' => $thisResult['GBuild_Time'],
|
||||
'auth_admin' => $output_auth_admin,
|
||||
'auth_clientAdmin' => $output_auth_clientAdmin)
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return $this->queryGroupByWhere('1');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -476,11 +535,10 @@ class DBUser extends Database {
|
||||
* @param string $value 內容
|
||||
*/
|
||||
public function changeGroupData($gId, $field, $value) {
|
||||
// UPDATE `UElearning`.`chu__User` SET `UMemo` = '測試者' WHERE `chu__User`.`UID` = 'yuan';
|
||||
|
||||
$sqlField = null;
|
||||
switch($field) {
|
||||
case 'group_id': $sqlField = 'UID'; break;
|
||||
case 'group_id': $sqlField = 'GID'; break;
|
||||
case 'name': $sqlField = 'GName'; break;
|
||||
case 'memo': $sqlField = 'GMemo'; break;
|
||||
case 'auth_admin': $sqlField = 'GAuth_Admin'; break;
|
||||
@ -491,6 +549,7 @@ class DBUser extends Database {
|
||||
|
||||
$sqlString = "UPDATE ".$this->table('AGroup').
|
||||
" SET `".$sqlField."` = :value".
|
||||
" , `GModifyTime` = NOW()".
|
||||
" WHERE `GID` = :gid";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
@ -504,17 +563,26 @@ class DBUser extends Database {
|
||||
/**
|
||||
* 插入班級資料
|
||||
*
|
||||
* @param string $cId 班級ID
|
||||
* @param string $name 班級顯示名稱
|
||||
* @param string $memo 備註
|
||||
* @param array $array 班級資料陣列,格式為:
|
||||
*
|
||||
* array( 'class_id' => <班級ID>,
|
||||
* 'name' => <班級顯示名稱>,
|
||||
* 'memo' => <備註>
|
||||
* );
|
||||
*
|
||||
* @return int 剛剛新增的ID
|
||||
*/
|
||||
public function insertClassGroup($cId, $name, $memo) {
|
||||
public function insertClassGroup($array) {
|
||||
|
||||
$cId = $array['class_id'];
|
||||
// TODO: 不填以下欄位也能進行操作
|
||||
$name = $array['name'];
|
||||
$memo = $array['memo'];
|
||||
|
||||
// 紀錄使用者帳號進資料庫
|
||||
$sqlString = "INSERT INTO ".$this->table('CGroup').
|
||||
" (`CID`, `CName`, `CMemo`, `CBuild_Time`)
|
||||
VALUES ( :id , :name, :memo , NOW() )";
|
||||
" (`CID`, `CName`, `CMemo`)
|
||||
VALUES ( :id , :name , :memo )";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(":id", $cId);
|
||||
@ -526,6 +594,8 @@ class DBUser extends Database {
|
||||
$sqlString = "SELECT LAST_INSERT_ID()";
|
||||
$query = $this->connDB->query($sqlString);
|
||||
$queryResult = $query->fetch();
|
||||
|
||||
if(isset($cId)) return $cId;
|
||||
return $queryResult[0];
|
||||
}
|
||||
|
||||
@ -544,42 +614,67 @@ class DBUser extends Database {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢一個班級資料
|
||||
*
|
||||
* @return array 班級資料陣列,格式為:
|
||||
*
|
||||
* array( 'class_id' => <班級ID>,
|
||||
* 'name' => <班級顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'build_time' => <建立時間>
|
||||
* );
|
||||
*
|
||||
* 內部使用的查詢動作
|
||||
* @param string $where 查詢語法
|
||||
* @return array 查詢結果陣列
|
||||
*/
|
||||
public function queryClassGroup($cId) {
|
||||
|
||||
protected function queryClassByWhere($where) {
|
||||
$sqlString = "SELECT * FROM ".$this->table('CGroup').
|
||||
" WHERE `CID` = :cid";
|
||||
" WHERE ".$where;
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->bindParam(':cid', $cId);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
$thisResult = $queryResultAll[0];
|
||||
// 製作回傳結果陣列
|
||||
$result = array('class_id' => $thisResult['CID'],
|
||||
'name' => $thisResult['CName'],
|
||||
'memo' => $thisResult['CMemo'],
|
||||
'build_time' => $thisResult['CBuild_Time']
|
||||
);
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
array_push($result,
|
||||
array( 'class_id' => $thisResult['CID'],
|
||||
'name' => $thisResult['CName'],
|
||||
'memo' => $thisResult['CMemo'],
|
||||
'build_time' => $thisResult['CBuildTime'],
|
||||
'modify_time' => $thisResult['CModifyTime'])
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查詢一個班級資料
|
||||
*
|
||||
* @param int $cId 班級ID
|
||||
* @return array 班級資料陣列,格式為:
|
||||
*
|
||||
* array( 'class_id' => <班級ID>,
|
||||
* 'name' => <班級顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'build_time' => <建立時間>,
|
||||
* 'modify_time' => <修改時間>
|
||||
* );
|
||||
*
|
||||
*/
|
||||
public function queryClassGroup($cId) {
|
||||
|
||||
$queryResultAll = $this->queryClassByWhere("`CID`=".$this->connDB->quote($cId));
|
||||
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
return $queryResultAll[0];
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -592,37 +687,15 @@ class DBUser extends Database {
|
||||
* 'class_id' => <班級ID>,
|
||||
* 'name' => <班級顯示名稱>,
|
||||
* 'memo' => <備註>,
|
||||
* 'build_time' => <建立時間>
|
||||
* 'build_time' => <建立時間>,
|
||||
* 'modify_time' => <修改時間>
|
||||
* )
|
||||
* );
|
||||
*
|
||||
*/
|
||||
public function queryAllClassGroup() {
|
||||
|
||||
$sqlString = "SELECT * FROM ".$this->table('CGroup');
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
$query->execute();
|
||||
|
||||
$queryResultAll = $query->fetchAll();
|
||||
// 如果有查到一筆以上
|
||||
if( count($queryResultAll) >= 1 ) {
|
||||
// 製作回傳結果陣列
|
||||
$result = array();
|
||||
foreach($queryResultAll as $key => $thisResult) {
|
||||
array_push($result,
|
||||
array( 'class_id' => $thisResult['CID'],
|
||||
'name' => $thisResult['CName'],
|
||||
'memo' => $thisResult['CMemo'],
|
||||
'build_time' => $thisResult['CBuild_Time'])
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
// 若都沒查到的話
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return $this->queryClassByWhere('1');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -650,6 +723,7 @@ class DBUser extends Database {
|
||||
|
||||
$sqlString = "UPDATE ".$this->table('CGroup').
|
||||
" SET `".$sqlField."` = :value".
|
||||
" , `CModifyTime` = NOW()".
|
||||
" WHERE `CID` = :cid";
|
||||
|
||||
$query = $this->connDB->prepare($sqlString);
|
||||
|
@ -58,9 +58,10 @@ class UserAdmin {
|
||||
* 'group_id' => 'user',
|
||||
* 'class_id' => '5-2', // (optional)
|
||||
* 'enable' => true, // (optional) 預設為true
|
||||
* 'learnStyle_mode' => 'harf-line-learn', // (optional)
|
||||
* 'material_mode' => 1, // (optional)
|
||||
* 'nickname' => 'eric', // (optional)
|
||||
* 'learnStyle_mode' => 3, // (optional)
|
||||
* 'material_mode' => 'normal', // (optional)
|
||||
* 'material_mode' => 'normal', // (optional)
|
||||
* 'enable_noAppoint' => true, // (optional)
|
||||
* 'realname' => 'Eric Chiu', // (optional)
|
||||
* 'email' => 'eric@example.tw', // (optional)
|
||||
* 'memo' => '' ) // (optional)
|
||||
@ -99,6 +100,9 @@ class UserAdmin {
|
||||
if( !isset($userInfoArray['material_mode']) ){
|
||||
$userInfoArray['material_mode'] = null;
|
||||
}
|
||||
if( !isset($userInfoArray['enable_noAppoint']) ){
|
||||
$userInfoArray['enable_noAppoint'] = null;
|
||||
}
|
||||
if( !isset($userInfoArray['nickname']) ){
|
||||
$userInfoArray['nickname'] = null;
|
||||
}
|
||||
@ -119,18 +123,22 @@ class UserAdmin {
|
||||
// 新增一筆使用者資料進資料庫
|
||||
$db = new Database\DBUser();
|
||||
$db->insertUser(
|
||||
$userInfoArray['user_id'],
|
||||
$passwdEncrypted,
|
||||
$userInfoArray['group_id'],
|
||||
$userInfoArray['class_id'],
|
||||
$userInfoArray['enable'],
|
||||
$userInfoArray['learnStyle_mode'],
|
||||
$userInfoArray['material_mode'],
|
||||
$userInfoArray['nickname'],
|
||||
$userInfoArray['realname'],
|
||||
$userInfoArray['email'],
|
||||
$userInfoArray['memo']
|
||||
array(
|
||||
'user_id' => $userInfoArray['user_id'],
|
||||
'password' => $passwdEncrypted,
|
||||
'group_id' => $userInfoArray['group_id'],
|
||||
'class_id' => $userInfoArray['class_id'],
|
||||
'enable' => $userInfoArray['enable'],
|
||||
'learnStyle_mode' => $userInfoArray['learnStyle_mode'],
|
||||
'material_mode' => $userInfoArray['material_mode'],
|
||||
'enable_noAppoint' => $userInfoArray['enable_noAppoint'],
|
||||
'nickname' => $userInfoArray['nickname'],
|
||||
'realname' => $userInfoArray['realname'],
|
||||
'email' => $userInfoArray['email'],
|
||||
'memo' => $userInfoArray['memo']
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
else throw Exception\NoDataException();
|
||||
|
@ -86,11 +86,12 @@ class UserGroupAdmin {
|
||||
// 新增一筆使用者資料進資料庫
|
||||
$db = new Database\DBUser();
|
||||
$db->insertGroup(
|
||||
$groupArray['group_id'],
|
||||
$groupArray['name'],
|
||||
$groupArray['memo'],
|
||||
$groupArray['auth_server_admin'],
|
||||
$groupArray['auth_client_admin']
|
||||
array( 'group_id' => $groupArray['group_id'],
|
||||
'name' => $groupArray['name'],
|
||||
'memo' => $groupArray['memo'],
|
||||
'auth_admin' => $groupArray['auth_server_admin'],
|
||||
'auth_clientAdmin' => $groupArray['auth_client_admin']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- 主機: localhost
|
||||
-- 產生時間: 2014 年 10 月 14 日 18:01
|
||||
-- 產生時間: 2014 年 10 月 23 日 22:19
|
||||
-- 伺服器版本: 5.6.16
|
||||
-- PHP 版本: 5.5.9
|
||||
|
||||
@ -30,7 +30,8 @@ CREATE TABLE IF NOT EXISTS `chu__AGroup` (
|
||||
`GID` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`GName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`GMemo` tinytext COLLATE utf8_unicode_ci,
|
||||
`GBuild_Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`GBuildTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`GModifyTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '權限群組資訊修改時間',
|
||||
`GAuth_Admin` tinyint(1) NOT NULL,
|
||||
`GAuth_ClientAdmin` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`GID`)
|
||||
@ -40,10 +41,11 @@ CREATE TABLE IF NOT EXISTS `chu__AGroup` (
|
||||
-- 資料表的匯出資料 `chu__AGroup`
|
||||
--
|
||||
|
||||
INSERT INTO `chu__AGroup` (`GID`, `GName`, `GMemo`, `GBuild_Time`, `GAuth_Admin`, `GAuth_ClientAdmin`) VALUES
|
||||
('admin', '管理員', NULL, '2014-10-07 08:38:03', 0, 0),
|
||||
('student', '學生', NULL, '2014-10-07 08:38:03', 0, 0),
|
||||
('teacher', '老師', NULL, '2014-10-07 08:38:03', 0, 0);
|
||||
INSERT INTO `chu__AGroup` (`GID`, `GName`, `GMemo`, `GBuildTime`, `GModifyTime`, `GAuth_Admin`, `GAuth_ClientAdmin`) VALUES
|
||||
('admin', '管理員', NULL, '2014-10-07 08:38:03', '2014-10-23 05:33:32', 0, 0),
|
||||
('student', '學生', NULL, '2014-10-07 08:38:03', '2014-10-23 05:33:32', 0, 0),
|
||||
('teacher', '老師', NULL, '2014-10-07 08:38:03', '2014-10-23 05:33:32', 0, 0),
|
||||
('user', '一般使用者', NULL, '2014-10-23 20:14:52', '2014-10-23 20:14:52', 0, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -51,13 +53,6 @@ INSERT INTO `chu__AGroup` (`GID`, `GName`, `GMemo`, `GBuild_Time`, `GAuth_Admin`
|
||||
-- 替換檢視表以便查看 `chu__AGroup_with_people`
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `chu__AGroup_with_people` (
|
||||
`GID` varchar(30)
|
||||
,`GName` varchar(100)
|
||||
,`in_user` bigint(21)
|
||||
,`GMemo` tinytext
|
||||
,`GBuild_Time` timestamp
|
||||
,`GAuth_Admin` tinyint(1)
|
||||
,`GAuth_ClientAdmin` tinyint(1)
|
||||
);
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -106,7 +101,8 @@ CREATE TABLE IF NOT EXISTS `chu__CGroup` (
|
||||
`CID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`CName` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`CMemo` tinytext COLLATE utf8_unicode_ci,
|
||||
`CBuild_Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`CBuildTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`CModifyTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`CID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='使用者班級分類' AUTO_INCREMENT=1 ;
|
||||
|
||||
@ -116,11 +112,6 @@ CREATE TABLE IF NOT EXISTS `chu__CGroup` (
|
||||
-- 替換檢視表以便查看 `chu__CGroup_with_people`
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `chu__CGroup_with_people` (
|
||||
`CID` int(11)
|
||||
,`CName` varchar(100)
|
||||
,`in_user` bigint(21)
|
||||
,`CMemo` tinytext
|
||||
,`CBuild_Time` timestamp
|
||||
);
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -1073,7 +1064,7 @@ CREATE TABLE IF NOT EXISTS `chu__Material` (
|
||||
`MID` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '教材內部編號',
|
||||
`TID` int(10) unsigned NOT NULL COMMENT '標的內部編號',
|
||||
`MEntity` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否為實體教材',
|
||||
`MMode` enum('normal') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'normal' COMMENT '教材模式',
|
||||
`MMode` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'normal' COMMENT '教材模式',
|
||||
`MUrl` varchar(1000) COLLATE utf8_unicode_ci NOT NULL COMMENT '教材檔案路徑',
|
||||
PRIMARY KEY (`MID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='教材' AUTO_INCREMENT=31 ;
|
||||
@ -1116,6 +1107,25 @@ INSERT INTO `chu__Material` (`MID`, `TID`, `MEntity`, `MMode`, `MUrl`) VALUES
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 資料表結構 `chu__MaterialKind`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `chu__MaterialKind` (
|
||||
`MkID` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`MkName` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`MkID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- 資料表的匯出資料 `chu__MaterialKind`
|
||||
--
|
||||
|
||||
INSERT INTO `chu__MaterialKind` (`MkID`, `MkName`) VALUES
|
||||
('normal', '一般教材');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 資料表結構 `chu__Recommand`
|
||||
--
|
||||
@ -1134,10 +1144,9 @@ CREATE TABLE IF NOT EXISTS `chu__Recommand` (
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `chu__Study` (
|
||||
`SID` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`TID` int(10) NOT NULL COMMENT '標的內部編號',
|
||||
`UID` int(30) NOT NULL COMMENT '使用者名稱',
|
||||
`LMode` int(11) NOT NULL COMMENT '學習導引模式',
|
||||
`MMode` int(11) NOT NULL COMMENT '教材模式',
|
||||
`SaID` int(10) NOT NULL,
|
||||
`UID` int(30) NOT NULL,
|
||||
`TID` int(10) NOT NULL COMMENT '標的編號',
|
||||
`In_TargetTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '進入標的時間',
|
||||
`Out_TargetTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '離開標的時間',
|
||||
PRIMARY KEY (`SID`)
|
||||
@ -1150,10 +1159,13 @@ CREATE TABLE IF NOT EXISTS `chu__Study` (
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `chu__StudyActivity` (
|
||||
`SaID` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`SaID` int(10) NOT NULL AUTO_INCREMENT COMMENT '學習活動流水編號',
|
||||
`UID` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`ThID` int(10) NOT NULL COMMENT '主題編號',
|
||||
`CID` int(11) NOT NULL COMMENT '班級名稱',
|
||||
`StartTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '開始時間',
|
||||
`StartTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`LMode` int(2) NOT NULL DEFAULT '1' COMMENT '學習導引模式',
|
||||
`MMode` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT '教材模式',
|
||||
`LearnTime` int(4) NOT NULL,
|
||||
`Delay` int(11) NOT NULL DEFAULT '0' COMMENT '實際狀態延誤(分)',
|
||||
PRIMARY KEY (`SaID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='學習活動' AUTO_INCREMENT=1 ;
|
||||
@ -1174,6 +1186,28 @@ CREATE TABLE IF NOT EXISTS `chu__StudyQuestion` (
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 資料表結構 `chu__StudyWill`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `chu__StudyWill` (
|
||||
`SwID` int(10) NOT NULL AUTO_INCREMENT COMMENT '預約學習活動流水編號',
|
||||
`UID` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`ThID` int(10) NOT NULL COMMENT '主題編號',
|
||||
`StartTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '預約生效時間',
|
||||
`ExpiredTime` int(11) NOT NULL COMMENT '過期時間',
|
||||
`LMode` int(2) NOT NULL DEFAULT '1' COMMENT '學習導引模式',
|
||||
`MMode` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT '教材模式',
|
||||
`LearnTime` int(4) NOT NULL COMMENT '學習總時間',
|
||||
`Delay` int(11) NOT NULL DEFAULT '0' COMMENT '實際狀態延誤(分)',
|
||||
`Lock` tinyint(1) NOT NULL DEFAULT '1' COMMENT '鎖定不讓學生更改',
|
||||
`BuildTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`ModifyTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`SwID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='預約學習活動' AUTO_INCREMENT=1 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- 資料表結構 `chu__Target`
|
||||
--
|
||||
@ -1299,8 +1333,10 @@ INSERT INTO `chu__TBelong` (`ThID`, `TID`, `Weights`) VALUES
|
||||
CREATE TABLE IF NOT EXISTS `chu__Theme` (
|
||||
`ThID` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`ThName` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '主題名稱',
|
||||
`ThLearnTotal` int(4) NOT NULL COMMENT '學習此主題要花的總時間(m)',
|
||||
`ThLearnTime` int(4) NOT NULL COMMENT '學習此主題要花的總時間(m)',
|
||||
`ThIntroduction` tinytext COLLATE utf8_unicode_ci COMMENT '介紹',
|
||||
`ThBuildTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`ThModifyTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`ThID`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='主題' AUTO_INCREMENT=2 ;
|
||||
|
||||
@ -1308,8 +1344,8 @@ CREATE TABLE IF NOT EXISTS `chu__Theme` (
|
||||
-- 資料表的匯出資料 `chu__Theme`
|
||||
--
|
||||
|
||||
INSERT INTO `chu__Theme` (`ThID`, `ThName`, `ThLearnTotal`, `ThIntroduction`) VALUES
|
||||
(1, '生命科學', 40, NULL);
|
||||
INSERT INTO `chu__Theme` (`ThID`, `ThName`, `ThLearnTime`, `ThIntroduction`, `ThBuildTime`, `ThModifyTime`) VALUES
|
||||
(1, '生命科學', 40, NULL, '2014-10-23 09:21:03', '2014-10-23 09:21:03');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -1323,11 +1359,13 @@ CREATE TABLE IF NOT EXISTS `chu__User` (
|
||||
`GID` varchar(30) COLLATE utf8_unicode_ci NOT NULL COMMENT '使用者群組',
|
||||
`CID` int(11) DEFAULT NULL COMMENT '使用者班級',
|
||||
`UEnabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '帳號啟用狀態',
|
||||
`UBuild_Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '帳號建立時間',
|
||||
`LMode` enum('line-learn','harf-line-learn','non-line-learn') COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '學習導引模式',
|
||||
`MMode` int(11) DEFAULT NULL COMMENT '教材模式',
|
||||
`UBuildTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '帳號建立時間',
|
||||
`UModifyTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '帳號資訊修改時間',
|
||||
`LMode` int(2) DEFAULT NULL COMMENT '學習導引模式',
|
||||
`MMode` varchar(10) COLLATE utf8_unicode_ci DEFAULT 'normal' COMMENT '教材模式',
|
||||
`UEnable_NoAppoint` tinyint(1) NOT NULL DEFAULT '1' COMMENT '開放非預約學習',
|
||||
`UNickname` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '暱稱',
|
||||
`UReal_Name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '真實姓名',
|
||||
`URealName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '真實姓名',
|
||||
`UEmail` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '使用者email',
|
||||
`UMemo` tinytext COLLATE utf8_unicode_ci COMMENT '備註',
|
||||
PRIMARY KEY (`UID`)
|
||||
@ -1356,8 +1394,7 @@ CREATE TABLE IF NOT EXISTS `chu__UserSession` (
|
||||
-- 檢視表結構 `chu__AGroup_with_people`
|
||||
--
|
||||
DROP TABLE IF EXISTS `chu__AGroup_with_people`;
|
||||
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=`yuan`@`localhost` SQL SECURITY DEFINER VIEW `chu__AGroup_with_people` AS select `group`.`GID` AS `GID`,`group`.`GName` AS `GName`,(select count(`user`.`GID`) from `chu__User` `user` where (`user`.`GID` = `group`.`GID`)) AS `in_user`,`group`.`GMemo` AS `GMemo`,`group`.`GBuild_Time` AS `GBuild_Time`,`group`.`GAuth_Admin` AS `GAuth_Admin`,`group`.`GAuth_ClientAdmin` AS `GAuth_ClientAdmin` from `chu__AGroup` `group` where 1;
|
||||
-- 使用中(#1356 - View 'UElearning.chu__AGroup_with_people' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them)
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -1365,8 +1402,7 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`yuan`@`localhost` SQL SECURITY DEFINER VIEW
|
||||
-- 檢視表結構 `chu__CGroup_with_people`
|
||||
--
|
||||
DROP TABLE IF EXISTS `chu__CGroup_with_people`;
|
||||
|
||||
CREATE ALGORITHM=UNDEFINED DEFINER=`yuan`@`localhost` SQL SECURITY DEFINER VIEW `chu__CGroup_with_people` AS select `group`.`CID` AS `CID`,`group`.`CName` AS `CName`,(select count(`user`.`CID`) from `chu__User` `user` where (`user`.`CID` = `group`.`CID`)) AS `in_user`,`group`.`CMemo` AS `CMemo`,`group`.`CBuild_Time` AS `CBuild_Time` from `chu__CGroup` `group` where 1;
|
||||
-- 使用中(#1356 - View 'UElearning.chu__CGroup_with_people' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them)
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
@ -35,12 +35,25 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testCreateUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enPublic,
|
||||
$nickName, $realName, $email, $memo){
|
||||
|
||||
$this->db->insertUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$nickName, $realName, $email, $memo);
|
||||
$this->db->insertUser(
|
||||
array(
|
||||
'user_id' => $uId,
|
||||
'password' => $uPassword,
|
||||
'group_id' => $gId,
|
||||
'class_id' => $cId,
|
||||
'enable' => $enable,
|
||||
'learnStyle_mode' => $l_mode,
|
||||
'material_mode' => $m_mode,
|
||||
'enable_noAppoint' => $enPublic,
|
||||
'nickname' => $nickName,
|
||||
'realname' => $realName,
|
||||
'email' => $email,
|
||||
'memo' => $memo
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +62,7 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testQueryUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enPublic,
|
||||
$nickName, $realName, $email, $memo){
|
||||
|
||||
// 查詢使用者
|
||||
@ -63,6 +76,7 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($info['enable'], $enable);
|
||||
$this->assertEquals($info['learnStyle_mode'], $l_mode);
|
||||
$this->assertEquals($info['material_mode'], $m_mode);
|
||||
$this->assertEquals($info['enable_noAppoint'],$enPublic);
|
||||
$this->assertEquals($info['nickname'], $nickName);
|
||||
$this->assertEquals($info['realname'], $realName);
|
||||
$this->assertEquals($info['email'], $email);
|
||||
@ -86,7 +100,7 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testChangeUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enPublic,
|
||||
$nickName, $realName, $email, $memo){
|
||||
|
||||
$afterData = 'sfisjojjoij';
|
||||
@ -124,13 +138,18 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
* 測試時要填的資料
|
||||
*/
|
||||
public function userDataProvider(){
|
||||
|
||||
//$uId, $uPassword, $gId, $cId, $enable,
|
||||
//$l_mode, $m_mode, $enPublic,
|
||||
//$nickName, $realName, $email, $memo
|
||||
|
||||
return array(
|
||||
array('yuan_unittest', 'pass123', 'admin', null, true,
|
||||
'harf-line-learn', 1,
|
||||
null, null, true,
|
||||
'元兒~', 'Yuan Chiu', 'chyuaner@gmail.com', null),
|
||||
|
||||
array('eee_unittest', 'qqqssss', 'admin', null, 0,
|
||||
'harf-line-learn', '1',
|
||||
0, 'normal', false,
|
||||
'sss', 'Yuan Chiu', 'chyuanesr@gmail.com', null)
|
||||
);
|
||||
}
|
||||
@ -144,7 +163,14 @@ class DBUserTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testCreateGroup($gId, $name, $memo, $auth_admin, $auth_clientAdmin){
|
||||
|
||||
$this->db->insertGroup($gId, $name, $memo, $auth_admin, $auth_clientAdmin);
|
||||
$this->db->insertGroup(
|
||||
array( 'group_id' => $gId,
|
||||
'name' => $name,
|
||||
'memo' => $memo,
|
||||
'auth_admin' => $auth_admin,
|
||||
'auth_clientAdmin' => $auth_clientAdmin
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class UserAdminTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testCreateUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enable_noAppoint,
|
||||
$nickName, $realName, $email, $memo)
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ class UserAdminTest extends \PHPUnit_Framework_TestCase
|
||||
// 建立資料庫管理物件
|
||||
$userAdmin = new UserAdmin();
|
||||
|
||||
// TODO: 建立使用者
|
||||
// 建立使用者
|
||||
$userAdmin->create(
|
||||
array( 'user_id' => $uId,
|
||||
'password' => $uPassword,
|
||||
@ -35,7 +35,8 @@ class UserAdminTest extends \PHPUnit_Framework_TestCase
|
||||
'class_id' => $cId,
|
||||
'enable' => $enable,
|
||||
'learnStyle_mode' => $l_mode,
|
||||
'material_mode' => $m_mode,
|
||||
'material_mode' => $m_mode,
|
||||
'enable_noAppoint' => $enable_noAppoint,
|
||||
'nickname' => $nickName,
|
||||
'realname' => $realName,
|
||||
'email' => $email,
|
||||
@ -88,13 +89,13 @@ class UserAdminTest extends \PHPUnit_Framework_TestCase
|
||||
public function userDataProvider(){
|
||||
return array(
|
||||
array('yuan_unittest', 'pass123', 'admin', null, true,
|
||||
'harf-line-learn', 1,
|
||||
3, 'normal', true,
|
||||
'元兒~', 'Yuan Chiu', 'chyuaner@gmail.com', null),
|
||||
|
||||
array('eee_unittest', 'qqqssss', 'admin', null, 1,
|
||||
'harf-line-learn', '1',
|
||||
0, 'normal', false,
|
||||
'sss', 'Yuan Chiu', 'chyuanesr@gmail.com', null)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testCreateUser($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enable_noAppoint,
|
||||
$nickName, $realName, $email, $memo)
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
// 建立資料庫管理物件
|
||||
$userAdmin = new User\UserAdmin();
|
||||
|
||||
// TODO: 建立使用者
|
||||
// 建立使用者
|
||||
$userAdmin->create(
|
||||
array( 'user_id' => $uId,
|
||||
'password' => $uPassword,
|
||||
@ -35,7 +35,8 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
'class_id' => $cId,
|
||||
'enable' => $enable,
|
||||
'learnStyle_mode' => $l_mode,
|
||||
'material_mode' => $m_mode,
|
||||
'material_mode' => $m_mode,
|
||||
'enable_noAppoint' => $enable_noAppoint,
|
||||
'nickname' => $nickName,
|
||||
'realname' => $realName,
|
||||
'email' => $email,
|
||||
@ -54,7 +55,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testGetInfo($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enable_noAppoint,
|
||||
$nickName, $realName, $email, $memo)
|
||||
{
|
||||
try {
|
||||
@ -82,7 +83,7 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
* @dataProvider userDataProvider
|
||||
*/
|
||||
public function testSetInfo($uId, $uPassword, $gId, $cId, $enable,
|
||||
$l_mode, $m_mode,
|
||||
$l_mode, $m_mode, $enable_noAppoint,
|
||||
$nickName, $realName, $email, $memo)
|
||||
{
|
||||
try {
|
||||
@ -140,13 +141,13 @@ class UserTest extends \PHPUnit_Framework_TestCase
|
||||
public function userDataProvider(){
|
||||
return array(
|
||||
array('yuan_unittest', 'pass123', 'admin', null, true,
|
||||
'harf-line-learn', 1,
|
||||
3, 'normal', true,
|
||||
'元兒~', 'Yuan Chiu', 'chyuaner@gmail.com', null),
|
||||
|
||||
array('eee_unittest', 'qqqssss', 'admin', null, 1,
|
||||
'harf-line-learn', '1',
|
||||
0, 'normal', false,
|
||||
'sss', 'Yuan Chiu', 'chyuanesr@gmail.com', null)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user