diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-19 06:35:54 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-19 06:35:54 +0000 |
commit | 161998dde6d976c45cfcea31f1128147acc3d64f (patch) | |
tree | a1ba84b418e98eafb112c577844aa04e4592bde6 | |
parent | e14d5574b6861314c2133b156c8f2c9c94aeb1b6 (diff) |
Fix some broken-ness:
1) Item_Controller::_create() and _update() were swapped
2) _create() was redirecting to the wrong urls on success
3) Change in-place return parameter from __return to _return
4) Change in-place code to tunnel _put via POST
-rw-r--r-- | core/controllers/items.php | 14 | ||||
-rw-r--r-- | core/views/in_place_edit.html.php | 2 | ||||
-rw-r--r-- | core/views/welcome.html.php | 2 |
3 files changed, 7 insertions, 11 deletions
diff --git a/core/controllers/items.php b/core/controllers/items.php index d56ef774..705ecbfb 100644 --- a/core/controllers/items.php +++ b/core/controllers/items.php @@ -48,11 +48,9 @@ class Items_Controller extends REST_Controller { return url::redirect("{$item->type}s}/$item->id"); } - public function _update($item) { + public function _create($item) { // @todo Productionize this code // 1) Add security checks - // 2) Support owner_ids properly - $user = Session::instance()->get("user"); $owner_id = $user ? $user->id : $item->owner_id; @@ -64,7 +62,7 @@ class Items_Controller extends REST_Controller { $this->input->post("title", $this->input->post("name")), $this->input->post("description"), $owner_id); - url::redirect("album/{$album->id}"); + url::redirect("albums/{$album->id}"); break; case "photo": @@ -81,7 +79,7 @@ class Items_Controller extends REST_Controller { throw new Exception("@todo ERROR_IN_UPLOAD_FILE"); } } - url::redirect("album/{$item->id}"); + url::redirect("albums/{$item->id}"); } else { $photo = photo::create( $item->id, @@ -106,7 +104,7 @@ class Items_Controller extends REST_Controller { url::redirect("{$parent->type}s/{$parent->id}"); } - public function _create($item) { + public function _update($item) { // @todo Productionize this // 1) Figure out how to do the right validation here. Validate the form input and apply it to // the model as appropriate. @@ -133,8 +131,8 @@ class Items_Controller extends REST_Controller { // parent_id, owner_id $item->save(); - if (array_key_exists("__return", $post)) { - print $item->{$post["__return"]}; + if (array_key_exists("_return", $post)) { + print $item->{$post["_return"]}; } } } diff --git a/core/views/in_place_edit.html.php b/core/views/in_place_edit.html.php index 75500625..f02b77ba 100644 --- a/core/views/in_place_edit.html.php +++ b/core/views/in_place_edit.html.php @@ -3,7 +3,7 @@ $(document).ready(function() { ajax_update = function(className, id) { return function(value, settings) { - var post_data = {'__return': settings.name}; + var post_data = {'_method': 'put', '_return': settings.name}; post_data[settings.name] = value; $.post("<?= url::site("items/__ID__") ?>".replace("__ID__", id), post_data, diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index a015fc92..a3f70d33 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -187,7 +187,6 @@ <input type="submit" value="upload"/> <input id="photo_upload" name="file[]" type="file"/> <input type="hidden" name="type" value="photo"/> - <input type="hidden" name="_method" value="put"/> </form> </fieldset> <fieldset> @@ -196,7 +195,6 @@ <input type="submit" value="create"/> <input type="text" name="name"/> <input type="hidden" name="type" value="album"/> - <input type="hidden" name="_method" value="put"/> </form> </fieldset> </div> |