DEV: Настройка уведомлений (вторая часть)
This commit is contained in:
parent
77272a3258
commit
c675133a7a
7 changed files with 42 additions and 13 deletions
|
@ -80,6 +80,7 @@ class AddAnswerController extends MainController
|
|||
}
|
||||
$type = 11; // Упоминания в ответе
|
||||
NotificationsModel::send($uid['user_id'], $user_id, $type, $last_id, $url_answer, 1);
|
||||
Base::mailText($user_id, 'appealed');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,10 @@ class RecoverController extends MainController
|
|||
$code = $uInfo['user_id'] . '-' . Base::randomString('crypto', 25);
|
||||
UserModel::initRecover($uInfo['user_id'], $code);
|
||||
|
||||
// Добавим текс письма тут
|
||||
// Отправка e-mail
|
||||
$newpass_link = 'https://' . HLEB_MAIN_DOMAIN . '/recover/remind/' . $code;
|
||||
$mail_message = "Your link to change your password: \n" . $newpass_link . "\n\n";
|
||||
|
||||
Base::mailText($email, Config::get(Config::PARAM_NAME) . ' - changing your password', $mail_message);
|
||||
$mail_message = lang('Your link to change your password'). ": \n" . $newpass_link . "\n\n";
|
||||
Base::sendMail($email, Config::get(Config::PARAM_NAME) . ' — ' . lang('changing your password'), $mail_message);
|
||||
|
||||
Base::addMsg(lang('New password has been sent to e-mail'), 'success');
|
||||
redirect('/login');
|
||||
|
|
|
@ -104,10 +104,10 @@ class RegisterController extends MainController
|
|||
$email_code = Base::randomString('crypto', 20);
|
||||
UserModel::sendActivateEmail($active_uid, $email_code);
|
||||
|
||||
// Добавим текс письма тут
|
||||
$newpass_link = 'https://' . HLEB_MAIN_DOMAIN . '/email/avtivate/' . $email_code;
|
||||
$mail_message = "Activate E-mail: \n" . $newpass_link . "\n\n";
|
||||
Base::mailText($email, Config::get(Config::PARAM_NAME) . ' - email', $mail_message);
|
||||
// Отправка e-mail
|
||||
$link = 'https://' . HLEB_MAIN_DOMAIN . '/email/avtivate/' . $email_code;
|
||||
$mail_message = lang('Activate E-mail') . ": \n" . $link . "\n\n";
|
||||
Base::sendMail($email, Config::get(Config::PARAM_NAME) . ' — ' . lang('checking e-mail'), $mail_message);
|
||||
|
||||
Base::addMsg(lang('Check your e-mail to activate your account'), 'success');
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ class AddCommentController extends MainController
|
|||
}
|
||||
$type = 12; // Упоминания в комментарии
|
||||
NotificationsModel::send($uid['user_id'], $user_id, $type, $last_comment_id, $url_comment, 1);
|
||||
Base::mailText($user_id, 'appealed');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@ class AddPostController extends MainController
|
|||
}
|
||||
$type = 10; // Упоминания в посте
|
||||
NotificationsModel::send($uid['user_id'], $user_id, $type, $last_post_id, $url_post, 1);
|
||||
Base::mailText($user_id, 'appealed');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ return [
|
|||
'All comments' => 'Все комментарии',
|
||||
'All answers' => 'Все ответы',
|
||||
'Recommended' => 'Рекомендовано',
|
||||
'notification' => 'уведомление',
|
||||
'Notifications' => 'Уведомления',
|
||||
'Preferences' => 'Предпочтения',
|
||||
'Action' => 'Действие',
|
||||
|
@ -371,8 +372,14 @@ return [
|
|||
|
||||
'Email Notification' => 'Уведомлять по E-mail',
|
||||
'info_notifications' => 'Вы можете отписаться от всех уведомлений на E-mail в этом разделе',
|
||||
'When the message came to PM' => 'Когда пришло сообщение на PM',
|
||||
'When you contacted me via @' => 'Когда обратились ко мне через @',
|
||||
|
||||
'When the message came to PM' => 'Когда пришло сообщение на PM',
|
||||
'When you contacted me via @' => 'Когда обратились ко мне через @',
|
||||
'You were mentioned (@), see' => 'Вас упомянули (@), посмотреть',
|
||||
'Your link to change your password' => 'Ваша ссылка для изменения пароля',
|
||||
'changing your password' => 'изменение пароля',
|
||||
'Activate E-mail' => 'Ссылка для активации E-mail',
|
||||
'checking e-mail' => 'проверка e-mail',
|
||||
|
||||
'There are no domains' => 'Доменов нет',
|
||||
'Change the site' => 'Изменить сайт',
|
||||
|
|
|
@ -286,8 +286,27 @@ class Base
|
|||
}
|
||||
|
||||
// https://github.com/JacksonJeans/php-mail
|
||||
public static function mailText($email, $subject = '', $message = '')
|
||||
public static function mailText($user_id, $type)
|
||||
{
|
||||
// TODO: Let's check the e-mail at the mention
|
||||
if ($type == 'appealed') {
|
||||
$setting = NotificationsModel::getUserSetting($user_id);
|
||||
if ($setting) {
|
||||
if ($setting['setting_email_appealed'] == 1) {
|
||||
$user = UserModel::getUser($user_id, 'id');
|
||||
$link = 'https://' . HLEB_MAIN_DOMAIN . '/u/' . $user['user_login'] . '/notifications';
|
||||
$message = lang('You were mentioned (@), see') . ": \n" . $link . "\n\n" . HLEB_MAIN_DOMAIN;
|
||||
self::sendMail($user['user_email'], Config::get(Config::PARAM_NAME) . ' - ' . lang('notification'), $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function sendMail($email, $subject = '', $message = '')
|
||||
{
|
||||
|
||||
$mail = new Mail('smtp', [
|
||||
'host' => 'ssl://' . Config::get(Config::PARAM_SMTP_HOST),
|
||||
'port' => Config::get(Config::PARAM_SMTP_POST),
|
||||
|
@ -299,6 +318,7 @@ class Base
|
|||
->setTo($email)
|
||||
->setSubject($subject)
|
||||
->setText($message)
|
||||
->send();
|
||||
}
|
||||
->send();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue