Skip to content

Commit

Permalink
Merge branch 'wip-MDL-40850-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
Damyon Wiese committed Nov 26, 2013
2 parents f9cb086 + 1f897a7 commit 18962ad
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/editor/tinymce/plugins/managefiles/manage.php
Expand Up @@ -26,11 +26,6 @@
require_once('manage_form.php');
require_once($CFG->libdir.'/filestorage/file_storage.php');

require_login();
if (isguestuser()) {
print_error('noguest');
}

$itemid = required_param('itemid', PARAM_INT);
$maxbytes = optional_param('maxbytes', 0, PARAM_INT);
$subdirs = optional_param('subdirs', 0, PARAM_INT);
Expand All @@ -39,10 +34,28 @@
$areamaxbytes = optional_param('areamaxbytes', FILE_AREA_MAX_BYTES_UNLIMITED, PARAM_INT);
$contextid = optional_param('context', SYSCONTEXTID, PARAM_INT);

$context = context::instance_by_id($contextid);
if ($context->contextlevel == CONTEXT_MODULE) {
// Module context.
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
require_login($cm->course, true, $cm);
} else if (($coursecontext = $context->get_course_context(false)) && $coursecontext->id != SITEID) {
// Course context or block inside the course.
require_login($coursecontext->instanceid);
$PAGE->set_context($context);
} else {
// Block that is not inside the course, user or system context.
require_login();
$PAGE->set_context($context);
}
if (isguestuser()) {
// Guests can never manage files.
print_error('noguest');
}

$title = get_string('manageareafiles', 'tinymce_managefiles');

$PAGE->set_url('/lib/editor/tinymce/plugins/managefiles/manage.php');
$PAGE->set_context(context::instance_by_id($contextid));
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->set_pagelayout('popup');
Expand All @@ -58,7 +71,7 @@
'accepted_types' => $accepted_types,
'areamaxbytes' => $areamaxbytes,
'return_types' => $return_types,
'context' => context::instance_by_id($contextid)
'context' => $context
);

$usercontext = context_user::instance($USER->id);
Expand Down

0 comments on commit 18962ad

Please sign in to comment.