summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-08 07:27:46 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-08 07:27:46 +0000
commitea7cc4f46edc730ff873c579a6c63490d24496a6 (patch)
tree9d18dceba15bac847bf5d0c1751093fd87932aaa
parent28b739a2105cba83f877d4fc4022d710b920b5a7 (diff)
Simplify the way that we find the user id (just look it up, and if there's a database exception use the null value)
-rw-r--r--core/controllers/welcome.php11
1 files changed, 6 insertions, 5 deletions
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 {