From 5ea05a44238fb4bfe66e91589ed53345c37ac3fc Mon Sep 17 00:00:00 2001 From: rWatcher Date: Wed, 13 Jun 2012 19:17:51 -0400 Subject: [PATCH] Limit year list to choices that are valid for the selected user. --- .../calendarview/controllers/calendarview.php | 35 +++++++++++++------ .../helpers/calendarview_theme.php | 5 ++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/3.0/modules/calendarview/controllers/calendarview.php b/3.0/modules/calendarview/controllers/calendarview.php index d3a52f53..c8bf841b 100644 --- a/3.0/modules/calendarview/controllers/calendarview.php +++ b/3.0/modules/calendarview/controllers/calendarview.php @@ -234,16 +234,31 @@ class CalendarView_Controller extends Controller { // Generate a list of years, starting with the year the earliest photo was // taken, and ending with the year of the most recent photo. $valid_years = Array(); - $all_photos = ORM::factory("item") - ->viewable() - ->where("type", "!=", "album") - ->where("captured", "!=", "") - ->order_by("captured", "DESC") - ->find_all(); - $counter = date('Y', $all_photos[count($all_photos)-1]->captured); - while ($counter <= date('Y', $all_photos[0]->captured)) { - $valid_years[$counter] = $counter; - $counter++; + if ($display_user == -1) { + $all_photos = ORM::factory("item") + ->viewable() + ->where("type", "!=", "album") + ->where("captured", "!=", "") + ->order_by("captured", "DESC") + ->find_all(); + $counter = date('Y', $all_photos[count($all_photos)-1]->captured); + while ($counter <= date('Y', $all_photos[0]->captured)) { + $valid_years[$counter] = $counter; + $counter++; + } + } else { + $all_photos = ORM::factory("item") + ->viewable() + ->where("type", "!=", "album") + ->where("captured", "!=", "") + ->where("owner_id", "=", $display_user) + ->order_by("captured", "DESC") + ->find_all(); + $counter = date('Y', $all_photos[count($all_photos)-1]->captured); + while ($counter <= date('Y', $all_photos[0]->captured)) { + $valid_years[$counter] = $counter; + $counter++; + } } // Create the form. diff --git a/3.0/modules/calendarview/helpers/calendarview_theme.php b/3.0/modules/calendarview/helpers/calendarview_theme.php index 1e3114a0..5c571525 100644 --- a/3.0/modules/calendarview/helpers/calendarview_theme.php +++ b/3.0/modules/calendarview/helpers/calendarview_theme.php @@ -18,9 +18,8 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class calendarview_theme_Core { - static function head($theme) { - $theme->css("calendarview_menu.css"); - return $theme->css("calendarview_calendar.css"); + return $theme->css("calendarview_calendar.css") . + $theme->css("calendarview_menu.css"); } }