Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/user/components/preferences.php
Строк: 56
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_user_preferences extends VModule_user
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
VAuth::check('Registered');
    
        
$errors        = array();
        
$messages    = array();
        
$user_id    = (int) $_SESSION['user_id'];
        
$locked        $this->is_locked($user_id);
        
        if (
$locked) {
            
$errors[] = __('account-locked');
        }
        
        if (isset(
$_POST['submit_preferences_edit']) && !$locked) {
            
$filter                    VF::factory('filter');
            
$profile                $filter->get('profile');
            
$profile_comments        $filter->get('profile_comments');
            
$show_videos            $filter->get('show_videos');
            
$show_video_favorites    $filter->get('show_video_favorites');
            
$show_video_history        $filter->get('show_video_ratings');
            
$show_video_ratings        $filter->get('show_video_ratings');
            
$show_video_playlists    $filter->get('show_video_playlists');
            
$show_friends            $filter->get('show_friends');
            
$show_subscriptions        $filter->get('show_subscriptions');
            
$show_subscribers        $filter->get('show_subscribers');
            
$show_activity            $filter->get('show_activity');
            
$allow_comments            $filter->get('allow_comment');
            
$allow_friends            $filter->get('allow_friends');
            
$allow_message            $filter->get('allow_message');
            
$show_albums            = (isset($_POST['show_albums'])) ? $filter->get('show_albums') : 'all';
            
$show_photo_favorites    = (isset($_POST['show_photo_favorites'])) ? $filter->get('show_photo_favorites') : 'all';
            
            if (!
$errors) {
                
$this->db->query("UPDATE #__user_preferences
                            SET profile = '"
.$this->db->escape($profile)."',
                                profile_comments = '"
.$this->db->escape($profile_comments)."',
                                show_videos = '"
.$this->db->escape($show_videos)."',
                                show_video_favorites = '"
.$this->db->escape($show_video_favorites)."',
                                show_video_history = '"
.$this->db->escape($show_video_history)."',
                                show_video_ratings = '"
.$this->db->escape($show_video_ratings)."',
                                show_video_playlists = '"
.$this->db->escape($show_video_playlists)."',
                                show_albums    = '"
.$this->db->escape($show_albums)."',
                                show_photo_favorites = '"
.$this->db->escape($show_photo_favorites)."',
                                show_friends = '"
.$this->db->escape($show_friends)."',
                                show_subscriptions = '"
.$this->db->escape($show_subscriptions)."',
                                show_subscribers = '"
.$this->db->escape($show_subscribers)."',
                                show_activity = '"
.$this->db->escape($show_activity)."',
                                allow_comments = '"
.$this->db->escape($allow_comments)."',
                                allow_friends = '"
.$this->db->escape($allow_friends)."',
                                allow_message = '"
.$this->db->escape($allow_message)."'
                            WHERE user_id = "
.$user_id."
                            LIMIT 1"
);
                
$messages[] = __('preferences-success');
            }
        }
        
        
$this->db->query('SELECT * FROM #__user_preferences WHERE user_id = '.$user_id.' LIMIT 1');
        if (!
$this->db->affected_rows()) {
            throw new 
Exception('Failed to load user data! Application error!?');
        }
        
        
$this->tpl->menu        'home';
        
$this->tpl->submenu        'user-preferences';
        
$this->tpl->meta_title    __('preferences-meta-title');
        
$this->tpl->errors        $errors;
        
$this->tpl->messages    $messages;
        
$this->tpl->prefs        $this->db->fetch_assoc();
        
$this->tpl->load(array('header''user_preferences''footer'));
        
$this->tpl->display();
    }

    private function 
is_locked($user_id)
    {
        
$this->db->query("SELECT locked FROM #__user WHERE user_id = ".$user_id." LIMIT 1");
        if (
$this->db->affected_rows()) {
            return (bool) 
$this->db->fetch_field('locked');
        }

        
VModule::load('error'true);
    }    
}
Онлайн: 2
Реклама