if ($new && isset($_POST['cancel'])) {
    if ($view->get('type') == 'profile' || $view->get('type') == 'dashboard') {
        throw new AccessDeniedException(get_string('cantdeleteview', 'view'));
    }
    form_validate(param_variable('sesskey', null));
    $view->delete();
    $view->post_edit_redirect();
}
// If a block was configured & submitted, build the form now so it can
// be processed without having to render the other blocks.
if ($blockid = param_integer('blockconfig', 0)) {
    // However, if removing a newly placed block, let it fall through to process_changes
    if (!isset($_POST['cancel_action_configureblockinstance_id_' . $blockid]) || !param_integer('removeoncancel', 0) || param_integer('pieform_jssubmission', 0)) {
        require_once get_config('docroot') . 'blocktype/lib.php';
        $bi = new BlockInstance($blockid);
        $bi->build_configure_form();
    }
}
View::set_nav($group, $institution, $view->get('type') == 'profile');
if ($view->get('type') == 'profile') {
    $profile = true;
    $displaylink = get_config('wwwroot') . 'user/view.php';
    $title = get_string('usersprofile', 'mahara', display_name($view->get('owner'), null, true));
    define('TITLE', $title . ': ' . get_string('editcontentandlayout', 'view'));
} else {
    if ($view->get('type') == 'dashboard') {
        $dashboard = true;
        $displaylink = get_config('wwwroot');
        $title = get_string('usersdashboard', 'mahara', display_name($view->get('owner'), null, true));
        define('TITLE', $title . ': ' . get_string('editcontentandlayout', 'view'));
    } else {