예제 #1
0
 /**
  * On User delete, also delete all comments
  *
  * @param type $event
  */
 public static function onUserDelete($event)
 {
     foreach (MessageEntry::findAll(array('user_id' => $event->sender->id)) as $messageEntry) {
         $messageEntry->delete();
     }
     foreach (UserMessage::findAll(array('user_id' => $event->sender->id)) as $userMessage) {
         $userMessage->message->leave($event->sender->id);
     }
     return true;
 }
 /**
  * Creates the Wall Widget
  */
 public function run()
 {
     return $this->render('notifications', array('newMailMessageCount' => UserMessage::getNewMessageCount()));
 }
예제 #3
0
 /**
  * Deletes a message, including all dependencies.
  */
 public function delete()
 {
     foreach (MessageEntry::findAll(array('message_id' => $this->id)) as $messageEntry) {
         $messageEntry->delete();
     }
     foreach (UserMessage::findAll(array('message_id' => $this->id)) as $userMessage) {
         $userMessage->delete();
     }
     parent::delete();
 }
 /**
  * Returns the Message Model by given Id
  * Also an access check will be performed.
  *
  * If insufficed privileges or not found null will be returned.
  *
  * @param int $id
  */
 private function getMessage($id)
 {
     $message = Message::findOne(['id' => $id]);
     if ($message != null) {
         $userMessage = UserMessage::findOne(['user_id' => Yii::$app->user->id, 'message_id' => $message->id]);
         if ($userMessage != null) {
             return $message;
         }
     }
     return null;
 }