-
Notifications
You must be signed in to change notification settings - Fork 902
/
ReviewReportPlugin.inc.php
129 lines (112 loc) · 4.34 KB
/
ReviewReportPlugin.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* @file plugins/reports/reviews/ReviewReportPlugin.inc.php
*
* Copyright (c) 2013-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class ReviewReportPlugin
* @ingroup plugins_reports_review
* @see ReviewReportDAO
*
* @brief Review report plugin
*/
import('classes.plugins.ReportPlugin');
class ReviewReportPlugin extends ReportPlugin {
/**
* Called as a plugin is registered to the registry
* @param $category String Name of category plugin was registered to
* @return boolean True if plugin initialized successfully; if false,
* the plugin will not be registered.
*/
function register($category, $path) {
$success = parent::register($category, $path);
if ($success && Config::getVar('general', 'installed')) {
$this->import('ReviewReportDAO');
$reviewReportDAO = new ReviewReportDAO();
DAORegistry::registerDAO('ReviewReportDAO', $reviewReportDAO);
}
$this->addLocaleData();
return $success;
}
/**
* Get the name of this plugin. The name must be unique within
* its category.
* @return String name of plugin
*/
function getName() {
return 'ReviewReportPlugin';
}
function getDisplayName() {
return __('plugins.reports.reviews.displayName');
}
function getDescription() {
return __('plugins.reports.reviews.description');
}
function display($args, $request) {
$journal =& Request::getJournal();
header('content-type: text/comma-separated-values');
header('content-disposition: attachment; filename=reviews-' . date('Ymd') . '.csv');
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
$reviewReportDao =& DAORegistry::getDAO('ReviewReportDAO');
list($commentsIterator, $reviewsIterator) = $reviewReportDao->getReviewReport($journal->getId());
$comments = array();
while ($row =& $commentsIterator->next()) {
if (isset($comments[$row['article_id']][$row['author_id']])) {
$comments[$row['article_id']][$row['author_id']] .= "; " . $row['comments'];
} else {
$comments[$row['article_id']][$row['author_id']] = $row['comments'];
}
}
$yesnoMessages = array( 0 => __('common.no'), 1 => __('common.yes'));
import('classes.submission.reviewAssignment.ReviewAssignment');
$recommendations = ReviewAssignment::getReviewerRecommendationOptions();
$columns = array(
'round' => __('plugins.reports.reviews.round'),
'article' => __('article.articles'),
'articleid' => __('article.submissionId'),
'reviewerid' => __('plugins.reports.reviews.reviewerId'),
'reviewer' => __('plugins.reports.reviews.reviewer'),
'firstname' => __('user.firstName'),
'middlename' => __('user.middleName'),
'lastname' => __('user.lastName'),
'dateassigned' => __('plugins.reports.reviews.dateAssigned'),
'datenotified' => __('plugins.reports.reviews.dateNotified'),
'dateconfirmed' => __('plugins.reports.reviews.dateConfirmed'),
'datecompleted' => __('plugins.reports.reviews.dateCompleted'),
'datereminded' => __('plugins.reports.reviews.dateReminded'),
'declined' => __('submissions.declined'),
'cancelled' => __('common.cancelled'),
'recommendation' => __('reviewer.article.recommendation'),
'comments' => __('comments.commentsOnArticle')
);
$yesNoArray = array('declined', 'cancelled');
$fp = fopen('php://output', 'wt');
PKPString::fputcsv($fp, array_values($columns));
import('submission.sectionEditor.SectionEditorAction');
while ($row =& $reviewsIterator->next()) {
foreach ($columns as $index => $junk) {
if (in_array($index, $yesNoArray)) {
$columns[$index] = $yesnoMessages[$row[$index]];
} elseif ($index == "recommendation") {
$columns[$index] = (!isset($row[$index])) ? __('common.none') : __($recommendations[$row[$index]]);
} elseif ($index == "comments") {
if (isset($comments[$row['articleid']][$row['reviewerid']])) {
$columns[$index] = PKPString::html2text(strip_tags($comments[$row['articleid']][$row['reviewerid']]));
} elseif (isset($row['reviewformid'])) {
$columns[$index] = PKPString::html2text(strip_tags(SectionEditorAction::getReviewFormResponses($row['reviewid'], $row['reviewformid'])));
} else {
$columns[$index] = "";
}
} else {
$columns[$index] = $row[$index];
}
}
PKPString::fputcsv($fp, $columns);
unset($row);
}
fclose($fp);
}
}
?>