summaryrefslogtreecommitdiff
path: root/modules/server_add/controllers/server_add.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/server_add/controllers/server_add.php')
-rw-r--r--modules/server_add/controllers/server_add.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/modules/server_add/controllers/server_add.php b/modules/server_add/controllers/server_add.php
index d7572b52..f68335df 100644
--- a/modules/server_add/controllers/server_add.php
+++ b/modules/server_add/controllers/server_add.php
@@ -42,7 +42,6 @@ class Server_Add_Controller extends Admin_Controller {
// Make a tree with the parents back up to the authorized path, and all the children under the
// current path.
- Kohana_Log::add("error", $path);
if (server_add::is_valid_path($path)) {
$tree->parents[] = $path;
while (server_add::is_valid_path(dirname($tree->parents[0]))) {
@@ -110,7 +109,7 @@ class Server_Add_Controller extends Admin_Controller {
}
$task = task::run($task_id);
- print json_encode(array("done" => $task->done,
+ print json_encode(array("done" => (bool)$task->done,
"status" => $task->status,
"percent_complete" => $task->percent_complete));
}
@@ -226,16 +225,36 @@ class Server_Add_Controller extends Admin_Controller {
$name = basename($entry->file);
$title = item::convert_filename_to_title($name);
if (is_dir($entry->file)) {
- $album = album::create($parent, $name, $title, null, $owner_id);
+ $album = ORM::factory("item");
+ $album->type = "album";
+ $album->parent_id = $parent->id;
+ $album->name = $name;
+ $album->title = $title;
+ $album->owner_id = $owner_id;
+ $album->save();
$entry->item_id = $album->id;
} else {
try {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
- $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
+ $photo = ORM::factory("item");
+ $photo->type = "photo";
+ $photo->parent_id = $parent->id;
+ $photo->set_data_file($entry->file);
+ $photo->name = $name;
+ $photo->title = $title;
+ $photo->owner_id = $owner_id;
+ $photo->save();
$entry->item_id = $photo->id;
} else if (in_array($extension, array("flv", "mp4"))) {
- $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
+ $movie = ORM::factory("item");
+ $movie->type = "movie";
+ $movie->parent_id = $parent->id;
+ $movie->set_data_file($entry->file);
+ $movie->name = $name;
+ $movie->title = $title;
+ $movie->owner_id = $owner_id;
+ $movie->save();
$entry->item_id = $movie->id;
} else {
// This should never happen, because we don't add stuff to the list that we can't