// The tutor might not have access to the view any more; send
        // them back to the group page.
        redirect(get_config('wwwroot') . 'group/view.php?id=' . $groupid);
    }
    redirect(get_config('wwwroot') . 'view/view.php?id=' . $view->get('id'));
}
// If the view has comments turned off, tutors can still leave
// comments if the view is submitted to their group.
if (!empty($releaseform) || ($commenttype = $view->user_comments_allowed($USER))) {
    $defaultprivate = !empty($releaseform);
    $moderate = isset($commenttype) && $commenttype === 'private';
    $addfeedbackform = pieform(ArtefactTypeComment::add_comment_form($defaultprivate, $moderate));
}
if ($USER->is_logged_in()) {
    $objectionform = pieform(objection_form());
    if ($notrudeform = $view->notrude_form()) {
        $notrudeform = pieform($notrudeform);
    }
}
$viewbeingwatched = (int) record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid);
$feedback = ArtefactTypeComment::get_comments($limit, $offset, $showcomment, $view);
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
    $THEME = new Theme($viewtheme);
}
$stylesheets = array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">');
$can_edit = $USER->can_edit_view($view) && !$submittedgroup && !$view->is_submitted();
$smarty = smarty(array('paginator', 'viewmenu', 'artefact/resume/resumeshowhide.js'), $stylesheets, array(), array('stylesheets' => array('style/views.css'), 'sidebars' => false));
$javascript = <<<EOF
var viewid = {$viewid};