示例#1
0
 /**
  * Initiates the password reset process on behalf of the user
  * Generates a unique hash and an expiration time that the hash is valid up until (defaults to 15 minutes)
  * This key will internally expire (but not be expunged) after that time
  */
 public function initPasswordResetProcess()
 {
     if (!$this->validate()) {
         return false;
     }
     $hash = Cii::generateSafeHash();
     $expires = strtotime("+15 minutes");
     $meta = UserMetadata::model()->findByAttributes(array('user_id' => $this->_user->id, 'key' => 'passwordResetCode'));
     if ($meta === NULL) {
         $meta = new UserMetadata();
     }
     $meta->user_id = $this->_user->id;
     $meta->key = 'passwordResetCode';
     $meta->value = $hash;
     $meta->save();
     $meta = UserMetadata::model()->findByAttributes(array('user_id' => $this->_user->id, 'key' => 'passwordResetExpires'));
     if ($meta === NULL) {
         $meta = new UserMetadata();
     }
     $meta->user_id = $this->_user->id;
     $meta->key = 'passwordResetExpires';
     $meta->value = $expires;
     $meta->save();
     $emailSettings = new EmailSettings();
     $emailSettings->send($this->_user, Yii::t('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
     // Set success flash
     Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array('{{email}}' => $this->email)));
     return true;
 }
示例#2
0
 /**
  * Sends an invite to a new user
  * @return boolean
  */
 public function invite()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = new Users();
     $user->attributes = array('email' => $this->email, 'firstName' => null, 'lastName' => null, 'displayName' => null, 'password' => null, 'user_role' => 5, 'status' => Users::PENDING_INVITATION);
     // Create a new user, but bypass validation
     if ($user->save(false)) {
         $meta = new UserMetadata();
         $meta->attributes = array('user_id' => $user->id, 'key' => 'invitationKey', 'value' => Cii::generateSafeHash());
         // If the key was savedm send the email out
         if ($meta->save()) {
             $emailSettings = new EmailSettings();
             $emailSettings->send($user, Yii::t('ciims.models.InvitationForm', "You've Been Invited..."), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.invite', array('user' => $user, 'hash' => $meta->value), true, true);
             return true;
         }
         $user->delete();
     }
     return false;
 }
