<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Announcement_Plugin_Core
{
  public function onItemDeleteBefore($event)
  {
    $payload = $event->getPayload();
    if( $payload instanceof Core_Model_Item_Abstract && $payload->getType() === 'user' )
    {
      $table = Engine_Api::_()->getDbtable('announcements', 'announcement');
      foreach( $table->fetchAll($table->select()->where('user_id = ?', $payload->getIdentity())) as $announcement )
      {
        $announcement->delete();
      }
    }
  }
}
