Ejemplo 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;
 }
 /**
  * Deletes a message, including all dependencies.
  */
 public function delete()
 {
     foreach (ServicesMessageEntry::findAll(array('message_id' => $this->id)) as $messageEntry) {
         $messageEntry->delete();
     }
     foreach (ServicesUserMessage::findAll(array('message_id' => $this->id)) as $userMessage) {
         $userMessage->delete();
     }
     parent::delete();
 }