function __construct()
 {
     $guid = getInput("guid");
     $reply = getInput("reply");
     if (!$reply) {
         new SystemMessage("Message body cannot be left empty.");
         forward();
     }
     $message = getEntity($guid);
     $to = getLoggedInUserGuid() == $message->to ? $message->from : $message->to;
     $from = getLoggedInUserGuid();
     $to_user = getEntity($to);
     $from_user = getEntity($from);
     $message_element = new Messageelement();
     $message_element->message = $reply;
     $message_element->to = $to;
     $message_element->from = $from;
     $message_element->container_guid = $guid;
     $message_element->save();
     $link = getSiteURL() . "messages";
     notifyUser("message", $to, getLoggedInUserGuid(), $to);
     sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true));
     new SystemMessage("Your message has been sent.");
     forward("messages/" . $message->guid);
 }
 public function __construct()
 {
     gateKeeper();
     $email_users = array();
     $container_guid = getInput("container_guid");
     $topic = getEntity($container_guid);
     $category_guid = $topic->container_guid;
     $category = getEntity($category_guid);
     $description = getInput("comment");
     $comment = new Forumcomment();
     $comment->description = $description;
     $comment->container_guid = $container_guid;
     $comment->category_guid = $category_guid;
     $comment->owner_guid = getLoggedInUserGuid();
     $comment->save();
     new SystemMessage("Your comment has been posted.");
     new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id);
     $all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid));
     $notify_users = array($topic->owner_guid);
     $container_owner_guid = $topic->owner_guid;
     $container_owner = getEntity($container_owner_guid);
     if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") {
         $email_users[] = $container_guid;
     }
     foreach ($all_comments as $comment) {
         $user_guid = $comment->owner_guid;
         $user = getEntity($user_guid);
         switch ($user->notify_when_forum_comment_topic_i_own) {
             case "both":
                 $notify_users[] = $comment->owner_guid;
                 $email_users[] = $comment->owner_guid;
                 break;
             case "email":
                 $email_users[] = $comment->owner_guid;
                 break;
             case "site":
                 $notify_users[] = $comment->owner_guid;
                 break;
             case "none":
                 break;
         }
     }
     $notify_users = array_unique($notify_users);
     foreach ($notify_users as $user_guid) {
         notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid);
     }
     foreach ($email_users as $user) {
         $params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
         sendEmail($params);
     }
     forward();
 }
 public function __construct($data = NULL)
 {
     gateKeeper();
     $logged_in_user = getLoggedInUser();
     if (!$data) {
         // Get the comment body
         $comment_body = getInput("comment");
         // Get container url
         $container_guid = getInput("guid");
     } else {
         $comment_body = $data['comment_body'];
         $container_guid = $data['container_guid'];
     }
     $container = getEntity($container_guid);
     $container_owner_guid = $container->owner_guid;
     if ($container_owner_guid) {
         $container_owner = getEntity($container_owner_guid);
     }
     $url = $container->getURL();
     if (!$url) {
         $url = getSiteURL();
     }
     // Create the comment
     CommentsPlugin::createComment($container_guid, $comment_body);
     if ($container_owner_guid) {
         if ($container_owner_guid != getLoggedInUserGuid()) {
             $params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
             switch ($logged_in_user->getSetting("notify_when_comment")) {
                 case "email":
                     sendEmail($params);
                     break;
                 case "none":
                     break;
                 case "site":
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
                 case "both":
                     sendEmail($params);
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
             }
         }
     }
     runHook("add:comment:after");
     if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body)));
     } elseif (!$container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body)));
     }
     // Return to container page.
     forward();
 }
 static function sendVerificationEmail($user)
 {
     if ($user->verified == "true") {
         return false;
     }
     $user->email_verification_code = randString(70);
     $user->save();
     if (sendEmail(array("from" => array("email" => getSiteEmail(), "name" => getSiteName()), "to" => array("email" => $user->email, "name" => $user->first_name . " " . $user->last_name), "subject" => display("email/verify_email_subject", array("user_guid" => $user->guid)), "body" => display("email/verify_email_body", array("user_guid" => $user->guid))))) {
         return true;
     }
     $user->email_verification_code = NULL;
     $user->save();
     return false;
 }
 function __construct()
 {
     gateKeeper();
     $to = getInput("to");
     $from = getLoggedInUserGuid();
     $subject = getInput("subject");
     $message_body = getInput("message");
     if (!$message_body) {
         new SystemMessage("Message body cannot be left blank.");
         forward();
     }
     // Make sure recipient is a user
     $to_user = getEntity($to);
     classGateKeeper($to_user, "User");
     // Make sure logged in user and to user are friends
     if (!FriendsPlugin::friends(getLoggedInUserGuid(), $to)) {
         forward();
     }
     // Create a new message
     $message = new Message();
     $message->to = $to;
     $message->from = $from;
     $message->subject = $subject;
     $message->save();
     $message_element = new Messageelement();
     $message_element->to = $to;
     $message_element->from = $from;
     $message_element->subject = $subject;
     $message_element->message = $message_body;
     $message_element->container_guid = $message->guid;
     $message_element->save();
     $link = getSiteURL() . "messages";
     $notify = $to_user->notify_when_message;
     if (!$notify) {
         $notify = "both";
     }
     if ($notify == "both" || $notify == "site") {
         notifyUser("message", $to, $from, $to);
     }
     if ($notify == "both" || ($notify = "email")) {
         sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true));
     }
     new SystemMessage("Your message has been sent.");
     forward();
 }
 public function sendPasswordResetLink()
 {
     $this->password_reset_code = Security::generateToken();
     $this->save();
     try {
         $mail = new \PHPMailer(true);
         $mail->From = getSiteEmail();
         $mail->FromName = getSiteName();
         $mail->addAddress($this->email);
         $mail->isHTML(true);
         $mail->Subject = display("email/forgot_password_subject");
         $mail->Body = display("email/forgot_password_body", array("user_guid" => $this->guid));
         $mail->From = getSiteEmail();
         $mail->FromName = getSiteName();
         $mail->isHTML(true);
         // Set email format to HTML
         $mail->send();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
Beispiel #7
0
/*//////////////////////////////////////////////////////////////////////////////////////////*/
$emptyName = FALSE;
$emptyEmail = FALSE;
$emptyEmailVerify = FALSE;
$notSameEmail = FALSE;
$emptySubject = FALSE;
$emptyMessage = FALSE;
$displayForm = TRUE;
// If ther is the good data in $_POST
if (isset($_POST['name']) && !empty($_POST['name']) && isset($_POST['Email']) && !empty($_POST['Email']) && $_POST['Email'] == $_POST['EmailVerify'] && isset($_POST['subject']) && !empty($_POST['subject']) && isset($_POST['message']) && !empty($_POST['message'])) {
    // Data processing
    $name = htmlentities($_POST['name'], ENT_QUOTES);
    $Email = htmlentities($_POST['Email'], ENT_QUOTES);
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $recipient = getSiteEmail();
    // If data are good to send a email or not, appropriate message
    if (sendEmail($name, $Email, $subject, $message, $recipient)) {
        $_SESSION['textInfo'] = 'Votre message a été envoyé avec succès.';
        goPage('information');
    } else {
        $error = '<span style="color: red">
                                Il y a eu une erreur dans l\'envoi de votre message.
                                Veuillez verifier vos données et réessayer, ou retenter plus tard.
                              </span>';
    }
}
/*//////////////////////////////////////////////////////////////////////////////////////////*/
/*//////////////////////////////////////////////////////////////////////////////////////////*/
/*////////////////////////////////// Display contact page //////////////////////////////////*/
/*//////////////////////////////////////////////////////////////////////////////////////////*/
function reply($params)
{
    $guid = $params['message_guid'];
    $reply = $params['reply'];
    $message = getEntity($guid);
    $to = $params['to'];
    $from = $params['from'];
    $to = $from == $message->from ? $message->to : $message->from;
    $to_user = getEntity($to);
    $from_user = getEntity($from);
    $message_element = new Messageelement();
    $message_element->message = $reply;
    $message_element->to = $to;
    $message_element->from = $from;
    $message_element->container_guid = $guid;
    $message_element->save();
    $link = getSiteURL() . "messages";
    notifyUser("message", $to, getLoggedInUserGuid(), $to);
    sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true));
    return "success";
}