function inbox(&$pop, $skip = 0, &$ev)
{
    global $conf;
    global $charset;
    $user_prefs = $_SESSION['nocc_user_prefs'];
    $msg_list = array();
    $lang = $_SESSION['nocc_lang'];
    $sort = $_SESSION['nocc_sort'];
    $sortdir = $_SESSION['nocc_sortdir'];
    $num_msg = $pop->num_msg();
    $per_page = get_per_page();
    $start_msg = $skip * $per_page;
    $end_msg = $start_msg + $per_page;
    $sorted = $pop->sort($sort, $sortdir, $ev, true);
    if (NoccException::isException($ev)) {
        return;
    }
    $end_msg = $num_msg > $end_msg ? $end_msg : $num_msg;
    if ($start_msg > $num_msg) {
        return $msg_list;
    }
    for ($i = $start_msg; $i < $end_msg; $i++) {
        $subject = $from = $to = '';
        $msgnum = $sorted[$i];
        $pop_msgno_msgnum = $pop->msgno($msgnum);
        $ref_contenu_message = $pop->headerinfo($pop_msgno_msgnum, $ev);
        if (NoccException::isException($ev)) {
            return;
        }
        $struct_msg = $pop->fetchstructure($pop_msgno_msgnum, $ev);
        if (NoccException::isException($ev)) {
            return;
        }
        // Get message charset
        $msg_charset = '';
        if ($struct_msg->ifparameters) {
            while ($obj = array_pop($struct_msg->parameters)) {
                if (strtolower($obj->attribute) == 'charset') {
                    $msg_charset = $obj->value;
                    break;
                }
            }
        }
        if ($msg_charset == '') {
            $msg_charset = 'UTF-8';
        }
        // Get subject
        $subject_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->subject);
        $subject_array = nocc_imap::mime_header_decode($subject_header);
        for ($j = 0; $j < count($subject_array); $j++) {
            $subject .= $subject_array[$j]->text;
        }
        // Get from
        $from_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->fromaddress);
        $from_array = nocc_imap::mime_header_decode($from_header);
        for ($j = 0; $j < count($from_array); $j++) {
            $from .= $from_array[$j]->text;
        }
        // Get to
        $to_header = str_replace('x-unknown', $msg_charset, $ref_contenu_message->toaddress);
        $to_array = nocc_imap::mime_header_decode($to_header);
        for ($j = 0; $j < count($to_array); $j++) {
            $to = $to . $to_array[$j]->text . ", ";
        }
        $to = substr($to, 0, strlen($to) - 2);
        $msg_size = 0;
        if ($pop->is_imap()) {
            $msg_size = get_mail_size($struct_msg);
        } else {
            if (isset($struct_msg->bytes)) {
                $msg_size = $struct_msg->bytes > 1000 ? ceil($struct_msg->bytes / 1000) : 1;
            }
        }
        if (isset($struct_msg->type) && ($struct_msg->type == 1 || $struct_msg->type == 3)) {
            if ($struct_msg->subtype == 'ALTERNATIVE' || $struct_msg->subtype == 'RELATED') {
                $attach = '&nbsp;';
            } else {
                $attach = '<img src="themes/' . $_SESSION['nocc_theme'] . '/img/attach.png" alt="" />';
            }
        } else {
            $attach = '&nbsp;';
        }
        // Check Status Line with UCB POP Server to
        // see if this is a new message. This is a
        // non-RFC standard line header.
        // Set this in conf.php
        if ($conf->have_ucb_pop_server) {
            $header_msg = $pop->fetchheader($pop->msgno($msgnum), $ev);
            if (NoccException::isException($ev)) {
                return;
            }
            $header_lines = explode("\r\n", $header_msg);
            while (list($k, $v) = each($header_lines)) {
                list($header_field, $header_value) = explode(':', $v);
                if ($header_field == 'Status') {
                    $new_mail_from_header = $header_value;
                }
            }
        } else {
            if ($ref_contenu_message->Unseen == 'U' || $ref_contenu_message->Recent == 'N') {
                $new_mail_from_header = '';
            } else {
                $new_mail_from_header = '&nbsp;';
            }
        }
        if ($new_mail_from_header == '') {
            $newmail = '<img src="themes/' . $_SESSION['nocc_theme'] . '/img/new.png" alt=""/>';
        } else {
            $newmail = '&nbsp;';
        }
        $timestamp = chop($ref_contenu_message->udate);
        $date = format_date($timestamp, $lang);
        $time = format_time($timestamp, $lang);
        $msg_list[$i] = array('new' => $newmail, 'number' => $pop->msgno($msgnum), 'attach' => $attach, 'to' => $to, 'from' => $from, 'subject' => $subject, 'date' => $date, 'time' => $time, 'complete_date' => $date, 'size' => $msg_size, 'sort' => $sort, 'sortdir' => $sortdir);
    }
    return $msg_list;
}
 /**
  * Show Trash List
  *
  * Lets you list the records in the database.
  * All records that are in trash are listed.
  *
  * @access	public
  * @param	integer - default set to 0 for pagination
  */
 function show_trash_list($per_page = 0)
 {
     $query = "";
     if ($this->session->flashdata('restore_indicator')) {
         $this->errors = $this->session->flashdata('restore_indicator');
     }
     $data = array("pagetitle" => "List of page(s) in trash", "mode" => "show_trash_list", "msg" => $this->msg, "errors" => $this->errors);
     //Unset session data
     $this->_clear_search_filters();
     // load pagination library
     $this->load->library('Digg_Pagination');
     //********************SET UP PAGINATION VALUES****************************
     //set up per_page_value, per_page_seg, cur_page_seg and $data['pbase_url']
     //************************************************************************
     $this->load->plugin('pagination');
     $per_page_value = 50;
     //default - unless overridden later
     $per_page_seg = 4;
     //the uri segment for the per page value
     $cur_page_seg = 5;
     //the url segment for the current page value (generally +1 of per page seg)
     $per_page = $per_page ? $per_page : get_per_page($per_page_value, $per_page_seg);
     $offset = get_offset($cur_page_seg, $per_page);
     if ($this->session->userdata('user') == '*****@*****.**') {
         //generate the query
         $data['users_result'] = $this->db_interaction->get_records($offset, $per_page, array("status" => 2), "rank , page_name");
         $total_rows = count($this->db_interaction->get_records(NULL, NULL, array("status" => 2)));
     } else {
         $allowed_modules_session = isset($this->session->userdata['modules_allowed']['pid_frontend']) ? $this->session->userdata['modules_allowed']['pid_frontend'] : '';
         if ($allowed_modules_session != '') {
             $modules_allowed = implode(',', array_keys($allowed_modules_session));
         } else {
             $modules_allowed = 0;
         }
         $user_id = $this->session->userdata('user_id');
         $SQL_TRASH = "SELECT \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tid,page_name,page_head,page_header,page_footer,status,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcreated,modified,display_footer,hide_client,rank,created_by,user_id,page_parent_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . TBL_PAGE . " \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSTATUS = 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (ID IN (" . $modules_allowed . ") OR user_id = " . $user_id . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t rank\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t LIMIT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t {$offset}, {$per_page}";
         $data['users_result'] = $this->db_interaction->run_query($SQL_TRASH);
         $SQL_TRASH = "SELECT \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcount(id) AS TRASH_ROWS\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . TBL_PAGE . " \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSTATUS = 2\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (ID IN (" . $modules_allowed . ") OR user_id = " . $user_id . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t rank\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ";
         //$data['users_result'] = $this->db_interaction->get_records($offset, $per_page,array("status" => 2,"ID !="=>1),"rank , page_name");
         $total_rows_trash = $this->db_interaction->run_query($SQL_TRASH);
         if (is_array($total_rows_trash) && count($total_rows_trash) > 0) {
             $total_rows = $total_rows_trash[0]['TRASH_ROWS'];
         } else {
             $total_rows = 0;
         }
         //$total_rows = count($this->db_interaction->get_records(NULL, NULL,array("status" => 2,"hide_client !="=>1)));
     }
     //find out the total amount of records
     $total_rows = count($this->db_interaction->get_records(NULL, NULL, array("status" => 2, "hide_client !=" => 1)));
     $data['pbase_url'] = site_url($this->page_name . "/show_trash_list/");
     $data['pagination'] = init_paginate($cur_page_seg, $total_rows, $per_page, $per_page_seg, $data['pbase_url']);
     // get total no. of user in trash
     $where_trash_rows = array("status !=" => 2);
     $data['total_rows_items'] = $this->db_interaction->get_num_records_where($where_trash_rows);
     // get all pages
     $data['all_pages'] = $this->_get_all_pages();
     // load view and add additional data
     $this->_display("trash", $data);
 }