示例#3
0
 /**
  * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent
  * @return boolean
  */
 public function sendVerificationEmail()
 {
     $emailSettings = new EmailSettings();
     return $emailSettings->send($this->_user, Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'), 'base.themes.' . Cii::getConfig('theme', 'default') . '.views.email.email-change', array('key' => $this->setNewEmailChangeKey(), 'user' => $this->_user));
 }
示例#4
0
 /**
  * Creates a new user, and sends the appropriate messaging out
  * @return boolean
  */
 public function save($sendEmail = true)
 {
     if (!$this->validate()) {
         return false;
     }
     $this->_user = new Users();
     // Set the model attributes
     $this->_user->attributes = array('email' => $this->email, 'password' => $this->password, 'username' => $this->username, 'user_role' => 1, 'status' => $sendEmail ? Users::PENDING_INVITATION : Users::ACTIVE);
     // If we saved the user model, return true
     if ($this->_user->save()) {
         // This class my be extended by other modules, in which case we don't need to send an activation form if we don't want need it to.
         if ($sendEmail) {
             $meta = new UserMetadata();
             $meta->attributes = array('user_id' => $this->_user->id, 'key' => 'activationKey', 'value' => Cii::generateSafeHash());
             $meta->save();
             // Send the registration email
             $emailSettings = new EmailSettings();
             $emailSettings->send($this->_user, Yii::t('ciims.email', 'Activate Your Account'), 'base.themes.' . Cii::getConfig('theme', 'default') . '.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true);
         }
         return true;
     }
     return false;
 }
示例#5
0
文件: Users.php 项目: bartuspan/CiiMS
 /**
  * Sets some default values for the user record.
  * TODO: This should have been moved to CiiModel
  * @see CActiveRecord::beforeValidate()
  **/
 public function beforeValidate()
 {
     // If the password is nulled, or unchanged
     if ($this->password == NULL || $this->password == Cii::get($this->_oldAttributes, 'password', false)) {
         if (!$this->isNewRecord) {
             $this->password = $this->_oldAttributes['password'];
         }
     } else {
         $this->password = password_hash($this->password, PASSWORD_BCRYPT, array('cost' => Cii::getBcryptCost()));
         if (!$this->isNewRecord) {
             $emailSettings = new EmailSettings();
             $emailSettings->send($this, Yii::t('ciims.models.Users', 'CiiMS Password Change Notification'), 'webroot.themes.' . Cii::getConfig('theme', 'default') . '.views.email.passwordchange', array('user' => $this));
         }
     }
     return parent::beforeValidate();
 }
示例#6
0
 function Emails($transaction = false, $dump = false)
 {
     if ($transaction) {
         global $_CONF;
         loadclass('Transactions');
         loadclass('Sites');
         loadclass('Merchants');
         loadclass('MerchantAccounts');
         loadclass('Customers');
         loadclass('EmailSettings');
         $customer = new Customers($transaction->transactionCustomerID);
         $merchant = new Merchants($transaction->transactionMerchantID);
         //if(!($_CONF[mail_enabled]!='FALSE' && $merchant->merchantEmailSending==1)) return false;
         $merchantaccount = new MerchantAccounts($merchant->merchantMerchantAccountID);
         $site = new Sites($transaction->transactionSiteID);
         $order = unserialize($customer->customerOrderObject);
         $emailSettings = new EmailSettings($merchant->merchantEmailSettingID);
         $smarty = new Smarty();
         $smarty->assign($transaction->getValues());
         $smarty->assign($customer->getValues());
         $smarty->assign($merchant->getValues());
         $smarty->assign($merchantaccount->getValues());
         $smarty->assign($emailSettings->getValues());
         $smarty->assign($site->getValues());
         $smarty->assign($order);
         $smarty->assign('Order', $order);
         if (!empty($emailSettings->emailFromEmail)) {
             $from = "{$emailSettings->emailCompanyName} <{$emailSettings->emailFromEmail}>";
         }
         $recipients[] = $customer->customerEmail;
         if ($site->siteEmailSendCustomerService) {
             $recipients[] = $site->siteCustomerSupportEmail;
         }
         if ($site->siteEmailSendAdditionalRecipients) {
             $recipients[] = $site->siteEmailAdditionalRecipients;
         }
         $smarty->assign('mheaders', $emailSettings->emailHeaders);
         $emails_dir = $_CONF[root_dir] . $_CONF[emails_dir];
         if (is_dir($emails_dir . "/merchant_emails/" . $merchant->getID())) {
             $emails_dir = $emails_dir . "/merchant_emails/" . $merchant->getID() . "/";
         }
         switch ($transaction->transactionType) {
             case 'rebill':
                 if ($transaction->transactionStatus == 'approved' || $transaction->transactionStatus == 'test' && $transaction->transactionReturnNumber == 'AUTH_TESTCARD_APP') {
                     $subject = $emailSettings->emailPaymentSubject;
                     $smarty->assign('msubject', $subject);
                     if (!$site->siteRebillEmailTemplate) {
                         $site->siteRebillEmailTemplate = $_CONF[emails_rebill];
                     }
                     $out = $smarty->fetch($emails_dir . $site->siteRebillEmailTemplate);
                 } else {
                     return false;
                     // $out=$smarty->fetch($_CONF[root_dir].$_CONF[emails_dir].$_CONF[emails_rebill]);
                 }
                 break;
             case 'sale':
                 if ($transaction->transactionStatus == 'approved' || $transaction->transactionStatus == 'test' && $transaction->transactionReturnNumber == 'AUTH_TESTCARD_APP') {
                     $subject = $emailSettings->emailPaymentSubject;
                     $smarty->assign('msubject', $subject);
                     if (!$site->sitePaymentEmailTemplate) {
                         $site->sitePaymentEmailTemplate = $_CONF[emails_payment];
                     }
                     $out = $smarty->fetch($emails_dir . $site->sitePaymentEmailTemplate);
                 } else {
                     return false;
                     //$out=$smarty->fetch($_CONF[root_dir].$_CONF[emails_dir].$_CONF[emails_payment]);
                 }
                 break;
             case 'chargeback':
                 $out = $smarty->fetch($emails_dir . $_CONF[emails_chargeback]);
                 break;
             case 'refund':
                 $out = $smarty->fetch($emails_dir . $_CONF[emails_refund]);
                 break;
             case 'reversal':
                 $out = $smarty->fetch($emails_dir . $_CONF[emails_reversal]);
                 break;
         }
         $body = $smarty->getSmartyVar('capture.body');
         $subject = $smarty->getSmartyVar('capture.subject');
         $headers = array();
         if ($add_h = explode("\n", $smarty->getSmartyVar('capture.headers'))) {
             $headers = array_merge($headers, $add_h);
         }
         if ($dump) {
             mydump($body);
             mydump($subject);
             mydump($headers);
             mydump($recipients);
             exit;
         }
         if ($_CONF[mail_enabled] != 'FALSE' && $merchant->merchantEmailSending == 1) {
             return pmail($recipients, $body, $subject, $headers, $from);
         }
     }
 }
示例#7
0
 /**
  * Generic method for sending an email. Instead of having to call a bunch of code all over over the place
  * This method can be called which should be able to handle almost anything.
  * @deprecated, @todo: Deprecate usage of this method
  * @see models/settings/EmailSettings::send
  * @return boolean
  */
 public function sendEmail($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug = false)
 {
     Yii::log(Yii::t('ciims.core', 'Use of CiiController::sendEmail is deprecated, and will be dropped in a future version. Use EmailSettings::send instead'), 'warning', 'ciims.core');
     $email = new EmailSettings();
     return $email->send($user, $subject, $viewFile, $content, $return, $processOutput, YII_DEBUG);
 }
示例#8
0
 /**
  * The SMTP port.
  * @return int Connection port of the SMTP server.
  */
 public function getSmtpPort()
 {
     return $this->settings->getSmtpPort();
 }