]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/PathController.php
allow anonymous routes creation
[syj.git] / application / controllers / PathController.php
index 37394d02dbfd4bc3331a3771543f09d772365187..6ef95292baf813d54c7a3a41a0dff0f032148d29 100644 (file)
@@ -6,12 +6,6 @@ class PathController extends Zend_Controller_Action
 {
     public function indexAction() {
         $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom');
-
-        $user = $this->_helper->SyjSession->user();
-        if (!$user) {
-            throw new Syj_Exception_Forbidden();
-        }
-
         $decoder = new gisconverter\WKT();
 
         try {
@@ -32,16 +26,24 @@ class PathController extends Zend_Controller_Action
             }
         }
         $path->geom = $geom;
+
+        $user = $this->_helper->SyjSession->user();
+        if (!$user and !$formData["geom_accept"]) {
+            throw new Syj_Exception_Request();
+        }
+
         if ($path->getId()) {
-            if ($path->owner->id != $user->id) {
-                throw new Syj_Exception_Forbidden();
+            if (!$path->isCreator($user)) {
+                throw new Syj_Exception_Request();
             }
         } else {
-            $path->owner = $user;
+            $path->creator = $user;
         }
+
         if (isset($formData["geom_title"])) {
             $path->title = $formData["geom_title"];
         }
+        $path->creatorIp = $this->getRequest()->getClientIp(true);
         try {
             $pathMapper->save ($path);
         } catch(Zend_Db_Statement_Exception $e) {