X-Git-Url: https://dev.renevier.net/?p=syj.git;a=blobdiff_plain;f=application%2Fcontrollers%2FPathController.php;h=aa41866679103703bb66909032302ecd59fd645d;hp=c3c085a8695ff1eddbed1874edea580e8b9644ed;hb=ec061a75fe57a25eb7ef0894f5e723397ba35472;hpb=3ff82e2d9fa289beba4e965b82772cf83f905b2f diff --git a/application/controllers/PathController.php b/application/controllers/PathController.php index c3c085a..aa41866 100644 --- a/application/controllers/PathController.php +++ b/application/controllers/PathController.php @@ -5,10 +5,32 @@ class PathController extends Zend_Controller_Action { public function indexAction() { - return $this->save(new Syj_Model_Path()); + $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom'); + $path = new Syj_Model_Path(); + + $user = $this->_helper->SyjSession->user(); + if (!$user and !$formData["geom_accept"]) { + throw new Syj_Exception_Request(); + } + $path->creator = $user; + $path->creatorIp = $this->getRequest()->getClientIp(true); + + return $this->save($path, $formData); } public function updateAction() { + $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom'); + return $this->save($this->getPath(), $formData); + } + + public function deleteAction() { + $path = $this->getPath(); + $pathMapper = new Syj_Model_PathMapper(); + $pathMapper->delete ($path); + $this->_helper->SyjApi->setCode(204); + } + + public function getPath() { $idx = $this->getRequest()->getUserParam('idx'); $path = new Syj_Model_Path(); $pathMapper = new Syj_Model_PathMapper(); @@ -19,28 +41,15 @@ class PathController extends Zend_Controller_Action throw new Syj_Exception_NotFound('Not Found', 404); } } - return $this->save($path); - } - public function save(Syj_Model_Path $path) { - $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom'); - - /* authorization check */ $user = $this->_helper->SyjSession->user(); - if (!$user and !$formData["geom_accept"]) { - throw new Syj_Exception_Request(); - } - - /* setting creator property */ - if ($path->getId()) { - if (!$path->isCreator($user)) { - throw new Syj_Exception_Request(); - } - } else { - $path->creator = $user; + if (!$path->isCreator($user)) { + throw new Syj_Exception_Forbidden(); } - $path->creatorIp = $this->getRequest()->getClientIp(true); + return $path; + } + public function save(Syj_Model_Path $path, $formData) { /* setting geom property */ $decoder = new gisconverter\WKT(); try {