getName(); * $group->setName('測試用'); * echo $group->getName(); * } * catch (User\Exception\GroupNoFoundException $e) { * echo 'No Found group: '. $e->getGroupId(); * } * * @version 2.0.0 * @package UElearning * @subpackage User */ class UserGroup { /** * 群組ID * @type string */ protected $gId; // ======================================================================== /** * 查詢到此帳號的所有資訊的結果 * * 由 $this->getQuery() 抓取資料表中所有資訊,並放在此陣列裡 * @type array */ protected $queryResultArray; /** * 從資料庫取得此群組查詢 * * @throw UElearning\User\Exception\GroupNoFoundException * @since 2.0.0 */ protected function getQuery(){ // 從資料庫查詢群組 $db = new Database\DBUser(); $groupInfo = $db->queryGroup($this->gId); // 判斷有沒有這個群組 if( $groupInfo != null ) { $this->queryResultArray = $groupInfo; } else throw new Exception\GroupNoFoundException($this->gId); } /** * 從資料庫更新此群組設定 * * @since 2.0.0 */ protected function setUpdate($field, $value){ /// 將新設定寫進資料庫裡 $db = new Database\DBUser(); $db->changeGroupData($this->gId, $field, $value); $this->getQuery(); } // ======================================================================== /** * 建構子 * * @param string $inputGID 群組ID * @since 2.0.0 */ public function __construct($inputGID){ $this->gId = $inputGID; $this->getQuery(); } // ======================================================================== /** * 取得群組ID * * @return string 群組ID * @since 2.0.0 */ public function getID(){ return $this->gId; } // ------------------------------------------------------------------------ /** * 取得帳號建立時間 * * @return string 建立時間 * @since 2.0.0 */ public function getCreateTime(){ return $this->queryResultArray['build_time']; } // ======================================================================== /** * 取得群組顯示名稱 * * @return string 群組名稱 * @since 2.0.0 */ public function getName(){ return $this->queryResultArray['name']; } /** * 設定群組顯示名稱 * * @param string $name 群組名稱 * @since 2.0.0 */ public function setName($name){ // 將新設定寫進資料庫裡 $this->setUpdate('name', $name); } /** * 取得帳號備註資訊 * * @return string 使用者帳號備註資訊 * @since 2.0.0 */ public function getMemo(){ return $this->queryResultArray['memo']; } /** * 修改帳號備註資訊 * * @param string $input 新的帳號備註資訊 * @since 2.0.0 */ public function setMemo($input){ $this->setUpdate('memo', $input); } // ======================================================================== /** * 取得權限清單 * * @return array 權限清單 */ public function getPermissionList() { // TODO: 取得權限清單 } /** * 是否擁有此權限 * * @param string $permissionName 權限名稱 * @return bool 是否擁有 */ public function havePermission($permissionName) { // TODO: 是否擁有此權限 } /** * 設定擁有此權限 * * @param string $permissionName 權限名稱 * @return bool 是否擁有 */ public function setPermission($permissionName, $setBool) { // TODO: 設定擁有此權限 } }