...

View Full Version : Last 5 Messages Issue



CoolAsCarlito
10-22-2012, 11:10 PM
What I'm trying to do is figure out how I can have the following happen. I have a lot of pages that make a function call that gets the last 5 received personal messages which includes the actual personal messages page which is displayed below as the controller. It has the $last_5_personal_messages variable as well as the $personal_messages variable. They both make function calls to the get_messages function. If you also notice there's functions called important, lastweek, thisweek, today. These functions pass what kind of data is passed to the inbox message so it knows what kind of data to go retrieve which it gets the messages. I'm trying to figure out how I can adjust the function call so that it can get the data for the last 5 messages because I am stuck.



<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Personalmessages extends CI_Controller {

public function __construct()
{
parent::__construct();
}

public function index()
{
redirect('kowmanager/personalmessages/inbox/');
}

public function inbox($display = NULL, $datetime_format = NULL)
{
$message_box_messages = array();
$css_page_addons = '';
$js_page_addons = '';
$meta_tag_addons = '';
$site_title = 'KOW Manager Personal Messages';

$user_data = $this->users_model->is_logged_in($this->session->userdata('xtr'));

if ($user_data === FALSE)
{
redirect('login', 'refresh');
}
else
{
$body_content = $this->config->item('themes_path').'/'.$this->config->item('default_theme').'/cpanel/messages_view';
$body_type = 'full';
$geo_data = $this->functions_model->geo_matching();

/*
* Gets the last 5 messages that were recieved.
*
@param integer $user_data->user_id User ID of the logged in user.
@param integer or empty Represents the number of messages to retrieve. Empty represents getting all messages.
@param integer $geo_data['zipz']['timezone'] The time offset of the user logged in based on his timezone.
@param string inbox or outbox Tells the function which type of messages to retrieve.
@param string d F Y g:i a Tells how to format the datetime_sent in the get_personal_messages functions.
@param empty.
*/
$last_5_personal_messages = $this->messages_model->get_personal_messages($user_data->user_id, 5, $geo_data['zipz']['timezone'], 'inbox', 'd F Y g:i a', '');

/*
* Grabs messages for the logged in user.
*
@param integer $user_data->user_id User ID of the logged in user.
@param integer or empty Represents the number of messages to retrieve. Empty represents getting all messages.
@param integer $geo_data['zipz']['timezone'] The time offset of the user logged in based on his timezone.
@param string inbox or outbox Tells the function which type of messages to retrieve.
@param string $datetime_format Tells how to format the datetime_sent in the get_personal_messages functions. Specified from the type function.
@param array Sends a type of message(today, last_week, this_week, important) and a values to look for.
*/
$personal_messages = $this->messages_model->get_personal_messages($user_data->user_id,'', $geo_data['zipz']['timezone'], 'inbox', $datetime_format, $display);
}

if (count($message_box_messages) !== 0)
{
$message_boxes = $this->functions_model->build_message_boxes_output(array('display' => 'show', 'message' => $message_box_messages));
}
else
{
$message_boxes = array('display' => 'none');
}

$meta_tags = $this->functions_model->meta_tags();

if (isset($site_title) && (empty($site_title)))
{
$site_title = $this->functions_model->site_title();
}

$this->data['user_data'] = $user_data;
$this->data['last_5_personal_messages'] = $last_5_personal_messages;
$this->data['personal_messages'] = $personal_messages;
$this->data['notifications'] = $this->site_model->get_notifications();
$this->data['server_data'] = $this->server_model->get_server_data();
$this->data['site_data'] = $this->site_model->get_site_data();
$this->data['message_boxes'] = $message_boxes;
$this->data['css_page_addons'] = $css_page_addons;
$this->data['js_page_addons'] = $js_page_addons;
$this->data['site_title'] = $site_title;
$this->data['body_content'] = $body_content;
$this->data['body_type'] = $body_type;
$this->data['meta_tags'] = $meta_tags;
$this->data['site_url'] = $this->functions_model->site_url();
$this->load->view($this->config->item('themes_path').'/'.$this->config->item('default_theme').'/cpanel/template/index', $this->data);
}

public function today()
{
$today = date('Y-m-d', time());
$start_range = $today.' 00:00:00';
$end_range = $today. ' 23:59:59';
$this->inbox(array('type' => 'today', 'values' => array('start_time' => $start_range, 'end_time' => $end_range)), 'H:s:i a');
}

public function thisweek()
{

$start_range = $today.' 00:00:00';
$end_range = $today. ' 23:59:59';
$this->inbox(array('type' => 'thisweek', 'values' => array('start_time' => $start_range, 'end_time' => $end_range)), 'M d');
}

public function lastweek()
{
$this->inbox(array('type' => 'lastweek', 'values' => array('start_time' => $start_range, 'end_time' => $end_range)), 'M d');
}

public function important()
{
$this->inbox(array('type' => 'important', 'values' => 0), '');
}
}
/* End of file personalmessages.php */
/* Location: ./application/controllers/personalmessages.php */

CoolAsCarlito
10-23-2012, 10:45 AM
*bump*



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum