Viewing file: my_controller.php (5.27 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
* System in Educational Enterprise Resource Planning System
*
* LICENSE
*
* This source file is subject to the GPL license that is bundled
* with this package in the file alumni_licence.php
*
* @package System in Educational Enterprise Resource Planning System
* @subpackage Alumni System
* @copyright Copyright (C) 2011 by Information System Engineering Research Labolatory, Burapha University
http://iserl.buu.ac.th
iserl.callcenter@gmail.com
* @license http://cvs.buu.ac.th/mis/alumni_licence.php GNU GPL v1
* @author Information System Engineering Research Labolatory, Burapha University
*
*
*/
class My_controller extends CI_Controller {
public $body;
public $mmn;
public function __construct()
{
parent::__construct();
$this->load->library('session');
$this->body = '';
}
function setCRUD($UsID,$gpid,$mnid){
$this->load->model('ums/m_umpermission','');
$this->load->model('ums/m_umgpermission','');
$X = 1;
$C = 1;
$R = 1;
$U = 1;
$D = 1;
$oUp = $this->m_umpermission->SearchByKey($UsID, $mnid);
if ($oUp){
$X = $oUp['pmX'];
$C = $oUp['pmC'];
$R = $oUp['pmR'];
$U = $oUp['pmU'];
$D = $oUp['pmD'];
} else {
$oGp = $this->m_umgpermission->SearchByKey($gpid, $mnid);
if ($oGp){
$X = $oGp['gpX'];
$C = $oGp['gpC'];
$R = $oGp['gpR'];
$U = $oGp['gpU'];
$D = $oGp['gpD'];
}
}
$data = array( 'X' => $X,
'C' => $C,
'R' => $R,
'U' => $U,
'D' => $D);
$this->session->set_userdata($data);
return 0;
}
function show() {
$UsID = $this->session->userdata('UsID');
$gpid = $this->session->userdata('GpID');
$stid = $this->session->userdata('StID');
$mnid = $this->session->userdata('MnID');
if($this->session->userdata('MnID')){
$this->setCRUD($UsID,$gpid,$mnid);
}
if($this->session->userdata('logged_in')){
$data ='';
if($this->session->userdata('StID')){
$this->load->model('ums/m_ummenu','');
$data['mmn']= $this->m_ummenu->RSByStIDGpIDUsIDPrIDLv($stid,$gpid,$UsID,0,0);
if($this->session->userdata('MnID')){
$data['history'] = $this->menuHistory($this->session->userdata('MnID'));
}
}
$mn['menu'] = $this->load->view('info/v_postlogin',$data,true);
$lv['body'] = $this->body;
$lv['blog'] = (isset($this->blog)) ? $this->blog : '';
}else{
$mn['menu'] = $this->load->view('info/v_prelogin','',true);
$lv['body'] = $this->load->view('info/v_info','',true);
}
$lv['head'] = $this->load->view('info/v_header',$mn,true);
$lv['footer'] = $this->load->view('info/v_footer','',true);
$this->load->view('info/v_in',$lv);
}
function showPopup() {
$mn = '';
$lv['head'] = $this->load->view('info/v_headerPopup',$mn,true);
$lv['body'] = $this->body;
$lv['footer'] = $this->load->view('info/v_footerPopup','',true);;
$this->load->view('info/v_in',$lv);
}
function genMn(){
$stid = $this->session->userdata('StID');
$gpid = $this->session->userdata('GpID');
$UsID = $this->session->userdata('UsID');
$this->load->model('ums/m_ummenu','');
$rs = $this->m_ummenu->RSByStIDGpIDUsIDPrIDLv($stid,$gpid,$UsID,0,0);
return $rs;
}
function menuHistory($MnID){
$his = "";
$this->load->model('ums/m_ummenu','m1');
$qry = $this->m1->getByKey($MnID);
$rs = $qry->row();
if($rs->MnParentMnID>0){
$ret = $this->menuHistory($rs->MnParentMnID);
//$img = "<img src=\"".base_url()."images/submenu_mini.gif\" align='absmiddle' border='0'> ";
$img = ' » ';
if($rs->MnURL != '')
$his.=$ret.$img."<span onclick=\"doSubmitMn(".$rs->MnStID.",".$rs->MnID.")\" onmouseover=\"this.style.cursor='pointer';this.style.color = '#0066FF';\" onmouseout=\"this.style.color = '#000000';\">".$rs->MnNameT."</span>";
// $his.=$ret." $img <a href=\" ".site_url()."info/info/submenu/$rs->MnStID/$rs->MnID\">$rs->MnNameT</a>";
else
$his.=$ret." $img $rs->MnNameT";
//$his.=$ret." $img <a href=\" ".site_url()."info/info/submenu/$rs->MnStID/$rs->MnID\">$rs->MnNameT</a>";
}else{
$img = "<img src=\"".base_url()."images/sysgrp_mini.gif\" align='absmiddle' border='0'> ";
// $his = "$img <a href=\" ".site_url()."info/info/submenu/$rs->MnStID/$rs->MnID\">$rs->MnNameT</a> ";
$his.=$img." <span onclick=\"doSubmitMn(".$rs->MnStID.",".$rs->MnID.")\" onmouseover=\"this.style.cursor='pointer';this.style.color = '#0066FF';\" onmouseout=\"this.style.color = '#000000';\">".$rs->MnNameT."</span>";
}
return $his;
}
function loginByPsId ($stid="", $gpid="", $ps_id="") {
$this->load->model('ums/m_umuser','obj');
$rs = $this->obj->checkUserByPsId($ps_id);
if ($rs) {
$data = array('UsID' => $rs['UsID'],
'UsName' => $rs['UsName'],
'UsLogin' => $rs['UsLogin'],
'UsPsCode' => $rs['UsPsCode'],
'UsWgID' => $rs['UsWgID'],
'logged_in' => TRUE);
$this->session->set_userdata($data);
redirect('/info/info/mainMenu/'.$stid.'/'.$gpid);
} else {
$this->session->set_flashdata('message', '<div id="message" align="center"><font color="red">ชื่อเข้าใช้งานหรือรหัสผ่านผิดพลาด</font></div>');
redirect('info/info');
}
}
}
?>
|