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;
 }
 /**
  * @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);
     }
 }
 /**
  * @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);
     }
 }
 /**
  * @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());
     }
 }
 /**
  * @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);
     }
 }
 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);
     }
 }
Exemple #7
0
 public function SendReport($report, $definition, $toAddress, $reportUser)
 {
     $message = new ReportEmailMessage($report, $definition, $toAddress, $reportUser);
     ServiceLocator::GetEmailService()->Send($message);
 }
Exemple #8
0
 /**
  * @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;
 }
Exemple #9
0
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');
Exemple #10
0
 public function Notify(User $user)
 {
     $activationCode = uniqid();
     $this->activationRepository->AddActivation($user, $activationCode);
     ServiceLocator::GetEmailService()->Send(new AccountActivationEmail($user, $activationCode));
 }
Exemple #11
0
 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));
         }
     }
 }