View | Details | Raw Unified | Return to bug 4231
Collapse All | Expand All

(-) (+83 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file ReviewReportDAO.inc.php
5
 *
6
 * Copyright (c) 2003-2009 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 * 
9
 * @class ReviewReportDAO
10
 * @ingroup plugins_reports_review
11
 * @see ReviewReportPlugin
12
 *
13
 * @brief Review report DAO
14
 */
15
16
//$Id: ReviewReportDAO.inc.php,v 1.6 2009/04/08 20:01:36 asmecher Exp $
17
18
19
import('classes.article.ArticleComment');
20
import('db.DBRowIterator');
21
22
class ReviewReportDAO extends DAO {
23
	/**
24
	 * Get the review report data.
25
	 * @param $journalId int
26
	 * @return array
27
	 */
28
	function getReviewReport($journalId) {
29
		$primaryLocale = Locale::getPrimaryLocale();
30
		$locale = Locale::getLocale();
31
32
		$result =& $this->retrieve(
33
			'SELECT	article_id,
34
				comments,
35
				author_id
36
			FROM	article_comments
37
			WHERE	comment_type = ?',
38
			array(
39
				COMMENT_TYPE_PEER_REVIEW
40
			)
41
		);
42
		import('db.DBRowIterator');
43
		$commentsReturner = new DBRowIterator($result);
44
45
		$result =& $this->retrieve(
46
			'SELECT r.round AS round,
47
				COALESCE(asl.setting_value, aspl.setting_value) AS article,
48
				a.article_id AS articleId,
49
				u.user_id AS reviewerId,
50
				u.username AS reviewer,
51
				u.first_name AS firstName,
52
				u.middle_name AS middleName,
53
				u.last_name AS lastName,
54
				r.date_assigned AS dateAssigned,
55
				r.date_notified AS dateNotified,
56
				r.date_confirmed AS dateConfirmed,
57
				r.date_completed AS dateCompleted,
58
				r.date_reminded AS dateReminded,
59
				(r.declined=1) AS declined,
60
				(r.cancelled=1) AS cancelled,
61
				r.recommendation AS recommendation
62
			FROM	review_assignments r
63
				LEFT JOIN articles a ON r.article_id = a.article_id
64
				LEFT JOIN article_settings asl ON (a.article_id=asl.article_id AND asl.locale=? AND asl.setting_name=?)
65
				LEFT JOIN article_settings aspl ON (a.article_id=aspl.article_id AND aspl.locale=? AND aspl.setting_name=?),
66
				users u
67
			WHERE	u.user_id=r.reviewer_id AND a.journal_id= ?
68
			ORDER BY article',
69
			array(
70
				$locale,
71
				'title',
72
				$primaryLocale,
73
				'title',
74
				$journalId
75
			)
76
		);
77
		$reviewsReturner = new DBRowIterator($result);
78
79
		return array($commentsReturner, $reviewsReturner);
80
	}
81
}
82
83
?>
(-)plugins/reports/reviews/ReviewReportPlugin.inc.php (+125 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @file ReviewReportPlugin.inc.php
5
 *
6
 * Copyright (c) 2003-2009 John Willinsky
7
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
8
 * 
9
 * @class ReviewReportPlugin
10
 * @ingroup plugins_reports_review
11
 * @see ReviewReportDAO
12
 *
13
 * @brief Review report plugin
14
 */
15
16
//$Id: ReviewReportPlugin.inc.php,v 1.6 2009/04/08 20:01:36 asmecher Exp $
17
18
import('classes.plugins.ReportPlugin');
19
20
class ReviewReportPlugin extends ReportPlugin {
21
	/**
22
	 * Called as a plugin is registered to the registry
23
	 * @param $category String Name of category plugin was registered to
24
	 * @return boolean True if plugin initialized successfully; if false,
25
	 * 	the plugin will not be registered.
26
	 */
27
	function register($category, $path) {
28
		$success = parent::register($category, $path);
29
		if ($success) {
30
			$this->import('ReviewReportDAO');
31
			$reviewReportDAO = new ReviewReportDAO();
32
			DAORegistry::registerDAO('ReviewReportDAO', $reviewReportDAO);
33
		}
34
		$this->addLocaleData();
35
		return $success;
36
	}
37
38
	/**
39
	 * Get the name of this plugin. The name must be unique within
40
	 * its category.
41
	 * @return String name of plugin
42
	 */
43
	function getName() {
44
		return 'ReviewReportPlugin';
45
	}
46
47
	function getDisplayName() {
48
		return Locale::translate('plugins.reports.reviews.displayName');
49
	}
50
51
	function getDescription() {
52
		return Locale::translate('plugins.reports.reviews.description');
53
	}
54
55
	function display(&$args) {
56
		$journal =& Request::getJournal();
57
58
		header('content-type: text/comma-separated-values');
59
		header('content-disposition: attachment; filename=report.csv');
60
61
		$reviewReportDao =& DAORegistry::getDAO('ReviewReportDAO');
62
		list($commentsIterator, $reviewsIterator) = $reviewReportDao->getReviewReport($journal->getJournalId());
63
64
		$comments = array();
65
		while ($row =& $commentsIterator->next()) {
66
			if (isset($comments[$row['article_id']][$row['author_id']])) {
67
				$comments[$row['article_id']][$row['author_id']] .= "; " . $row['comments'];
68
			} else {
69
				$comments[$row['article_id']][$row['author_id']] = $row['comments'];
70
			}
71
		}
72
73
		$yesnoMessages = array( 0 => Locale::translate('common.no'), 1 => Locale::translate('common.yes'));
74
75
		import('submission.reviewAssignment.ReviewAssignment');
76
		$recommendations = ReviewAssignment::getReviewerRecommendationOptions();
77
78
		$columns = array(
79
			'round' => Locale::translate('plugins.reports.reviews.round'),
80
			'article' => Locale::translate('article.articles'),
81
			'articleid' => Locale::translate('article.submissionId'),
82
			'reviewerid' => Locale::translate('plugins.reports.reviews.reviewerId'),
83
			'reviewer' => Locale::translate('plugins.reports.reviews.reviewer'),
84
			'firstname' => Locale::translate('user.firstName'),
85
			'middlename' => Locale::translate('user.middleName'),
86
			'lastname' => Locale::translate('user.lastName'),
87
			'dateassigned' => Locale::translate('plugins.reports.reviews.dateAssigned'),
88
			'datenotified' => Locale::translate('plugins.reports.reviews.dateNotified'),
89
			'dateconfirmed' => Locale::translate('plugins.reports.reviews.dateConfirmed'),
90
			'datecompleted' => Locale::translate('plugins.reports.reviews.dateCompleted'),
91
			'datereminded' => Locale::translate('plugins.reports.reviews.dateReminded'),
92
			'declined' => Locale::translate('submissions.declined'),
93
			'cancelled' => Locale::translate('common.cancelled'),
94
			'recommendation' => Locale::translate('reviewer.article.recommendation'),
95
			'comments' => Locale::translate('comments.commentsOnArticle')
96
		);
97
		$yesNoArray = array('declined', 'cancelled');
98
99
		$fp = fopen('php://output', 'wt');
100
		String::fputcsv($fp, array_values($columns));
101
102
		while ($row =& $reviewsIterator->next()) {
103
			foreach ($columns as $index => $junk) {
104
				if (in_array($index, $yesNoArray)) {
105
					$columns[$index] = $yesnoMessages[$row[$index]];
106
				} elseif ($index == "recommendation") {
107
					$columns[$index] = (!isset($row[$index])) ? Locale::translate('common.none') : Locale::translate($recommendations[$row[$index]]);
108
				} elseif ($index == "comments") {
109
					if (isset($comments[$row['articleid']][$row['reviewerid']])) {
110
						$columns[$index] = $comments[$row['articleid']][$row['reviewerid']];
111
					} else {
112
						$columns[$index] = "";
113
					}
114
				} else {
115
					$columns[$index] = $row[$index];
116
				}
117
			}
118
			String::fputcsv($fp, $columns);
119
			unset($row);
120
		}
121
		fclose($fp);
122
	}
123
}
124
125
?>
(-)plugins/reports/reviews/index.php (+24 lines)
Added Link Here 
1
<?php
2
3
/**
4
 * @defgroup plugins_reports_reviews
5
 */
6
 
7
/**
8
 * @file index.php
9
 *
10
 * Copyright (c) 2003-2009 John Willinsky
11
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
12
 *
13
 * @brief Wrapper for review report plugin.
14
 *
15
 * @ingroup plugins_reports_reviews
16
 */
17
18
//$Id: index.php,v 1.4 2009/04/08 20:01:36 asmecher Exp $
19
20
require_once('ReviewReportPlugin.inc.php');
21
22
return new ReviewReportPlugin();
23
24
?>
(-)plugins/reports/reviews/locale/en_US/locale.xml (+27 lines)
Added Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE locale SYSTEM "../../../../../lib/pkp/dtd/locale.dtd">
3
4
<!--
5
  * locale.xml
6
  *
7
  * Copyright (c) 2003-2009 John Willinsky
8
  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9
  *
10
  * Localization strings for the en_US (U.S. English) locale.
11
  *
12
  * $Id: locale.xml,v 1.4 2009/04/08 20:01:36 asmecher Exp $
13
  -->
14
15
<locale name="en_US" full_name="U.S. English">
16
	<message key="plugins.reports.reviews.displayName">Review Report</message>
17
	<message key="plugins.reports.reviews.description">This plugin implements a CSV report containing a list of review assignments for a journal.</message>
18
	<message key="plugins.reports.reviews.round">Round</message>
19
	<message key="plugins.reports.reviews.reviewerId">Reviewer ID</message>
20
	<message key="plugins.reports.reviews.reviewer">Reviewer</message>
21
	<message key="plugins.reports.reviews.dateAssigned">Date Assigned</message>
22
	<message key="plugins.reports.reviews.dateNotified">Date Notified</message>
23
	<message key="plugins.reports.reviews.dateConfirmed">Date Confirmed</message>
24
	<message key="plugins.reports.reviews.dateCompleted">Date Completed</message>
25
	<message key="plugins.reports.reviews.dateReminded">Date Reminded</message>
26
</locale>
27

Return to bug 4231