Skip to content

Commit

Permalink
Allow item_rest::put() to replace the current data file. Remove
Browse files Browse the repository at this point in the history
data_rest::put() altogether; it's no longer necessary.
  • Loading branch information
bharat committed Aug 8, 2010
1 parent 7f61f97 commit 4e95ec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 0 additions & 12 deletions modules/gallery/helpers/data_rest.php
Expand Up @@ -58,18 +58,6 @@ static function get($request) {
return $result;
}

static function put($request) {
$item = rest::resolve($request->url);
access::required("edit", $item);

if ($item->is_album()) {
throw new Rest_Exception("Bad Request", 400, array("errors" => array("type" => "invalid")));
}

$item->set_data_file($request->file);
$item->save();
}

static function resolve($id) {
$item = ORM::factory("item", $id);
if (!access::can("view", $item)) {
Expand Down
6 changes: 6 additions & 0 deletions modules/gallery/helpers/item_rest.php
Expand Up @@ -126,6 +126,12 @@ static function put($request) {
}
}
}

// Replace the data file, if required
if (($item->is_photo() || $item->is_movie()) && isset($request->file)) {
$item->set_data_file($request->file);
}

$item->save();

if (isset($request->params->members) && $item->sort_column == "weight") {
Expand Down

0 comments on commit 4e95ec8

Please sign in to comment.