How to use getLocale method of mail class

Best Atoum code snippet using mail.getLocale

Registration.php

Source:Registration.php Github

copy

Full Screen

...77 {78 if (!isset($data['nickname'])) {79 // Bitte geben Sie einen Benutzernamen an80 throw new QUI\Exception(81 QUI::getLocale()->get(82 'quiqqer/intranet',83 'exception.enter.username'84 )85 );86 }87 if (!isset($data['email'])) {88 // Bitte geben Sie eine E-Mail Adresse an89 throw new QUI\Exception(90 QUI::getLocale()->get(91 'quiqqer/intranet',92 'exception.enter.mail'93 )94 );95 }96 if (!Orthos::checkMailSyntax($data['email'])) {97 throw new QUI\Exception(98 QUI::getLocale()->get(99 'quiqqer/intranet',100 'exception.enter.correct.mail'101 )102 );103 }104 // Passwort Prüfung105 if (!isset($data['password']) || empty($data['password'])) {106 // Bitte geben Sie ein Passwort ein107 throw new QUI\Exception(108 QUI::getLocale()->get(109 'quiqqer/intranet',110 'exception.enter.pw'111 )112 );113 }114 $Users = QUI::getUsers();115 if ($Users->usernameExists($data['nickname'])) {116 // Bitte verwenden Sie einen andere Benutzernamen117 throw new QUI\Exception(118 QUI::getLocale()->get(119 'quiqqer/intranet',120 'exception.different.username'121 )122 );123 }124 $Plugin = QUI::getPluginManager()->get('quiqqer/intranet');125 $groupids = $Plugin->getSettings('registration', 'standardGroups');126 // user default language127 $langs = QUI::availableLanguages();128 $newLang = QUI::getLocale()->getCurrent();129 $userLang = 'en';130 if (in_array($newLang, $langs)) {131 $userLang = $newLang;132 }133 $User = $Users->register(array(134 'username' => $data['nickname'],135 'password' => $data['password'],136 'email' => $data['email'],137 'usergroup' => $groupids,138 'lang' => $userLang139 ));140 if ($Plugin->getSettings('registration', 'sendMailOnRegistration')) {141 $this->sendRegistrationMail($User);142 }143 if ($Plugin->getSettings('registration', 'sendInfoMailOnRegistrationTo')) {144 $this->sendInformationRegistrationMailTo($User);145 }146 return $User;147 }148 /**149 * Register an user with social media network150 *151 * @param string $socialType - Social media name152 * @param array $socialData - Social media data153 *154 * @return User155 * @throws QUI\Exception156 */157 public function socialRegister($socialType, $socialData)158 {159 $Users = QUI::getUsers();160 if (!isset($socialData['email'])) {161 throw new QUI\Exception(162 QUI::getLocale()->get(163 'quiqqer/intranet',164 'exception.social.registration.cannot.excecute'165 )166 );167 }168 $email = $socialData['email'];169 if ($Users->usernameExists($email) || $Users->emailExists($email)) {170 throw new QUI\Exception(171 QUI::getLocale()->get(172 'quiqqer/intranet',173 'exception.user.exists'174 )175 );176 }177 // social auth check178 $token = array();179 if (isset($socialData['token'])) {180 $token = json_encode($socialData['token']);181 }182 $Social = $this->getSocial($socialType);183 if (!$Social->isAuth($token)) {184 throw new QUI\Exception(185 QUI::getLocale()->get(186 'quiqqer/intranet',187 'exception.social.network.no.token'188 )189 );190 }191 // user creation192 $Plugin = QUI::getPluginManager()->get('quiqqer/intranet');193 $groupids = $Plugin->getSettings('registration', 'standardGroups');194 // user default language195 $langs = QUI::availableLanguages();196 $newLang = QUI::getLocale()->getCurrent();197 $userLang = 'en';198 if (in_array($newLang, $langs)) {199 $userLang = $newLang;200 }201 $User = $Users->register(array(202 'username' => $email,203 'password' => md5(mt_rand(0, 100000)),204 'email' => $email,205 'usergroup' => $groupids,206 'lang' => $userLang207 ));208 // social media data209 $Social->onRegistration($User, $token);210 // user via social media are directly activated211 $this->activate($User->getId(), $User->getAttribute('activation'));212 // social media, user is directly loged in213 QUI::getSession()->set('uid', $User->getId());214 QUI::getSession()->set('auth', 1);215 if ($Plugin->getSettings('registration', 'sendInfoMailOnRegistrationTo')) {216 $this->sendInformationRegistrationMailTo($User);217 }218 return $User;219 }220 /**221 * Get social type object222 *223 * @param String $socialType224 *225 * @throws QUI\Exception226 * @return QUI\Intranet\Social\Google|QUI\Intranet\Social\Facebook227 */228 public function getSocial($socialType)229 {230 if ($socialType == 'google') {231 return new Social\Google();232 }233 if ($socialType == 'facebook') {234 return new Social\Facebook();235 }236 throw new QUI\Exception(237 QUI::getLocale()->get(238 'quiqqer/intranet',239 'exception.social.network.unknown'240 )241 );242 }243 /**244 * Activate an deactivated user with its code and user-id245 *246 * @param Integer|String $uid - use-id or username247 * @param String $code248 *249 * @return User250 * @throws QUI\Exception251 */252 public function activate($uid, $code)253 {254 if (empty($code)) {255 // Es wurde kein Aktivierungscode übermittelt256 throw new QUI\Exception(257 QUI::getLocale()->get(258 'quiqqer/intranet',259 'exception.no.activation.code'260 )261 );262 }263 if (empty($uid)) {264 // Bitte geben Sie einen Benutzernamen an265 throw new QUI\Exception(266 QUI::getLocale()->get(267 'quiqqer/intranet',268 'exception.enter.username'269 )270 );271 }272 $Users = QUI::getUsers();273 try {274 // username?275 $User = $Users->getUserByName($uid);276 } catch (QUI\Exception $Exception) {277 // user id?278 $User = $Users->get($uid);279 }280 $User->activate($code);281 $this->sendActivasionSuccessMail($User);282 $autoLogin = $this->getConfig()->get('registration', 'autoLoginOnActivasion');283 if ($autoLogin) {284 // login285 QUI::getSession()->set('uid', $User->getId());286 QUI::getSession()->set('auth', 1);287 $this->setLoginData(288 QUI::getUsers()->get($User->getId())289 );290 }291 QUI::getEvents()292 ->fireEvent('registrationUserActivate', array($this, $User));293 return $User;294 }295 /**296 * Disable the user297 *298 * @param Integer|String $user299 * @param string $disableHash300 *301 * @throws QUI\Exception302 */303 public function disable($user, $disableHash)304 {305 $User = $this->getUser($user);306 if ($User->isDeleted()) {307 throw new QUI\Exception(308 QUI::getLocale()->get(309 'quiqqer/intranet',310 'exception.disable.user.already.deleted'311 )312 );313 }314 $hashLifetime = $this->getConfig()->get('disable', 'hashLifetime');315 $hash = $User->getAttribute('quiqqer.intranet.disable.hash');316 $hashTime = $User->getAttribute('quiqqer.intranet.disable.time');317 if ($hashTime < time() - $hashLifetime) {318 throw new QUI\Exception(319 QUI::getLocale()->get(320 'quiqqer/intranet',321 'exception.disable.hash.expired'322 )323 );324 }325 if ($disableHash != $hash) {326 throw new QUI\Exception(327 QUI::getLocale()->get(328 'quiqqer/intranet',329 'exception.disable.hash.wrong'330 )331 );332 }333 $User->disable(QUI::getUsers()->getSystemUser());334 // disable event335 QUI::getEvents()->fireEvent('registrationUserDisabled', array($this));336 }337 /**338 * Change the E-Mail from an user339 * The user get a mail for the mail confirmation if the new mail is different as the current340 *341 * @param QUI\Users\User $User - User342 * @param String $email - new mail343 *344 * @throws QUI\Exception345 */346 public function changeMailFromUser($User, $email)347 {348 if ($email == $User->getAttribute('email')) {349 return;350 }351 if (!Orthos::checkMailSyntax($email)) {352 throw new QUI\Exception(353 QUI::getLocale()->get(354 'quiqqer/system',355 'exception.not.correct.email'356 )357 );358 }359 // check if the new mail exists in the system360 if (QUI::getUsers()->emailExists($email)) {361 throw new QUI\Exception(362 QUI::getLocale()->get(363 'quiqqer/system',364 'exception.user.register.email.exists'365 )366 );367 }368 // if the quiqqer.intranet.new.email is the same,369 // we only send a new activasion and dont set a new hash370 $newMail = $User->getAttribute('quiqqer.intranet.new.email');371 $mailhash = $User->getAttribute('quiqqer.intranet.new.email.hash');372 if (empty($newMail) || empty($mailhash) || $newMail != $email) {373 $hash = Orthos::getPassword();374 $User->setAttribute('quiqqer.intranet.new.email', $email);375 $User->setAttribute('quiqqer.intranet.new.email.hash', $hash);376 $User->save();377 }378 $this->sendNewEMailActivasion($User);379 }380 /**381 * Set the new email for the user382 *383 * @param {String|Integer} $user - username, user-id384 * @param {String} $hash - hash to activate the new mail385 *386 * @throws QUI\Exception387 */388 public function setNewEmail($user, $hash)389 {390 $User = $this->getUser($user);391 $newMail = $User->getAttribute('quiqqer.intranet.new.email');392 $mailHash = $User->getAttribute('quiqqer.intranet.new.email.hash');393 if (!$newMail || !Orthos::checkMailSyntax($newMail)) {394 throw new QUI\Exception(395 QUI::getLocale()->get(396 'quiqqer/intranet',397 'exception.wrong.hash'398 )399 );400 }401 // check if the new mail exists in the system402 if (QUI::getUsers()->emailExists($newMail)) {403 throw new QUI\Exception(404 QUI::getLocale()->get(405 'quiqqer/system',406 'exception.user.register.email.exists'407 )408 );409 }410 if ($mailHash != $hash) {411 throw new QUI\Exception(412 QUI::getLocale()->get(413 'quiqqer/intranet',414 'exception.wrong.hash'415 )416 );417 }418 $User->setAttribute('email', $newMail);419 $User->removeAttribute('quiqqer.intranet.new.email');420 $User->removeAttribute('quiqqer.intranet.new.email.hash');421 $User->save(QUI::getUsers()->getSystemUser());422 }423 /**424 * helper methods425 */426 /**427 * Return the project for the intranet plugin428 *429 * @return QUI\Projects\Project430 */431 protected function getProject()432 {433 if ($this->getAttribute('Project')) {434 return $this->getAttribute('Project');435 }436 return QUI::getProjectManager()->get();437 }438 /**439 * Return registration site -> quiqqer/intranet:intranet/registration440 *441 * @throws QUI\Exception442 * @return QUI\Projects\Site\Edit443 */444 protected function getRegSite()445 {446 $Project = $this->getProject();447 $list = $Project->getSites(array(448 'where' => array(449 'type' => 'quiqqer/intranet:intranet/registration'450 ),451 'limit' => 1452 ));453 if (!isset($list[0])) {454 throw new QUI\Exception(455 QUI::getLocale()->get(456 'quiqqer/intranet',457 'exception.registrationSite.not.found'458 )459 );460 }461 return $list[0];462 }463 /**464 * Return the User by mail, id, username465 *466 * @param String|Integer $user467 *468 * @return QUI\Users\User469 * @throws QUI\Exception470 */471 protected function getUser($user)472 {473 $Users = QUI::getUsers();474 if ($Users->usernameExists($user)) {475 return $Users->getUserByName($user);476 }477 if ($Users->emailExists($user)) {478 return $Users->getUserByMail($user);479 }480 if ((int)$user == $user) {481 return $Users->get((int)$user);482 }483 throw new QUI\Exception(484 QUI::getLocale()->get(485 'quiqqer/system',486 'exception.lib.user.wrong.uid'487 ),488 404489 );490 }491 /**492 * Returns the intranet config object493 *494 * @return Bool|QUI\Config495 */496 protected function getConfig()497 {498 if ($this->Config) {499 return $this->Config;500 }501 $Package = QUI::getPackageManager()->getInstalledPackage('quiqqer/intranet');502 $this->Config = $Package->getConfig();503 return $this->Config;504 }505 /**506 * Mail Methods507 */508 /**509 * Send a registration mail to the user510 *511 * @param QUI\Users\User $User512 * @param QUI\Projects\Site|bool $Site - (optional)513 *514 * @throws QUI\Exception515 */516 public function sendRegistrationMail(User $User, $Site = false)517 {518 $Project = $this->getProject();519 $Locale = QUI::getLocale();520 $project = $Project->getAttribute('name');521 // if no site, find a registration site522 if (!isset($Site) || !$Site) {523 $Site = $this->getRegSite();524 }525 // create registration mail526 $reg_url = $Project->getVHost(true) . URL_DIR . $Site->getUrlRewritten() . '?';527 $reg_url .= 'code=' . $User->getAttribute('activation') . '&';528 $reg_url .= 'uid=' . $User->getId();529 if ($Locale->exists('project/' . $project, 'intranet.registration.MAILFromText')) {530 $MAILFromText = $Locale->get(531 'project/' . $project,532 'intranet.registration.MAILFromText',533 array(534 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')535 )536 );537 } else {538 $MAILFromText = $Locale->get(539 'quiqqer/intranet',540 'mail.registration.MAILFromText',541 array(542 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')543 )544 );545 }546 if ($Locale->exists('project/' . $project, 'intranet.registration.MailSubject')) {547 $MailSubject = $Locale->get(548 'project/' . $project,549 'intranet.registration.MailSubject'550 );551 } else {552 $MailSubject = $Locale->get(553 'quiqqer/intranet',554 'mail.registration.MailSubject'555 );556 }557 $MailBody = QUI::getLocale()->get(558 'quiqqer/intranet',559 'mail.registration.Body',560 array('registration_url' => $reg_url)561 );562 // send mail563 $Mail = new QUI\Mail\Mailer();564 $Mail->setProject($this->getProject());565 $Mail->setFromName($MAILFromText);566 $Mail->setSubject($MailSubject);567 $Mail->setBody($MailBody);568 $Mail->addRecipient($User->getAttribute('email'));569 if (!$Mail->send()) {570 throw new QUI\Exception(571 QUI::getLocale()->get(572 'quiqqer/intranet',573 'exception.send.registration.mail.fail'574 )575 );576 }577 }578 /**579 * Send an activasion success mail580 *581 * @param QUI\Users\User $User582 * @param QUI\Projects\Site|bool $Site - (optional)583 *584 * @throws QUI\Exception585 */586 public function sendActivasionSuccessMail(User $User, $Site = false)587 {588 $Project = $this->getProject();589 $Engine = QUI::getTemplateManager()->getEngine();590 if (!isset($Site) || !$Site) {591 $Site = $this->getRegSite();592 }593 /**594 * Registrierungs Mail595 */596 $Engine->assign(array(597 'Project' => $Project,598 'Site' => $Site,599 'User' => $User600 ));601 // Mail vars602 $Locale = QUI::getLocale();603 $project = $Project->getAttribute('name');604 // schauen ob es übersetzungen dafür gibt605 if ($Locale->exists('project/' . $project, 'intranet.activation.MAILFromText')) {606 $MAILFromText = $Locale->get(607 'project/' . $project,608 'intranet.activation.MAILFromText',609 array(610 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')611 )612 );613 } else {614 $MAILFromText = $Locale->get(615 'quiqqer/intranet',616 'mail.activation.MAILFromText',617 array(618 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')619 )620 );621 }622 if ($Locale->exists('project/' . $project, 'intranet.activation.Subject')) {623 $MailSubject = $Locale->get(624 'project/' . $project,625 'intranet.activation.MailSubject'626 );627 } else {628 $MailSubject = $Locale->get(629 'quiqqer/intranet',630 'mail.activation.MailSubject'631 );632 }633 $MailBody = QUI::getLocale()->get(634 'quiqqer/intranet',635 'mail.activation.Body'636 );637 // send mail638 $Mail = new QUI\Mail\Mailer();639 $Mail->setProject($this->getProject());640 $Mail->setSubject($MailSubject);641 $Mail->setFromName($MAILFromText);642 $Mail->addRecipient($User->getAttribute('email'));643 $Mail->setBody($MailBody);644 if (!$Mail->send()) {645 throw new QUI\Exception(646 QUI::getLocale()->get(647 'quiqqer/intranet',648 'exception.send.activation.successful.mail.fail'649 )650 );651 }652 }653 /**654 * Send an disable mail655 * it starts the disable process656 *657 * @param QUI\Users\User $User658 * @param QUI\Projects\Site|bool $Site - (optional)659 *660 * @throws QUI\Exception661 */662 public function sendDisableMail(User $User, $Site = false)663 {664 $Project = $this->getProject();665 $Engine = QUI::getTemplateManager()->getEngine();666 if (!isset($Site) || !$Site) {667 $Site = $this->getRegSite();668 }669 // disable event670 QUI::getEvents()->fireEvent('registrationUserDisable', array($this));671 // create new disable link672 $hashLifetime = $this->getConfig()->get('disable', 'hashLifetime');673 $hashtime = $User->getAttribute('quiqqer.intranet.disable.time');674 $hash = $User->getAttribute('quiqqer.intranet.disable.hash');675 // wenn hash abgelaufen, neuen hash setzen676 if (!$hashtime || $hashLifetime < time() - $hashtime) {677 $hash = Orthos::getPassword();678 $User->setAttribute('quiqqer.intranet.disable.hash', $hash);679 $User->setAttribute('quiqqer.intranet.disable.time', time());680 $User->save();681 }682 /**683 * Disable Mail684 */685 $Engine->assign(array(686 'Project' => $Project,687 'Site' => $Site,688 'User' => $User689 ));690 $disable_link = $Project->getVHost(true) . $Site->getUrlRewritten(array(691 'uid' => $User->getId(),692 'hash' => $hash,693 'type' => 'disable'694 ));695 // Mail vars696 $Locale = QUI::getLocale();697 $project = $Project->getAttribute('name');698 // schauen ob es übersetzungen dafür gibt699 if ($Locale->exists('project/' . $project, 'intranet.disable.MAILFromText')) {700 $MAILFromText = $Locale->get(701 'project/' . $project,702 'intranet.disable.MAILFromText',703 array(704 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')705 )706 );707 } else {708 $MAILFromText = $Locale->get(709 'quiqqer/intranet',710 'mail.disable.MAILFromText',711 array(712 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')713 )714 );715 }716 if ($Locale->exists('project/' . $project, 'intranet.disable.Subject')) {717 $MailSubject = $Locale->get(718 'project/' . $project,719 'intranet.disable.MailSubject'720 );721 } else {722 $MailSubject = $Locale->get(723 'quiqqer/intranet',724 'mail.disable.MailSubject'725 );726 }727 $MailBody = QUI::getLocale()->get(728 'quiqqer/intranet',729 'mail.disable.Body',730 array(731 'disable_link' => $disable_link732 )733 );734 // send mail735 $Mail = new QUI\Mail\Mailer();736 $Mail->setProject($this->getProject());737 $Mail->setSubject($MailSubject);738 $Mail->setFromName($MAILFromText);739 $Mail->addRecipient($User->getAttribute('email'));740 $Mail->setBody($MailBody);741 if (!$Mail->send()) {742 throw new QUI\Exception(743 QUI::getLocale()->get(744 'quiqqer/intranet',745 'exception.send.disable.mail.fail'746 )747 );748 }749 }750 /**751 * Sends a password forgotten Mail752 *753 * @param Integer|String $user754 *755 * @throws QUI\Exception756 */757 public function sendPasswordForgottenMail($user)758 {759 $Project = $this->getProject();760 $User = $this->getUser($user);761 $Users = QUI::getUsers();762 if (!$Users->isUser($User)) {763 throw new QUI\Exception(764 QUI::getLocale()->get(765 'system',766 'exception.lib.user.user.not.found'767 ),768 404769 );770 }771 $RegSite = $this->getRegSite();772 $hash = Orthos::getPassword();773 $url = $Project->getVHost(true) . $RegSite->getUrlRewritten(array(774 'uid' => $User->getId(),775 'pass' => 'new',776 'hash' => $hash777 ));778 $User->setAttribute('quiqqer.intranet.passwordForgotten.hash', $hash);779 $User->save($Users->getSystemUser());780 /**781 * create mail782 */783 $project = $Project->getName();784 // schauen ob es übersetzungen dafür gibt785 if (QUI::getLocale()->exists('project/' . $project, 'intranet.forgotten.password.MAILFromText')786 ) {787 $MAILFromText = QUI::getLocale()->get(788 'project/' . $project,789 'intranet.forgotten.password.MAILFromText',790 array(791 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')792 )793 );794 } else {795 $MAILFromText = QUI::getLocale()->get(796 'quiqqer/intranet',797 'mail.forgotten.password.MAILFromText',798 array(799 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')800 )801 );802 }803 if (QUI::getLocale()->exists('project/' . $project, 'intranet.forgotten.password.Subject')) {804 $MailSubject = QUI::getLocale()->get(805 'project/' . $project,806 'intranet.forgotten.password.MailSubject'807 );808 } else {809 $MailSubject = QUI::getLocale()->get(810 'quiqqer/intranet',811 'mail.forgotten.password.MailSubject'812 );813 }814 $MailBody = QUI::getLocale()->get(815 'quiqqer/intranet',816 'mail.forgotten.password.Body',817 array('password_url' => $url)818 );819 // send mail820 $Mail = new QUI\Mail\Mailer();821 $Mail->setProject($this->getProject());822 $Mail->setSubject($MailSubject);823 $Mail->setFromName($MAILFromText);824 $Mail->addRecipient($User->getAttribute('email'));825 $Mail->setBody($MailBody);826 $Mail->Template->setAttributes(array(827 'Project' => $Project,828 'Site' => $RegSite,829 'User' => $User,830 'hash' => $hash831 ));832 if (!$Mail->send()) {833 throw new QUI\Exception(834 QUI::getLocale()->get(835 'quiqqer/intranet',836 'exception.send.forgotten.password.mail.fail'837 )838 );839 }840 QUI::getMessagesHandler()->addSuccess(841 QUI::getLocale()->get(842 'quiqqer/intranet',843 'message.send.forgotten.password.successfully'844 )845 );846 }847 /**848 * set a new password and send the password via mail849 *850 * @param String $user - User E-Mail, User-Id, Username851 * @param String $hash - User password hash852 *853 * @throws QUI\Exception854 */855 public function sendNewPasswordMail($user, $hash)856 {857 $Project = $this->getProject();858 $User = $this->getUser($user);859 $RegSite = $this->getRegSite();860 $Users = QUI::getUsers();861 // Hash Abfrage862 $userHash863 = $User->getAttribute('quiqqer.intranet.passwordForgotten.hash');864 if ($userHash != $hash) {865 throw new QUI\Exception(866 QUI::getLocale()->get(867 'quiqqer/intranet',868 'exception.wrong.hash'869 )870 );871 }872 // set new password873 $newpass = Orthos::getPassword();874 $User->setPassword($newpass, $Users->getSystemUser());875 $User->save($Users->getSystemUser());876 // create mail877 $project = $Project->getName();878 // schauen ob es übersetzungen dafür gibt879 if (QUI::getLocale()->exists('project/' . $project, 'intranet.new.password.MAILFromText')880 ) {881 $MAILFromText = QUI::getLocale()->get(882 'project/' . $project,883 'intranet.new.password.MAILFromText',884 array(885 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')886 )887 );888 } else {889 $MAILFromText = QUI::getLocale()->get(890 'quiqqer/intranet',891 'mail.new.password.MAILFromText',892 array(893 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')894 )895 );896 }897 if (QUI::getLocale()->exists('project/' . $project, 'intranet.new.password.Subject')) {898 $MailSubject = QUI::getLocale()->get(899 'project/' . $project,900 'intranet.new.password.MailSubject'901 );902 } else {903 $MailSubject = QUI::getLocale()->get(904 'quiqqer/intranet',905 'mail.new.password.MailSubject'906 );907 }908 $MailBody = QUI::getLocale()->get(909 'quiqqer/intranet',910 'mail.new.password.Body',911 array(912 'username' => $User->getName(),913 'uid' => $User->getId(),914 'password' => $newpass915 )916 );917 // send mail918 $Mail = new QUI\Mail\Mailer();919 $Mail->setProject($this->getProject());920 $Mail->setSubject($MailSubject);921 $Mail->setFromName($MAILFromText);922 $Mail->addRecipient($User->getAttribute('email'));923 $Mail->setBody($MailBody);924 $Mail->Template->setAttributes(array(925 'Project' => $Project,926 'Site' => $RegSite,927 'User' => $User,928 'hash' => $hash929 ));930 if (!$Mail->send()) {931 throw new QUI\Exception(932 QUI::getLocale()->get(933 'quiqqer/intranet',934 'exception.send.new.password.mail.fail'935 )936 );937 }938 $User->setAttribute(939 'quiqqer.intranet.passwordForgotten.hash',940 Orthos::getPassword()941 );942 $User->save($Users->getSystemUser());943 QUI::getMessagesHandler()->addSuccess(944 QUI::getLocale()->get(945 'quiqqer/intranet',946 'message.send.new.password.successfully'947 )948 );949 }950 /**951 * Sends an information mail to an admin about a registration952 *953 * @param QUI\Users\User $User954 */955 protected function sendInformationRegistrationMailTo(User $User)956 {957 $email = $this->getConfig()958 ->get('registration', 'sendInfoMailOnRegistrationTo');959 if (!$email) {960 return;961 }962 // mail subject963 $subject = QUI::getLocale()->get(964 'quiqqer/intranet',965 'mail.registration.admin.info.subject'966 );967 if ($User->getAttribute('quiqqer.intranet.googleid')) {968 $subject = QUI::getLocale()->get(969 'quiqqer/intranet',970 'mail.registration.admin.info.subject.social',971 array('social' => 'Google SignIn')972 );973 }974 if ($User->getAttribute('quiqqer.intranet.facebookid')) {975 $subject = QUI::getLocale()->get(976 'quiqqer/intranet',977 'mail.registration.admin.info.subject.social',978 array('social' => 'Facebook SignIn')979 );980 }981 $useragent = '';982 if (isset($_SERVER['HTTP_USER_AGENT'])) {983 $useragent = $_SERVER['HTTP_USER_AGENT'];984 }985 // geodaten wenn vorhanden986 $geopIpData = "" .987 (isset($_SERVER["GEOIP_COUNTRY_CODE"])988 ? $_SERVER["GEOIP_COUNTRY_CODE"] : '') . " " .989 (isset($_SERVER["GEOIP_COUNTRY_NAME"])990 ? $_SERVER["GEOIP_COUNTRY_NAME"] : '') . ", " .991 (isset($_SERVER["GEOIP_CITY"]) ? utf8_encode($_SERVER["GEOIP_CITY"])992 : '') . " (" .993 (isset($_SERVER["GEOIP_LATITUDE"]) ? $_SERVER["GEOIP_LATITUDE"]994 : '') . " / " .995 (isset($_SERVER["GEOIP_LONGITUDE"]) ? $_SERVER["GEOIP_LONGITUDE"]996 : '') . " )\n";997 // userdata998 $attributes = $User->getAttributes();999 $data = "";1000 foreach ($attributes as $key => $value) {1001 if (!is_string($value)) {1002 continue;1003 }1004 if (empty($value)) {1005 continue;1006 }1007 $data .= $key . ': ' . $value . "\n";1008 }1009 $body = QUI::getLocale()->get(1010 'quiqqer/intranet',1011 'mail.registration.admin.info.body',1012 array(1013 'user_name' => $User->getName(),1014 'user_id' => $User->getId(),1015 'user_agent' => $useragent,1016 'user_ip' => QUI\Utils\System::getClientIP(),1017 'geo_ip_data' => $geopIpData,1018 'data' => $data1019 )1020 );1021 QUI::getMailManager()->send($email, $subject, $body);1022 }1023 /**1024 * Send the user an email activasion for its new email1025 *1026 * @param QUI\Users\User $User1027 *1028 * @throws QUI\Exception1029 */1030 protected function sendNewEMailActivasion(User $User)1031 {1032 $Project = $this->getProject();1033 $RegSite = $this->getRegSite();1034 $emailHash = $User->getAttribute('quiqqer.intranet.new.email.hash');1035 $newEmail = $User->getAttribute('quiqqer.intranet.new.email');1036 // create mail1037 $project = $Project->getName();1038 // schauen ob es übersetzungen dafür gibt1039 if (QUI::getLocale()->exists('project/' . $project, 'intranet.new.email.MAILFromText')) {1040 $MAILFromText = QUI::getLocale()->get(1041 'project/' . $project,1042 'intranet.new.email.MAILFromText',1043 array(1044 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')1045 )1046 );1047 } else {1048 $MAILFromText = QUI::getLocale()->get(1049 'quiqqer/intranet',1050 'intranet.new.email.MAILFromText',1051 array(1052 'mailFromText' => $this->getConfig()->get('registration', 'mailFromText')1053 )1054 );1055 }1056 if (QUI::getLocale()->exists('project/' . $project, 'intranet.new.email.MailSubject')) {1057 $MailSubject = QUI::getLocale()->get(1058 'project/' . $project,1059 'intranet.new.email.MailSubject'1060 );1061 } else {1062 $MailSubject = QUI::getLocale()->get(1063 'quiqqer/intranet',1064 'intranet.new.email.MailSubject'1065 );1066 }1067 $activasion_link = $Project->getVHost(true) . $RegSite->getUrlRewritten(array(1068 'uid' => $User->getId(),1069 'hash' => $emailHash,1070 'type' => 'newMail'1071 ));1072 $MailBody = QUI::getLocale()->get(1073 'quiqqer/intranet',1074 'intranet.new.email.Body',1075 array(1076 'username' => $User->getName(),1077 'uid' => $User->getId(),1078 'hash' => $emailHash,1079 'activasion_link' => $activasion_link1080 )1081 );1082 // send mail1083 $Mail = new QUI\Mail\Mailer();1084 $Mail->setProject($this->getProject());1085 $Mail->setSubject($MailSubject);1086 $Mail->setFromName($MAILFromText);1087 $Mail->addRecipient($newEmail);1088 $Mail->setBody($MailBody);1089 $Mail->Template->setAttributes(array(1090 'Project' => $Project,1091 'Site' => $RegSite,1092 'User' => $User,1093 'hash' => $emailHash1094 ));1095 if (!$Mail->send()) {1096 throw new QUI\Exception(1097 QUI::getLocale()->get(1098 'quiqqer/intranet',1099 'exception.send.new.email.fail'1100 )1101 );1102 }1103 QUI::getMessagesHandler()->addSuccess(1104 QUI::getLocale()->get(1105 'quiqqer/intranet',1106 'message.send.new.email.successfully'1107 )1108 );1109 }1110}...

Full Screen

Full Screen

Mails.php

Source:Mails.php Github

copy

Full Screen

...19 * @return void20 */21 public function sendNewOrderMail($order)22 {23 $customerLocale = $this->getLocale($order);24 try {25 /* email to customer */26 $configKey = 'emails.general.notifications.emails.general.notifications.new-order';27 if (core()->getConfigData($configKey)) {28 $this->prepareMail($customerLocale, new NewOrderNotification($order));29 }30 /* email to admin */31 $configKey = 'emails.general.notifications.emails.general.notifications.new-admin';32 if (core()->getConfigData($configKey)) {33 $this->prepareMail(config('app.locale'), new NewAdminNotification($order));34 }35 } catch (\Exception $e) {36 report($e);37 }38 }39 /**40 * Send new invoice mail to the customer.41 *42 * @param \Webkul\Sales\Contracts\Invoice $invoice43 * @return void44 */45 public function sendNewInvoiceMail($invoice)46 {47 $customerLocale = $this->getLocale($invoice);48 try {49 if ($invoice->email_sent) {50 return;51 }52 /* email to customer */53 $configKey = 'emails.general.notifications.emails.general.notifications.new-invoice';54 if (core()->getConfigData($configKey)) {55 $this->prepareMail($customerLocale, new NewInvoiceNotification($invoice));56 }57 } catch (\Exception $e) {58 report($e);59 }60 }61 /**62 * Send new refund mail to the customer.63 *64 * @param \Webkul\Sales\Contracts\Refund $refund65 * @return void66 */67 public function sendNewRefundMail($refund)68 {69 $customerLocale = $this->getLocale($refund);70 try {71 /* email to customer */72 $configKey = 'emails.general.notifications.emails.general.notifications.new-refund';73 if (core()->getConfigData($configKey)) {74 $this->prepareMail($customerLocale, new NewRefundNotification($refund));75 }76 } catch (\Exception $e) {77 report($e);78 }79 }80 /**81 * Send new shipment mail to the customer.82 *83 * @param \Webkul\Sales\Contracts\Shipment $shipment84 * @return void85 */86 public function sendNewShipmentMail($shipment)87 {88 $customerLocale = $this->getLocale($shipment);89 try {90 if ($shipment->email_sent) {91 return;92 }93 /* email to customer */94 $configKey = 'emails.general.notifications.emails.general.notifications.new-shipment';95 if (core()->getConfigData($configKey)) {96 $this->prepareMail($customerLocale, new NewShipmentNotification($shipment));97 }98 /* email to admin */99 $configKey = 'emails.general.notifications.emails.general.notifications.new-inventory-source';100 if (core()->getConfigData($configKey)) {101 $this->prepareMail(config('app.locale'), new NewInventorySourceNotification($shipment));102 }103 } catch (\Exception $e) {104 report($e);105 }106 }107 /**108 * Send cancel order mail.109 *110 * @param \Webkul\Sales\Contracts\Order $order111 * @return void112 */113 public function sendCancelOrderMail($order)114 {115 $customerLocale = $this->getLocale($order);116 try {117 /* email to customer */118 $configKey = 'emails.general.notifications.emails.general.notifications.cancel-order';119 if (core()->getConfigData($configKey)) {120 $this->prepareMail($customerLocale, new CancelOrderNotification($order));121 }122 /* email to admin */123 $configKey = 'emails.general.notifications.emails.general.notifications.new-admin';124 if (core()->getConfigData($configKey)) {125 $this->prepareMail(config('app.locale'), new CancelOrderAdminNotification($order));126 }127 } catch (\Exception $e) {128 report($e);129 }130 }131 /**132 * Send order comment mail.133 *134 * @param \Webkul\Sales\Contracts\OrderComment $comment135 * @return void136 */137 public function sendOrderCommentMail($comment)138 {139 $customerLocale = $this->getLocale($comment);140 if (! $comment->customer_notified) {141 return;142 }143 try {144 /* email to customer */145 $this->prepareMail($customerLocale, new OrderCommentNotification($comment));146 } catch (\Exception $e) {147 report($e);148 }149 }150 /**151 * Get the locale of the customer if somehow item name changes then the english locale will pe provided.152 *153 * @param object \Webkul\Sales\Contracts\Order|\Webkul\Sales\Contracts\Invoice|\Webkul\Sales\Contracts\Refund|\Webkul\Sales\Contracts\Shipment|\Webkul\Sales\Contracts\OrderComment154 * @return string155 */156 private function getLocale($object)157 {158 if ($object instanceof \Webkul\Sales\Contracts\OrderComment) {159 $object = $object->order;160 }161 $objectFirstItem = $object->items->first();162 return isset($objectFirstItem->additional['locale']) ? $objectFirstItem->additional['locale'] : 'en';163 }164 /**165 * Prepare mail.166 *167 * @return void168 */169 private function prepareMail($locale, $notification)170 {...

Full Screen

Full Screen

MessageCatalogue.php

Source:MessageCatalogue.php Github

copy

Full Screen

1<?php...

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$locale = $mail->getLocale();2echo $locale;3$mail->setLocale('fr_FR');4$locale = $mail->getLocale();5echo $locale;6$mail->setLocale('en_US');7$locale = $mail->getLocale();8echo $locale;9$mail->setLocale('en_GB');10$locale = $mail->getLocale();11echo $locale;12$mail->setLocale('de_DE');13$locale = $mail->getLocale();14echo $locale;15$mail->setLocale('de_AT');16$locale = $mail->getLocale();17echo $locale;18$mail->setLocale('de_CH');19$locale = $mail->getLocale();20echo $locale;21$mail->setLocale('es_ES');22$locale = $mail->getLocale();23echo $locale;24$mail->setLocale('es_AR');25$locale = $mail->getLocale();26echo $locale;27$mail->setLocale('es_MX');28$locale = $mail->getLocale();29echo $locale;30$mail->setLocale('es_CO');31$locale = $mail->getLocale();32echo $locale;33$mail->setLocale('es_VE');34$locale = $mail->getLocale();35echo $locale;36$mail->setLocale('es_CL');37$locale = $mail->getLocale();38echo $locale;39$mail->setLocale('es_PE');

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1include_once("mail.php");2$mail = new Mail();3echo $mail->getLocale();4include_once("mail.php");5$mail = new Mail();6$mail->setLocale("en_US");

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$mail = new mail($to, $from, $subject, $body);2$mail->setLocale('en_US');3$mail->send();4$mail = new mail($to, $from, $subject, $body);5$mail->setLocale('fr_FR');6$mail->send();7Related posts: PHP | Mail::send() Method PHP | Mail::setReturnPath() Method PHP | Mail::setSubjectCharset() Method PHP | Mail::setBodyCharset() Method PHP | Mail::setFrom() Method PHP | Mail::setFromName() Method PHP | Mail::setTo() Method PHP | Mail::setCc() Method PHP | Mail::setBcc() Method PHP | Mail::setSubject() Method PHP | Mail::setBody() Method PHP | Mail::setPriority() Method PHP | Mail::setHeader() Method PHP | Mail::setHtml() Method PHP | Mail::setHtmlImage() Method PHP | Mail::setHtmlImageCid() Method PHP | Mail::setHtmlImageFilename() Method PH

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$mail = new Mail();2$locale = $mail->getLocale();3echo $locale;4Related Posts: PHP | Mail::getContentType() Method5PHP | Mail::getHeaderCharset() Method6PHP | Mail::getPriority() Method7PHP | Mail::getSubjectCharset() Method8PHP | Mail::getTo() Method9PHP | Mail::getBcc() Method10PHP | Mail::getFrom() Method11PHP | Mail::getReplyTo() Method12PHP | Mail::getCc() Method13PHP | Mail::getSender() Method14PHP | Mail::getReturnPath() Method15PHP | Mail::getHeaders() Method16PHP | Mail::getSubject() Method17PHP | Mail::getContentType() Method18PHP | Mail::getHeaderCharset() Method19PHP | Mail::getPriority() Method20PHP | Mail::getSubjectCharset() Method21PHP | Mail::getTo() Method22PHP | Mail::getBcc() Method23PHP | Mail::getFrom() Method24PHP | Mail::getReplyTo() Method25PHP | Mail::getCc() Method26PHP | Mail::getSender() Method27PHP | Mail::getReturnPath() Method28PHP | Mail::getHeaders() Method29PHP | Mail::getSubject() Method30PHP | Mail::getContentType() Method31PHP | Mail::getHeaderCharset() Method32PHP | Mail::getPriority() Method33PHP | Mail::getSubjectCharset() Method34PHP | Mail::getTo() Method35PHP | Mail::getBcc() Method36PHP | Mail::getFrom() Method37PHP | Mail::getReplyTo() Method38PHP | Mail::getCc() Method39PHP | Mail::getSender() Method40PHP | Mail::getReturnPath() Method41PHP | Mail::getHeaders() Method42PHP | Mail::getSubject() Method43PHP | Mail::getContentType() Method44PHP | Mail::getHeaderCharset() Method45PHP | Mail::getPriority() Method46PHP | Mail::getSubjectCharset() Method47PHP | Mail::getTo() Method48PHP | Mail::getBcc() Method49PHP | Mail::getFrom() Method50PHP | Mail::getReplyTo() Method51PHP | Mail::getCc() Method52PHP | Mail::getSender() Method

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$locale = $mail->getLocale();2echo "Locale: $locale";3PHP mail() - Send mail using SMTP authentication4PHP mail() - Send mail using local mail server5PHP mail() - Send mail using Gmail SMTP server6PHP mail() - Send mail using MS Exchange server7PHP mail() - Send mail using MS Exchange server with SSL8PHP mail() - Send mail using MS Exchange server with TLS9PHP mail() - Send mail using Yahoo! Mail SMTP server10PHP mail() - Send mail using Yahoo! Mail SMTP server with SSL11PHP mail() - Send mail using Yahoo! Mail SMTP server with TLS12PHP mail() - Send mail using AOL Mail SMTP server13PHP mail() - Send mail using AOL Mail SMTP server with SSL14PHP mail() - Send mail using AOL Mail SMTP server with TLS15PHP mail() - Send mail using Hotmail SMTP server16PHP mail() - Send mail using Hotmail SMTP server with SSL17PHP mail() - Send mail using Hotmail SMTP server with TLS18PHP mail() - Send mail using Outlook.com SMTP server19PHP mail() - Send mail using Outlook.com SMTP server with SSL20PHP mail() - Send mail using Outlook.com SMTP server with TLS21PHP mail() - Send mail using Office 365 SMTP server22PHP mail() - Send mail using Office 365 SMTP server with SSL23PHP mail() - Send mail using Office 365 SMTP server with TLS24PHP mail() - Send mail using Gmail SMTP server with OAuth25PHP mail() - Send mail using Yahoo! Mail SMTP server with OAuth26PHP mail() - Send mail using AOL Mail SMTP server with OAuth27PHP mail() - Send mail using Hotmail SMTP server with OAuth28PHP mail() - Send mail using Outlook.com SMTP server with OAuth29PHP mail() - Send mail using Office 365 SMTP server with OAuth30PHP mail() - Send mail using Gmail SMTP server with XOAUTH231PHP mail() - Send mail using Yahoo! Mail SMTP server with XOAUTH232PHP mail() - Send mail using AOL Mail SMTP server with XOAUTH233PHP mail() - Send mail using Hotmail SMTP server with XOAUTH234PHP mail() - Send mail using Outlook.com SMTP server with XO

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger getLocale code on LambdaTest Cloud Grid

Execute automation tests with getLocale on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful