Skip to content

Commit

Permalink
*8015* Count article or issue view when no galley is found
Browse files Browse the repository at this point in the history
  • Loading branch information
beghelli committed May 2, 2013
1 parent 2a1894e commit 0299293
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions plugins/generic/usageStats/UsageStatsLoader.inc.php
Expand Up @@ -261,45 +261,45 @@ private function _getAssocFromReferer($referer) {

// Get the internal object id (avoiding public ids).
switch ($assocType) {
case ASSOC_TYPE_ARTICLE:
$assocId = $this->_getInternalArticleId($assocId, $journal);
break;
case ASSOC_TYPE_SUPP_FILE:
$articleId = $this->_getInternalArticleId($parentObjectId, $journal);
$suppFileDao = DAORegistry::getDAO('SuppFileDAO');
if ($journal->getSetting('enablePublicSuppFileId')) {
$suppFile = $suppFileDao->getSuppFileByBestSuppFileId($assocId, $articleId);
} else {
$suppFile = $suppFileDao->getSuppFile((int) $assocId, $articleId);
}
if (!is_a($suppFile, 'SuppFile')) {
$assocId = $suppFile->getId();
} else {
$assocId = false;
}
echo('Supp file. File id: ' . $assocId . PHP_EOL);
break;
case ASSOC_TYPE_GALLEY:
$articleId = $this->_getInternalArticleId($parentObjectId, $journal);
if (!$articleId) {
$assocId = false;
break;
}

$galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
if ($journal->getSetting('enablePublicGalleyId')) {
$galley =& $galleyDao->getGalleyByBestGalleyId($assocId, $articleId);
} else {
$galley =& $galleyDao->getGalley($assocId, $articleId);
}
if (is_a($galley, 'ArticleGalley')) {
$assocId = $galley->getId();
if ($assocType == ASSOC_TYPE_SUPP_FILE) {
$suppFileDao = DAORegistry::getDAO('SuppFileDAO');
if ($journal->getSetting('enablePublicSuppFileId')) {
$suppFile = $suppFileDao->getSuppFileByBestSuppFileId($assocId, $articleId);
} else {
$suppFile = $suppFileDao->getSuppFile((int) $assocId, $articleId);
}
if (is_a($suppFile, 'SuppFile')) {
$assocId = $suppFile->getId();
} else {
$assocId = false;
}
break;
} else {
$assocId = false;
$galleyDao = DAORegistry::getDAO('ArticleGalleyDAO');
if ($journal->getSetting('enablePublicGalleyId')) {
$galley =& $galleyDao->getGalleyByBestGalleyId($assocId, $articleId);
} else {
$galley =& $galleyDao->getGalley($assocId, $articleId);
}
if (is_a($galley, 'ArticleGalley')) {
$assocId = $galley->getId();
break;
}
}
break;
case ASSOC_TYPE_ISSUE:
$assocId = $this->_getInternalIssueId($assocId, $journal);

// Couldn't retrieve galley,
// count as article view.
$assocType = ASSOC_TYPE_ARTICLE;
$assocId = $parentObjectId;
case ASSOC_TYPE_ARTICLE:
$assocId = $this->_getInternalArticleId($assocId, $journal);
break;
case ASSOC_TYPE_ISSUE_GALLEY:
$issueId = $this->_getInternalIssueId($parentObjectId, $journal);
Expand All @@ -315,9 +315,15 @@ private function _getAssocFromReferer($referer) {
}
if (is_a($galley, 'IssueGalley')) {
$assocId = $issue->getId();
break;
} else {
$assocId = false;
// Count as a issue view. Don't break
// so the issue case will be handled.
$assocType = ASSOC_TYPE_ISSUE;
$assocId = $parentObjectId;
}
case ASSOC_TYPE_ISSUE:
$assocId = $this->_getInternalIssueId($assocId, $journal);
break;
}
}
Expand Down

0 comments on commit 0299293

Please sign in to comment.