Файл: adultscript-2.0.3-pro/files/modules/user/components/notifications.php
Строк: 83
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_user_notifications 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_notifications_edit']) && !$locked) {
$video_approve = (isset($_POST['video_approve']) && $_POST['video_approve'] == 'on') ? 1 : 0;
$video_comment = (isset($_POST['video_comment']) && $_POST['video_comment'] == 'on') ? 1 : 0;
$video_rating = (isset($_POST['video_rating']) && $_POST['video_rating'] == 'on') ? 1 : 0;
$subscription = (isset($_POST['subscription']) && $_POST['subscription'] == 'on') ? 1 : 0;
$friend_request = (isset($_POST['friend_request']) && $_POST['friend_request'] == 'on') ? 1 : 0;
$friend_approve = (isset($_POST['friend_approve']) && $_POST['friend_approve'] == 'on') ? 1 : 0;
$new_message = (isset($_POST['new_message']) && $_POST['new_message'] == 'on') ? 1 : 0;
$profile_comment = (isset($_POST['profile_comment']) && $_POST['profile_comment'] == 'on') ? 1 : 0;
$this->db->query("UPDATE #__user_notifications
SET video_approve = '".$video_approve."',
video_comment = '".$video_comment."',
video_rating = '".$video_rating."',
subscription = '".$subscription."',
friend_request = '".$friend_request."',
friend_approve = '".$friend_approve."',
new_message = '".$new_message."',
profile_comment = '".$profile_comment."'
WHERE user_id = ".$user_id."
LIMIT 1");
$messages[] = __('notifications-success');
}
$this->db->query('SELECT * FROM #__user_notifications 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-notifications';
$this->tpl->meta_title = __('notifications-meta-title');
$this->tpl->errors = $errors;
$this->tpl->messages = $messages;
$this->tpl->notifs = $this->db->fetch_assoc();
$this->tpl->load(array('header', 'user_notifications', '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);
}
}