Пример #1
0
 public function actionEditCtl()
 {
     if ($this->_isPost()) {
         $actArr = $this->_modelAct->findByChild($_POST['Id']);
         $ctl = ucwords($_POST['value']);
         $ctlUpdate = array('value' => $ctl, 'allow' => $_POST['allow']);
         $this->_modelAct->update($ctlUpdate, "Id={$_POST['Id']}");
         foreach ($actArr as $value) {
             list($ctlStr, $actStr) = explode('_', $value['value']);
             $childValue = "{$ctl}_{$actStr}";
             $this->_modelAct->update(array('value' => $childValue), "Id={$value['Id']}");
         }
         $this->_utilMsg->showMsg('更新控制器成功', 1, Tools::url(CONTROL, 'AddCtl'));
     } else {
         $ctlArr = $this->_modelAct->findById($_GET['Id']);
         $this->_view->assign('data', $ctlArr);
         $this->_view->assign('id', $_GET['Id']);
         $this->_utilMsg->createNavBar();
         $this->_view->display();
     }
 }
Пример #2
0
 public function actionEditCtl()
 {
     if ($this->_isPost()) {
         $actArr = $this->_modelAct->findByChild($_POST['Id']);
         $ctl = ucwords($_POST['value']);
         $ctlUpdate = array();
         $ctlUpdate['value'] = $ctl;
         if ($_POST['rbac_everyone']) {
             $ctlUpdate['allow'] = RBAC_EVERYONE;
         } else {
             if (count($_POST['allow'])) {
                 $ctlUpdate['allow'] = implode(',', $_POST['allow']);
             }
         }
         $this->_modelAct->update($ctlUpdate, "Id={$_POST['Id']}");
         foreach ($actArr as $value) {
             list($ctlStr, $actStr) = explode('_', $value['value']);
             $childValue = "{$ctl}_{$actStr}";
             $this->_modelAct->update(array('value' => $childValue), "Id={$value['Id']}");
         }
         $this->_utilMsg->showMsg('更新控制器成功', 1, Tools::url(CONTROL, 'AddCtl'));
     } else {
         $data = $this->_modelAct->findById($_GET['Id']);
         if ($data['allow'] == RBAC_EVERYONE) {
             $this->_view->assign('everyone', 1);
         }
         $selectedRoles = explode(',', $data['allow']);
         $allRoles = $this->_modelAct->getAllRoles();
         $selectedUser = $this->_modelAct->getUserAct($data['value']);
         $this->_view->assign('selectedRoles', $selectedRoles);
         $this->_view->assign('allRoles', $allRoles);
         $this->_view->assign('selectedUser', $selectedUser);
         $this->_view->assign('data', $data);
         $this->_view->assign('id', $_GET['Id']);
         $this->_utilMsg->createNavBar();
         $this->_view->display();
     }
 }