/** * Post admin action. */ public function adminAction() { $config = Zend_Registry::get('config'); $this->view->headScript()->appendFile($config->baseurl . '/js/jquery.validate.min.js'); $this->view->headScript()->appendFile($config->baseurl . '/js/create.js'); $id = $this->_getParam('id'); $city = $this->_getParam('city'); $advertisement = $this->advertisement->findById($id); if (empty($advertisement)) { throw new Exception('ID 缺失或者帖子没找到!'); } else { $this->view->view_id = $id; $form = new AdminPost($advertisement, $city); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { // $isValid = $this->_helper->common->validReCaptcha ( $this->_getAllParams() ); // if ($isValid) { $city = $form->getValue('city'); $action = $form->getValue('action'); $password = $form->getValue('password'); $cityObj = $this->city->findByName($city); if (!isset($cityObj)) { throw new Exception('暂时不支持所在城市!'); } switch ($action) { case 0: if ($password == $advertisement->password) { $db = Zend_Registry::get('db'); $db->beginTransaction(); $this->advertisement->closeAdvertisement($id); $db->commit(); $this->_redirect('/' . $city . '/bulletin/list'); } else { throw new Exception('没有权限关闭该帖子!'); } break; case 1: if ($password == $advertisement->password) { $form = new CreateOrUpdatePost($advertisement, $password, $cityObj); $this->view->form = $form; } else { throw new Exception('没有权限修改该帖子!'); } break; case 2: if ($password == '12345678') { $db = Zend_Registry::get('db'); $db->beginTransaction(); $this->advertisement->deleteAdvertisement($id); $db->commit(); $this->_redirect('/' . $city . '/bulletin/list'); } else { throw new Exception('没有权限删除该帖子!'); } break; } } } // } } }