' . oc_('Discussions are closed') . '
';
}
// Get assigned papers & display legend if not chair
$reviewPaperAR = array();
$completedPaperAR = array();
$advocatePaperAR = array();
$conflictAR = array();
if ($access != 1) {
// Check that discussions are open
if (!$OC_statusAR['OC_DISCUSSION_open']) {
warn(oc_('Discussions are closed'));
exit;
}
// Check if reviewer, that's ok
if (($_SESSION[OCC_SESSION_VAR_NAME]['acpc'] != 'T') && !$OC_configAR['OC_DISCUSSION_reviewerAccess']) {
warn(oc_('You do not have permission to access the discussion'));
exit;
}
// Get review papers
$q = "SELECT `paperid`, `completed` FROM `" . OCC_TABLE_PAPERREVIEWER . "` WHERE `reviewerid`='" . safeSQLstr($uid) . "'";
$r = ocsql_query($q) or err('Unable to retrieve review submissions');
while ($l = ocsql_fetch_assoc($r)) {
$reviewPaperAR[] = $l['paperid'];
if ($l['completed'] == 'T') {
$completedPaperAR[] = $l['paperid'];
}
}
// Get advocate papers
if ($OC_configAR['OC_paperAdvocates']) {
$q = "SELECT `paperid` FROM `" . OCC_TABLE_PAPERADVOCATE . "` WHERE `advocateid`='" . safeSQLstr($uid) . "'";
$r = ocsql_query($q) or err('Unable to retrieve advocate submissions');
while ($l = ocsql_fetch_assoc($r)) {
$advocatePaperAR[] = $l['paperid'];
}
}
// Get conflicts
$conflictAR = getConflicts($uid);
// Get notification status if ! chair
$notification = oc_('On');
if ($uid != 0) {
$q = "SELECT `notification` FROM `" . OCC_TABLE_MODULE_OC_DISCUSSION_NOTIFICATION . "` WHERE `accountid`='" . safeSQLstr($uid) . "'";
$r = ocsql_query($q) or err('Unable to retrieve notification status');
if (ocsql_num_rows($r) == 1) {
$l = ocsql_fetch_assoc($r);
if ($l['notification'] == 0) {
$notification = oc_('Off');
}
}
}
// Display legend & Notification
print '' . oc_('Legend:') . ' ';
if ($OC_configAR['OC_paperAdvocates'] && ($_SESSION[OCC_SESSION_VAR_NAME]['acpc'] == 'T')) {
print ' ' . oc_('Advocate') . ' ';
}
print ' ' . oc_('Reviewer');
if ($uid != 0) {
print ' ' . oc_('Notification:') . ' ' . $notification . '';
}
print '
';
}
// Sort order
$order = '';
if (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc','desc'))) {
$order = $_REQUEST['order'];
if ($order == 'asc') {
$rsort = 'desc';
} else {
$rsort = 'asc';
}
}
// Sort by
$sort = '';
if (isset($_REQUEST['sort'])) {
switch ($_REQUEST['sort']) {
case 'paperid':
if (empty($order)) {
$order = 'asc';
$rsort = 'desc';
}
$sort = "`paperid` " . oc_strtoupper($order);
$stitle = '' . oc_('Score') . '';
$ptitle = '' . oc_('Submission') . '
';
$lptitle = '' . oc_('Last Post') . '';
break;
case 'score':
if ($OC_configAR['OC_DISCUSSION_includeStatus'] && $OC_configAR['OC_DISCUSSION_showScore']) {
if (empty($order)) {
$order = 'desc';
$rsort = 'asc';
}
$sort = "`recavg` " . oc_strtoupper($order);
$stitle = '' . oc_('Score') . '
';
$ptitle = '' . oc_('Submission') . '';
$lptitle = '' . oc_('Last Post') . '';
}
break;
}
}
if (empty($sort)) {
if (empty($order)) {
$order = 'desc';
$rsort = 'asc';
}
$sort = "`lastpost` " . oc_strtoupper($order) . ", `paperid` ASC";
$stitle = '' . oc_('Score') . '';
$ptitle = '' . oc_('Submission') . '';
$lptitle = '' . oc_('Last Post') . '
';
}
// Get posts per paper
$q = "SELECT `paperid`, COUNT(`paperid`) AS `count` FROM `" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "` GROUP BY `paperid`";
$r = ocsql_query($q) or err('Unable to retrieve post counts');
$postCountAR = array();
while ($l = ocsql_fetch_assoc($r)) {
$postCountAR[$l['paperid']] = $l['count'];
}
// Get first new post
$q = "SELECT `" . OCC_TABLE_MODULE_OC_DISCUSSION_READ . "`.`paperid`, MIN(`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`postid`) AS `firstnew` FROM `" . OCC_TABLE_MODULE_OC_DISCUSSION_READ . "` LEFT JOIN (`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`) ON (`" . OCC_TABLE_MODULE_OC_DISCUSSION_READ . "`.`paperid`=`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`paperid` AND `" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`postid`>`" . OCC_TABLE_MODULE_OC_DISCUSSION_READ . "`.`lastread`) WHERE `" . OCC_TABLE_MODULE_OC_DISCUSSION_READ . "`.`accountid`='" . $uid . "' GROUP BY `paperid`";
$r = ocsql_query($q) or err('Unable to retrieve new post info');
$newPostAR = array();
while ($l = ocsql_fetch_assoc($r)) {
$newPostAR[$l['paperid']] = $l['firstnew'];
}
// Get papers
$q = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `" . OCC_TABLE_PAPER . "`.`title`, `" . OCC_TABLE_PAPER . "`.`accepted`, MAX(`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`time`) AS `lastpost`, MAX(`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`postid`) AS `lastpostid`, FORMAT(AVG(`score`),2) AS `recavg` FROM `" . OCC_TABLE_PAPER . "` LEFT JOIN (`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`) ON (`" . OCC_TABLE_MODULE_OC_DISCUSSION_POST . "`.`paperid`=`" . OCC_TABLE_PAPER . "`.`paperid`) LEFT JOIN (`" . OCC_TABLE_PAPERREVIEWER . "`) ON (`" . OCC_TABLE_PAPERREVIEWER . "`.`paperid`=`" . OCC_TABLE_PAPER . "`.`paperid`) GROUP BY `" . OCC_TABLE_PAPER . "`.`paperid` ORDER BY $sort";
$r = ocsql_query($q) or err('Unable to retrieve submissions');
if (ocsql_num_rows($r) == 0) {
warn(oc_('No submissions are available'));
}
// Display papers
print '
';
$row = 1;
while ($l = ocsql_fetch_assoc($r)) {
$class = '';
$incompleteReview = false;
// if not chair, check whether to skip & set row color
if ($access != 1) {
// set row color
if (in_array($l['paperid'], $advocatePaperAR)) {
$class = 'oc_discussion_advocate';
} elseif (in_array($l['paperid'], $reviewPaperAR)) {
$class = 'oc_discussion_review';
}
// skip if not allowed access
if ((!$OC_configAR['OC_DISCUSSION_accessAllPapers'] && empty($class)) // Not Assigned
||
(!$OC_configAR['OC_DISCUSSION_overrideConflict'] && in_array($l['paperid'] . '-' . $uid, $conflictAR)) // In conflict
) {
continue;
}
// incomplete review?
if (in_array($l['paperid'], $reviewPaperAR) && !$OC_configAR['OC_DISCUSSION_incompleteReviewAccess'] && !in_array($l['paperid'], $completedPaperAR)) {
$incompleteReview = true;
}
} else {
// set row color to use
if ($row == 1) {
$class = 'row2';
$row = 2;
} else {
$class = 'row1';
$row = 1;
}
}
// Display first new icon?
if (!empty($l['lastpost']) && !$incompleteReview && (!array_key_exists($l['paperid'],$newPostAR) || !empty($newPostAR[$l['paperid']]))) {
$firstnewLink = '
';
} else {
$firstnewLink = '';
}
// Link in last post
if ($incompleteReview) {
$lastpost = 'incomplete review';
} elseif (!empty($l['lastpost'])) {
$lastpost = '' . oc_strftime('%c', $l['lastpost']) . '';
} else {
$lastpost = ' ';
}
print '';
if ($OC_configAR['OC_DISCUSSION_includeStatus']) {
$status = $l['accepted'];
$statusStyle = 'color: #555; background-color: #' . (isset($OC_acceptanceColorAR[$l['accepted']]) ? $OC_acceptanceColorAR[$l['accepted']] : 'ddd');
print '' . safeHTMLstr($l['accepted']) . ' | ';
if ($OC_configAR['OC_DISCUSSION_showScore']) {
print '' . (empty($l['recavg']) ? ' ' : $l['recavg']) . ' | ';
}
}
print '' . $firstnewLink;
if ($incompleteReview) {
print '' . $l['paperid'] . '. ' . safeHTMLstr($l['title']) . '';
} else {
print '' . $l['paperid'] . '. ' . safeHTMLstr($l['title']) . '';
}
print ' | ' . safeHTMLstr($lastpost) . ' | ' . (isset($postCountAR[$l['paperid']]) ? $postCountAR[$l['paperid']] : ' ') . ' |
';
}
//T: %1$s = UTC offset (e.g., -0400); %2$s = time
print '
' . sprintf(oc_('All times are UTC %1$s. The time now is %2$s'), date('O'), oc_strftime('%X')) . '
';
printFooter();