コード例 #1
0
ファイル: messages.php プロジェクト: arp19690/newtravel
 public function delete_conversation($other_username)
 {
     if (isset($this->session->userdata["user_id"])) {
         $redis_functions = new Redisfunctions();
         $user_id = $this->session->userdata["user_id"];
         $me_username = $this->session->userdata["user_username"];
         $other_user_records = $redis_functions->get_user_profile_data($other_username);
         if (!empty($other_user_records)) {
             $other_user_id = $other_user_records['user_id'];
             $model = new Common_model();
             $sql = 'SELECT message_id FROM ' . TABLE_MESSAGES . ' WHERE ((message_user_from=' . $other_user_id . ' AND message_user_to=' . $user_id . ') OR (message_user_to=' . $other_user_id . ' AND message_user_from=' . $user_id . '))';
             $chat_records = $model->query($sql);
             if (!empty($chat_records)) {
                 $message_id_arr = array();
                 foreach ($chat_records as $chat_value) {
                     $message_id_arr[] = $chat_value['message_id'];
                 }
                 $redis_functions->set_deleted_message_ids($me_username, $message_id_arr);
                 $this->session->set_flashdata('success', 'Your conversation with ' . stripslashes($other_user_records['user_fullname']) . ' marked as deleted');
             }
         } else {
             $this->session->set_flashdata('error', 'An error occurred. Please try again later.');
         }
         redirect(base_url('my-chats'));
     } else {
         display_404_page();
     }
 }