public function editUserTypeAction()
 {
     $user_type_id = $this->getRequest()->getParam('id');
     if (!$user_type_id) {
         $user_type_id = 0;
     }
     $form = new RsvAcl_Form_FrmUserType();
     $db = new RsvAcl_Model_DbTable_DbUserType();
     $rs = $db->getUserTypeInfo('SELECT * FROM rsv_acl_user_type where user_type_id=' . $user_type_id);
     Application_Model_Decorator::setForm($form, $rs);
     $this->view->form = $form;
     $this->view->user_id = $user_type_id;
     $tr = Application_Form_FrmLanguages::getCurrentlanguage();
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         if ($rs[0]['user_type'] == $post['user_type']) {
             Application_Form_FrmMessage::message($tr->translate('ROW_AFFECTED'));
             $db->updateUserType($post, $rs[0]['user_type_id']);
             Application_Form_FrmMessage::redirector('/rsvAcl/user-type/index');
         } else {
             if (!$db->isUserTypeExist($post['user_type'])) {
                 $db->updateUserType($post, $rs[0]['user_type_id']);
                 Application_Form_FrmMessage::message($tr->translate('ROW_AFFECTED'));
                 Application_Form_FrmMessage::redirector('/rsvAcl/user-type/index');
             } else {
                 Application_Form_FrmMessage::message('User had existed already');
             }
         }
     }
 }
Example #2
0
 public function editAction()
 {
     if ($this->getRequest()->getParam('id')) {
         $db = new RsvAcl_Model_DbTable_DbUserType();
         $user_type_id = $this->getRequest()->getParam('id');
         $rs = $db->getUserType($user_type_id);
         $this->view->usertype = $rs;
         $db1 = new Application_Model_DbTable_DbGlobal();
         $allusertype = $db1->getGlobalDb('SELECT user_type_id,user_type FROM rms_acl_user_type WHERE status=1 AND user_type_id <> ' . $user_type_id);
         $options = array('' => 'Please select');
         foreach ($allusertype as $read) {
             $options[$read['user_type_id']] = $read['user_type'];
         }
         $this->view->usertype_list = $options;
     } else {
         Application_Form_FrmMessage::message('User type had not existed');
     }
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         //print_r($rs); exit;
         if ($rs['user_type'] == $post['user_type']) {
             $db->updateUserType($post, $rs['user_type_id']);
             //write log file
             $userLog = new Application_Model_Log();
             $userLog->writeUserLog($user_type_id);
             //End write log file
             //Application_Form_FrmMessage::message('One row affected!');
             Application_Form_FrmMessage::redirector('/rsvacl/usertype/index');
         } else {
             if (!$db->isUserTypeExist($post['user_type'])) {
                 $db->updateUserType($post, $rs['user_type_id']);
                 //write log file
                 $userLog = new Application_Model_Log();
                 $userLog->writeUserLog($user_type_id);
                 //End write log file
                 //Application_Form_FrmMessage::message('One row affected!');
                 Application_Form_FrmMessage::redirector('/rsvacl/usertype/index');
             } else {
                 Application_Form_FrmMessage::message('User had existed already');
             }
         }
     }
 }
 public function editUserAccessAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (!$id) {
         $id = 0;
     }
     $session = new Zend_Session_Namespace('auth');
     $session->user_type_id = $id;
     $session->lock();
     $form = new RsvAcl_Form_FrmUserAccess();
     //echo "it works"; exit;
     $db = new RsvAcl_Model_DbTable_DbUserAccess();
     $sql = "select user_type_id, user_type  from rms_acl_user_type where user_type_id=" . $id;
     $rs = $db->getUserAccessInfo($sql);
     //print_r($rs); exit;
     //Sophen add here
     //to assign project list in view
     $db_acl = new Application_Model_DbTable_DbGlobal();
     $sqlNotParentId = "SELECT user_type_id FROM `rms_acl_user_type` WHERE `parent_id` =" . $id;
     $notParentId = $db_acl->getGlobalDb($sqlNotParentId);
     $usernotparentid = $notParentId[0]['user_type_id'];
     //print $usernotparentid; exit;
     if ($id == 1) {
         $sql_acl = "select acl.acl_id,CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access from rms_acl_acl as acl";
     }
     if (!$usernotparentid) {
         $sql_acl = "SELECT acl.acl_id, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status FROM rms_acl_user_access AS ua \n\t\t\t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.user_type_id)\n\t\t\t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id;
     } else {
         $sql_acl = "SELECT acl.acl_id, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status FROM rms_acl_user_access AS ua \n\t\t\t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\n\t\t\t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id;
     }
     //print $sql_acl; exit;
     $acl_name = $db_acl->getGlobalDb($sql_acl);
     //print_r($acl_name); exit;
     if ($acl_name != '') {
         $form->setAcl($acl_name);
     }
     Application_Model_Decorator::setForm($form, $rs);
     $this->view->form = $form;
     $rows = array();
     for ($i = 1; $i <= $form->getPlus(); $i++) {
         $rows[] = array($i, $form->getElement('acl_id_' . $i)->getLabel(), $form->getElement('acl_id_' . $i));
     }
     $list = new Application_Form_Frmlist();
     $tr = Application_Form_FrmLanguages::getCurrentlanguage();
     $columns = array($tr->translate('URL'), $tr->translate('STATUS'));
     $this->view->form_layout = $list->getCheckList('radio', $columns, $rows);
     $this->view->id = $id;
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         //if($rs[0]['']==$post['username']){
         $db_user = new RsvAcl_Model_DbTable_DbUserType();
         print_r($post);
         exit;
         //print $rs[0]['user_type_id']; exit;
         $db_user->updateUserTypeAccess($post['user_type'], $rs[0]['user_type_id']);
         $db->assignAcl($post, $rs[0]['user_type_id'], $form->getPlus());
         //write log file
         $userLog = new Application_Model_Log();
         $userLog->writeUserLog($id);
         //End write log file
         //Application_Form_FrmMessage::message('One row affected!');
         Application_Form_FrmMessage::redirector('/rmsAcl/user-access/index');
         /*}else{
         			if(!$db->isUserExist($post['username'])){
         				$db->updateUser($post,$rs[0]['user_id']);
         				 //write log file 
         			        //$userLog= new RsvLogging_Model_RsvLogging();
         			    	//$userLog->writeUserLog($user_id);
         			     //End write log file
         				Application_Form_FrmMessage::message('One row affected!');
         				Application_Form_FrmMessage::redirector('/rmsAcl/user/index');						
         			}else {
         				Application_Form_FrmMessage::message('User had existed already');
         			}
         		}*/
     }
 }
