Exemplo n.º 1
0
$item = false;
if ($i) {
    $item = new \mod_mediagallery\item($i);
    $g = $item->galleryid;
    if (!$item->user_can_edit()) {
        print_error('nopermissions', 'error', null, 'edit item');
    }
}
$gallery = new \mod_mediagallery\gallery($g);
$mediagallery = $gallery->get_collection();
$course = $DB->get_record('course', array('id' => $mediagallery->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('mediagallery', $mediagallery->id, $course->id, false, MUST_EXIST);
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
$pageurl = new moodle_url('/mod/mediagallery/item.php', array('g' => $gallery->id));
if (!$gallery->user_can_contribute()) {
    print_error('nopermissions', 'error', $pageurl, 'edit gallery');
}
$PAGE->set_url($pageurl);
$PAGE->set_title(format_string($mediagallery->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
$PAGE->add_body_class('mediagallery-mode-' . $gallery->mode);
if ($gallery) {
    $pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $g));
    $navnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
    if (empty($navnode)) {
        $navnode = $PAGE->navbar;
    }
    $node = $navnode->add(format_string($gallery->name), $pageurl);
    $node->make_active();
Exemplo n.º 2
0
// Request update from theBox (does nothing if synced within the past hour).
if (!$gallery) {
    $mediagallery->sync($forcesync);
}
if ($mediagallery->was_deleted()) {
    $coursecontext = $context->get_course_context();
    $pageurl = new moodle_url('/mod/mediagallery/view.php');
    $PAGE->set_context($coursecontext);
    $PAGE->set_pagelayout('incourse');
    $PAGE->set_url($pageurl);
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('collectionwasdeleted', 'mediagallery'));
    echo $OUTPUT->footer();
    exit;
}
$canedit = $gallery && $gallery->user_can_contribute();
if ($mediagallery->is_read_only() || !$canedit) {
    $options['editing'] = false;
}
require_login($course, true, $cm);
if ($gallery) {
    $pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $g, 'page' => $page));
    $navnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
    if (empty($navnode)) {
        $navnode = $PAGE->navbar;
    }
    $navurl = clone $pageurl;
    $node = $navnode->add(format_string($gallery->name), $navurl);
    $node->make_active();
    if ($options['editing']) {
        $pageurl->param('editing', true);