summaryrefslogtreecommitdiff
path: root/modules/image_block
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-02-27 05:39:51 +0000
committerBharat Mediratta <bharat@menalto.com>2009-02-27 05:39:51 +0000
commitcd0f9a5d6c1c46684d4fa4e48cdb1e0c75da94e7 (patch)
treef6c05b2c71ed586e5133123e32c7781e758a75e9 /modules/image_block
parentab973bd87168ab11ff5242824738edb89f0bc3e2 (diff)
Optimize the code by ditching the count query; we don't need it.
Diffstat (limited to 'modules/image_block')
-rw-r--r--modules/image_block/helpers/image_block_theme.php12
1 files changed, 2 insertions, 10 deletions
diff --git a/modules/image_block/helpers/image_block_theme.php b/modules/image_block/helpers/image_block_theme.php
index 96ee58e2..bf87c852 100644
--- a/modules/image_block/helpers/image_block_theme.php
+++ b/modules/image_block/helpers/image_block_theme.php
@@ -19,15 +19,6 @@
*/
class image_block_theme_Core {
static function sidebar_blocks($theme) {
- // Leave as a count so we can filter based on viewable items.
- $viewable_items = ORM::factory("item")
- ->viewable()
- ->select("COUNT(*) AS C")
- ->find()->C;
- if (empty($viewable_items)) {
- return "";
- }
-
$block = new Block();
$block->css_id = "gImageBlock";
$block->title = t("Random Image");
@@ -43,6 +34,7 @@ class image_block_theme_Core {
->find_all(1);
if ($items->count() == 0) {
+ // Try once more. If this fails, just ditch the block altogether
$items = ORM::factory("item")
->viewable()
->where("type !=", "album")
@@ -50,7 +42,7 @@ class image_block_theme_Core {
->orderby(array("rand_key" => "DESC"))
->find_all(1);
}
-
+
$block->content->item = $items->current();
return $items->count() == 0 ? "" : $block;