$start = $pagenavi->getStart();
 $limit = $pagenavi->getLimit();
 if ($is_users) {
     $objs =& xoonips_eventlog_get_users($start, $limit);
     foreach ($objs as $obj) {
         $user = array();
         $uname = $obj->getExtraVar('uname');
         $email = $obj->getExtraVar('email');
         $user['uname'] = $textutil->html_special_chars($uname);
         $user['company_name'] = $textutil->html_special_chars($obj->getVar('company_name', 'n'));
         $user['division'] = $textutil->html_special_chars($obj->getVar('division', 'n'));
         $user['email'] = $textutil->html_special_chars($email);
         $users[] = $user;
     }
 } else {
     $objs =& xoonips_eventlog_get_items($start, $limit);
     foreach ($objs as $obj) {
         $item = array();
         $item_id = $obj->getVar('item_id', 's');
         $title = xoonips_eventlog_get_item_title($item_id);
         $display_name = $obj->getExtraVar('display_name');
         $uname = $obj->getExtraVar('uname');
         $item['item_id'] = $item_id;
         $item['title'] = $textutil->html_special_chars($title);
         $item['display_name'] = $textutil->html_special_chars($display_name);
         $item['uname'] = $textutil->html_special_chars($uname);
         $items[] = $item;
     }
 }
 $navi = $pagenavi->getTemplateVars(10);
 $breadcrumbs[] = array('name' => _MD_XOONIPS_BREADCRUMBS_EVENTLOG_LIST);
/**
 * download list of registered users or items
 *
 * @access public
 * @param bool $is_post true if request method is 'POST'
 * @param int $log_type_id id of log type
 */
function xoonips_eventlog_download_registered_list($is_post, $log_type_id)
{
    $ticket_area = 'xoonips_eventlog_download';
    $mimetype = 'text/csv';
    $url = XOOPS_URL . '/modules/xoonips/event_log.php';
    $condition_map = array(20 => array('user', 'User List,,%s users', 'Name,Company,Division,Email'), 21 => array('item', 'Item List,,%s items', 'Item ID,Title,Item Type,Contributor'));
    // check arguments
    if (!isset($condition_map[$log_type_id])) {
        die('invalid log type id ');
    }
    list($mode, $csv_title_fmt, $csv_header) = $condition_map[$log_type_id];
    $filename = date('Y') . '-' . $mode . '.csv';
    // check token ticket for get request
    if (!$is_post) {
        if (!$GLOBALS['xoopsGTicket']->check($is_post, $ticket_area, false)) {
            redirect_header($url, 3, $GLOBALS['xoopsGTicket']->getErrors());
            exit;
        }
    }
    // check download condition
    $download =& xoonips_getutility('download');
    if (!$download->check_pathinfo($filename)) {
        // require PATH_INFO on KHTML browser (Safari)
        $token_ticket = $GLOBALS['xoopsGTicket']->getTicketParamString(__LINE__, true, 1800, $ticket_area);
        $reload_url = $download->append_pathinfo($url, $filename);
        $reload_url .= '?mode=download&log_type_id=' . $log_type_id . '&' . $token_ticket;
        header('Location: ' . $reload_url);
        exit;
    }
    // output HTTP headers
    $download->output_header($filename, $mimetype, 0);
    switch ($mode) {
        case 'user':
            $objs =& xoonips_eventlog_get_users(0, 0);
            // output csv header
            $cnt = count($objs);
            $csv_title = sprintf($csv_title_fmt, $cnt);
            echo $csv_title . "\r\n";
            echo $csv_header . "\r\n";
            foreach ($objs as $obj) {
                $line = array();
                $line[] = $obj->getExtraVar('uname');
                $line[] = $obj->getVar('company_name', 'n');
                $line[] = $obj->getVar('division', 'n');
                $line[] = $obj->getExtraVar('email');
                echo _xoonips_eventlog_array2csv($download, $line);
            }
            break;
        case 'item':
            $objs =& xoonips_eventlog_get_items(0, 0);
            // output csv header
            $cnt = count($objs);
            $csv_title = sprintf($csv_title_fmt, $cnt);
            echo $csv_title . "\r\n";
            echo $csv_header . "\r\n";
            foreach ($objs as $obj) {
                $line = array();
                $item_id = $obj->getVar('item_id', 'n');
                $line[] = $item_id;
                $line[] = xoonips_eventlog_get_item_title($item_id);
                $line[] = $obj->getExtraVar('display_name');
                $line[] = $obj->getExtraVar('uname');
                echo _xoonips_eventlog_array2csv($download, $line);
            }
            break;
    }
    exit;
}