/** * Deletes the specified history entries or all entries if no ids are specified. * * @param array $a_hist_entry_ids The ids of the entries to delete or null to delete all entries */ public function deleteVersions($a_hist_entry_ids = null) { global $ilDB; require_once "./Services/History/classes/class.ilHistory.php"; if ($a_hist_entry_ids == null || count($a_hist_entry_ids) < 1) { $ilDB->manipulate("UPDATE file_data SET version = 1 WHERE file_id = " . $ilDB->quote($this->getId(), 'integer')); $this->setVersion(0); $this->clearDataDirectory(); ilHistory::_removeEntriesForObject($this->getId()); self::handleQuotaUpdate($this); } else { $actualVersionDeleted = false; // get all versions $versions = $this->getVersions(); // delete each version foreach ($a_hist_entry_ids as $hist_id) { $entry = null; // get version foreach ($versions as $index => $version) { if ($version["hist_entry_id"] == $hist_id) { // remove each history entry ilHistory::_removeEntryByHistoryID($hist_id); // delete directory $version_dir = $this->getDirectory($version["version"]); ilUtil::delDir($version_dir); // is actual version? if ($version["version"] == $this->getVersion()) { $actualVersionDeleted = true; } // remove from array unset($versions[$index]); break; } } } // update actual version if it was deleted before if ($actualVersionDeleted) { // get newest version (already sorted by getVersions) $version = reset($versions); $this->updateWithVersion($version); } else { // updateWithVersion() will trigger quota, too self::handleQuotaUpdate($this); } } }