本文整理汇总了PHP中ServiceLocator::GetEmailService方法的典型用法代码示例。如果您正苦于以下问题:PHP ServiceLocator::GetEmailService方法的具体用法?PHP ServiceLocator::GetEmailService怎么用?PHP ServiceLocator::GetEmailService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceLocator
的用法示例。
在下文中一共展示了ServiceLocator::GetEmailService方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Register
public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array(), $groups = null)
{
$encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
$attributes = new UserAttribute($additionalFields);
if ($this->CreatePending()) {
$user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
} else {
$user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
}
$user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
$user->ChangeCustomAttributes($attributeValues);
if ($groups != null) {
$user->WithGroups($groups);
}
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
foreach (ReservationEvent::AllEvents() as $event) {
$user->ChangeEmailPreference($event, true);
}
}
$userId = $this->_userRepository->Add($user);
$this->AutoAssignPermissions($userId);
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user, ServiceLocator::GetServer()->GetUserSession()));
}
return $user;
}
示例2: Notify
/**
* @param ReservationSeries $reservationSeries
* @return void
*/
public function Notify($reservationSeries)
{
$resourceAdmins = array();
$applicationAdmins = array();
$groupAdmins = array();
if ($this->SendForResourceAdmins($reservationSeries)) {
$resourceAdmins = $this->userViewRepo->GetResourceAdmins($reservationSeries->ResourceId());
}
if ($this->SendForApplicationAdmins($reservationSeries)) {
$applicationAdmins = $this->userViewRepo->GetApplicationAdmins();
}
if ($this->SendForGroupAdmins($reservationSeries)) {
$groupAdmins = $this->userViewRepo->GetGroupAdmins($reservationSeries->UserId());
}
$admins = array_merge($resourceAdmins, $applicationAdmins, $groupAdmins);
if (count($admins) == 0) {
// skip if there is nobody to send to
return;
}
$owner = $this->userRepo->LoadById($reservationSeries->UserId());
$resource = $reservationSeries->Resource();
$adminIds = array();
/** @var $admin UserDto */
foreach ($admins as $admin) {
$id = $admin->Id();
if (array_key_exists($id, $adminIds) || $id == $owner->Id()) {
// only send to each person once
continue;
}
$adminIds[$id] = true;
$message = $this->GetMessage($admin, $owner, $reservationSeries, $resource);
ServiceLocator::GetEmailService()->Send($message);
}
}
示例3: Notify
/**
* @param ReservationSeries $reservationSeries
*/
function Notify($reservationSeries)
{
$instance = $reservationSeries->CurrentInstance();
$owner = $this->userRepository->LoadById($reservationSeries->UserId());
foreach ($instance->UnchangedParticipants() as $userId) {
$participant = $this->userRepository->LoadById($userId);
$message = new ParticipantUpdatedEmail($owner, $participant, $reservationSeries, $this->attributeRepository);
ServiceLocator::GetEmailService()->Send($message);
}
}
示例4: Notify
/**
* @param ReservationSeries $reservation
* @return void
*/
public function Notify($reservation)
{
$owner = $this->_userRepo->LoadById($reservation->UserId());
if ($this->ShouldSend($owner)) {
$message = $this->GetMessage($owner, $reservation, $this->_attributeRepo);
ServiceLocator::GetEmailService()->Send($message);
} else {
Log::Debug('Owner does not want these types of email notifications. Email=%s, ReferenceNumber=%s', $owner->EmailAddress(), $reservation->CurrentInstance()->ReferenceNumber());
}
}
示例5: Notify
/**
* @param ReservationSeries $reservationSeries
*/
function Notify($reservationSeries)
{
$owner = null;
$instance = $reservationSeries->CurrentInstance();
foreach ($instance->UnchangedInvitees() as $userId) {
if ($owner == null) {
$owner = $this->userRepository->LoadById($reservationSeries->UserId());
}
$invitee = $this->userRepository->LoadById($userId);
$message = new InviteeAddedEmail($owner, $invitee, $reservationSeries, $this->attributeRepository);
ServiceLocator::GetEmailService()->Send($message);
}
}
示例6: SendRandomPassword
public function SendRandomPassword()
{
$emailAddress = $this->_page->GetEmailAddress();
Log::Debug('Password reset request for email address %s requested from REMOTE_ADDR: %s REMOTE_HOST: %s', $emailAddress, $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_HOST']);
$temporaryPassword = Password::GenerateRandom();
$passwordEncryption = new PasswordEncryption();
$salt = $passwordEncryption->Salt();
$encrypted = $passwordEncryption->Encrypt($temporaryPassword, $salt);
$userRepository = new UserRepository();
$user = $userRepository->FindByEmail($emailAddress);
if ($user != null) {
$user->ChangePassword($encrypted, $salt);
$userRepository->Update($user);
$emailMessage = new ForgotPasswordEmail($user, $temporaryPassword);
ServiceLocator::GetEmailService()->Send($emailMessage);
}
}
示例7: SendReport
public function SendReport($report, $definition, $toAddress, $reportUser)
{
$message = new ReportEmailMessage($report, $definition, $toAddress, $reportUser);
ServiceLocator::GetEmailService()->Send($message);
}
示例8: Add
/**
* @param User $user
* @return int
*/
public function Add(User $user)
{
$db = ServiceLocator::GetDatabase();
$id = $db->ExecuteInsert(new RegisterUserCommand($user->Username(), $user->EmailAddress(), $user->FirstName(), $user->LastName(), $user->encryptedPassword, $user->passwordSalt, $user->Timezone(), $user->Language(), $user->Homepage(), $user->GetAttribute(UserAttribute::Phone), $user->GetAttribute(UserAttribute::Organization), $user->GetAttribute(UserAttribute::Position), $user->StatusId(), $user->GetPublicId(), $user->GetDefaultScheduleId()));
$user->WithId($id);
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user));
}
foreach ($user->GetAddedAttributes() as $added) {
$db->Execute(new AddAttributeValueCommand($added->AttributeId, $added->Value, $user->Id(), CustomAttributeCategory::USER));
}
$addedPreferences = $user->GetAddedEmailPreferences();
foreach ($addedPreferences as $event) {
$db->Execute(new AddEmailPreferenceCommand($id, $event->EventCategory(), $event->EventType()));
}
$userGroups = $user->Groups();
if (!empty($userGroups)) {
foreach ($userGroups as $group) {
$db->Execute(new AddUserGroupCommand($id, $group->GroupId));
}
}
return $id;
}
示例9: define
This script must be executed every minute for to enable Reservation Reminders functionality
* * * * * php -f /home/mydomain/public_html/booked/Jobs/sendreminders.php
* * * * * /path/to/php -f /home/mydomain/public_html/booked/Jobs/sendreminders.php
*/
define('ROOT_DIR', dirname(__FILE__) . '/../');
//define('ROOT_DIR', __DIR__ . '/../');
require_once ROOT_DIR . 'Domain/Access/namespace.php';
require_once ROOT_DIR . 'Domain/Reminder.php';
require_once ROOT_DIR . 'lib/Email/Messages/ReminderEmail.php';
require_once ROOT_DIR . 'Jobs/JobCop.php';
Log::Debug('Running sendreminders.php');
JobCop::EnsureCommandLine();
try {
$repository = new ReminderRepository();
$now = Date::Now();
$startNotices = $repository->GetReminderNotices($now, ReservationReminderType::Start);
Log::Debug('Found %s start reminders', count($startNotices));
foreach ($startNotices as $notice) {
ServiceLocator::GetEmailService()->Send(new ReminderStartEmail($notice));
}
$endNotices = $repository->GetReminderNotices(Date::Now(), ReservationReminderType::End);
Log::Debug('Found %s end reminders', count($endNotices));
foreach ($endNotices as $notice) {
ServiceLocator::GetEmailService()->Send(new ReminderEndEmail($notice));
}
} catch (Exception $ex) {
Log::Error('Error running sendreminders.php: %s', $ex);
}
Log::Debug('Finished running sendreminders.php');
示例10: Notify
public function Notify(User $user)
{
$activationCode = uniqid();
$this->activationRepository->AddActivation($user, $activationCode);
ServiceLocator::GetEmailService()->Send(new AccountActivationEmail($user, $activationCode));
}
示例11: DeleteUser
public function DeleteUser($userId)
{
$user = $this->userRepository->LoadById($userId);
$this->userRepository->DeleteById($userId);
if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
$currentUser = ServiceLocator::GetServer()->GetUserSession();
$applicationAdmins = $this->userViewRepository->GetApplicationAdmins();
$groupAdmins = $this->userViewRepository->GetGroupAdmins($userId);
foreach ($applicationAdmins as $applicationAdmin) {
ServiceLocator::GetEmailService()->Send(new AccountDeletedEmail($user, $applicationAdmin, $currentUser));
}
foreach ($groupAdmins as $groupAdmin) {
ServiceLocator::GetEmailService()->Send(new AccountDeletedEmail($user, $groupAdmin, $currentUser));
}
}
}