Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/message/components/inbox.php
Строк: 59
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_message_inbox extends VModule_message
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
VAuth::check('Registered');
        
        
VLanguage::load('frontend.user');
        
        
$user_id     = (int) $_SESSION['user_id'];
        
        
$errors        = array();
        
$messages    = array();
        if (isset(
$_POST['action'])) {
            
$action trim($_POST['action']);
            
$msg_id = (isset($_POST['id'])) ? (int) trim($_POST['id']) : 0;
            if (
$msg_id) {
                switch (
$action) {
                    case 
'delete':
                        
$this->delete($msg_id0$user_id);
                        
$messages[] = __('msg-delete-success');
                        break;
                    default:
                        
$errors[] = 'Invalid action! What exactly did you click!?';
                }
            } else {
                
$errors[] = 'Invalid message! Are you sure this message exists!?';
            }
        }
        
        if (isset(
$_POST['submit-actions'])) {
            
$ids     $this->get_checked_ids();
            if (
$ids) {
                
$action    trim($_POST['actions']);
                if (
$action == 'delete') {
                    
$this->db->query("DELETE FROM #__message
                                      WHERE msg_id IN ("
.implode(','array_values($ids)).")
                                      AND receiver_id = "
.$user_id);
                    
$messages[] = __('msgs-delete-success');
                } else {
                    
$errors[] = __('action-invalid');
                }
            } else {
                
$errors[] = __('msgs-empty');
            }
        }
        
        
$page            = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;
        
$sql_count        "SELECT COUNT(DISTINCT sender_id) AS total_msgs
                           FROM #__message
                           WHERE receiver_id = "
.$user_id."
                           AND status IN (1, 2, 3)"
;
        
$total_msgs        $this->db->get_field($sql_count'total_msgs');
        
$pagination        VPagination::get($page$total_msgs20);
        
$sql            "SELECT m.msg_id, m.sender_id, m.receiver_id, m.subject,
                                  m.message, m.send_time, m.status,
                                  u.username, u.avatar, u.gender
                           FROM #__message AS m
                           LEFT JOIN #__user AS u ON (u.user_id = m.sender_id)
                           WHERE m.receiver_id = "
.$user_id."
                           AND m.status IN (1, 2, 3)
                           GROUP BY m.sender_id
                           ORDER BY m.msg_id DESC
                           LIMIT "
.$pagination['limit'];
        
$msgs            $this->db->get_rows($sql);
    
        
$this->tpl->menu        'home';
        
$this->tpl->submenu        'user-message-inbox';
        
$this->tpl->colmenu        'manage';
        
        
$this->tpl->title        __('inbox-title');
        
$this->tpl->meta_title    __('inbox-meta-title');
        
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
$this->tpl->msgs        $msgs;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->load(array('header''user_messages''footer'));
        
$this->tpl->display();
    }
}
Онлайн: 0
Реклама