]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/PathController.php
do not fail when client uses a proxy
[syj.git] / application / controllers / PathController.php
index aa41866679103703bb66909032302ecd59fd645d..48a22befd43930ef1d0f6a8036e28524c1ea347d 100644 (file)
@@ -13,21 +13,25 @@ class PathController extends Zend_Controller_Action
             throw new Syj_Exception_Request();
         }
         $path->creator = $user;
-        $path->creatorIp = $this->getRequest()->getClientIp(true);
+        $path->creatorIp = trim(end(split(',', $this->getRequest()->getClientIp(true))));
 
-        return $this->save($path, $formData);
+        $this->save($path, $formData);
+        $data = array('redirect' => "idx/" . (string)$path->id);
+        $this->_helper->SyjApi->setCode(201)->setBodyJson($data);
     }
 
     public function updateAction() {
         $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom');
-        return $this->save($this->getPath(), $formData);
+        $path = $this->getPath();
+        $this->save($path, $formData);
+        $this->_helper->SyjApi->setCode(200); // we should use 204, but ie mangles 204 to 1223
     }
 
     public function deleteAction() {
         $path = $this->getPath();
         $pathMapper = new Syj_Model_PathMapper();
         $pathMapper->delete ($path);
-        $this->_helper->SyjApi->setCode(204);
+        $this->_helper->SyjApi->setCode(200); // we should use 204, but ie mangles 204 to 1223
     }
 
     public function getPath() {
@@ -84,8 +88,6 @@ class PathController extends Zend_Controller_Action
                 throw $e;
             }
         }
-
-        $this->_helper->SyjApi->setBody($path->id);
     }
 
 }