From ea7cc4f46edc730ff873c579a6c63490d24496a6 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 8 Nov 2008 07:27:46 +0000 Subject: Simplify the way that we find the user id (just look it up, and if there's a database exception use the null value) --- core/controllers/welcome.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index b411e314..c05cba68 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -91,17 +91,18 @@ class Welcome_Controller extends Template_Controller { function add($count) { srand(time()); $parents = ORM::factory("item")->where("type", "album")->find_all()->as_array(); - $user_module = ORM::factory("module")->where("name", "user")->find(); - - if ($user_module->loaded) { + + try { $user_id = ORM::factory("user")->find()->id; - } else { + } catch (Exception $e) { $user_id = null; } + for ($i = 0; $i < $count; $i++) { $parent = $parents[array_rand($parents)]; if (!rand(0, 10)) { - $parents[] = album::create($parent->id, "rnd_" . rand(), "Rnd $i", "rnd $i", "random album $i", $user_id) + $parents[] = album::create( + $parent->id, "rnd_" . rand(), "Rnd $i", "rnd $i", "random album $i", $user_id) ->set_thumbnail(DOCROOT . "core/tests/test.jpg", 200, 150) ->save(); } else { -- cgit v1.2.3