Ejemplo n.º 1
0
 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');
         			}
         		}*/
     }
 }