Example #4
0
 public function addAction()
 {
     /* Initialize action controller here */
     if ($this->getRequest()->getParam('id')) {
         $id = $this->getRequest()->getParam('id');
         $db = new RsvAcl_Model_DbTable_DbUserType();
         $userAccessQuery = "SELECT user_type_id, user_type, status from rms_acl_user_type where user_type_id=" . $id;
         $rows = $db->getUserTypeInfo($userAccessQuery);
         $this->view->rs = $rows;
         //Add filter search
         $gc = new Application_Model_GlobalClass();
         // For list all module
         $sql = "SELECT DISTINCT acl.`module` FROM `rms_acl_acl` AS acl";
         $this->view->optoin_mod = $gc->getOptonsHtml($sql, "module", "module");
         // For list all controller
         $sql = "SELECT DISTINCT acl.`controller` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1";
         $this->view->optoin_con = $gc->getOptonsHtml($sql, "controller", "controller");
         // For List all action
         $sql = "SELECT DISTINCT acl.`action` FROM `rms_acl_acl` AS acl WHERE acl.`status` = 1";
         $this->view->optoin_act = $gc->getOptonsHtml($sql, "action", "action");
         //For Status enable or disable
         $this->view->optoin_status = $gc->getYesNoOption();
         $where = " ";
         $status = null;
         if ($this->getRequest()->isPost()) {
             $post = $this->getRequest()->getPost();
             if (!empty($post['fmod'])) {
                 $where .= " AND acl.`module` = '" . $post['fmod'] . "' ";
             }
             if (!empty($post['fcon'])) {
                 $where .= " AND acl.`controller` = '" . $post['fcon'] . "' ";
             }
             if (!empty($post['fact'])) {
                 $where .= " AND acl.`action` = '" . $post['fact'] . "' ";
             }
             if (!empty($post['fstatus'])) {
                 $status = $post['fstatus'] === "Yes" ? 1 : 0;
                 //$where .= " AND  acl.`status` = " . $st ;
             }
             //echo $where; exit;
         } else {
             $post = array('fmod' => '', 'fcon' => '', 'fact' => '', 'fstatus' => '');
         }
         $this->view->data = $post;
         //Sophen add here
         //to assign project list in view
         $db_acl = new Application_Model_DbTable_DbGlobal();
         $sqlNotParentId = "SELECT user_type_id FROM `rms_acl_user_type` WHERE `parent_id` =" . $id;
         $notParentId = $db_acl->getGlobalDb($sqlNotParentId);
         $usernotparentid = $notParentId[0]['user_type_id'];
         if ($id == 1) {
             //Display all for admin id = 1
             //Do not change admin id = 1 in database
             //Otherwise, it error
             $sql = "select acl.acl_id,acl.label,CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access\r\n    \t\t\tfrom rms_acl_acl as acl\r\n    \t\t\tWHERE 1 " . $where;
         } else {
             //Display all of his/her parent access
             $sql = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n    \t\t\tFROM rms_acl_user_access AS ua\r\n    \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\r\n    \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ut.user_type_id =" . $id . $where;
         }
         //echo $sql; exit;
         $acl = $db_acl->getGlobalDb($sql);
         $acl = is_null($acl) ? array() : $acl;
         //print_r($acl);
         $this->view->acl = $acl;
         if (!$usernotparentid) {
             ///Display only of his/her parent access	and not have user_type_id of user access in user type parent id
             //ua.user_type_id != ut.parent_id
             $sql_acl = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n    \t\t\tFROM rms_acl_user_access AS ua\r\n    \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.user_type_id)\r\n    \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where;
         } else {
             //Display only he / she access in rsv_acl_user_access
             $sql_acl = "SELECT acl.acl_id,acl.label, CONCAT(acl.module,'/', acl.controller,'/', acl.action) AS user_access, acl.status\r\n    \t\t\tFROM rms_acl_user_access AS ua\r\n    \t\t\tINNER JOIN rms_acl_user_type AS ut ON (ua.user_type_id = ut.parent_id)\r\n    \t\t\tINNER JOIN rms_acl_acl AS acl ON (acl.acl_id = ua.acl_id) WHERE ua.user_type_id =" . $id . $where;
         }
         $acl_name = $db_acl->getGlobalDb($sql_acl);
         $acl_name = is_null($acl_name) ? array() : $acl_name;
         $imgnone = '<img src="' . BASE_URL . '/images/icon/none.png"/>';
         $imgtick = '<img src="' . BASE_URL . '/images/icon/tick.png"/>';
         $rows = array();
         foreach ($acl as $com) {
             $img = '<img src="' . BASE_URL . '/images/icon/none.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ',' . $id . ');" class="pointer"/>';
             $tmp_status = 0;
             foreach ($acl_name as $read) {
                 if ($read['acl_id'] == $com['acl_id']) {
                     $img = '<img src="' . BASE_URL . '/images/icon/tick.png" id="img_' . $com['acl_id'] . '" onclick="changeStatus(' . $com['acl_id'] . ', ' . $id . ');" class="pointer"/>';
                     $tmp_status = 1;
                     break;
                 }
             }
             if (!empty($status) || $status === 0) {
                 if ($tmp_status !== $status) {
                     continue;
                 }
             }
             $rows[] = array($com['acl_id'], $com['label'], $com['user_access'], $img);
         }
         //     		$list=new Application_Form_Frmlist();
         $list = new Application_Form_Frmtable();
         $tr = Application_Form_FrmLanguages::getCurrentlanguage();
         $columns = array("Label", $tr->translate('URL'), $tr->translate('STATUS'));
         $this->view->list = $list->getCheckList('radio', $columns, $rows);
         //$this->view->acl_name=$acl_name;
     }
 }