public function beforeSave()
 {
     if ($this->isNewRecord) {
         // If the user has activated email receiving, send a email
         if ($this->to_user->privacy && $this->to_user->privacy->message_new_message) {
             Yum::log(Yum::t('Message id {id} has been sent from user {from_user_id} to user {to_user_id}', array('{id}' => $this->id, '{from_user_id}' => $this->from_user_id, '{to_user_id}' => $this->to_user_id)));
             YumMailer::send($this->to_user->profile->email, $this->title, $this->message);
         }
     }
     return parent::beforeSave();
 }
Exemple #2
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         // If the user has activated email receiving, send a email
         if ($this->to_user->privacy && $this->to_user->privacy->message_new_message) {
             Yum::log(Yum::t('Message id {id} has been sent from user {from_user_id} to user {to_user_id}', array('{id}' => $this->id, '{from_user_id}' => $this->from_user_id, '{to_user_id}' => $this->to_user_id)));
             $answer_link = CHtml::link(Yum::t('Click here to respond to {username}', array('{username}' => $this->from_user->username)), Yii::app()->controller->createAbsoluteUrl('//message/message/compose', array('to_user_id' => $this->from_user_id)));
             YumMailer::send($this->to_user->profile->email, Yum::t('New message from {from}: {subject}', array('{from}' => $this->from_user->username, '{subject}' => $this->title)), $this->message . '<br />' . $answer_link);
         }
     }
     return parent::beforeSave();
 }
 public function beforeSave()
 {
     $this->updatetime = time();
     // If the user has activated email receiving, send a email
     if ($this->isNewRecord) {
         if ($user = YumUser::model()->findByPk($this->friend_id)) {
             if (Yum::hasModule('messages') && $user->privacy && $user->privacy->message_new_friendship) {
                 Yii::import('application.modules.messages.models.YumMessage');
                 YumMessage::write($user, $this->inviter, Yum::t('New friendship request from {username}', array('{username}' => $this->inviter->username)), YumTextSettings::getText('text_friendship_new', array('{username}' => $this->inviter->username, '{link_friends}' => Yii::app()->controller->createUrl('//friendship/friendship/index'), '{link_profile}' => Yii::app()->controller->createUrl('//profile/profile/view'), '{message}' => $this->message)));
             }
         }
     }
     return parent::beforeSave();
 }
 public function beforeSave()
 {
     $this->updatetime = time();
     // If the user has activated email receiving, send a email
     if ($this->isNewRecord) {
         if ($user = YumUser::model()->findByPk($this->friend_id)) {
             if (Yum::hasModule('message') && $user->privacy && $user->privacy->message_new_friendship) {
                 Yii::import('user.message.models.YumMessage');
                 YumMessage::write($user, $this->inviter, Yum::t('New friendship request from {username}', array('{username}' => $this->inviter->username)), strtr('A new friendship request from {username} has been made: {message} <a href="{link_friends}">Manage my friends</a><br /><a href="{link_profile}">To the profile</a>', array('{username}' => $this->inviter->username, '{link_friends}' => Yii::app()->controller->createUrl('//friendship/friendship/index'), '{link_profile}' => Yii::app()->controller->createUrl('//profile/profile/view'), '{message}' => $this->message)));
             }
         }
     }
     return parent::beforeSave();
 }