Ejemplo n.º 1
0
 public function send(Message $message)
 {
     $messageFile = $this->getFilePath($message->getTo());
     \common_Logger::d('Wrote message to ' . $messageFile);
     $written = file_put_contents($messageFile, $message->getBody());
     return $written !== false;
 }
 public function sendSelfMsg()
 {
     $message = new Message();
     $message->setTo(\common_session_SessionManager::getSession()->getUser());
     $message->setBody('<h1>Tao Dev Message send on the ' . \tao_helpers_Date::displayeDate(time()) . '</h1>');
     $success = MessagingService::singleton()->send($message);
     return $this->returnJson(array('success' => $success, 'message' => __('Send a message')));
 }
Ejemplo n.º 3
0
 public function send(Message $message)
 {
     $receiver = $message->getTo();
     $path = $this->getOption(self::CONFIG_FILEPATH) . \tao_helpers_File::getSafeFileName($receiver->getIdentifier()) . DIRECTORY_SEPARATOR;
     if (!file_exists($path)) {
         mkdir($path);
     }
     $messageFile = $path . \tao_helpers_File::getSafeFileName('message.html', $path);
     \common_Logger::d($messageFile);
     $written = file_put_contents($messageFile, $message->getBody());
     return $written !== false;
 }
Ejemplo n.º 4
0
 /**
  * Send email message with password recovery instructions.
  * 
  * @author Aleh Hutnikau <*****@*****.**>
  * @param core_kernel_classes_Resource $user The user has requested password recovery.
  * @return boolean Whether message was sent.
  */
 public function sendMail(\core_kernel_classes_Resource $user)
 {
     $messagingService = $this->getMessagingService();
     if (!$messagingService->isAvailable()) {
         throw new PasswordRecoveryException('Messaging service is not available.');
     }
     $generisUser = new \core_kernel_users_GenerisUser($user);
     $userNameProperty = new \core_kernel_classes_Property(PROPERTY_USER_FIRSTNAME);
     $messageData = array('user_name' => (string) $user->getOnePropertyValue($userNameProperty), 'link' => $this->getPasswordRecoveryLink($user));
     $message = new Message();
     $message->setTo($generisUser);
     $message->setBody($this->getMailContent($messageData));
     $message->setTitle(__("Your TAO Password"));
     $result = $messagingService->send($message);
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Get a "From" address. If it was not specified for message then value will be retrieved from config.
  * @param Message $message (optional)
  * @return string
  */
 public function getFrom(Message $message = null)
 {
     $from = $message === null ? null : $message->getFrom();
     if (!$from) {
         $from = $this->getOption(self::CONFIG_DEFAULT_SENDER);
     }
     return $from;
 }