<?php
if ( !defined( 'SMARTY_DIR' ) ) {
	include_once( '../init.php' );
}
include('sessioninc.php');

$userid = $_REQUEST['id'];

$username = $osDB->getOne('select username from ! where id = ?',array( USER_TABLE, $userid) );

$useralbums =& $osDB->getAll('select id, name from ! where username = ?', array(USERALBUMS_TABLE, $username) );

$useralbums = array_merge(array(array('id'=>'0','name'=>'Profile Pictures'), array('id'=>'999','name'=>'General')), $useralbums);

$album_id = $_REQUEST['album_id'];

if ($album_id != '') {
	$pics =& $osDB->getAll('select picno from ! where userid = ? and album_id =?',array( USER_SNAP_TABLE, $userid, $album_id) );
} else {
	$pics =& $osDB->getAll('select picno from ! where userid = ? and (album_id is NUll or album_id = ?)',array( USER_SNAP_TABLE, $userid, 0) );
}

$t->assign('useralbums', $useralbums);

$t->assign('username',$username);

$t->assign('pics',$pics);

unset($pics, $useralbums);

$t->assign('userid',$userid);

$t->assign('err', $err);

$t->assign('album_id', $album_id);

$t->display( 'userpicgallery.tpl' );

?>