Example #1
0
 /**
  * Bounce message to sender.
  *
  * @param   object  $message parsed message structure.
  * @param   array   array(ERROR_CODE, ERROR_STRING) of error to bounce
  * @return  void
  */
 public function bounceMessage($message, $error)
 {
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/bounced_email.tpl.text');
     $tpl->assign(array('error_code' => $error[0], 'error_message' => $error[1], 'date' => $message->date, 'subject' => Mime_Helper::fixEncoding($message->subject), 'from' => Mime_Helper::fixEncoding($message->fromaddress), 'to' => Mime_Helper::fixEncoding($message->toaddress), 'cc' => Mime_Helper::fixEncoding(@$message->ccaddress)));
     $sender_email = Mail_Helper::getEmailAddress($message->fromaddress);
     $usr_id = User::getUserIDByEmail($sender_email);
     // change the current locale
     if ($usr_id) {
         Language::set(User::getLang($usr_id));
     }
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $mail->send($setup['from'], $sender_email, APP_SHORT_NAME . ': ' . ev_gettext('Postmaster notify: see transcript for details'));
     if ($usr_id) {
         Language::restore();
     }
 }
Example #2
0
 public function testGetAndSetLang()
 {
     $this->user->setLang('en');
     $this->assertEquals('en', $this->user->getLang());
 }
Example #3
0
 /**
  * Method used to set the appropriate preference of the language
  * for the application based on user preference.
  *
  * @return  void
  */
 public static function setPreference()
 {
     $usr_id = Auth::getUserID();
     $lang = null;
     if (!empty($usr_id)) {
         // try user preference
         $usr_lang = User::getLang($usr_id);
         if (self::set($usr_lang)) {
             $lang = $usr_lang;
         }
     }
     if ($lang == null) {
         // fall back to system default
         define('APP_CURRENT_LOCALE', APP_DEFAULT_LOCALE);
         // we don't need to set language again as APP_DEFAULT_LOCALE was set by self::setup()
         // self::set(APP_CURRENT_LOCALE);
     } else {
         define('APP_CURRENT_LOCALE', $lang);
     }
 }
 /**
  * Method used to send the account details of an user.
  *
  * @param   integer $usr_id The user ID
  * @return  void
  */
 public function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info['projects'] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'user' => $info));
     Language::set(User::getLang($usr_id));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $to = $mail->getFormattedName($info['usr_full_name'], $info['usr_email']);
     // TRANSLATORS: %s = APP_SHORT_NAME
     $subject = ev_gettext('%s: Your User Account Details', APP_SHORT_NAME);
     $mail->send($setup['from'], $to, $subject);
     Language::restore();
 }
Example #5
0
$res = null;
if ($cat == 'update_account') {
    $preferences = $_POST;
    // if the user is trying to upload a new signature, override any changes to the textarea
    if (!empty($_FILES['file_signature']['name'])) {
        $preferences['email_signature'] = file_get_contents($_FILES['file_signature']['tmp_name']);
    }
    $res = Prefs::set($usr_id, $preferences);
    User::updateSMS($usr_id, @$_POST['sms_email']);
} elseif ($cat == 'update_name') {
    $res = User::updateFullName($usr_id);
} elseif ($cat == 'update_email') {
    $res = User::updateEmail($usr_id);
} elseif ($cat == 'update_password') {
    $res = Auth::updatePassword($usr_id, $_POST['new_password'], $_POST['confirm_password']);
}
if ($res == 1) {
    Misc::setMessage(ev_gettext('Your information has been updated'));
} elseif ($res == -1) {
    Misc::setMessage(ev_gettext('Sorry, there was an error updating your information'), Misc::MSG_ERROR);
}
$prefs = Prefs::get($usr_id);
$prefs['sms_email'] = User::getSMS($usr_id);
$tpl->assign('user_prefs', $prefs);
$tpl->assign('user_info', User::getDetails($usr_id));
$tpl->assign('assigned_projects', Project::getAssocList($usr_id, false, true));
$tpl->assign('zones', Date_Helper::getTimezoneList());
$tpl->assign('avail_langs', Language::getAvailableLanguages());
$tpl->assign('current_locale', User::getLang($usr_id, true));
$tpl->assign(array('can_update_name' => Auth::canUserUpdateName($usr_id), 'can_update_email' => Auth::canUserUpdateEmail($usr_id), 'can_update_password' => Auth::canUserUpdatePassword($usr_id)));
$tpl->displayTemplate();