root/trunk/inc/messages/inbox.inc.php

Revision 21, 2.1 KB (checked in by alexx, 7 years ago)

Add pagination to friends list

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25include_once(INCLUDESPATH.'/pager.inc.php');
26
27$_SMARTY['Title'] =  'Messages';
28
29$nb_messages = $db->getOne('SELECT COUNT(id_mess) FROM message WHERE id=? AND box=?', array($_SESSION['my_id'],'inbox'));
30
31$pager =& Pager_dotnode::factory(null, array('totalItems' => $nb_messages));
32
33list($first_item, $last_item) = $pager->getOffsetByPageId();
34$limit_offset = $first_item-1;
35$limit_length = $last_item-$limit_offset;
36
37$messages_r = $db->query('SELECT id_mess, id_from, from_str, type, dest, subject, message, flag, date FROM message WHERE id=? AND box=? ORDER by date DESC LIMIT !,!', array($_SESSION['my_id'],'inbox', $limit_offset, $limit_length ));
38
39if(!DB::isError($messages_r) )
40while($message = $messages_r->fetchRow())
41        $messages[$message['id_mess']] = $message;
42else
43    error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | '.$messages_r->getUserInfo());
44
45$_SESSION['nb_new_messages'] = $db->getOne('SELECT COUNT(id_mess) FROM message WHERE id=? AND box=? AND flag=?', array($_SESSION['my_id'], 'inbox', 'new'));
46$_SESSION['nb_new_messages_timestamp'] = 1;
47
48$_SMARTY['pager'] = $pager->getLinks();
49$_SMARTY['messages'] = $messages;
50?>
Note: See TracBrowser for help on using the browser.