Exemplo n.º 1
0
 /**
  * On User delete, also delete all comments
  *
  * @param type $event
  */
 public static function onUserDelete($event)
 {
     foreach (ServicesMessageEntry::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;
 }
Exemplo n.º 2
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();
 }