/** * Delete document * * @param void * @return null */ function delete() { $filepath = $this->getFilePath(); db_begin_work(); $delete = parent::delete(); if (!$delete || is_error($delete)) { db_rollback(); return $delete; } // if $delete_attachments = Attachments::deleteByObject($this); if (!$delete_attachments || is_error($delete_attachments)) { db_rollback(); return $delete_attachments; } // if if (is_file($filepath)) { @unlink($filepath); } // if db_commit(); return true; }
/** * Delete this object * * If $drop_subitems is TRUE subitems will be delete from the database. If it * is false relation will be nullified * * @param boolean $drop_subitems * @return boolean * @throws DBQueryError */ function delete($drop_subitems = true) { db_begin_work(); $delete = parent::delete(); if (is_error($delete) || !$delete) { db_rollback(); return $delete; } // if $subitems = $this->getSubitems(); if (is_foreachable($subitems)) { foreach ($subitems as $subitem) { if ($drop_subitems) { $delete = $subitem->delete(); if (is_error($delete)) { db_rollback(); return $delete; } // if } else { $subitem->setParent(null, false); $save = $subitem->save(); if (is_error($save)) { db_rollback(); return $save; } // if } // if } // foreach } // if StarredObjects::deleteByObject($this); // Attachments if ($this->can_have_attachments) { Attachments::deleteByObject($this); } // if // Subscriptions if ($this->can_have_subscribers) { Subscriptions::deleteByParent($this); } // if // Asignments if ($this->can_have_assignees) { Assignments::deleteByObject($this); } // if // Activity log if ($this->log_activities) { ActivityLogs::deleteByObject($this); } // if // Reminders if ($this->can_send_reminders) { Reminders::deleteByObject($this); } // if search_index_remove($this->getId(), 'ProjectObject'); db_commit(); return true; }