diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-26 16:27:23 +0000 |
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-26 16:27:23 +0000 |
| commit | f6169047b12346f82aa3214337256b41c595cb8a (patch) | |
| tree | b8a61583fddfd94c48570c2e83f96191dc524f6a /modules/local_import/controllers | |
| parent | c3fcd3a79bd2f171b15384ea0ff44677b0c7a730 (diff) | |
Fix up add from server:
1) Upload requests are serialized so we don't over load the server or get
race conditions occurring.
2) new albums are created based on the file structure of the
authorized path that is the source directory.
Diffstat (limited to 'modules/local_import/controllers')
| -rw-r--r-- | modules/local_import/controllers/local_import.php | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/modules/local_import/controllers/local_import.php b/modules/local_import/controllers/local_import.php index 7f98edb5..138b61b1 100644 --- a/modules/local_import/controllers/local_import.php +++ b/modules/local_import/controllers/local_import.php @@ -60,16 +60,14 @@ class Local_Import_Controller extends Controller { $parent = ORM::factory("item", $id); access::can("local_import", $item); - if (!$parent->loaded) { + if (!$parent->is_album() && !$parent->loaded ) { throw new Exception("@todo BAD_ALBUM"); } $path = $this->input->post("path"); - $base_path = $parent->file_path(); $source_path = $path[0]; for ($i = 1; $i < count($path); $i++) { // skip the first path - $base_path .= "/$path[$i]"; $source_path .= "/$path[$i]"; $pathinfo = pathinfo($source_path); set_time_limit(30); @@ -79,25 +77,15 @@ class Local_Import_Controller extends Controller { ->where("parent_id", $parent->id) ->find(); if (!$album->loaded) { - $parent = album::create($parent, $path[$i], $path[$i]); - log::success("content", t("Added album"), - html::anchor("albums/{$parent->id}", t("view album"))); - message::success(t("Added album %album_title", array("album_title" => $parent->title))); - } else { - $parent = $album; + $album = album::create($parent, $path[$i], $path[$i], null, user::active()->id); } + $parent = $album; } else if (in_array($pathinfo["extension"], array("flv", "mp4"))) { - $movie = - movie::create($parent, $source_path, basename($source_path), basename($source_path)); - log::success("content", t("Added a movie"), - html::anchor("movies/{$movie->id}", t("view movie"))); - message::success(t("Added movie %movie_title", array("movie_title" => $movie->title))); + $movie = movie::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); } else { - $photo = - photo::create($parent, $source_path, basename($source_path), basename($source_path)); - log::success("content", t("Added a photo"), - html::anchor("photos/{$photo->id}", t("view photo"))); - message::success(t("Added photo %photo_title", array("photo_title" => $photo->title))); + $photo = photo::create($parent, $source_path, basename($source_path), + basename($source_path), null, user::active()->id); } } } |
