18 import(
'lib.pkp.classes.site.Version');
30 if(!$productType || !$product) {
32 $productType =
'core';
42 'SELECT * FROM versions WHERE current = 1'
47 if ($result->RecordCount() == 1) {
49 if (isset($oldVersion)) $returner = $oldVersion;
58 'SELECT * FROM versions WHERE current = 1 AND product_type = ? AND product = ?',
59 array($productType, $product)
61 $versionCount = $result->RecordCount();
62 if ($versionCount == 1) {
64 } elseif ($versionCount >1) {
65 fatalError(
'More than one current version defined for the product type "'.$productType.
'" and product "'.$product.
'"!');
82 if(!$productType || !$product) {
84 $productType =
'core';
89 'SELECT * FROM versions WHERE product_type = ? AND product = ? ORDER BY date_installed DESC',
90 array($productType, $product)
93 while (!$result->EOF) {
115 (isset($row[
'product_type']) ? $row[
'product_type'] :
null),
116 (isset($row[
'product']) ? $row[
'product'] :
null),
117 (isset($row[
'product_class_name']) ? $row[
'product_class_name'] :
''),
118 (isset($row[
'lazy_load']) ? $row[
'lazy_load'] : 0),
119 (isset($row[
'sitewide']) ? $row[
'sitewide'] : 0)
133 $isNewVersion =
true;
135 if ($version->getCurrent()) {
138 $versionHistory = $this->
getVersionHistory($version->getProductType(), $version->getProduct());
140 $oldVersion = array_shift($versionHistory);
142 if ($version->compare($oldVersion) == 0) {
145 $isNewVersion =
false;
146 } elseif ($version->compare($oldVersion) == 1) {
149 $this->
update(
'UPDATE versions SET current = 0 WHERE current = 1 AND product = ?', $version->getProduct());
152 fatalError(
'You are trying to downgrade the product "'.$version->getProduct().
'" from version ['.$oldVersion->getVersionString(
false).
'] to version ['.$version->getVersionString(
false).
']. Downgrades are not supported.');
160 if ($version->getDateInstalled() ==
null) {
166 sprintf(
'INSERT INTO versions
167 (major, minor, revision, build, date_installed, current, product_type, product, product_class_name, lazy_load, sitewide)
169 (?, ?, ?, ?, %s, ?, ?, ?, ?, ?, ?)',
172 (
int) $version->getMajor(),
173 (
int) $version->getMinor(),
174 (
int) $version->getRevision(),
175 (
int) $version->getBuild(),
176 (
int) $version->getCurrent(),
177 $version->getProductType(),
178 $version->getProduct(),
179 $version->getProductClassName(),
180 ($version->getLazyLoad()?1:0),
181 ($version->getSitewide()?1:0)
187 'UPDATE versions SET current = ?, product_class_name = ?, lazy_load = ?, sitewide = ?
188 WHERE product_type = ? AND product = ? AND major = ? AND minor = ? AND revision = ? AND build = ?',
190 (
int) $version->getCurrent(),
191 $version->getProductClassName(),
192 ($version->getLazyLoad()?1:0),
193 ($version->getSitewide()?1:0),
194 $version->getProductType(),
195 $version->getProduct(),
196 (
int) $version->getMajor(),
197 (
int) $version->getMinor(),
198 (
int) $version->getRevision(),
199 (
int) $version->getBuild()
217 if (count($context)) {
218 assert(count($context)==1);
219 $contextWhereClause =
'AND (context_id = ? OR v.sitewide = 1)';
221 $contextWhereClause =
'';
226 FROM versions v LEFT JOIN plugin_settings ps ON
227 lower(v.product_class_name) = ps.plugin_name
228 AND ps.setting_name = \'enabled\' '.$contextWhereClause.
'
229 WHERE v.current = 1 AND (ps.setting_value = \'1\' OR v.lazy_load <> 1)',
233 $productArray = array();
234 while(!$result->EOF) {
235 $row = $result->getRowAssoc(
false);
240 return $productArray;
250 'UPDATE versions SET current = 0 WHERE current = 1 AND product_type = ? AND product = ?',
251 array($productType, $product)