Пример #1
0
    if (!empty($_POST['message']) && !ctype_space($_POST['message'])) {
        $message['message'] = htmlspecialchars($_POST['message']);
        View::$vars->msg = $message['message'];
    } else {
        View::$vars->errors['message'] = Language::GetText('error_message');
    }
    // Create message if no errors were found
    if (empty(View::$vars->errors)) {
        $message['user_id'] = View::$vars->user->user_id;
        Plugin::Trigger('message_send.before_send_message');
        Message::Create($message);
        View::$vars->to = NULL;
        View::$vars->subject = NULL;
        View::$vars->msg = NULL;
        // Send recipient email notification if opted-in
        $privacy = Privacy::LoadByUser($recipient->user_id);
        if ($privacy->OptCheck('new_message')) {
            $replacements = array('host' => HOST, 'sitename' => $config->sitename, 'sender' => View::$vars->user->username, 'email' => $recipient->email);
            $mail = new Mail();
            $mail->LoadTemplate('new_message', $replacements);
            $mail->Send($recipient->email);
        }
        View::$vars->message = Language::GetText('success_message_sent');
        View::$vars->message_type = 'success';
        Plugin::Trigger('message_send.send_message');
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
Пример #2
0
<?php

// Include required files
include_once dirname(dirname(dirname(__FILE__))) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Privacy');
// Establish page variables, objects, arrays, etc
View::InitView('privacy_settings');
Plugin::Trigger('privacy_settings.start');
Functions::RedirectIf(View::$vars->logged_in = User::LoginCheck(), HOST . '/login/');
View::$vars->user = new User(View::$vars->logged_in);
View::$vars->privacy = Privacy::LoadByUser(View::$vars->user->user_id);
View::$vars->data = array();
View::$vars->errors = array();
View::$vars->message = null;
/**************************
 * Handle Form if submitted
 *************************/
if (isset($_POST['submitted'])) {
    // Validate Video Comments
    if (isset($_POST['video_comment']) && in_array($_POST['video_comment'], array('0', '1'))) {
        View::$vars->data['video_comment'] = $_POST['video_comment'];
    } else {
        View::$vars->errors['video_comment'] = TRUE;
    }
    // Validate Private Message
    if (isset($_POST['new_message']) && in_array($_POST['new_message'], array('0', '1'))) {
        View::$vars->data['new_message'] = $_POST['new_message'];
    } else {
        View::$vars->errors['new_message'] = TRUE;
    }
Пример #3
0
 /**
  * Make a video visible to the public and notify subscribers of new video
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void Video is activated, subscribers are notified, and admin
  * alerted. If approval is required video is marked as pending and placed in queue
  */
 public function Approve($action)
 {
     App::LoadClass('User');
     App::LoadClass('Privacy');
     App::LoadClass('Mail');
     global $config;
     $send_alert = false;
     Plugin::Trigger('video.before_approve');
     // 1) Admin created video in Admin Panel
     // 2) User created video
     // 3) Video is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // User uploaded video but needs admin approval
         if ($action == 'activate' && Settings::Get('auto_approve_videos') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Video Awaiting Approval';
             $body = 'A new video has been uploaded and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending approval'));
             Plugin::Trigger('video.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_videos') == '1') {
                 $send_alert = true;
                 $subject = 'New Video Uploaded';
                 $body = 'A new video has been uploaded.';
             }
             // Activate & Release
             $this->Update(array('status' => 'approved', 'released' => 1));
             // Send subscribers notification if opted-in
             $query = "SELECT user_id FROM " . DB_PREFIX . "subscriptions WHERE member = {$this->user_id}";
             $result = $this->db->Query($query);
             while ($opt = $this->db->FetchObj($result)) {
                 $subscriber = new User($opt->user_id);
                 $privacy = Privacy::LoadByUser($opt->user_id);
                 if ($privacy->OptCheck('new_video')) {
                     $replacements = array('host' => HOST, 'sitename' => $config->sitename, 'email' => $subscriber->email, 'member' => $this->username, 'title' => $this->title, 'video_id' => $this->video_id, 'slug' => $this->slug);
                     $mail = new Mail();
                     $mail->LoadTemplate('new_video', $replacements);
                     $mail->Send($subscriber->email);
                     Plugin::Trigger('video.notify_subscribers');
                 }
             }
             Plugin::Trigger('video.release');
         }
         // Video is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Approve Video
             $this->Update(array('status' => 'approved'));
             Plugin::Trigger('video.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Title: {$this->title}\n";
         $body .= "URL: {$this->url}\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('video.approve');
 }
Пример #4
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
App::LoadClass('Privacy');
// Establish page variables, objects, arrays, etc
View::InitView('opt_out');
Plugin::Trigger('opt_out.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
### Verify user actually unsubscribed
if (isset($_GET['email'])) {
    $data = array('email' => $_GET['email']);
    $id = User::Exist($data);
    if ($id) {
        $privacy = Privacy::LoadByUser($id);
        $data = array('new_video' => 'no', 'new_message' => 'no', 'video_comment' => 'no');
        Plugin::Trigger('opt_out.opt_out');
        $privacy->Update($data);
    } else {
        App::Throw404();
    }
} else {
    App::Throw404();
}
// Output Page
Plugin::Trigger('opt_out.before_render');
View::Render('opt_out.tpl');
Пример #5
0
 /**
  * Make a comment visible to the public and notify user of new comment
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void Comment is activated, user is notified, and admin alerted.
  * If approval is required comment is marked pending and placed in queue
  */
 public function Approve($action)
 {
     App::LoadClass('User');
     App::LoadClass('Video');
     App::LoadClass('Privacy');
     App::LoadClass('Mail');
     global $config;
     $send_alert = false;
     $video = new Video($this->video_id);
     Plugin::Trigger('comment.before_approve');
     // 1) Admin posted comment in Admin Panel
     // 2) Comment is posted by user
     // 3) Comment is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // Comment is being posted by user, but approval is required
         if ($action == 'activate' && Settings::Get('auto_approve_comments') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Comment Awaiting Approval';
             $body = 'A new comment has been posted and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending'));
             Plugin::Trigger('comment.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_comments') == '1') {
                 $send_alert = true;
                 $subject = 'New Comment Posted';
                 $body = 'A new comment has been posted.';
             }
             // Activate & Release
             $this->Update(array('status' => 'approved', 'released' => 1));
             // Send video owner new comment notifition, if opted-in
             $privacy = Privacy::LoadByUser($video->user_id);
             if ($privacy->OptCheck('video_comment')) {
                 $user = new User($video->user_id);
                 $replacements = array('host' => HOST, 'sitename' => $config->sitename, 'email' => $user->email, 'title' => $video->title);
                 $mail = new Mail();
                 $mail->LoadTemplate('video_comment', $replacements);
                 $mail->Send($user->email);
                 Plugin::Trigger('comment.notify_member');
             }
             Plugin::Trigger('comment.release');
         }
         // Comment is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Activate Comment
             $this->Update(array('status' => 'approved'));
             Plugin::Trigger('comment.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Author: {$this->name}\n";
         $body .= "Video URL: {$video->url}/\n";
         $body .= "Comments: {$this->comments}\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('comment.approve');
 }