public function raiseEvent($eventName, $model, $params = array()) { Yii::import('application.modules.notifier.models.NotifierModel'); if ($this->init == 0) { $this->init(); } $notifyModel = NotifierModel::model()->findByAttributes(array('event' => $eventName)); if (!$notifyModel) { return false; } $this->_params = $params; $forceEmail = $this->getFromParam('forceEmail'); $to = ''; if ($forceEmail) { $to = $forceEmail; } else { $user = $this->getFromParam('user'); if ($user) { $to = $user->email; } } if (isset($this->_userRules[$eventName]) && $to) { $rules = $this->_userRules[$eventName]; if ($eventName == 'onNewUser' && param('user_registrationMode') == 'without_confirm') { $rules['active'] = false; } $rules['subject'] = $notifyModel->getStrByLang('subject'); $rules['body'] = $notifyModel->getStrByLang('body'); if ($rules['active']) { $this->_processEvent($rules, $model, $to); } } if (isset($this->_adminRules[$eventName])) { $rules = $this->_adminRules[$eventName]; $rules['subject'] = $notifyModel->getStrByLang('subject_admin'); $rules['body'] = $notifyModel->getStrByLang('body_admin'); $this->sendToAdmin = true; if ($rules['active']) { if ($eventName == 'onNewApartment' || $eventName == 'onNewComment' || $eventName == 'onNewComplain' || $eventName == 'onNewBooking' || $eventName == 'onNewSimpleBookingForRent' || $eventName == 'onNewSimpleBookingForBuy' || $eventName == 'onNewReview') { $this->_processEvent($rules, $model, param('adminEmail'), true); } else { $this->_processEvent($rules, $model, param('adminEmail')); } } } }
public function raiseEvent($eventName, $model, $params = array()) { Yii::import('application.modules.notifier.models.NotifierModel'); if ($this->init == 0) { $this->init(); } $notifyModel = NotifierModel::model()->findByAttributes(array('event' => $eventName)); if (!$notifyModel) { return false; } $this->_params = $params; $forceEmail = $this->getFromParam('forceEmail'); $to = ''; if ($forceEmail) { $to = $forceEmail; } else { $user = $this->getFromParam('user'); if ($user) { $to = $user->email; } } if (isset($this->_userRules[$eventName]) && $to) { $rules = $this->_userRules[$eventName]; $rules['subject'] = $notifyModel->getStrByLang('subject'); $rules['body'] = $notifyModel->getStrByLang('body'); if ($rules['active']) { $this->_processEvent($rules, $model, $to); } } if (isset($this->_adminRules[$eventName])) { $rules = $this->_adminRules[$eventName]; $rules['subject'] = $notifyModel->getStrByLang('subject_admin'); $rules['body'] = $notifyModel->getStrByLang('body_admin'); $this->sendToAdmin = true; if ($rules['active']) { $this->_processEvent($rules, $model, param('adminEmail')); } } }