/**
  * After save event
  */
 public function afterSave()
 {
     // Update Topic
     PersonalMessageTopic::model()->updateByPk($this->topic_id, array('last_reply_created_at' => $this->created_at, 'last_reply_author_id' => $this->user_id));
     // Send notifications
     PersonalMessageTopic::model()->sendNotifications($this->topic_id, $this->id);
     return parent::afterSave();
 }
 /**
  * Delete help topic action
  */
 public function actionDelete()
 {
     // Check Access
     checkAccessThrowException('op_personalmessages_delete');
     if (isset($_GET['id']) && ($model = PersonalMessageTopic::model()->findByPk($_GET['id']))) {
         alog(at("Deleted Personal Message '{name}'.", array('{name}' => $model->title)));
         // Make sure we are allowed to delete this
         if ($model->author_id != Yii::app()->user->id) {
             ferror(at('Sorry, You are not the author of this personal message so you can not delete it.'));
             alog(at("Tried Deleting a Personal Message '{name}' When he is not the author.", array('{name}' => $model->title)));
             $this->redirect(getReferrer('personalmessages/index'));
         }
         $model->delete();
         fok(at('Personal Message Deleted.'));
         $this->redirect(array('personalmessages/index'));
     } else {
         $this->redirect(array('personalmessages/index'));
     }
 }
 /**
  * After save operations
  */
 public function afterSave()
 {
     // Add message to the reply table
     $reply = new PersonalMessageReply();
     $reply->topic_id = $this->id;
     $reply->message = $this->message;
     $reply->save();
     // Update Topic
     PersonalMessageTopic::model()->updateByPk($this->id, array('first_post' => $reply->id, 'last_reply_created_at' => $reply->created_at, 'last_reply_author_id' => $reply->user_id));
     // Add current user
     $participant = new PersonalMessageParticipant();
     $participant->topic_id = $this->id;
     $participant->user_id = Yii::app()->user->id;
     $participant->save();
     // Add recipients to the particiapnts table
     foreach ($this->to as $userid) {
         $participant = new PersonalMessageParticipant();
         $participant->topic_id = $this->id;
         $participant->user_id = $userid;
         $participant->save();
     }
     // Add the notifications for all the participants
     $this->sendNotifications(null, $reply->id);
     return parent::afterSave();
 }
Пример #4
0
echo t('Profile');
?>
</a>
							<a href="<?php 
echo $this->createUrl('login/logout');
?>
" class="submeta"><?php 
echo t('Logout');
?>
</a>
						</div>
					</div>
					
					<div class="user_meta user_meta_extended">
						<?php 
$title = PersonalMessageTopic::model()->getUserNotificationCount(Yii::app()->user->id);
?>
						<?php 
echo at("You Have {link} New Personal Messages. <br />{create}", array('{create}' => CHtml::link(at('Compose Message'), 'javascript:', array('id' => 'create-message')), '{link}' => CHtml::link($title, array('personalmessages/index'), array('class' => 'submeta'))));
?>
					</div>
				</div>
			
				<div class="clear"></div>
			</div>
	
			<section id="top">
					
				<section id="top_bar">						
					<section id="main_menu">
						<?php