if (!$flickr_user) {
    error_404();
}
$owner = users_get_by_id($flickr_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
$more = array('viewer_id' => $GLOBALS['cfg']['user']['id'], 'page' => get_int32("page"));
$user_context = get_str("context");
$user_context = $user_context == 'posted' ? 'posted' : 'taken';
$GLOBALS['smarty']->assign("context", $user_context);
$more['context'] = $user_context;
$rsp = flickr_photos_archives_for_user_and_year($owner, $year, $more);
$photos = $rsp['rows'];
flickr_photos_utils_assign_can_view_geo($photos, $GLOBALS['cfg']['user']['id']);
$years = flickr_photos_archives_years_for_user($owner, $more);
$count_years = count($years);
for ($i = 0; $i < $count_years; $i++) {
    if ($years[$i] != $year) {
        continue;
    }
    $next_year = $years[$i + 1];
    $previous_year = $years[$i - 1];
    break;
}
$months = dates_utils_months();
$user_months = flickr_photos_archives_months_for_user($owner, $year, $more);
$GLOBALS['smarty']->assign("next_year", $next_year);
$GLOBALS['smarty']->assign("previous_year", $previous_year);
if (!$previous_year) {
    $ymd = "{$year}-01-01";
<?php

include "include/init.php";
loadlib("flickr_photos_archives");
if ($path = get_str("path")) {
    $flickr_user = flickr_users_get_by_path_alias($path);
} else {
    if ($nsid = get_str("nsid")) {
        $flickr_user = flickr_users_get_by_nsid($nsid);
    }
}
if (!$flickr_user) {
    error_404();
}
$owner = users_get_by_id($flickr_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
$more = array('viewer_id' => $GLOBALS['cfg']['user']['id']);
$context = get_str("context");
$GLOBALS['smarty']->assign("context", $context);
if (!$context || $context == 'posted') {
    $years_posted = flickr_photos_archives_years_for_user($owner, array('context' => 'posted'));
    $GLOBALS['smarty']->assign_by_ref("posted", $years_posted);
}
if (!$context || $context == 'taken') {
    $years_taken = flickr_photos_archives_years_for_user($owner, array('context' => 'taken'));
    $GLOBALS['smarty']->assign_by_ref("taken", $years_taken);
}
$GLOBALS['smarty']->display("page_flickr_photos_user_archives.txt");
exit;