protected function hook_preDelete()
 {
     $this->_file_id = $this->file_id;
     parent::hook_preDelete();
 }
 protected function hook_postDelete()
 {
     $q = $this->_getQuery();
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere('task_project = ' . $this->_old_key);
     $tasks_to_delete = $q->loadColumn();
     $q->clear();
     $task = new w2p_Actions_BulkTasks();
     $task->overrideDatabase($this->_query);
     foreach ($tasks_to_delete as $task_id) {
         $task->task_id = $task_id;
         $task->delete();
     }
     $q->clear();
     $q->addTable('files');
     $q->addQuery('file_id');
     $q->addWhere('file_project = ' . $this->_old_key);
     $files_to_delete = $q->loadColumn();
     $q->clear();
     $file = new CFile();
     $file->overrideDatabase($this->_query);
     foreach ($files_to_delete as $file_id) {
         $file->file_id = $file_id;
         $file->delete();
     }
     $q->clear();
     $q->addTable('events');
     $q->addQuery('event_id');
     $q->addWhere('event_project = ' . $this->_old_key);
     $events_to_delete = $q->loadColumn();
     $q->clear();
     $event = new CEvent();
     $event->overrideDatabase($this->_query);
     foreach ($events_to_delete as $event_id) {
         $event->event_id = $event_id;
         $event->delete();
     }
     $q->clear();
     // remove the project-contacts and project-departments map
     $q->setDelete('project_contacts');
     $q->addWhere('project_id =' . $this->_old_key);
     $q->exec();
     $q->clear();
     $q->setDelete('project_departments');
     $q->addWhere('project_id =' . $this->_old_key);
     $q->exec();
     $q->clear();
     $q->setDelete('tasks');
     $q->addWhere('task_represents_project =' . $this->_old_key);
     parent::hook_preDelete();
 }
 protected function hook_preDelete()
 {
     $this->_project_id = $this->task_project;
     parent::hook_preDelete();
 }