Author: Michael Slusarz (slusarz@horde.org)
Inheritance: extends Horde_Core_Factory_Base
Example #1
0
 /**
  * Notifies about an alarm by e-mail.
  *
  * @param array $alarm  An alarm hash.
  *
  * @throws Horde_Alarm_Exception
  */
 public function notify(array $alarm)
 {
     if (!empty($alarm['internal']['mail']['sent'])) {
         return;
     }
     if (empty($alarm['params']['mail']['email'])) {
         if (empty($alarm['user'])) {
             return;
         }
         $email = $this->_identity->create($alarm['user'])->getDefaultFromAddress(true);
     } else {
         $email = $alarm['params']['mail']['email'];
     }
     try {
         $mail = new Horde_Mime_Mail(array('Subject' => $alarm['title'], 'To' => $email, 'From' => $email, 'Auto-Submitted' => 'auto-generated', 'X-Horde-Alarm' => $alarm['title']));
         if (isset($alarm['params']['mail']['mimepart'])) {
             $mail->setBasePart($alarm['params']['mail']['mimepart']);
         } elseif (empty($alarm['params']['mail']['body'])) {
             $mail->setBody($alarm['text']);
         } else {
             $mail->setBody($alarm['params']['mail']['body']);
         }
         $mail->send($this->_mail);
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_Alarm_Exception($e);
     }
     $alarm['internal']['mail']['sent'] = true;
     $this->alarm->internal($alarm['id'], $alarm['user'], $alarm['internal']);
 }
Example #2
0
 /**
  * Returns the Horde_Identity instance.
  *
  * @param string $user    The user to use, if not the current user.
  * @param string $driver  The identity driver. Either empty (use default
  *                        driver) or an application name.
  *
  * @return Horde_Identity  The singleton identity instance.
  * @throws Horde_Exception
  */
 public function create($user = null, $driver = null)
 {
     return parent::create($GLOBALS['registry']->convertUsername($user, true), $driver);
 }