function expunge($pPackage = NULL) { if (!empty($pPackage)) { $this->mPackage = $pPackage; } if ($this->isValid()) { $this->load(); $this->mDb->StartTrans(); // first we get all related versions $query = "SELECT `packager_id` FROM `" . BIT_DB_PREFIX . "packager_versions` WHERE `package` = ?"; $ids = $this->mDb->getCol($query, array($this->mPackage)); foreach ($ids as $id) { $version = new PackagerVersions($id); $version->load(); $version->expunge(); } if (!$this->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "packager_packages` WHERE `package` = ?", array($this->mPackage))) { $this->mErrors['delete'] = tra('The data could not be removed from the database.'); } if (count($this->mErrors) == 0) { $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } $this->postStore(); return count($this->mErrors) == 0; }
/** * Initiate class * * @return void */ function PackagerVersions($pPackagerId = NULL) { PackagerVersions::PackagerVersions(); $this->mPackagerId = $pPackagerId; }
/** * get the most recent version of a given package * * @param array $pPackage * @access public * @return latest version number of given package */ function getLatestVersion($pPackage) { if (!empty($pPackage)) { require_once PACKAGER_PKG_PATH . "PackagerVersions.php"; $query = "SELECT * FROM `" . BIT_DB_PREFIX . "packager_versions` WHERE `package`=? ORDER BY " . $this->mDb->convertSortmode('release_date_desc'); if ($ret = $this->mDb->getRow($query, array($pPackage))) { $ret['display_url'] = PackagerVersions::getDisplayUrlFromHash($ret); $ret['package_url'] = PackagerVersions::getPackageUrl($ret); } return $ret; } }
<?php if (!empty($_REQUEST['package'])) { $gPackager = new Packager($_REQUEST['package']); $gPackager->load(); } else { $gPackager = new Packager(); } if (@BitBase::verifyId($_REQUEST['packager_id'])) { $gVersions = new PackagerVersions($_REQUEST['packager_id']); $gVersions->load(); } else { $gVersions = new PackagerVersions(); } $gPackager->verifyServer(); $gBitSmarty->assign_by_ref('gPackager', $gPackager); $gBitSmarty->assign_by_ref('gVersions', $gVersions);