Example #1
0
    } 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';
    }
}
// Output page
Plugin::Trigger('message_send.before_render');
View::Render('myaccount/message_send.tpl');
Example #2
0
 /**
  * Make a user visible to the public and notify admin of registration
  * @global object $config Site configuration settings
  * @param string $action Step in the approval proccess to perform. Allowed values: create|activate|approve
  * @return void User is activated, and admin alerted. If approval is
  * required user is marked pending and placed in queue
  */
 public function Approve($action)
 {
     global $config;
     $send_alert = false;
     Plugin::Trigger('user.before_approve');
     // 1) Admin created user in Admin Panel
     // 2) User signed up & activated
     // 3) User is being approved by admin for first time
     if (in_array($action, array('create', 'activate')) || $action == 'approve' && $this->released == 0) {
         // User is activating account, but approval is required
         if ($action == 'activate' && Settings::Get('auto_approve_users') == '0') {
             // Send Admin Approval Alert
             $send_alert = true;
             $subject = 'New Member Awaiting Approval';
             $body = 'A new member has registered and is awaiting admin approval.';
             // Set Pending
             $this->Update(array('status' => 'pending'));
             Plugin::Trigger('user.approve_required');
         } else {
             // Send Admin Alert
             if (in_array($action, array('create', 'activate')) && Settings::Get('alerts_users') == '1') {
                 $send_alert = true;
                 $subject = 'New Member Registered';
                 $body = 'A new member has registered.';
             }
             // Activate & Release
             $this->Update(array('status' => 'active', 'released' => 1));
             // Update user's anonymous comments IF/APP
             $query = "UPDATE " . DB_PREFIX . "comments SET user_id = {$this->user_id} WHERE email = '{$this->email}'";
             $this->db->Query($query);
             // Send Welcome email
             if ($action == 'approve') {
                 App::LoadClass('Mail');
                 $mail = new Mail();
                 $mail->LoadTemplate('account_approved', array('sitename' => $config->sitename));
                 $mail->Send($this->email);
             }
             Plugin::Trigger('user.release');
         }
         // User is being re-approved
     } else {
         if ($action == 'approve' && $this->released != 0) {
             // Activate User
             $this->Update(array('status' => 'active'));
             Plugin::Trigger('user.reapprove');
         }
     }
     // Send admin alert
     if ($send_alert) {
         $body .= "\n\n=======================================================\n";
         $body .= "Username: {$this->username}\n";
         $body .= "Profile URL: " . HOST . "/members/{$this->username}/\n";
         $body .= "=======================================================";
         App::Alert($subject, $body);
     }
     Plugin::Trigger('user.approve');
 }
Example #3
0
            View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
        } else {
            View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
        }
    } else {
        View::$vars->errors['email'] = Language::GetText('error_email');
    }
    ### Create user if no errors were found
    if (empty(View::$vars->errors)) {
        View::$vars->data['confirm_code'] = User::CreateToken();
        View::$vars->data['status'] = 'new';
        View::$vars->data['password'] = md5(View::$vars->data['password']);
        Plugin::Trigger('register.before_create');
        User::Create(View::$vars->data);
        View::$vars->message = Language::GetText('success_registered');
        View::$vars->message_type = 'success';
        $replacements = array('confirm_code' => View::$vars->data['confirm_code'], 'host' => HOST, 'sitename' => $config->sitename);
        $mail = new Mail();
        $mail->LoadTemplate('welcome', $replacements);
        $mail->Send(View::$vars->data['email']);
        Plugin::Trigger('register.create');
        unset(View::$vars->data);
    } else {
        View::$vars->message = Language::GetText('errors_below');
        View::$vars->message .= '<br /><br /> - ' . implode('<br /> - ', View::$vars->errors);
        View::$vars->message_type = 'error';
    }
}
// Output Page
Plugin::Trigger('register.before_render');
View::Render('register.tpl');
Example #4
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');
 }
Example #5
0
***********************/
if (isset($_POST['submitted_forgot'])) {
    View::$vars->forgot_submit = TRUE;
    // validate email
    $string = '/^[a-z0-9][a-z0-9\\._-]+@[a-z0-9][a-z0-9\\.-]+[a-z0-9]{2,4}$/i';
    if (!empty($_POST['email']) && !ctype_space($_POST['email']) && preg_match($string, $_POST['email'])) {
        $data = array('email' => $_POST['email']);
        $user_id = User::Exist($data);
        if ($user_id) {
            $user = new User($user_id);
            $new_password = $user->ResetPassword();
            View::$vars->message = Language::GetText('success_login_sent');
            View::$vars->message_type = 'success';
            View::$vars->forgot_submit = NULL;
            $replacements = array('sitename' => $config->sitename, 'username' => $user->username, 'password' => $new_password);
            $mail = new Mail();
            $mail->LoadTemplate('forgot_password', $replacements);
            $mail->Send($user->email);
            Plugin::Trigger('login.password_reset');
        } else {
            View::$vars->message = Language::GetText('error_no_users_email');
            View::$vars->message_type = 'error';
        }
    } else {
        View::$vars->message = Language::GetText('error_email');
        View::$vars->message_type = 'error';
    }
}
// Output Page
Plugin::Trigger('login.before_render');
View::Render('login.tpl');
Example #6
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');
 }