]> dev.renevier.net Git - syj.git/blobdiff - application/controllers/IdxController.php
separate route to create a new path, and to update an existing one
[syj.git] / application / controllers / IdxController.php
index ac315581eafbc29eb300c65cbba1a7c9c908b835..0b53b2a6fd22d32db56dc274fe83aec51bd5d49b 100644 (file)
@@ -20,7 +20,7 @@ class IdxController extends Zend_Controller_Action
     public function indexAction() {
         $url = $this->getRequest()->getUserParam('url');
 
-        $geomform = new Syj_Form_Geom(array('name' => 'geomform', 'action' => 'path'));
+        $geomform = new Syj_Form_Geom(array('name' => 'geomform'));
         $loginform = new Syj_Form_Login(array('name' => 'loginform', 'action' => 'login'));
         $userform = new Syj_Form_User(array('name' => 'userform', 'action' => 'user'));
         $newpwdform = new Syj_Form_Newpwd(array('name' => 'newpwdform', 'action' => 'newpwd'));
@@ -35,13 +35,14 @@ class IdxController extends Zend_Controller_Action
                     throw new Syj_Exception_NotFound('Not Found', 404);
                 }
             }
+            $geomform->setAction('path/' . (string)$path->id . '/update');
             $title = $path->displayTitle;
             $this->view->path = $path;
             $geomform->geom_title->setValue($path->title);
             $geomform->geom_data->setValue((string)$path->geom);
-            $geomform->geom_id->setValue((string)$path->id);
             $loginform->login_geom_id->setValue((string)$path->id);
         } else {
+            $geomform->setAction('path');
             $extent = new phptojs\JsObject('gMaxExtent', $this->_helper->syjGeoip($this->getRequest()->getClientIp(true)));
             $this->view->headScript()->prependScript((string) $extent);
             $title = "Show your journey";
@@ -68,14 +69,12 @@ class IdxController extends Zend_Controller_Action
         }
 
         if (isset($path)) {
-            if ($user and $path->owner->id == $user->id) {
-                $loggedinfo->isowner = true;
-            } else {
-                $loggedinfo->isowner = false;
+            $loggedinfo->iscreator = $path->isCreator($user);
+            if ($path->creator) {
+                $loggedinfo->creatorname = $this->view->escape((string)$path->creator->pseudo);
             }
-            $loggedinfo->ownername = $this->view->escape((string)$path->owner->pseudo);
         } else {
-            $loggedinfo->isowner = true;
+            $loggedinfo->iscreator = true;
         }
 
         $this->view->headScript()->prependScript((string) $loggedinfo);
@@ -85,7 +84,7 @@ class IdxController extends Zend_Controller_Action
         $this->view->jslocales = array(
             'saveSuccess' => __("save took place successfully"),
             'requestError' => __("server did not understood request. That's probably caused by a bug in SYJ"),
-            'UnreferencedError' => __("path did not exist in the server. May be it has been already deleted"),
+            'gonePathError' => __("route has been deleted from the server."),
             'uniquePathError' => __("similar path seems to already exist. Please do not create two exactly identical paths"),
             'notReachedError' => __("server could not be reached"),
             'serverError' => __("there was a server error"),
@@ -93,8 +92,6 @@ class IdxController extends Zend_Controller_Action
             'userEmptyWarn' => __("you must enter a login name"),
             'loginSuccess' => __("Login correct"),
             'loginFailure' => __("Wrong login/password"),
-            'loginNeeded' => __("You need to login before retrying to save"),
-            'cookiesNeeded' => __("You need to have cookies enabled to login to SYJ"),
             'passwordEmptyWarn' => __("you must enter a password"),
             'passwordNoMatchWarn' => __("Password do not match"),
             'acceptTermsofuseWarn' => __("You must accept terms of use"),