本文整理汇总了PHP中AppContext::get_mail_service方法的典型用法代码示例。如果您正苦于以下问题:PHP AppContext::get_mail_service方法的具体用法?PHP AppContext::get_mail_service怎么用?PHP AppContext::get_mail_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppContext
的用法示例。
在下文中一共展示了AppContext::get_mail_service方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_check_mail
function test_check_mail()
{
$ret = AppContext::get_mail_service()->is_mail_valid('toto@test.fr');
self::assertTrue($ret);
$ret = AppContext::get_mail_service()->is_mail_valid('toto_bidon');
self::assertFalse($ret);
}
示例2: send_email_confirmation
public static function send_email_confirmation($user_id, $email, $pseudo, $login, $password, $registration_pass)
{
$lang = LangLoader::get('user-common');
$user_accounts_config = UserAccountsConfig::load();
$general_config = GeneralConfig::load();
$site_name = $general_config->get_site_name();
$subject = StringVars::replace_vars($lang['registration.subject-mail'], array('site_name' => $site_name));
switch ($user_accounts_config->get_member_accounts_validation_method()) {
case UserAccountsConfig::AUTOMATIC_USER_ACCOUNTS_VALIDATION:
$parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => $lang['registration.email.automatic-validation'], 'signature' => MailServiceConfig::load()->get_mail_signature());
$content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
break;
case UserAccountsConfig::MAIL_USER_ACCOUNTS_VALIDATION:
$parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => StringVars::replace_vars($lang['registration.email.mail-validation'], array('validation_link' => UserUrlBuilder::confirm_registration($registration_pass)->absolute())), 'signature' => MailServiceConfig::load()->get_mail_signature());
$content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
break;
case UserAccountsConfig::ADMINISTRATOR_USER_ACCOUNTS_VALIDATION:
$alert = new AdministratorAlert();
$alert->set_entitled($lang['registration.pending-approval']);
$alert->set_fixing_url(UserUrlBuilder::edit_profile($user_id)->relative());
$alert->set_priority(AdministratorAlert::ADMIN_ALERT_MEDIUM_PRIORITY);
$alert->set_id_in_module($user_id);
$alert->set_type('member_account_to_approbate');
AdministratorAlertService::save_alert($alert);
$parameters = array('pseudo' => $pseudo, 'site_name' => $site_name, 'host' => $general_config->get_site_url(), 'login' => $login, 'password' => $password, 'accounts_validation_explain' => $lang['registration.email.administrator-validation'], 'signature' => MailServiceConfig::load()->get_mail_signature());
$content = StringVars::replace_vars($lang['registration.content-mail'], $parameters);
AppContext::get_mail_service()->send_from_properties($email, $subject, $content);
break;
}
}
示例3: Add_msg
function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false)
{
global $LANG;
##### Insertion message #####
$last_timestamp = time();
$result = PersistenceContext::get_querier()->insert(PREFIX . 'forum_msg', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'contents' => FormatingHelper::strparse($contents), 'timestamp' => $last_timestamp, 'timestamp_edit' => 0, 'user_id_edit' => 0, 'user_ip' => AppContext::get_request()->get_ip_address()));
$last_msg_id = $result->get_last_inserted_id();
//Topic
PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . AppContext::get_current_user()->get_id() . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'");
//On met à jour le last_topic_id dans la catégorie dans le lequel le message a été posté
PersistenceContext::get_querier()->update(ForumSetup::$forum_cats_table, array('last_topic_id' => $idtopic), 'WHERE id = :id', array('id' => $idcat));
//Mise à jour du nombre de messages du membre.
PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg + 1 WHERE user_id = '" . AppContext::get_current_user()->get_id() . "'");
//On marque le topic comme lu.
mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp);
##### Gestion suivi du sujet mp/mail #####
if (!$new_topic) {
//Message précédent ce nouveau message.
$previous_msg_id = 0;
try {
$previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'MAX(id)', 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $last_msg_id));
} catch (RowNotFoundException $e) {
}
$title_subject = TextHelper::html_entity_decode($title);
$title_subject_pm = $title_subject;
if (AppContext::get_current_user()->get_id() > 0) {
$pseudo = '';
try {
$pseudo = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'display_name', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id()));
} catch (RowNotFoundException $e) {
}
$pseudo_pm = '<a href="' . UserUrlBuilder::profile(AppContext::get_current_user()->get_id())->rel() . '">' . $pseudo . '</a>';
} else {
$pseudo = $LANG['guest'];
$pseudo_pm = $LANG['guest'];
}
$next_msg_link = '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . ($previous_msg_id ? '#m' . $previous_msg_id : '');
$preview_contents = substr($contents, 0, 300);
//Récupération des membres suivant le sujet.
$max_time = time() - SessionsConfig::load()->get_active_session_duration();
$result = PersistenceContext::get_querier()->select("SELECT m.user_id, m.display_name, m.email, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = :idtopic AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = :idtopic AND v.last_view_id IS NOT NULL AND m.user_id != :user_id", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id()));
while ($row = $result->fetch()) {
//Envoi un Mail à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') {
AppContext::get_mail_service()->send_from_properties($row['email'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject, AppContext::get_current_user()->get_display_name(), $preview_contents, HOST . DIR . $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1));
}
//Envoi un MP à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') {
$content = sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject_pm, AppContext::get_current_user()->get_display_name(), $preview_contents, '<a href="' . $next_msg_link . '">' . $next_msg_link . '</a>', '<a href="/forum/action.php?ut=' . $idtopic . '&trt=2">/forum/action.php?ut=' . $idtopic . '&trt=2</a>');
PrivateMsg::start_conversation($row['user_id'], $LANG['forum_mail_title_new_post'], nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
}
}
$result->dispose();
forum_generate_feeds();
//Regénération du flux rss.
}
return $last_msg_id;
}
示例4: __construct
public function __construct($error_message = '')
{
if (empty($error_message)) {
$error_message = LangLoader::get_message('form.doesnt_match_mail_regex', 'status-messages-common');
}
$this->set_validation_error_message($error_message);
$mail_service = AppContext::get_mail_service();
$regex = $mail_service->get_mail_checking_regex();
parent::__construct($regex, $regex, $error_message);
}
示例5: __construct
/**
* @desc Constructs a FormFieldMailEditor.
* @param string $id Field identifier
* @param string $label Field label
* @param string $value Default value
* @param string[] $field_options Map containing the options
* @param FormFieldConstraint[] $constraints The constraints checked during the validation
*/
public function __construct($id, $label, $value, $field_options = array(), array $constraints = array())
{
if (isset($field_options['multiple'])) {
$simple_regex = AppContext::get_mail_service()->get_mail_checking_raw_regex();
$constraints[] = new FormFieldConstraintRegex('`^' . $simple_regex . '(?:,' . $simple_regex . ')*$`i');
} else {
$constraints[] = new FormFieldConstraintMailAddress();
}
parent::__construct($id, $label, $value, $field_options, $constraints);
$this->set_css_form_field_class('form-field-email');
}
示例6: send_email
private function send_email()
{
$change_password_pass = KeyGenerator::generate_key(15);
$user = $this->get_user();
PHPBoostAuthenticationMethod::update_auth_infos($user->get_id(), null, null, null, null, $change_password_pass);
$general_config = GeneralConfig::load();
$parameters = array('pseudo' => $user->get_display_name(), 'host' => $general_config->get_site_url(), 'change_password_link' => UserUrlBuilder::change_password($change_password_pass)->absolute(), 'signature' => MailServiceConfig::load()->get_mail_signature());
$subject = $general_config->get_site_name() . ' : ' . $this->lang['forget-password'];
$content = StringVars::replace_vars($this->lang['forget-password.mail.content'], $parameters);
AppContext::get_mail_service()->send_from_properties($user->get_email(), $subject, $content);
$this->tpl->put('MSG', MessageHelper::display($this->lang['forget-password.success'], MessageHelper::SUCCESS));
}
示例7: send_mail
public function send_mail($subscribers, $sender, $subject, $contents)
{
$contents = $this->parse_contents($contents) . $this->add_unsubscribe_link();
foreach ($subscribers as $values) {
$mail_subscriber = !empty($values['mail']) ? $values['mail'] : NewsletterDAO::get_mail_for_member($values['user_id']);
if (!empty($mail_subscriber)) {
$mail = new Mail();
$mail->set_sender($sender);
$mail->set_is_html(true);
$mail->set_subject($subject);
$mail->set_content($contents);
$mail->add_recipient($mail_subscriber);
//TODO gestion des erreurs
AppContext::get_mail_service()->try_to_send($mail);
}
}
}
示例8: send_installation_mail
private function send_installation_mail($login, $password, $email)
{
$general_config = GeneralConfig::load();
AppContext::get_mail_service()->send_from_properties($email, $this->messages['admin.created.email.object'], sprintf($this->messages['admin.created.email.unlockCode'], stripslashes($login), stripslashes($login), $password, $general_config->get_site_url() . $general_config->get_site_path()));
}
示例9: send_mail
private function send_mail()
{
$message = '';
$current_user = AppContext::get_current_user();
$fields = $this->config->get_fields();
$recipients_field_id = $this->config->get_field_id_by_name('f_recipients');
$recipients_field = new ContactField();
$recipients_field->set_properties($fields[$recipients_field_id]);
$recipients = $recipients_field->get_possible_values();
$recipients['admins']['email'] = implode(';', MailServiceConfig::load()->get_administrators_mails());
$subject_field_id = $this->config->get_field_id_by_name('f_subject');
$subject_field = new ContactField();
$subject_field->set_properties($fields[$subject_field_id]);
$subjects = $subject_field->get_possible_values();
if ($subject_field->get_field_type() == 'ContactShortTextField') {
$subject = $this->form->get_value('f_subject');
} else {
$subject = $this->form->get_value('f_subject')->get_raw_value();
}
$display_message_title = false;
if ($this->config->is_tracking_number_enabled()) {
$now = new Date();
$tracking_number = $this->config->get_last_tracking_number();
$tracking_number++;
$message .= $this->lang['contact.tracking_number'] . ' : ' . ($this->config->is_date_in_tracking_number_enabled() ? $now->get_year() . $now->get_month() . $now->get_day() . '-' : '') . $tracking_number . '
';
$this->config->set_last_tracking_number($tracking_number);
ContactConfig::save();
$subject = '[' . $tracking_number . '] ' . $subject;
$display_message_title = true;
}
foreach ($this->config->get_fields() as $id => $properties) {
$field = new ContactField();
$field->set_properties($properties);
if ($field->is_displayed() && $field->is_authorized() && $field->is_deletable()) {
try {
$value = ContactFieldsService::get_value($this->form, $field);
$message .= $field->get_name() . ': ' . $value . '
';
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
$display_message_title = true;
}
}
if ($display_message_title) {
$message .= $this->lang['contact.form.message'] . ':
';
}
$message .= $this->form->get_value('f_message');
$mail = new Mail();
$mail->set_sender(MailServiceConfig::load()->get_default_mail_sender(), $this->lang['module_title']);
$mail->set_reply_to($this->form->get_value('f_sender_mail'), $current_user->get_level() == User::VISITOR_LEVEL ? $this->lang['module_title'] : $current_user->get_display_name());
$mail->set_subject($subject);
$mail->set_content($message);
if ($recipients_field->is_displayed()) {
if (in_array($recipients_field->get_field_type(), array('ContactSimpleSelectField', 'ContactSimpleChoiceField'))) {
$recipients_mails = explode(';', $recipients[$this->form->get_value('f_recipients')->get_raw_value()]['email']);
} else {
$selected_recipients = $this->form->get_value('f_recipients');
$recipients_mails = array();
foreach ($selected_recipients as $recipient) {
$mails = explode(';', $recipients[$recipient->get_id()]['email']);
foreach ($mails as $m) {
$recipients_mails[] = $m;
}
}
}
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
} else {
if ($subject_field->get_field_type() != 'ContactShortTextField') {
$recipient = $subjects[$this->form->get_value('f_subject')->get_raw_value()]['recipient'];
$recipients_mails = explode(';', $recipients[$recipient]['email']);
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
} else {
$recipients_mails = explode(';', $recipients['admins']['email']);
foreach ($recipients_mails as $mail_address) {
$mail->add_recipient($mail_address);
}
}
}
$mail_service = AppContext::get_mail_service();
if ($this->config->is_sender_acknowledgment_enabled()) {
$acknowledgment = new Mail();
$acknowledgment->set_sender(MailServiceConfig::load()->get_default_mail_sender(), Mail::SENDER_ADMIN);
$acknowledgment->set_subject('[' . $this->lang['contact.acknowledgment_title'] . '] ' . $subject);
$acknowledgment->set_content($this->lang['contact.acknowledgment'] . $message);
$acknowledgment->add_recipient($this->form->get_value('f_sender_mail'));
return $mail_service->try_to_send($mail) && $mail_service->try_to_send($acknowledgment);
}
return $mail_service->try_to_send($mail);
}
示例10: send_mail
private static function send_mail($user_id, $title, $content)
{
AppContext::get_mail_service()->send_from_properties(self::get_member_mail($user_id), addslashes($title), sprintf(addslashes($content), GeneralConfig::load()->get_site_name(), addslashes(MailServiceConfig::load()->get_mail_signature())));
}
示例11: elseif
if ($convers['user_id'] == $current_user->get_id()) {
//Le membre est le créateur de la conversation.
$status = 1;
} elseif ($convers['user_id_dest'] == $current_user->get_id()) {
//Le membre est le destinataire de la conversation.
$status = 2;
}
$contents = FormatingHelper::strparse($contents, array(), false);
//Envoi du message privé.
$pm_msg_id = PrivateMsg::send($user_id_dest, $pm_id_get, $contents, $current_user->get_id(), $status);
//Envoi d'un mail si l'utilisateur a activé l'option
$pmtomail_field = ExtendedFieldsCache::load()->get_extended_field_by_field_name('user_pmtomail');
if (!empty($pmtomail_field) && $pmtomail_field['display']) {
if (PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER_EXTENDED_FIELDS, 'user_pmtomail', 'WHERE user_id = :id', array('id' => $user_id_dest))) {
$email_dest = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'email', 'WHERE user_id = :id', array('id' => $user_id_dest));
AppContext::get_mail_service()->send_from_properties($email_dest, $LANG['new_pm'] . ' : ' . $convers['title'], $contents);
}
}
//Calcul de la page vers laquelle on redirige.
$last_page = ceil(($convers['nbr_msg'] + 1) / 25);
$last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
$last_page = $last_page > 1 ? '&p=' . $last_page : '';
AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_id_get . $last_page, '-0-' . $pm_id_get . $last_page_rewrite . '.php', '&') . '#m' . $pm_msg_id);
} else {
//Le destinataire a supprimé la conversation.
AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_id_get . '&error=e_pm_del', '-0-' . $pm_id_get . '-0.php?error=e_pm_del', '&') . '#message_helper');
}
} else {
//Champs manquants.
AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_id_get . '&error=e_incomplete', '-0-' . $pm_id_get . '-0-e_incomplete.php', '&') . '#message_helper');
}
示例12: check_mail
private static function check_mail($mail)
{
return AppContext::get_mail_service()->is_mail_valid($mail);
}
示例13: save
private function save(HTTPRequestCustom $request)
{
$has_error = false;
$user_id = $this->user->get_id();
if ($this->form->get_value('delete_account')) {
UserService::delete_by_id($user_id);
} else {
$approbation = $this->internal_auth_infos['approved'];
if (AppContext::get_current_user()->is_admin()) {
$old_approbation = $approbation;
$approbation = $this->form->get_value('approbation');
$groups = array();
foreach ($this->form->get_value('groups') as $field => $option) {
$groups[] = $option->get_raw_value();
}
GroupsService::edit_member($user_id, $groups);
$this->user->set_groups($groups);
$this->user->set_level($this->form->get_value('rank')->get_raw_value());
}
if ($this->form->has_field('theme')) {
$this->user->set_theme($this->form->get_value('theme')->get_raw_value());
}
$this->user->set_locale($this->form->get_value('lang')->get_raw_value());
$this->user->set_display_name($this->form->get_value('display_name'));
$this->user->set_email($this->form->get_value('email'));
$this->user->set_locale($this->form->get_value('lang')->get_raw_value());
$this->user->set_editor($this->form->get_value('text-editor')->get_raw_value());
$this->user->set_show_email(!$this->form->get_value('user_hide_mail'));
$this->user->set_timezone($this->form->get_value('timezone')->get_raw_value());
try {
UserService::update($this->user, $this->member_extended_fields_service);
} catch (MemberExtendedFieldErrorsMessageException $e) {
$has_error = true;
$this->tpl->put('MSG', MessageHelper::display($e->getMessage(), MessageHelper::NOTICE));
}
$login = $this->form->get_value('email');
if ($this->form->get_value('custom_login', false)) {
$login = $this->form->get_value('login');
}
$password = $this->form->get_value('password');
if ($this->internal_auth_infos === null && !empty($password)) {
$authentication_method = new PHPBoostAuthenticationMethod($login, $password);
AuthenticationService::associate($authentication_method, $user_id);
} elseif (!empty($password)) {
$old_password = $this->form->get_value('old_password');
if (!empty($old_password)) {
$old_password_hashed = KeyGenerator::string_hash($old_password);
if ($old_password_hashed == $this->internal_auth_infos['password']) {
PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation, KeyGenerator::string_hash($password));
$has_error = false;
} else {
$has_error = true;
$this->tpl->put('MSG', MessageHelper::display($this->lang['profile.edit.password.error'], MessageHelper::NOTICE));
}
}
} else {
PHPBoostAuthenticationMethod::update_auth_infos($user_id, $login, $approbation);
}
if (AppContext::get_current_user()->is_admin()) {
if ($old_approbation != $approbation && $old_approbation == 0) {
//Recherche de l'alerte correspondante
$matching_alerts = AdministratorAlertService::find_by_criteria($user_id, 'member_account_to_approbate');
//L'alerte a été trouvée
if (count($matching_alerts) == 1) {
$alert = $matching_alerts[0];
$alert->set_status(AdministratorAlert::ADMIN_ALERT_STATUS_PROCESSED);
AdministratorAlertService::save_alert($alert);
$site_name = GeneralConfig::load()->get_site_name();
$subject = StringVars::replace_vars($this->user_lang['registration.subject-mail'], array('site_name' => $site_name));
$content = StringVars::replace_vars($this->user_lang['registration.email.mail-administrator-validation'], array('pseudo' => $this->user->get_display_name(), 'site_name' => $site_name, 'signature' => MailServiceConfig::load()->get_mail_signature()));
AppContext::get_mail_service()->send_from_properties($this->user->get_email(), $subject, $content);
}
}
$user_warning = $this->form->get_value('user_warning')->get_raw_value();
if (!empty($user_warning) && $user_warning != $this->user->get_warning_percentage()) {
MemberSanctionManager::caution($user_id, $user_warning, MemberSanctionManager::SEND_MP, str_replace('%level%', $user_warning, LangLoader::get_message('user_warning_level_changed', 'main')));
} elseif (empty($user_warning)) {
MemberSanctionManager::cancel_caution($user_id);
}
$user_readonly = $this->form->get_value('user_readonly')->get_raw_value();
if (!empty($user_readonly) && $user_readonly != $this->user->get_delay_readonly()) {
MemberSanctionManager::remove_write_permissions($user_id, time() + $user_readonly, MemberSanctionManager::SEND_MP, str_replace('%date%', $this->form->get_value('user_readonly')->get_label(), LangLoader::get_message('user_readonly_changed', 'main')));
} elseif (empty($user_readonly)) {
MemberSanctionManager::restore_write_permissions($user_id);
}
$user_ban = $this->form->get_value('user_ban')->get_raw_value();
if (!empty($user_ban) && $user_ban != $this->user->get_delay_banned()) {
MemberSanctionManager::banish($user_id, time() + $user_ban, MemberSanctionManager::SEND_MAIL);
} elseif ($user_ban != $this->user->get_delay_banned()) {
MemberSanctionManager::cancel_banishment($user_id);
}
}
SessionData::recheck_cached_data_from_user_id($user_id);
}
if (!$has_error) {
AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : UserUrlBuilder::edit_profile($user_id), $this->lang['user.message.success.edit']);
}
}