From 071f3f383167eed6d8a68219c19484b8c895b0ce Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Sun, 28 Nov 2010 19:37:57 +0800 Subject: [PATCH] - Code cleanup - Comments --- 3.0/modules/user_chroot/helpers/user_chroot.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/3.0/modules/user_chroot/helpers/user_chroot.php b/3.0/modules/user_chroot/helpers/user_chroot.php index 4d0a8499..8afa753f 100644 --- a/3.0/modules/user_chroot/helpers/user_chroot.php +++ b/3.0/modules/user_chroot/helpers/user_chroot.php @@ -21,18 +21,21 @@ class user_chroot_Core { private static $_album = null; + /** + * Return the root album of the current user, or false if the user is not + * chrooted. + */ public static function album() { if( is_null(self::$_album) ) { self::$_album = false; - $user = identity::active_user(); + $item = ORM::factory('item') + ->join('user_chroots', 'items.id', 'user_chroots.album_id') + ->where('user_chroots.id', '=', identity::active_user()->id) + ->find(); - $user_chroot = ORM::factory("user_chroot", $user->id); - if( $user_chroot->loaded() && $user_chroot->album_id != 0 ) { - $item = ORM::factory("item", $user_chroot->album_id); - if( $item->loaded() ) { - self::$_album = $item; - } + if( $item->loaded() ) { + self::$_album = $item; } }