コード例 #1
0
 /**
  * subscribe a user
  * @param object http request
  * @return bool
  */
 public function add(\applications\modules\users\entities\usersEntity $user)
 {
     //check if the email exists
     if (!$this->checkEmailExists($user->getEmail())) {
         if (ENABLE_MAIL_REGISTRATION == 1) {
             $user->setLevel(rand(100000, 999999));
             $user->setActive(0);
         } else {
             $user->setLevel(1);
             $user->setActive(1);
         }
         //try to save in db
         if ($this->currentManager->save($user)) {
             //send email
             $dest = $user->getEmail();
             $subject = WEBSITE_TITLE . ' - Activez votre compte';
             $msg = '<body><head></head><body><div style="width : 100%;height : 550px;padding : 25px;background-color : #EFEFEF"><div style="padding : 20px;width : 450px;margin-left: auto;margin-right: auto;background-color: #ffffff !important;box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.2);"><h2 style="color: #428bca !important;">Bonjour ' . $user->getName() . ' et bienvenue</h2><hr/>Votre compte est activ&eacute;, connectez-vous et rejoignez les nombreux ateliers propos&eacute;s.<br/><br/>Si vous rencontrez le moindre probl&egrave;me, n&#39;h&eacute;sitez pas &agrave; nous contacter &agrave; l&#39;adresse suivante : contact.agoraexmachina@gmail.com<br/><br/><br/><br/><p style="color: #555555 !important;">L&#39;&eacute;quipe AGORA Ex Machina.</p></div></div></body></body>';
             try {
                 sendEmail($dest, $subject, $msg);
                 return true;
             } catch (\Exception $e) {
                 \library\handleErrors::setErrors($this->errorSendEmail);
             }
         } else {
             \library\handleErrors::setErrors($this->errorSaveInDb);
         }
     } else {
         \library\handleErrors::setErrors($this->errorExistingElement);
     }
     return false;
 }