Merge branch 'MDL-34467-master' of git://github.com/ankitagarwal/moodle

This commit is contained in:
Dan Poltawski 2012-07-30 15:14:27 +08:00
commit 31e8166797
54 changed files with 104 additions and 104 deletions

View File

@ -18,7 +18,7 @@ $course = $DB->get_record('course', array('id'=> $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/glossary:approve', $context);
if (!$entry->approved and confirm_sesskey()) {

View File

@ -40,7 +40,7 @@ if (! $entry = $DB->get_record("glossary_entries", array("id"=>$entry))) {
}
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$manageentries = has_capability('mod/glossary:manageentries', $context);
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
@ -67,7 +67,7 @@ if ($confirm and confirm_sesskey()) { // the operation was confirmed.
if (!$newcm = get_coursemodule_from_instance('glossary', $entry->sourceglossaryid)) {
print_error('invalidcoursemodule');
}
$newcontext = get_context_instance(CONTEXT_MODULE, $newcm->id);
$newcontext = context_module::instance($newcm->id);
$entry->glossaryid = $entry->sourceglossaryid;
$entry->sourceglossaryid = 0;

View File

@ -17,7 +17,7 @@ if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
if (!$glossary = $DB->get_record('glossary', array('id'=>$cm->instance))) {
print_error('invalidid', 'glossary');

View File

@ -18,7 +18,7 @@ class mod_glossary_entry_form extends moodleform {
$definitionoptions = $this->_customdata['definitionoptions'];
$attachmentoptions = $this->_customdata['attachmentoptions'];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
// Prepare format_string/text options
$fmtoptions = array(
'context' => $context);
@ -96,7 +96,7 @@ class mod_glossary_entry_form extends moodleform {
$glossary = $this->_customdata['glossary'];
$cm = $this->_customdata['cm'];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$id = (int)$data['id'];
$data['concept'] = trim($data['concept']);

View File

@ -63,7 +63,7 @@ if ($hook > 0) {
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/glossary:managecategories', $context);
$strglossaries = get_string("modulenameplural", "glossary");

View File

@ -33,7 +33,7 @@ if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/glossary:export', $context);
$strglossaries = get_string("modulenameplural", "glossary");

View File

@ -42,7 +42,7 @@ if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
}
require_course_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/glossary:export', $context);
$returnurl = "view.php?id=$cm->id&mode=$prevmode&hook=".urlencode($hook);
@ -56,8 +56,8 @@ if (!$maincm = get_coursemodule_from_instance('glossary', $mainglossary->id)) {
print_error('invalidcoursemodule');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$maincontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$context = context_module::instance($cm->id);
$maincontext = context_module::instance($maincm->id);
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
print_error('coursemisconf');

View File

@ -33,7 +33,7 @@ if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/glossary:import', $context);
$strglossaries = get_string("modulenameplural", "glossary");

View File

@ -18,7 +18,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
require_course_login($course);
$PAGE->set_pagelayout('incourse');
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$context = context_course::instance($course->id);
add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", "");

View File

@ -60,7 +60,7 @@ function glossary_add_instance($glossary) {
$glossary->globalglossary = 0;
}
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
if (!has_capability('mod/glossary:manageentries', context_system::instance())) {
$glossary->globalglossary = 0;
}
@ -97,7 +97,7 @@ function glossary_update_instance($glossary) {
$glossary->globalglossary = 0;
}
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
if (!has_capability('mod/glossary:manageentries', context_system::instance())) {
// keep previous
unset($glossary->globalglossary);
}
@ -145,7 +145,7 @@ function glossary_delete_instance($id) {
return false;
}
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
if (!$context = context_module::instance($cm->id, IGNORE_MISSING)) {
return false;
}
@ -163,7 +163,7 @@ function glossary_delete_instance($id) {
foreach ($exported as $entry) {
$entry->glossaryid = $entry->sourceglossaryid;
$entry->sourceglossaryid = 0;
$newcontext = get_context_instance(CONTEXT_MODULE, $entry->sourcecmid);
$newcontext = context_module::instance($entry->sourcecmid);
if ($oldfiles = $fs->get_area_files($context->id, 'mod_glossary', 'attachment', $entry->id)) {
foreach ($oldfiles as $oldfile) {
$file_record = new stdClass();
@ -504,7 +504,7 @@ function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
// generate list of approval capabilities for all glossaries in the course.
$approvals = array();
foreach ($ids as $glinstanceid => $glcmid) {
$context = get_context_instance(CONTEXT_MODULE, $glcmid);
$context = context_module::instance($glcmid);
if (has_capability('mod/glossary:view', $context)) {
// get records glossary entries that are approved if user has no capability to approve entries.
if (has_capability('mod/glossary:approve', $context)) {
@ -730,7 +730,7 @@ function glossary_rating_validate($params) {
}
$cm = get_coursemodule_from_instance('glossary', $info->glossaryid, $info->course, false, MUST_EXIST);
$context = get_context_instance(CONTEXT_MODULE, $cm->id, MUST_EXIST);
$context = context_module::instance($cm->id, MUST_EXIST);
// if the supplied context doesnt match the item's context
if ($context->id != $params['context']->id) {
@ -1001,13 +1001,13 @@ function glossary_get_entries_search($concept, $courseid) {
//Check if the user is an admin
$bypassadmin = 1; //This means NO (by default)
if (has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_SYSTEM))) {
if (has_capability('moodle/course:viewhiddenactivities', context_system::instance())) {
$bypassadmin = 0; //This means YES
}
//Check if the user is a teacher
$bypassteacher = 1; //This means NO (by default)
if (has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $courseid))) {
if (has_capability('mod/glossary:manageentries', context_course::instance($courseid))) {
$bypassteacher = 0; //This means YES
}
@ -1091,7 +1091,7 @@ function glossary_print_entry_default ($entry, $glossary, $cm) {
$definition = '<span class="nolink">' . strip_tags($definition) . '</span>';
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$definition = file_rewrite_pluginfile_urls($definition, 'pluginfile.php', $context->id, 'mod_glossary', 'entry', $entry->id);
$options = new stdClass();
@ -1145,7 +1145,7 @@ function glossary_print_entry_definition($entry, $glossary, $cm) {
}
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$definition = file_rewrite_pluginfile_urls($definition, 'pluginfile.php', $context->id, 'mod_glossary', 'entry', $entry->id);
$options = new stdClass();
@ -1221,7 +1221,7 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
global $USER, $CFG, $DB, $OUTPUT;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$output = false; //To decide if we must really return text in "return". Activate when needed only!
$importedentry = ($entry->sourceglossaryid == $glossary->id);
@ -1278,7 +1278,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
$filecontext = $context;
if ($entry->sourceglossaryid == $cm->instance) {
if ($maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
$filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$filecontext = context_module::instance($maincm->id);
}
}
$fs = get_file_storage();
@ -1426,7 +1426,7 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$glos = $glossary->id;
}
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $glossary->course))) {
if (!has_capability('mod/glossary:manageentries', context_course::instance($glossary->course))) {
$glossarymodule = $DB->get_record("modules", array("name"=>"glossary"));
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
$onlyvisibletable = ", {course_modules} cm";
@ -1530,7 +1530,7 @@ function glossary_search_entries($searchterms, $glossary, $extended) {
function glossary_print_attachments($entry, $cm, $type=NULL, $align="left") {
global $CFG, $DB, $OUTPUT;
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
if (!$context = context_module::instance($cm->id, IGNORE_MISSING)) {
return '';
}
@ -1538,7 +1538,7 @@ function glossary_print_attachments($entry, $cm, $type=NULL, $align="left") {
if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
return '';
}
$filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$filecontext = context_module::instance($maincm->id);
} else {
$filecontext = $context;
@ -1657,7 +1657,7 @@ function glossary_get_file_info($browser, $areas, $course, $cm, $context, $filea
if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
return null;
}
$filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$filecontext = context_module::instance($maincm->id);
} else {
return null;
}
@ -1729,7 +1729,7 @@ function glossary_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
return false;
}
$filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$filecontext = context_module::instance($maincm->id);
} else {
return false;
@ -1865,7 +1865,7 @@ function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '',
function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
global $CFG, $DB, $OUTPUT;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
// Prepare format_string/text options
$fmtoptions = array(
@ -2735,7 +2735,7 @@ function glossary_reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
continue;
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
//delete ratings
@ -2768,7 +2768,7 @@ function glossary_reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
continue;
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
//delete ratings
@ -2798,7 +2798,7 @@ function glossary_reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
continue;
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
//delete ratings
@ -2824,7 +2824,7 @@ function glossary_reset_userdata($data) {
LEFT JOIN {user} u ON e.userid = u.id
WHERE g.course = ? AND e.userid > 0";
$course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
$course_context = context_course::instance($data->courseid);
$notenrolled = array();
$rs = $DB->get_recordset_sql($entriessql, $params);
if ($rs->valid()) {
@ -2835,7 +2835,7 @@ function glossary_reset_userdata($data) {
$DB->delete_records('glossary_entries', array('id'=>$entry->id));
if ($cm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment', $entry->id);
//delete ratings
@ -2857,7 +2857,7 @@ function glossary_reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
continue;
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
//delete ratings
$ratingdeloptions->contextid = $context->id;
@ -3064,7 +3064,7 @@ function glossary_comment_validate($comment_param) {
if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) {
throw new comment_exception('invalidcoursemodule');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
if ($glossary->defaultapproval and !$record->approved and !has_capability('mod/glossary:approve', $context)) {
throw new comment_exception('notapproved', 'glossary');

View File

@ -72,7 +72,7 @@ class glossary_full_portfolio_caller extends portfolio_module_caller_base {
$this->exportdata = array('entries' => $entries, 'aliases' => $aliases, 'categoryentries' => $categoryentries);
$fs = get_file_storage();
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
$context = context_module::instance($this->cm->id);
$this->multifiles = array();
foreach (array_keys($entries) as $entry) {
$this->keyedfiles[$entry] = array_merge(
@ -186,7 +186,7 @@ class glossary_full_portfolio_caller extends portfolio_module_caller_base {
* @return boolean
*/
public function check_permissions() {
return has_capability('mod/glossary:export', get_context_instance(CONTEXT_MODULE, $this->cm->id));
return has_capability('mod/glossary:export', context_module::instance($this->cm->id));
}
/**
@ -254,10 +254,10 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
JOIN {glossary_categories} c
ON c.id = ec.categoryid
WHERE ec.entryid = ?', array($this->entryid));
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
$context = context_module::instance($this->cm->id);
if ($this->entry->sourceglossaryid == $this->cm->instance) {
if ($maincm = get_coursemodule_from_instance('glossary', $this->entry->glossaryid)) {
$context = get_context_instance(CONTEXT_MODULE, $maincm->id);
$context = context_module::instance($maincm->id);
}
}
$this->aliases = $DB->get_record('glossary_alias', array('entryid'=>$this->entryid));
@ -283,7 +283,7 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
* @return boolean
*/
public function check_permissions() {
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
$context = context_module::instance($this->cm->id);
return has_capability('mod/glossary:exportentry', $context)
|| ($this->entry->userid == $this->user->id && has_capability('mod/glossary:exportownentry', $context));
}
@ -389,7 +389,7 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
public static function entry_content($course, $cm, $glossary, $entry, $aliases, $format) {
global $OUTPUT, $DB;
$entry = clone $entry;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$options = portfolio_format_text_options();
$options->trusted = $entry->definitiontrust;
$options->context = $context;
@ -427,7 +427,7 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
return '';
}
$filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
$filecontext = context_module::instance($maincm->id);
} else {
$filecontext = $context;

View File

@ -30,7 +30,7 @@ class mod_glossary_mod_form extends moodleform_mod {
$mform->addRule('entbypage', null, 'required', null, 'client');
$mform->addRule('entbypage', null, 'numeric', null, 'client');
if (has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
if (has_capability('mod/glossary:manageentries', context_system::instance())) {
$mform->addElement('checkbox', 'globalglossary', get_string('isglobal', 'glossary'));
$mform->addHelpButton('globalglossary', 'isglobal', 'glossary');

View File

@ -52,7 +52,7 @@ if ( !$entriesbypage = $glossary->entbypage ) {
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
// Prepare format_string/text options
$fmtoptions = array(

View File

@ -44,7 +44,7 @@
$glossaryid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST);
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$modcontext = context_module::instance($cm->id);
if ($COURSE->id == $cm->course) {
$course = $COURSE;

View File

@ -54,7 +54,7 @@ if ($entries) {
}
// make sure the entry is approved (or approvable by current user)
if (!$entry->approved and ($USER->id != $entry->userid)) {
$context = get_context_instance(CONTEXT_MODULE, $entry->cmid);
$context = context_module::instance($entry->cmid);
if (!has_capability('mod/glossary:approve', $context)) {
unset($entries[$key]);
continue;

View File

@ -54,14 +54,14 @@ if ($entries) {
}
// make sure the entry is approved (or approvable by current user)
if (!$entry->approved and ($USER->id != $entry->userid)) {
$context = get_context_instance(CONTEXT_MODULE, $entry->cmid);
$context = context_module::instance($entry->cmid);
if (!has_capability('mod/glossary:approve', $context)) {
unset($entries[$key]);
continue;
}
}
$context = get_context_instance(CONTEXT_MODULE, $entry->cmid);
$context = context_module::instance($entry->cmid);
$definition = file_rewrite_pluginfile_urls($entry->definition, 'pluginfile.php', $context->id, 'mod_glossary', 'entry', $entry->id);
$options = new stdClass();

View File

@ -251,7 +251,7 @@ $PAGE->set_url($url);
if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds)
&& $glossary->rsstype && $glossary->rssarticles) {
$rsstitle = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))) . ': %fullname%';
$rsstitle = format_string($course->shortname, true, array('context' => context_course::instance($course->id))) . ': %fullname%';
rss_add_http_header($context, 'mod_glossary', $glossary, $rsstitle);
}
@ -448,7 +448,7 @@ if ($allentries) {
$user = $DB->get_record("user", array("id"=>$entry->userid));
echo $OUTPUT->user_picture($user, array('courseid'=>$course->id));
$pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
$pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($course->id)));
} else {
echo '<th >';
}

View File

@ -101,7 +101,7 @@ function imscp_add_instance($data, $mform) {
// we need to use context now, so we need to make sure all needed info is already in db
$DB->set_field('course_modules', 'instance', $data->id, array('id'=>$cmid));
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
$imscp = $DB->get_record('imscp', array('id'=>$data->id), '*', MUST_EXIST);
if ($filename = $mform->get_new_filename('package')) {
@ -136,7 +136,7 @@ function imscp_update_instance($data, $mform) {
$DB->update_record('imscp', $data);
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
$imscp = $DB->get_record('imscp', array('id'=>$data->id), '*', MUST_EXIST);
if ($filename = $mform->get_new_filename('package')) {

View File

@ -35,7 +35,7 @@ function imscp_print_content($imscp, $cm, $course) {
$items = unserialize($imscp->structure);
$first = reset($items);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$urlbase = "$CFG->wwwroot/pluginfile.php";
$path = '/'.$context->id.'/mod_imscp/content/'.$imscp->revision.'/'.$first['href'];
$firsturl = file_encode_url($urlbase, $path, false);
@ -61,7 +61,7 @@ function imscp_print_content($imscp, $cm, $course) {
function imscp_htmllize_item($item, $imscp, $cm) {
global $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$urlbase = "$CFG->wwwroot/pluginfile.php";
$path = '/'.$context->id.'/mod_imscp/content/'.$imscp->revision.'/'.$item['href'];
$url = file_encode_url($urlbase, $path, false);

View File

@ -70,7 +70,7 @@ class mod_imscp_mod_form extends moodleform_mod {
return $errors;
}
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['package'], 'id', false)) {

View File

@ -43,7 +43,7 @@ if ($i) { // Two ways to specify the module
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/imscp:view', $context);
add_to_log($course->id, 'imscp', 'view', 'view.php?id='.$cm->id, $imscp->id, $cm->id);

View File

@ -37,7 +37,7 @@ $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*'
require_login($course, false, $cm);
require_sesskey();
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$canmanage = has_capability('mod/lesson:manage', $context);
$lessonoutput = $PAGE->get_renderer('mod_lesson');

View File

@ -35,7 +35,7 @@ $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*'
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:manage', $context);
$mode = optional_param('mode', get_user_preferences('lesson_view', 'collapsed'), PARAM_ALPHA);

View File

@ -40,7 +40,7 @@ $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*'
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
$PAGE->set_url('/mod/lesson/editpage.php', array('pageid'=>$pageid, 'id'=>$id, 'qtype'=>$qtype));

View File

@ -37,7 +37,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
$url = new moodle_url('/mod/lesson/essay.php', array('id'=>$id));

View File

@ -39,7 +39,7 @@ require_login($course, false, $cm);
$PAGE->set_url('/mod/lesson/grade.php', array('id'=>$cm->id));
if (has_capability('mod/lesson:edit', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (has_capability('mod/lesson:edit', context_module::instance($cm->id))) {
redirect('report.php?id='.$cm->id);
} else {
redirect('view.php?id='.$cm->id);

View File

@ -47,7 +47,7 @@ if ($link !== 0) {
}
$PAGE->set_url($url);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
switch ($mode) {
case 'add':

View File

@ -40,7 +40,7 @@ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST)
$lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
$strimportquestions = get_string("importquestions", "lesson");

View File

@ -53,7 +53,7 @@ $mod = $cm;
require_login($course, false, $cm);
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
$strimportppt = get_string("importppt", "lesson");

View File

@ -93,7 +93,7 @@ foreach ($lessons as $lesson) {
$link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
}
$cm = get_coursemodule_from_instance('lesson', $lesson->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
if ($lesson->deadline == 0) {
$due = $strnodeadline;

View File

@ -45,7 +45,7 @@ require_login($course, false, $cm);
$url = new moodle_url('/mod/lesson/lesson.php', array('id'=>$id,'action'=>$action));
$PAGE->set_url($url);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:edit', $context);
require_sesskey();

View File

@ -50,7 +50,7 @@ function lesson_add_instance($data, $mform) {
$lessonid = $DB->insert_record("lesson", $data);
$data->id = $lessonid;
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
$lesson = $DB->get_record('lesson', array('id'=>$lessonid), '*', MUST_EXIST);
if ($filename = $mform->get_new_filename('mediafilepicker')) {
@ -86,7 +86,7 @@ function lesson_update_instance($data, $mform) {
unset($data->mediafile);
$DB->update_record("lesson", $data);
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
if ($filename = $mform->get_new_filename('mediafilepicker')) {
if ($file = $mform->save_stored_file('mediafilepicker', $context->id, 'mod_lesson', 'mediafile', 0, '/', $filename, true)) {
$DB->set_field('lesson', 'mediafile', '/'.$file->get_filename(), array('id'=>$data->id));
@ -295,7 +295,7 @@ function lesson_print_overview($courses, &$htmlarray) {
$str .= $OUTPUT->box(get_string('lessoncloseson', 'lesson', userdate($lesson->deadline)), 'info');
// Attempt information
if (has_capability('mod/lesson:manage', get_context_instance(CONTEXT_MODULE, $lesson->coursemodule))) {
if (has_capability('mod/lesson:manage', context_module::instance($lesson->coursemodule))) {
// Number of user attempts
$attempts = $DB->count_records('lesson_attempts', array('lessonid'=>$lesson->id));
$str .= $OUTPUT->box(get_string('xattempts', 'lesson', $attempts), 'info');

View File

@ -484,7 +484,7 @@ function lesson_mediafile_block_contents($cmid, $lesson) {
**/
function lesson_clock_block_contents($cmid, $lesson, $timer, $page) {
// Display for timed lessons and for students only
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
if(!$lesson->timed || has_capability('mod/lesson:manage', $context)) {
return null;
}
@ -2373,7 +2373,7 @@ abstract class lesson_page extends lesson_base {
if (!isset($this->properties->contentsformat)) {
$this->properties->contentsformat = FORMAT_HTML;
}
$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
$context = context_module::instance($PAGE->cm->id);
$contents = file_rewrite_pluginfile_urls($this->properties->contents, 'pluginfile.php', $context->id, 'mod_lesson', 'page_contents', $this->properties->id); // must do this BEFORE format_text()!!!!!!
return format_text($contents, $this->properties->contentsformat, array('context'=>$context, 'noclean'=>true)); // page edit is marked with XSS, we want all content here
} else {

View File

@ -39,7 +39,7 @@ $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*'
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$canmanage = has_capability('mod/lesson:manage', $context);
$url = new moodle_url('/mod/lesson/mediafile.php', array('id'=>$id));

View File

@ -176,7 +176,7 @@ class lesson_page_type_branchtable extends lesson_page {
$DB->insert_record("lesson_branch", $branch);
// this is called when jumping to random from a branch table
$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
$context = context_module::instance($PAGE->cm->id);
if($newpageid == LESSON_UNSEENBRANCHPAGE) {
if (has_capability('mod/lesson:manage', $context)) {
$newpageid = LESSON_NEXTPAGE;

View File

@ -107,7 +107,7 @@ class lesson_page_type_endofbranch extends lesson_page {
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), get_context_instance(CONTEXT_MODULE, $PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
$answers = $this->get_answers();

View File

@ -76,7 +76,7 @@ class lesson_page_type_endofcluster extends lesson_page {
if (empty($properties->qoption)) {
$properties->qoption = '0';
}
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), get_context_instance(CONTEXT_MODULE, $PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
$answers = $this->get_answers();

View File

@ -131,7 +131,7 @@ class lesson_page_type_essay extends lesson_page {
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), get_context_instance(CONTEXT_MODULE, $PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
if (!array_key_exists(0, $this->answers)) {

View File

@ -298,7 +298,7 @@ class lesson_page_type_matching extends lesson_page {
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), get_context_instance(CONTEXT_MODULE, $PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
// need to add two to offset correct response and wrong response

View File

@ -158,7 +158,7 @@ class lesson_page_type_truefalse extends lesson_page {
$answers = $this->get_answers();
$properties->id = $this->properties->id;
$properties->lessonid = $this->lesson->id;
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), get_context_instance(CONTEXT_MODULE, $PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$properties = file_postupdate_standard_editor($properties, 'contents', array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$PAGE->course->maxbytes), context_module::instance($PAGE->cm->id), 'mod_lesson', 'page_contents', $properties->id);
$DB->update_record("lesson_pages", $properties);
// need to reset offset for correct and wrong responses

View File

@ -43,7 +43,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
$title = $this->page->course->shortname.": ".$activityname;
// Build the buttons
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
/// Header setup
$this->page->set_title($title);
@ -215,7 +215,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
$table->width = '80%';
$table->data = array();
$canedit = has_capability('mod/lesson:edit', get_context_instance(CONTEXT_MODULE, $this->page->cm->id));
$canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));
while ($pageid != 0) {
$page = $lesson->load_page($pageid);
@ -250,7 +250,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
$manager = lesson_page_type_manager::get($lesson);
$qtypes = $manager->get_page_type_strings();
$npages = count($lesson->load_all_pages());
$canedit = has_capability('mod/lesson:edit', get_context_instance(CONTEXT_MODULE, $this->page->cm->id));
$canedit = has_capability('mod/lesson:edit', context_module::instance($this->page->cm->id));
$content = '';
if ($canedit) {
@ -452,7 +452,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
public function ongoing_score(lesson $lesson) {
global $USER, $DB;
$context = get_context_instance(CONTEXT_MODULE, $this->page->cm->id);
$context = context_module::instance($this->page->cm->id);
if (has_capability('mod/lesson:manage', $context)) {
return $this->output->box(get_string('teacherongoingwarning', 'lesson'), "ongoing center");
} else {
@ -483,7 +483,7 @@ class mod_lesson_renderer extends plugin_renderer_base {
public function progress_bar(lesson $lesson) {
global $CFG, $USER, $DB;
$context = get_context_instance(CONTEXT_MODULE, $this->page->cm->id);
$context = context_module::instance($this->page->cm->id);
// lesson setting to turn progress bar on or off
if (!$lesson->progressbar) {

View File

@ -38,7 +38,7 @@ $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*'
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lesson:manage', $context);
$ufields = user_picture::fields('u'); // These fields are enough
@ -162,7 +162,7 @@ if ($action === 'delete') {
**************************************************************************/
echo $lessonoutput->header($lesson, $cm, $action);
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
$course_context = context_course::instance($course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
$seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
$seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));
@ -377,7 +377,7 @@ if ($action === 'delete') {
**************************************************************************/
echo $lessonoutput->header($lesson, $cm, $action);
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
$course_context = context_course::instance($course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
$seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
$seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));

View File

@ -38,7 +38,7 @@ if (!isset($currenttab)) {
}
if (!isset($cm)) {
$cm = get_coursemodule_from_instance('lesson', $lesson->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
}
if (!isset($course)) {
$course = $DB->get_record('course', array('id' => $lesson->course));

View File

@ -55,7 +55,7 @@ if ($pageid !== null) {
}
$PAGE->set_url($url);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$canmanage = has_capability('mod/lesson:manage', $context);
$lessonoutput = $PAGE->get_renderer('mod_lesson');

View File

@ -68,7 +68,7 @@ if ($l) { // Two ways to specify the module
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/lti:grade', $context);
$url = new moodle_url('/mod/lti/grade.php', array('id' => $cm->id));

View File

@ -37,7 +37,7 @@ $PAGE->set_pagelayout('popup');
$action = optional_param('action', null, PARAM_TEXT);
$typeid = optional_param('typeid', null, PARAM_INT);
require_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
require_capability('mod/lti:addcoursetool', context_course::instance($courseid));
if (!empty($typeid)) {
$type = lti_get_type($typeid);

View File

@ -395,7 +395,7 @@ function lti_grade_item_delete($basiclti) {
function lti_extend_settings_navigation($settings, $parentnode) {
global $PAGE;
if (has_capability('mod/lti:grade', get_context_instance(CONTEXT_MODULE, $PAGE->cm->id))) {
if (has_capability('mod/lti:grade', context_module::instance($PAGE->cm->id))) {
$keys = $parentnode->get_children_key_list();
$node = navigation_node::create('Submissions',

View File

@ -462,7 +462,7 @@ function lti_get_ims_role($user, $cmid, $courseid) {
//If no cmid is passed, check if the user is a teacher in the course
//This allows other modules to programmatically "fake" a launch without
//a real LTI instance
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
$coursecontext = context_course::instance($courseid);
if (has_capability('moodle/course:manageactivities', $coursecontext)) {
array_push($roles, 'Instructor');
@ -470,7 +470,7 @@ function lti_get_ims_role($user, $cmid, $courseid) {
array_push($roles, 'Learner');
}
} else {
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
if (has_capability('mod/lti:manage', $context)) {
array_push($roles, 'Instructor');

View File

@ -35,7 +35,7 @@ $course = $DB->get_record('course', array('id' => $lti->course));
require_login($course);
require_capability('mod/lti:requesttooladd', get_context_instance(CONTEXT_COURSE, $lti->course));
require_capability('mod/lti:requesttooladd', context_course::instance($lti->course));
$baseurl = lti_get_domain_from_url($lti->toolurl);

View File

@ -61,7 +61,7 @@ if (!empty($errormsg)) {
echo htmlspecialchars($errormsg);
$canaddtools = has_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
$canaddtools = has_capability('mod/lti:addcoursetool', context_course::instance($courseid));
if ($unsigned == 1 && $canaddtools) {
echo '<br /><br />';

View File

@ -98,7 +98,7 @@ switch ($messagetype) {
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
//Getting the grade requires the context is set
$context = get_context_instance(CONTEXT_COURSE, $ltiinstance->course);
$context = context_course::instance($ltiinstance->course);
$PAGE->set_context($context);
lti_verify_sourcedid($ltiinstance, $parsed);

View File

@ -73,7 +73,7 @@ if ($tool) {
}
$PAGE->set_cm($cm, $course); // set's up global $COURSE
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
$url = new moodle_url('/mod/lti/view.php', array('id'=>$cm->id));

View File

@ -110,7 +110,7 @@ function page_add_instance($data, $mform = null) {
// we need to use context now, so we need to make sure all needed info is already in db
$DB->set_field('course_modules', 'instance', $data->id, array('id'=>$cmid));
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
if ($mform and !empty($data->page['itemid'])) {
$draftitemid = $data->page['itemid'];
@ -152,7 +152,7 @@ function page_update_instance($data, $mform) {
$DB->update_record('page', $data);
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$context = context_module::instance($cmid);
if ($draftitemid) {
$data->content = file_save_draft_area_files($draftitemid, $context->id, 'mod_page', 'content', 0, page_get_editor_options($context), $data->content);
$DB->update_record('page', $data);
@ -430,7 +430,7 @@ function page_page_type_list($pagetype, $parentcontext, $currentcontext) {
function page_export_contents($cm, $baseurl) {
global $CFG, $DB;
$contents = array();
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
$page = $DB->get_record('page', array('id'=>$cm->instance), '*', MUST_EXIST);

View File

@ -48,7 +48,7 @@ if ($p) {
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$context = context_module::instance($cm->id);
require_capability('mod/page:view', $context);
add_to_log($course->id, 'page', 'view', 'view.php?id='.$cm->id, $page->id, $cm->id);