c = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']); $this->aGp=array('00'=>array(0,0,0,0,0)); $this->aUp=array('00'=>array(0,0,0,0,0)); } function getLoginName(){ return $this->userLogin; } function getUserIP(){ return $this->userIP; } function getName(){ return $this->userName; } function getDptCode(){ return $this->userDptCode; } function getDptName(){ return $this->userDptName; } function checkAA(){ return true; } function isExpire(){ return false; } function isActive(){ return $this->active; } function getKeyUP(){ return $this->userID.$this->MnID; } function getKeyGP(){ return $this->GpID.$this->MnID; } function GetRightsByMenu(){ global $oU; if (array_key_exists($this->getKeyUP(), $this->aUp)){ //echo "found in user permission."; $this->X=$this->aUp[$this->getKeyUP()][0]; $this->C=$this->aUp[$this->getKeyUP()][1]; $this->R=$this->aUp[$this->getKeyUP()][2]; $this->U=$this->aUp[$this->getKeyUP()][3]; $this->D=$this->aUp[$this->getKeyUP()][4]; }elseif (array_key_exists($this->getKeyGP(),$this->aGp)){ //echo "found in group permission."; $this->X=$this->aGp[$this->getKeyGP()][0]; $this->C=$this->aGp[$this->getKeyGP()][1]; $this->R=$this->aGp[$this->getKeyGP()][2]; $this->U=$this->aGp[$this->getKeyGP()][3]; $this->D=$this->aGp[$this->getKeyGP()][4]; }else{ //echo "get all permissions."; $this->X=1; $this->C=1; $this->R=1; $this->U=1; $this->D=1; } //ขาดส่วนบันทึกลง log } function CRUD($link, $linktype){ $linktype=strtolower($linktype); if (strpos("crud",$linktype)===false) die("ชนิดของ Link ต้องเป็น CRUD เท่านั้น"); $flg = false; if ($linktype=="c" and $this->C==0) $flg=true; elseif ($linktype=="r" and $this->R==0) $flg=true; elseif ($linktype=="u" and $this->U==0) $flg=true; elseif ($linktype=="d" and $this->D==0) $flg=true; if ($flg==false){ return $link; }else{ $link=trim($link); $s = strtolower($link); //---------------------------------------------------------------- //find image name // $input="images/del.gif"; // $output = "images/delgrey.gif"; // use explode fn // $this->createGreyFromGifJpg($input, $output); //--------------------------------------------------------------- //rename imagename.gif to imagenamegrey.gif $pGif = strpos($s,".gif"); if ($pGif===false){ }else{ $ss = substr_replace($link, "grey", $pGif).substr($link, $pGif); $link = $ss; $s = strtolower($link); } //rename imagename.jpg to imagenamegrey.jpg $pJpg = strpos($s,".jp"); if ($pJpg===false){ }else{ $ss = substr_replace($link, "grey", $pJpg).substr($link, $pJpg); $link = $ss; $s = strtolower($link); } //add disabled to input tag $pos = strpos($s,"input"); if ($pos===false){ }else{ $ss = substr_replace($link, "input disabled", $pos).substr($link, $pos+5); $link = $ss; $s = strtolower($link); } //change onclick-->onklick $pOnClick = strpos($s,"onclick"); if ($pOnClick===false){ }else{ $ss = substr_replace($link, "onklick", $pOnClick).substr($link, $pOnClick+7); $link = $ss; $s = strtolower($link); } //////////// //disable tag A $pHref = strpos($s,"href"); if ($pHref===false){ }else{ $ss = substr_replace($link, "href1", $pHref).substr($link, $pHref+4); $link = $ss; $s = strtolower($link); } //disable text between tag A and not have tag img $pImg = strpos($s,""); $p2 = strpos($link,"".substr($link, $p1+1,$p2).""; $link = $ss; $s = strtolower($link); } } return $link; } } /////////////////// function addNewUser($UsID, $UsName, $UsWgID, $UsStID=-1, $UsLogin="", $UsPassword="", $UsActive=1, $UsAdmin=0){ //used in import module //UsID บุคลากรใช้ personID, นิสิตใช้ รหัสนิสิต //UsLogin = personCode, studentCode //รหัสบุคลากร/รหัสนักศึกษา, ชื่อ, กลุ่มงาน, ระบบงาน, ชื่อล๊อกอิน, รหัสผ่าน, active, admin //กลุ่มงาน:: 1 ผู้ดูแลระบบ, 2 ผู้บริหารระดับสูง, 3 ผู้บริหาร, 4 เจ้าหน้าที่ทุกฝ่าย, 5 อาจารย์(ไม่ได้ใช้), 6 นักศึกษา //ระบบงาน:: -1 ไม่ระบุ, 7 ทะเบียน, 4 บุคลากร, 2 e-office, 3 กำกับงบ, 5, 6, 7, 8, 9, 10, ... include_once("global.php"); include_once("../class/clsConnection.php"); include_once("clsUmUser.php"); include_once("clsUmUserGroup.php"); $oCu = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']); $oUs = new umuser($oCu); $oUg = new umusergroup($oCu); $oCu->BeginTrans(); $oUs->AddNew(); $oUs->UsPsCode=$UsID; //ถ้าเป็นนิสิตให้เป็น UsID, personID $oUs->UsName=$UsName; $oUs->UsWgID=$UsWgID; //กลุ่มงนต้องกำหนดมาจากหน้า import โดยการ gen if($UsLogin=="") $UsLogin=$UsID; //ถ้าเป็นนิสิตให้เป็น UsID $oUs->UsLogin=$UsLogin; if($UsPassword=="") $UsPassword=$UsID; //ควรจะกำหนดมาจากหน้า import โดยการ gen $oUs->UsPassword=md5("O]O".$UsPassword."O[O"); $oUs->UsActive=$UsActive; $oUs->UsAdmin=$UsAdmin; $oUs->Save(); //////////////////////////////////////////////////// //add usergroup ตามกลุ่มระบบงาน /////////////////////////////////////////////////// //ไม่ระบุกลุ่ม จะให้สิทธิ์เป็นผู้ใช้ทั่วไป if($UsWgID=4 and $UsStID == -1){ $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID=100108; //ผู้ใช้ทั่วไประบบสารบรรณ $oUg->Save(); $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID=40044; //ผู้ใช้ทั่วไประบบบุคลากร $oUg->Save(); $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID=130131; //ผู้ใช้ทั่วไประบบบริการสนับสนุนทั่วไป $oUg->Save(); $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID=130132; //ผู้อนุมัติระบบบริการสนับสนุนทั่วไป $oUg->Save(); $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID=150154; //ผู้ใช้ทั่วไประบบประชุมอิเล็กทรอนิกส์ $oUg->Save(); } //ระบบทะเบียน if ($UsStID==70){ $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; //กำหนดรหัสกลุ่มระบบงาน if ($UsWgID==4) $oUg->UgGpID=70070; //เจ้าหน้าที่ if ($UsWgID==5) $oUg->UgGpID=70071; //อาจารย์ if ($UsWgID==6) $oUg->UgGpID=70072; //นักศึกษา //if ($UsWgID==4) $oUg->UgGpID=70073; //หอพักนักศึกษา //if ($UsWgID==4) $oUg->UgGpID=70074; //หน่วยแจ้งหนี้ $oUg->Save(); } $oCu->CommitTrans(); } function changePassword($UsLogin, $oldPassword, $newPassword){ include_once("clsUmUser.php"); $oUs = new umuser($this->c); $oUs->SearchByLogin($UsLogin, $oldPassword); if ($oUs->GetRecord()){ $oUs->Edit(); $oUs->UsPassword=md5("O]O".$newPassword."O[O"); $oUs->Save(); return 1; }else{ return 0; } } function deleteUser($UsCode, $password){ include_once("clsUmUser.php"); $oUs = new umuser($this->c); $oUs->SearchByLogin($UsCode, $password); if ($oUs->GetRecord()){ $oUs->Delete(); return 1; }else{ return 0; } } function updateGroupDefault(){ include_once("../class/clsConnection.php"); include_once("../class/clsDB.php"); include_once("clsUmUser.php"); include_once("clsUmUserGroup.php"); include_once("clsUmGroupDefault.php"); include_once("global.php"); $oCu = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']); $oUs = new umuser($oCu); $oUg = new umusergroup($oCu); $oGd = new umgroupdefault($oCu); $oCu->BeginTrans(); $oUs->RSumuser(); while($oUs->GetRecord()){ $oGd->RSGroupDefaultByWg($oUs->UsWgID); while($oGd->GetRecord()){ $oUg->SearchByKey($oGd->GdGpID, $oUs->UsID); if(!$oUg->GetRecord()){ $oUg->AddNew(); $oUg->UgUsID=$oUs->UsID; $oUg->UgGpID = $oGd->GdGpID; $oUg->Save(); } } } $oCu->CommitTrans(); } function updateUser(){} function addGroup($personID, $gpID){ include_once("clsUmUserGroup.php"); include_once("clsUmUser.php"); $oUg = new umusergroup($this->c); $oUs = new umuser($this->c); //echo "gpID = $gpID
"; //echo "personID = $personID
"; $oUs->SearchByPersonID($personID); if ($oUs->GetRecord()){ //echo "usID = $oUs->UsID
"; $oUg->SearchByKey($gpID, $oUs->UsID); if (!$oUg->GetRecord()){ $oUg->AddNew(); $oUg->UgGpID=$gpID; $oUg->UgUsID=$oUs->UsID; $oUg->Save(); return 1; }else{ return 0; } } } function delGroup($personID, $gpID){ include_once("clsUmUserGroup.php"); include_once("clsUmUser.php"); $oUg = new umusergroup($this->c); $oUs = new umuser($this->c); $oUs->SearchByPersonID($personID); if ($oUs->GetRecord()){ $oUg->SearchByKey($gpID,$oUs->UsID); if ($oUg->GetRecord()){ $oUg->Delete(); return 1; }else{ return 0; } } } function SearchByPsCodeAndPasswd($psCode, $passwd){ //include_once("global.php"); //include_once("../class/clsConnection.php"); //include_once("../class/clsDB.php"); include_once("clsUmUser.php"); $oCu = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']); $oUs = new umuser($oCu); $oUs->SearchByPsCode($psCode); if ($oUs->GetRecord() && $oUs->UsPassword==md5("O]O".$passwd."O[O")){ return 1; }else{ return 0; } } } //end class ?>