<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Fez - Digital Repository System                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2005, 2006, 2007 The University of Queensland,         |
// | Australian Partnership for Sustainable Repositories,                 |
// | eScholarship Project                                                 |
// |                                                                      |
// | Some of the Fez code was derived from Eventum (Copyright 2003, 2004  |
// | MySQL AB - http://dev.mysql.com/downloads/other/eventum/ - GPL)      |
// |                                                                      |
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or    |
// | (at your option) any later version.                                  |
// |                                                                      |
// | This program is distributed in the hope that it will be useful,      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place - Suite 330                                          |
// | Boston, MA 02111-1307, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Christiaan Kortekaas <c.kortekaas@library.uq.edu.au>,       |
// |          Matthew Smith <m.smith@library.uq.edu.au>                   |
// +----------------------------------------------------------------------+
//
//

include_once("config.inc.php");
include_once(APP_INC_PATH . "class.lister.php");
include_once(APP_INC_PATH . "class.auth.php");

if (APP_AUTHOR_PROFILE_REDIRECT == 'ON') {
    // Send to the new eSpace search profile page when only the author_id is supplied PT: #176474178
    if (count($_GET) === 2 &&
        array_key_exists('browse', $_GET) &&
        $_GET['browse'] === 'author_id' &&
        array_key_exists('value', $_GET) &&
        is_numeric($_GET['value'])
    ) {
        Lister::authorProfileRedirect($_GET['value']);
    }
}

$res = Lister::getList($_GET, true);
$pids = array();
if (is_array($res['list'])) {
	foreach ($res['list'] as $record) {
        if (array_key_exists('rek_pid', $record)) {
		    $pids[] = $record['rek_pid'];
        }
	}
}
/*
 * If this is a logged in user we want to save this data for view pages, so when can create
 * 'prev' and 'next' links
 */
$username = Auth::getUsername();
if (!empty($username)) {
	$_SESSION['list'] = $pids;
	$_SESSION['list_params'] = $_GET;
	$_SESSION['script_name'] = $_SERVER['SCRIPT_NAME'];
	$_SESSION['last_page'] = $res['list_info']['last_page'];
	$_SESSION['view_page'] = $res['list_info']['current_page'];
}

