public function set_unread_chats_username($username) { $custom_model = new Custom_model(); $user_profile_data = $this->get_user_profile_data($username); $records = $custom_model->get_unread_chats_username($user_profile_data['user_id']); $this->ci->redis->hSet('unread_chats_username', $username, json_encode($records)); return $records; }
public function get_unread_chats_ajax($other_username_enc, $latest_timestamp) { $json_data = array('status' => 'error', 'message' => 'An error occurred'); if (isset($this->session->userdata["user_id"])) { $custom_model = new Custom_model(); $redis_functions = new Redisfunctions(); $user_id = $this->session->userdata["user_id"]; $other_username = getEncryptedString($other_username_enc, 'decode'); $other_user_records = $redis_functions->get_user_profile_data($other_username); if (!empty($other_user_records)) { $other_user_id = $other_user_records['user_id']; $where_str = 'm1.`message_user_from` = ' . $other_user_id . ' and m1.`message_user_to` = ' . $user_id . ' AND m1.message_timestamp > ' . $latest_timestamp; $chat_records = $custom_model->get_chat_history($user_id, $other_user_id, $fields = NULL, $where_str); $str = $latest_message_timestamp = NULL; if (!empty($chat_records)) { $str = $chat_records; // Marking previous messages as read $latest_message_id = $chat_records[count($chat_records) - 1]['message_id']; $latest_message_timestamp = $chat_records[count($chat_records) - 1]['message_timestamp']; $this->mark_previous_messages_as_read($latest_message_id, $user_id, $other_user_id); } $json_data = array('status' => 'success', 'message' => 'Success', 'data' => $str, 'latest_timestamp' => $latest_message_timestamp); } else { $json_data = array('status' => 'error', 'message' => 'Not a valid choice'); } } $json_data = json_encode($json_data); echo $json_data; return $json_data; }
public function search_query($view_type = 'list', $page = 1) { $model = new Common_model(); $custom_model = new Custom_model(); if ($this->input->get('q')) { $params = $this->input->get(); $query = $params['q']; $user_id = isset($this->session->userdata['user_id']) == TRUE ? $this->session->userdata['user_id'] : NULL; if ($model->is_exists('ps_id', TABLE_POST_SEARCHES, array('ps_user_id' => $user_id, 'ps_query' => addslashes($query), 'ps_timestamp >=' => date('Y-m-d'))) == FALSE) { $data_array = array('ps_user_id' => $user_id, 'ps_query' => addslashes($query), 'ps_url' => addslashes(current_url()), 'ps_params' => json_encode($params), 'ps_ipaddress' => USER_IP, 'ps_useragent' => USER_AGENT); $model->insertData(TABLE_POST_SEARCHES, $data_array); } $order_by = get_post_mysql_sort_by(@$params['sort']); $group_by = 'p.post_id'; $where_cond_str = '1'; $search_results = $custom_model->get_search_results('p.post_url_key', $where_cond_str, $order_by, $group_by); $input_arr = array(base_url() => 'Home', '#' => 'Search'); $breadcrumbs = get_breadcrumbs($input_arr); $page_title = 'Search results'; $data["post_records"] = $search_results; $data["view_type"] = $view_type; $data["page"] = $page; $data["breadcrumbs"] = $breadcrumbs; $data["page_title"] = $page_title; $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME'); $this->template->write_view("content", "pages/trip/listing/list-page", $data); $this->template->render(); } else { display_404_page(); } }
public function viewProfile($username) { $data = array(); $model = new Common_model(); $custom_model = new Custom_model(); $pageNotFound = FALSE; if ($username) { $record = $model->is_exists("*", TABLE_USERS, array("username" => $username)); if (!empty($record)) { $record = $record[0]; $pageNotFound = TRUE; $is_friend = FALSE; $is_accepted = "0"; if (isset($this->session->userdata["user_id"])) { // $is_friend_record = $model->is_exists("friend_id, is_accepted", TABLE_FRIENDS, array("sent_from" => $this->session->userdata["user_id"], "sent_to" => $record["user_id"])); $is_friend_record = $custom_model->isFriend($this->session->userdata["user_id"], $record["user_id"], "friend_id, is_accepted"); if (!empty($is_friend_record)) { $is_friend = TRUE; $is_accepted = $is_friend_record[0]["is_accepted"]; } } $trips_record = $model->fetchSelectedData("trip_title, url_key", TABLE_TRIPS, array("trip_user_id" => $record["user_id"], "trip_status" => "1"), "trip_id", "DESC", "0,5"); // prd($trips_record); $my_connects_record = $custom_model->getMyFriends($record["user_id"], "first_name, last_name, user_facebook_id, username, user_id", "0,8"); $data["meta_title"] = ucwords($record["first_name"] . " " . $record["last_name"]) . " | " . $this->redis_functions->get_site_setting('SITE_NAME'); $data["meta_description"] = getNWordsFromString($record["user_bio"], 30); $data["record"] = $record; $data["is_friend"] = $is_friend; $data["is_accepted"] = $is_accepted; $data["trips_record"] = $trips_record; $data["my_connects_record"] = $my_connects_record; $data["my_connects_totalcount"] = $custom_model->getMyFriendsCount($record["user_id"]); $this->template->write_view("content", "pages/user/view-profile", $data); $this->template->render(); } } if ($pageNotFound == FALSE) { $this->template->write_view("content", "pages/index/page-not-found", $data); $this->template->render(); } }
<?php $redis_functions = new Redisfunctions(); $custom_model = new Custom_model(); $min_and_max_costs = $custom_model->get_min_and_max_cost_amounts(); $travel_mediums = $redis_functions->get_travel_mediums(); if (!isset($count_search_results)) { $count_search_results = 0; } ?> <form action="<?php echo base_url('trip/search/list'); ?> " method="GET"> <div class="clear"> <div class="srch-results-lbl fly-in"> <span><?php echo number_format($count_search_results); ?> results found.</span> </div> <div class="side-block fly-in"> <div class="side-block-search"> <div class="page-search-p"> <!-- // --> <div class="srch-tab-line"> <div class="clear"> <label>Location</label> <div class="input-a"><input type="text" name="search_location" value="<?php