summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-21 04:43:47 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-21 04:43:47 +0000
commit0573698155f04d6ccb6a68cf63fdeb8c73501576 (patch)
tree53c29ba805dfbb9882ae5408b4c2d12b5f724b0c /core
parent4c2ddfb8681392b98f0c10ef7f40937c77e5f20f (diff)
Add some more logging code. Now the site admin has some log entries to look at.
Diffstat (limited to 'core')
-rw-r--r--core/controllers/items.php15
-rw-r--r--core/controllers/welcome.php19
2 files changed, 30 insertions, 4 deletions
diff --git a/core/controllers/items.php b/core/controllers/items.php
index efbfa8d9..36d88084 100644
--- a/core/controllers/items.php
+++ b/core/controllers/items.php
@@ -61,12 +61,15 @@ class Items_Controller extends REST_Controller {
$this->input->post("title", $this->input->post("name")),
$this->input->post("description"),
$owner_id);
- url::redirect("albums/{$album->id}");
+ log::add("content", "Created an album", log::INFO,
+ html::anchor("albums/$album->id", "view album"));
+ url::redirect("albums/$album->id");
break;
case "photo":
if (is_array($_FILES["file"]["name"])) {
- for ($i = 0; $i < count($_FILES["file"]["name"]) - 1; $i++) {
+ $count = count($_FILES["file"]["name"]);
+ for ($i = 0; $i < $count - 1; $i++) {
if ($_FILES["file"]["error"][$i] == 0) {
$photo = photo::create(
$item->id,
@@ -78,7 +81,9 @@ class Items_Controller extends REST_Controller {
throw new Exception("@todo ERROR_IN_UPLOAD_FILE");
}
}
- url::redirect("albums/{$item->id}");
+ log::add("content", "Added $count photos", log::INFO,
+ html::anchor("albums/$item->id", "view album"));
+ url::redirect("albums/$item->id");
} else {
$photo = photo::create(
$item->id,
@@ -87,7 +92,9 @@ class Items_Controller extends REST_Controller {
$this->input->post("title", $this->input->post("name")),
$this->input->post("description"),
$owner_id);
- url::redirect("photos/{$photo->id}");
+ log::add("content", "Added a photo", log::INFO,
+ html::anchor("photos/$photo->id", "view photo"));
+ url::redirect("photos/$photo->id");
}
break;
}
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php
index bf887b04..d6c40850 100644
--- a/core/controllers/welcome.php
+++ b/core/controllers/welcome.php
@@ -198,10 +198,18 @@ class Welcome_Controller extends Template_Controller {
cookie::set("add_photos_path", $path);
+ $photo_count = 0;
foreach (glob("$path/*.[Jj][Pp][Gg]") as $file) {
set_time_limit(30);
photo::create($parent->id, $file, basename($file), basename($file));
+ $photo_count++;
}
+
+ if ($photo_count > 0) {
+ log::add("content", "(scaffold) Added $photo_count photos", log::INFO,
+ html::anchor("albums/$parent_id", "View album"));
+ }
+
url::redirect("welcome");
}
@@ -212,6 +220,7 @@ class Welcome_Controller extends Template_Controller {
$test_images = glob(APPPATH . "tests/images/*.[Jj][Pp][Gg]");
+ $album_count = $photo_count = 0;
for ($i = 0; $i < $count; $i++) {
set_time_limit(30);
@@ -226,12 +235,22 @@ class Welcome_Controller extends Template_Controller {
$parent->id, "rnd_" . rand(), "Rnd $i", "random album $i", $owner_id)
->set_thumb(DOCROOT . "core/tests/test.jpg", $thumb_size, $thumb_size)
->save();
+ $album_count++;
} else {
$photo_index = rand(0, count($test_images) - 1);
photo::create($parent->id, $test_images[$photo_index], basename($test_images[$photo_index]),
"rnd_" . rand(), "sample thumb", $owner_id);
+ $photo_count++;
}
}
+
+ if ($photo_count > 0) {
+ log::add("content", "(scaffold) Added $photo_count photos");
+ }
+
+ if ($album_count > 0) {
+ log::add("content", "(scaffold) Added $album_count albums");
+ }
url::redirect("welcome");
}