]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/PathController.php
remove uniquepath constraint
[syj.git] / application / controllers / PathController.php
index cdd067b6f4ba2b43722f7256d32d19fd2dd506e3..394da6921cac13042844cc78e0a5e4d99a839041 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-/*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+/*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
     and is published under the AGPL license. */
 
 class PathController extends Zend_Controller_Action
@@ -8,7 +8,7 @@ class PathController extends Zend_Controller_Action
         $formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom');
         $path = new Syj_Model_Path();
 
-        $user = $this->_helper->SyjSession->user();
+        $user = $this->_helper->SyjUserManager->current();
         if (!$user and !$formData["geom_accept"]) {
             throw new Syj_Exception_Request();
         }
@@ -52,7 +52,7 @@ class PathController extends Zend_Controller_Action
             }
         }
 
-        $user = $this->_helper->SyjSession->user();
+        $user = $this->_helper->SyjUserManager->current();
         if (!$path->isCreator($user)) {
             throw new Syj_Exception_Forbidden();
         }
@@ -78,7 +78,7 @@ class PathController extends Zend_Controller_Action
         }
 
         if ($geom::name != "LineString") {
-            throw new Syj_Exception_Request();
+            throw new Syj_Exception_InvalidGeomUpload();
         }
         $path->geom = $geom;
 
@@ -90,20 +90,7 @@ class PathController extends Zend_Controller_Action
 
         /* now, saving !*/
         $pathMapper = new Syj_Model_PathMapper();
-        try {
-            $pathMapper->save ($path);
-        } catch(Zend_Db_Statement_Exception $e) {
-            if ($e->getCode() == 23505) { // 23505: Unique violation throw new Syj_Exception_Request();
-                $message = $e->getMessage();
-                if (strpos($message, 'paths_geom_key') !== false) {
-                    throw new Syj_Exception_Request("uniquepath");
-                } else {
-                    throw $e;
-                }
-            } else {
-                throw $e;
-            }
-        }
+        $pathMapper->save ($path);
     }
 
 }