plugins/reports/reviews/ReviewReportPlugin.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 //$Id$
00017 
00018 import('classes.plugins.ReportPlugin');
00019 
00020 class ReviewReportPlugin extends ReportPlugin {
00027    function register($category, $path) {
00028       $success = parent::register($category, $path);
00029       if ($success) {
00030          $this->import('ReviewReportDAO');
00031          $reviewReportDAO = new ReviewReportDAO();
00032          DAORegistry::registerDAO('ReviewReportDAO', $reviewReportDAO);
00033       }
00034       $this->addLocaleData();
00035       return $success;
00036    }
00037 
00043    function getName() {
00044       return 'ReviewReportPlugin';
00045    }
00046 
00047    function getDisplayName() {
00048       return __('plugins.reports.reviews.displayName');
00049    }
00050 
00051    function getDescription() {
00052       return __('plugins.reports.reviews.description');
00053    }
00054 
00055    function display(&$args) {
00056       $conference =& Request::getConference();
00057       $schedConf =& Request::getSchedConf();
00058       AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON, LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OCS_MANAGER));
00059 
00060       header('content-type: text/comma-separated-values; charset=utf-8');
00061       header('content-disposition: attachment; filename=report.csv');
00062 
00063       $reviewReportDao =& DAORegistry::getDAO('ReviewReportDAO');
00064       list($commentsIterator, $reviewsIterator) = $reviewReportDao->getReviewReport($schedConf->getId());
00065 
00066       $comments = array();
00067       while ($row =& $commentsIterator->next()) {
00068          if (isset($comments[$row['paper_id']][$row['author_id']])) {
00069             $comments[$row['paper_id']][$row['author_id']] .= "; " . $row['comments'];
00070          } else {
00071             $comments[$row['paper_id']][$row['author_id']] = $row['comments'];
00072          }
00073       }
00074 
00075       $yesnoMessages = array( 0 => __('common.no'), 1 => __('common.yes'));
00076 
00077       import('classes.schedConf.SchedConf');
00078       $reviewTypes = array(
00079          REVIEW_MODE_ABSTRACTS_ALONE => __('manager.schedConfSetup.submissions.abstractsAlone'),
00080          REVIEW_MODE_BOTH_SEQUENTIAL => __('manager.schedConfSetup.submissions.bothSequential'),
00081          REVIEW_MODE_PRESENTATIONS_ALONE => __('manager.schedConfSetup.submissions.presentationsAlone'),
00082          REVIEW_MODE_BOTH_SIMULTANEOUS => __('manager.schedConfSetup.submissions.bothTogether')
00083       );
00084 
00085       import('submission.reviewAssignment.ReviewAssignment');
00086       $recommendations = ReviewAssignment::getReviewerRecommendationOptions();
00087 
00088       $columns = array(
00089          'reviewstage' => __('submissions.reviewType'),
00090          'paper' => __('paper.papers'),
00091          'paperid' => __('paper.submissionId'),
00092          'reviewerid' => __('plugins.reports.reviews.reviewerId'),
00093          'reviewer' => __('plugins.reports.reviews.reviewer'),
00094          'firstname' => __('user.firstName'),
00095          'middlename' => __('user.middleName'),
00096          'lastname' => __('user.lastName'),
00097          'dateassigned' => __('plugins.reports.reviews.dateAssigned'),
00098          'datenotified' => __('plugins.reports.reviews.dateNotified'),
00099          'dateconfirmed' => __('plugins.reports.reviews.dateConfirmed'),
00100          'datecompleted' => __('plugins.reports.reviews.dateCompleted'),
00101          'datereminded' => __('plugins.reports.reviews.dateReminded'),
00102          'declined' => __('submissions.declined'),
00103          'cancelled' => __('common.cancelled'),
00104          'recommendation' => __('reviewer.paper.recommendation'),
00105          'comments' => __('comments.commentsOnPaper')
00106       );
00107       $yesNoArray = array('declined', 'cancelled');
00108 
00109       $fp = fopen('php://output', 'wt');
00110       String::fputcsv($fp, array_values($columns));
00111 
00112       while ($row =& $reviewsIterator->next()) {
00113          foreach ($columns as $index => $junk) {
00114             if (in_array($index, array('declined', 'cancelled'))) {
00115                $yesNoIndex = $row[$index];
00116                if (is_string($yesNoIndex)) {
00117                   // Accomodate Postgres boolean casting
00118                   $yesNoIndex = $yesNoIndex == "f" ? 0 : 1;
00119                }
00120                $columns[$index] = $yesnoMessages[$yesNoIndex];
00121             } elseif ($index == "reviewstage") {
00122                $columns[$index] = $reviewTypes[$row[$index]];
00123             } elseif ($index == "recommendation") {
00124                $columns[$index] = (!isset($row[$index])) ? __('common.none') : __($recommendations[$row[$index]]);
00125             } elseif ($index == "comments") {
00126                if (isset($comments[$row['paperid']][$row['reviewerid']])) {
00127                   $columns[$index] = html_entity_decode(strip_tags($comments[$row['paperid']][$row['reviewerid']]), ENT_QUOTES, 'UTF-8');
00128                } else {
00129                   $columns[$index] = "";
00130                }
00131             } else {
00132                $columns[$index] = $row[$index];
00133             }
00134          }
00135          String::fputcsv($fp, $columns);
00136          unset($row);
00137       }
00138       fclose($fp);
00139    }
00140 }
00141 
00142 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7