public static function send(WT_Tree $tree, $to_email, $to_name, $replyto_email, $replyto_name, $subject, $message) { try { $mail = new Zend_Mail('UTF-8'); $mail->setSubject($subject)->setBodyHtml($message)->setBodyText(WT_Filter::unescapeHtml($message))->setFrom(WT_Site::getPreference('SMTP_FROM_NAME'), $tree->preference('title'))->addTo($to_email, $to_name)->setReplyTo($replyto_email, $replyto_name)->send(WT_Mail::transport()); } catch (Exception $ex) { Log::addErrorLog('Mail: ' . $ex->getMessage()); return false; } return true; }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $WEBTREES_EMAIL; $changes = WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne(); $days = get_block_setting($block_id, 'days', 1); $sendmail = get_block_setting($block_id, 'sendmail', true); $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('days', 'sendmail', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } if ($changes && $sendmail == 'yes') { // There are pending changes - tell moderators/managers/administrators about them. if (WT_TIMESTAMP - WT_Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getSetting('contactmethod') !== 'none') { foreach (WT_Tree::getAll() as $tree) { if (exists_pending_change($user, $tree)) { WT_I18N::init($user->getSetting('language')); WT_Mail::systemMessage($tree, $user, WT_I18N::translate('Pending changes'), WT_I18N::translate('There are pending changes for you to moderate.') . WT_Mail::EOL . WT_MAIL::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '</a>'); WT_I18N::init(WT_LOCALE); } } } } WT_Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } if (WT_USER_CAN_EDIT) { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $this->getTitle() . help_link('review_changes', $this->getName()); $content = ''; if (WT_USER_CAN_ACCEPT) { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . WT_I18N::translate('There are pending changes for you to moderate.') . "</a><br>"; } if ($sendmail == "yes") { $content .= WT_I18N::translate('Last email reminder was sent ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>"; } $changes = WT_DB::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array(WT_GED_ID))->fetchAll(); foreach ($changes as $change) { $record = WT_GedcomRecord::getInstance($change->xref); if ($record->canShow()) { $content .= '<b>' . $record->getFullName() . '</b>'; $content .= $block ? '<br>' : ' '; $content .= '<a href="' . $record->getHtmlUrl() . '">' . WT_I18N::translate('View the changes') . '</a>'; $content .= '<br>'; } } if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } } } }
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; }
} 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))); } $user->setSetting('verified', 1)->setSetting('reg_timestamp', date("U"))->setSetting('reg_hashcode', null); if (!$REQUIRE_ADMIN_AUTH_REGISTRATION) { set_user_setting($user_id, 'verified_by_admin', 1); } Log::addAuthenticationLog('User ' . $user_name . ' verified their email address'); echo '<br><br>' . WT_I18N::translate('You have confirmed your request to become a registered user.') . '<br><br>'; if ($REQUIRE_ADMIN_AUTH_REGISTRATION && !$user->getSetting('verified_by_admin')) { echo WT_I18N::translate('The administrator has been informed. As soon as he gives you permission to login, you can login with your user name and password.'); } else { echo WT_I18N::translate('You can now login with your user name and password.'); }
if (!(Auth::isAdmin() || $user && $user->getSetting('editaccount') && in_array($id2, array('language', 'visible_online', 'contact_method')))) { fail(); } // Validation switch ($id2) { case 'canadmin': // Cannot change our own admin status - either to add it or remove it if (Auth::user() == $user) { fail(); } break; case 'verified_by_admin': // Approving for the first time? Send a confirmation email if ($value && !$user->getSetting('verified_by_admin') && $user->getSetting('sessiontime') == 0) { WT_I18N::init($user->getSetting('language')); WT_Mail::system_message($WT_TREE, $user, WT_I18N::translate('Approval of account at %s', WT_SERVER_NAME . WT_SCRIPT_PATH), WT_I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now login by accessing the following link: %s', WT_SERVER_NAME . WT_SCRIPT_PATH, WT_SERVER_NAME . WT_SCRIPT_PATH)); } break; case 'auto_accept': case 'editaccount': case 'verified': case 'visibleonline': case 'max_relation_path': $value = (int) $value; break; case 'contactmethod': case 'comment': case 'language': case 'theme': break; default: