Beispiel #1
0
function addMessage($message)
{
    global $WT_TREE, $WT_REQUEST;
    $success = true;
    $sender = User::findByIdentifier($message['from']);
    $recipient = User::findByIdentifier($message['to']);
    // Sender may not be a webtrees user
    if ($sender) {
        $sender_email = $sender->getEmail();
        $sender_real_name = $sender->getRealName();
    } else {
        $sender_email = $message['from'];
        $sender_real_name = $message['from_name'];
    }
    // Send a copy of the copy message back to the sender.
    if ($message['method'] != 'messaging') {
        // Switch to the sender’s language.
        if ($sender) {
            WT_I18N::init($sender->getSetting('language'));
        }
        $copy_email = $message['body'];
        if (!empty($message['url'])) {
            $copy_email .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL;
        }
        $copy_email .= WT_Mail::auditFooter();
        if ($sender) {
            // Message from a logged-in user
            $copy_email = WT_I18N::translate('You sent the following message to a webtrees user:'******' ' . $recipient->getRealName() . WT_Mail::EOL . WT_Mail::EOL . $copy_email;
        } else {
            // Message from a visitor
            $copy_email = WT_I18N::translate('You sent the following message to a webtrees administrator:') . WT_Mail::EOL . WT_Mail::EOL . WT_Mail::EOL . $copy_email;
        }
        $success = $success && WT_Mail::send($WT_TREE, $sender_email, $sender_real_name, WT_Site::preference('SMTP_FROM_NAME'), $WT_TREE->preference('title'), WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $copy_email);
    }
    // Switch to the recipient’s language.
    WT_I18N::init($recipient->getSetting('language'));
    if (isset($message['from_name'])) {
        $message['body'] = WT_I18N::translate('Your name:') . ' ' . $message['from_name'] . WT_Mail::EOL . WT_I18N::translate('Email address:') . ' ' . $message['from_email'] . WT_Mail::EOL . WT_Mail::EOL . $message['body'];
    }
    // Add another footer - unless we are an admin
    if (!Auth::isAdmin()) {
        if (!empty($message['url'])) {
            $message['body'] .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL;
        }
        $message['body'] .= WT_Mail::auditFooter();
    }
    if (empty($message['created'])) {
        $message['created'] = gmdate("D, d M Y H:i:s T");
    }
    if ($message['method'] != 'messaging3' && $message['method'] != 'mailto' && $message['method'] != 'none') {
        WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($message['from'], $WT_REQUEST->getClientIp(), $recipient->getUserId(), $message['subject'], str_replace('<br>', '', $message['body'])));
    }
    if ($message['method'] != 'messaging') {
        if ($sender) {
            $original_email = WT_I18N::translate('The following message has been sent to your webtrees user account from ');
            $original_email .= $sender->getRealName();
        } else {
            $original_email = WT_I18N::translate('The following message has been sent to your webtrees user account from ');
            if (!empty($message['from_name'])) {
                $original_email .= $message['from_name'];
            } else {
                $original_email .= $message['from'];
            }
        }
        $original_email .= WT_Mail::EOL . WT_Mail::EOL . $message['body'];
        $success = $success && WT_Mail::send($WT_TREE, $recipient->getEmail(), $recipient->getRealName(), $sender_email, $sender_real_name, WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $original_email);
    }
    WT_I18N::init(WT_LOCALE);
    // restore language settings if needed
    return $success;
}
Beispiel #2
0
 case 'verify_hash':
     if (!WT_Site::preference('USE_REGISTRATION_MODULE')) {
         header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
         exit;
     }
     // switch language to webmaster settings
     $webmaster = User::find(get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID'));
     WT_I18N::init($webmaster->getSetting('language'));
     $user = User::findByIdentifier($user_name);
     $mail1_body = WT_I18N::translate('Hello administrator…') . WT_Mail::EOL . WT_Mail::EOL . WT_I18N::translate('A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', $user->getRealName(), $user->getUserName(), $user->getEmail()) . WT_Mail::EOL . WT_Mail::EOL;
     if ($REQUIRE_ADMIN_AUTH_REGISTRATION && !$user->getSetting('verified_by_admin')) {
         $mail1_body .= WT_I18N::translate('You now need to review the account details, and set the “approved” status to “yes”.');
     } else {
         $mail1_body .= WT_I18N::translate('You do not have to take any action; the user can now login.');
     }
     $mail1_body .= WT_Mail::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '</a>' . WT_Mail::auditFooter();
     $mail1_subject = WT_I18N::translate('New user at %s', WT_SERVER_NAME . WT_SCRIPT_PATH . ' ' . $WT_TREE->tree_title);
     // Change to the new user’s language
     WT_I18N::init($user->getSetting('language'));
     $controller->setPageTitle(WT_I18N::translate('User verification'));
     $controller->pageHeader();
     echo '<div id="login-register-page">';
     echo '<h2>' . WT_I18N::translate('User verification') . '</h2>';
     echo '<div id="user-verify">';
     echo WT_I18N::translate('The data for the user <b>%s</b> was checked.', $user_name);
     if ($user) {
         if ($user->checkPassword($user_password) && $user->getSetting('reg_hashcode') == $user_hashcode) {
             WT_Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $WEBTREES_EMAIL, $WEBTREES_EMAIL, $mail1_subject, $mail1_body);
             $mail1_method = $webmaster->getSetting('CONTACT_METHOD');
             if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
                 WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user_name, $WT_REQUEST->getClientIp(), $webmaster->getUserId(), $mail1_subject, WT_Filter::unescapeHtml($mail1_body)));