예제 #1
0
 /**
  * Send user a nofication or approve request
  *
  * @param string $user   Usersame
  * @param string $title   Title of notification
  * @param string $body   Content of notification
  *
  * @return boolean
  */
 public function sendNotification($user, $title, $body)
 {
     $to = Folks::getUserEmail($user);
     if ($to instanceof PEAR_Error) {
         return $to;
     }
     $result = Folks::sendMail($to, $title, $body);
     if ($result instanceof PEAR_Error) {
         return $result;
     }
     if (!$GLOBALS['registry']->hasInterface('letter')) {
         return true;
     }
     return $GLOBALS['registry']->callByPackage('letter', 'sendMessage', array($user, array('title' => $title, 'content' => $body)));
 }
예제 #2
0
$form->addHidden('', 'url', 'text', false);
$form->addVariable(_("Username"), 'username', 'text', true);
if (!empty($answer)) {
    if (!empty($question)) {
        $form->addVariable(_("Please respond to your security question: ") . $question, 'security_question', 'description', true);
    }
    $form->addVariable(_("Security answer"), 'security_answer', 'text', true);
} else {
    $desc = _("The picture above is for antispam checking. Please retype the characters from the picture. They are case sensitive.");
    $form->addVariable(_("Human check"), 'captcha', 'captcha', true, false, $desc, array(Folks::getCAPTCHA(!$form->isSubmitted()), HORDE_BASE . '/config/couri.ttf'));
}
/* Validate the form. */
if ($form->validate()) {
    $form->getInfo(null, $info);
    /* Get user email. */
    $email = Folks::getUserEmail($info['username']);
    if ($email instanceof PEAR_Error) {
        $notification->push($email);
        throw new Horde_Exception_AuthenticationFailure();
    }
    /* Check the given values with the prefs stored ones. */
    if (!empty($answer) && Horde_String::lower($answer) == Horde_String::lower($info['security_answer']) || empty($answer)) {
        /* Info matches, so reset the password. */
        $password = $auth->resetPassword($info['username']);
        if ($password instanceof PEAR_Error) {
            $notification->push($password);
            throw new Horde_Exception_AuthenticationFailure();
        }
        $body = sprintf(_("Your new password for %s is: %s. \n\n It was requested by %s on %s"), $registry->get('name', 'horde'), $password, $_SERVER['REMOTE_ADDR'], date('Ymd H:i:s'));
        Folks::sendMail($email, _("Your password has been reset"), $body);
        $notification->push(sprintf(_("Your password has been reset, check your email (%s) and log in with your new password."), $email), 'horde.success');