Exemplo n.º 1
0
            error('Invalid page ID');
        }
    }
    // Ensure this page is with this course
    if ($page->courseid != $course->id) {
        error(get_string('invalidpageid', 'format_page', $pageid));
    }
} else {
    // We don't have a page ID to work with
    if (has_capability('format/page:editpages', $context)) {
        $action = 'editpage';
        $page = new stdClass();
        $page->id = 0;
    } else {
        // Nothing this person can do about it, error out
        error(get_string('nopageswithcontent', 'format_page'));
    }
}
/// There are a couple processes that need some help via the session... take care of those.
$action = page_handle_session_hacks($course->id, $action);
/// Check if page wants to redirect
if (!empty($page->redirect) && empty($action)) {
    redirect($page->redirect, '', 0);
}
/// Override PAGE_COURSE_VIEW class mapping
page_import_types('course/format/page');
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
$PAGE->set_formatpage($page);
/// Handle format actions
page_format_execute_url_action($action);
Exemplo n.º 2
0
    } else {
        // Nothing this person can do about it, error out
        error(get_string('nopageswithcontent', 'format_page'));
    }
}
// TODO: put in equivalent of 'session hacks' used in page/format.php
// Override PAGE_COURSE_VIEW class mapping
//     we need to reset various things that have been previously set by moodle core
page_import_types('course/format/learning');
// note hat this includes /course/format/page/pagelib.php
$PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
$PAGE->set_formatpage($page);
$editing = $PAGE->user_is_editing();
$pageblocks = page_blocks_setup();
/// Handle format actions
page_format_execute_url_action($action, $course);
// ** Only get to his part if page_format_execute_url_action returns ** //
/// Make sure the individual page is 'published'
if (!($page->display & DISP_PUBLISH) and !(has_capability('format/page:editpages', $context) and $editing)) {
    error(get_string('thispageisnotpublished', 'format_page'));
}
/// Finally, we can print the page
if ($editing) {
    $PAGE->print_tabs('layout');
    page_print_jump_menu();
    if (has_capability('format/learning:manageactivities', $context)) {
        page_print_add_mods_form($page, $course);
    }
    $class = 'format-page editing';
} else {
    $class = 'format-page';