| | |
| | | if($this->getRequest()->isXmlHttpRequest()){ |
| | | $total = $this->module_service->getModuleTotal(); |
| | | $data['draw'] = !empty($_REQUEST['draw'])?$_REQUEST['draw']:1; |
| | | $data['start'] = !empty($_REQUEST['start'])?$_REQUEST['start']:0; |
| | | $data['length'] = !empty($_REQUEST['length'])?$_REQUEST['length']:10; |
| | | $data['recordsTotal'] = $total; |
| | | $data['recordsFiltered'] = $total; |
| | | $data['data'] = $this->module_service->getModuleList(); |
| | | $data['data'] = $this->module_service->getModuleList(array(), array(), array(), $data['length'], $data['start']); |
| | | //print_r($this->module_service->getModuleList()); |
| | | exit($this->sendToDataTable($data)); |
| | | } |
| | |
| | | $data['action'] = $this->getRequest()->getPost('action'); |
| | | $data['parent'] = $this->getRequest()->getPost('parent'); |
| | | $data['name'] = $this->getRequest()->getPost('name'); |
| | | $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent'])); |
| | | if($parent_module){ |
| | | if($parent['level'] <= 2 ){ |
| | | $data['level'] = $parent['level'] + 1; |
| | | if($data['parent'] != 0){ |
| | | $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent'])); |
| | | if($parent_module){ |
| | | $data['is_module'] = false; |
| | | if($parent_module['level'] <= 2 ){ |
| | | $data['level'] = $parent_module['level'] + 1; |
| | | } |
| | | else{ |
| | | exit($this->showError('目前栏目只支持三级', 400, true)); |
| | | } |
| | | } |
| | | else{ |
| | | exit($this->showError('目前栏目只支持三级', 400, true)); |
| | | exit($this->showError('所属栏目不存在,请重新选择', 400, true)); |
| | | } |
| | | } |
| | | else{ |
| | | exit($this->showError('所属栏目不存在,请重新选择', 400, true)); |
| | | $data['level'] = 1; |
| | | $data['is_module'] = true; |
| | | } |
| | | if($this->module_service->add($data)){ |
| | | Util::updateModules(); |
| | | exit($this->showSuccess('栏目添加成功', true)); |
| | | } |
| | | else{ |
| | |
| | | public function EditAction($id){ |
| | | $module = $this->module_service->getModuleInfo(array('_id' => $id)); |
| | | if($module){ |
| | | $data['module'] = $this->getRequest()->getPost('module'); |
| | | $data['controller'] = $this->getRequest()->getPost('controller'); |
| | | $data['action'] = $this->getRequest()->getPost('action'); |
| | | $data['parent'] = $this->getRequest()->getPost('parent'); |
| | | $data['name'] = $this->getRequest()->getPost('name'); |
| | | $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent'])); |
| | | if($parent_module){ |
| | | if($parent['level'] <= 2 ){ |
| | | $data['level'] = $parent['level'] + 1; |
| | | if($this->getRequest()->isXmlHttpRequest()){ |
| | | $data['module'] = $this->getRequest()->getPost('module'); |
| | | $data['controller'] = $this->getRequest()->getPost('controller'); |
| | | $data['action'] = $this->getRequest()->getPost('action'); |
| | | $data['parent'] = $this->getRequest()->getPost('parent'); |
| | | $data['name'] = $this->getRequest()->getPost('name'); |
| | | if($data['parent']){ |
| | | $parent_module = $this->module_service->getModuleInfo(array('_id' => $data['parent'])); |
| | | if($parent_module){ |
| | | if($parent_module['level'] <= 2 ){ |
| | | $data['level'] = $parent_module['level'] + 1; |
| | | } |
| | | else{ |
| | | exit($this->showError('目前栏目只支持三级', 400, true)); |
| | | } |
| | | } |
| | | else{ |
| | | exit($this->showError('所属栏目不存在,请重新选择', 400, true)); |
| | | } |
| | | } |
| | | else{ |
| | | exit($this->showError('目前栏目只支持三级', 400, true)); |
| | | $data['level'] = 1; |
| | | $data['is_module'] = true; |
| | | } |
| | | if($this->module_service->update($data, array('_id' => $module['_id']))){ |
| | | Util::updateModules(); |
| | | exit($this->showSuccess('栏目添加成功', true)); |
| | | } |
| | | else{ |
| | | exit($this->showError($this->module_service->error, 400, true)); |
| | | } |
| | | } |
| | | else{ |
| | | exit($this->showError('所属栏目不存在,请重新选择', 400, true)); |
| | | } |
| | | if($this->module_service->update($data)){ |
| | | exit($this->showSuccess('栏目添加成功', true)); |
| | | } |
| | | else{ |
| | | exit($this->showError($this->module_service->error, 400, true)); |
| | | } |
| | | $this->getView()->assign('module', $module); |
| | | } |
| | | else{ |
| | | $this->redirect('/error/show/type/no_data'); |