mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Merge branch 'MDL-34464_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
8dd154905b
@ -74,7 +74,7 @@ if (isguestuser()) {
|
||||
redirect('view.php?d='.$data->id);
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
/// If it's hidden then it doesn't show anything. :)
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
|
||||
@ -122,7 +122,7 @@ if ($cancel) {
|
||||
/// RSS and CSS and JS meta
|
||||
if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) {
|
||||
$rsspath = rss_get_url($context->id, $USER->id, 'mod_data', $data->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
$PAGE->add_alternate_version($courseshortname . ': %fullname%', $rsspath, 'application/rss+xml');
|
||||
}
|
||||
if ($data->csstemplate) {
|
||||
|
@ -49,9 +49,7 @@ $data->course = $cm->course;
|
||||
$data->cmidnumber = $cm->idnumber;
|
||||
$data->instance = $cm->instance;
|
||||
|
||||
if (! $context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('invalidcontext', '');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, false, $cm);
|
||||
require_capability(DATA_CAP_EXPORT, $context);
|
||||
@ -60,7 +58,6 @@ require_capability(DATA_CAP_EXPORT, $context);
|
||||
$fieldrecords = $DB->get_records('data_fields', array('dataid'=>$data->id), 'id');
|
||||
|
||||
if(empty($fieldrecords)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
if (has_capability('mod/data:managetemplates', $context)) {
|
||||
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id);
|
||||
} else {
|
||||
|
@ -88,7 +88,7 @@ if ($id) {
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
require_capability('mod/data:managetemplates', $context);
|
||||
|
||||
/************************************
|
||||
|
@ -43,7 +43,7 @@ class data_field_file extends data_field_base {
|
||||
|
||||
if (!empty($content->content)) {
|
||||
if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false)) {
|
||||
return false;
|
||||
}
|
||||
@ -166,7 +166,7 @@ class data_field_file extends data_field_base {
|
||||
// delete existing files
|
||||
$fs->delete_area_files($this->context->id, 'mod_data', 'content', $content->id);
|
||||
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $value, 'timecreated DESC');
|
||||
|
||||
if (count($files)<2) {
|
||||
|
@ -76,7 +76,7 @@ if ($rid) {
|
||||
require_course_login($course, true, $cm);
|
||||
|
||||
/// If it's hidden then it's don't show anything. :)
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities',get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities',context_module::instance($cm->id))) {
|
||||
$PAGE->set_title($data->name);
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
|
@ -42,7 +42,7 @@ class data_field_picture extends data_field_base {
|
||||
file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id);
|
||||
if (!empty($content->content)) {
|
||||
if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false)) {
|
||||
return false;
|
||||
}
|
||||
@ -214,7 +214,7 @@ class data_field_picture extends data_field_base {
|
||||
case 'file':
|
||||
$fs = get_file_storage();
|
||||
$fs->delete_area_files($this->context->id, 'mod_data', 'content', $content->id);
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $value);
|
||||
if (count($files)<2) {
|
||||
// no file
|
||||
|
@ -62,7 +62,7 @@ if ($id) {
|
||||
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
require_capability('mod/data:manageentries', $context);
|
||||
$form = new mod_data_import_form(new moodle_url('/mod/data/import.php'));
|
||||
|
||||
|
@ -37,7 +37,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, "data", "view all", "index.php?id=$course->id", "");
|
||||
|
||||
|
@ -114,7 +114,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/
|
||||
$this->define_default_field();
|
||||
}
|
||||
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
|
||||
$this->context = context_module::instance($this->cm->id);
|
||||
}
|
||||
|
||||
|
||||
@ -783,7 +783,7 @@ function data_add_record($data, $groupid=0){
|
||||
global $USER, $DB;
|
||||
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$record = new stdClass();
|
||||
$record->userid = $USER->id;
|
||||
@ -898,7 +898,7 @@ function data_delete_instance($id) { // takes the dataid
|
||||
}
|
||||
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
/// Delete all the associated information
|
||||
|
||||
@ -1160,7 +1160,7 @@ function data_grade_item_delete($data) {
|
||||
function data_print_template($template, $records, $data, $search='', $page=0, $return=false) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
static $fields = NULL;
|
||||
static $isteacher;
|
||||
@ -1418,7 +1418,7 @@ function data_rating_validate($params) {
|
||||
|
||||
$course = $DB->get_record('course', array('id'=>$info->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('data', $info->dataid, $course->id, false, MUST_EXIST);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id, MUST_EXIST);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
// if the supplied context doesnt match the item's context
|
||||
if ($context->id != $params['context']->id) {
|
||||
@ -1466,7 +1466,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order='
|
||||
global $CFG, $DB, $PAGE, $OUTPUT;
|
||||
|
||||
$cm = get_coursemodule_from_instance('data', $data->id);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
echo '<br /><div class="datapreferences">';
|
||||
echo '<form id="options" action="view.php" method="get">';
|
||||
echo '<div>';
|
||||
@ -1741,7 +1741,7 @@ function data_convert_to_roles($data, $teacherroles=array(), $studentroles=array
|
||||
$cmid = $cm->id;
|
||||
}
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cmid);
|
||||
$context = context_module::instance($cmid);
|
||||
|
||||
|
||||
// $data->participants:
|
||||
@ -2005,7 +2005,7 @@ function data_user_can_add_entry($data, $currentgroup, $groupmode, $context = nu
|
||||
|
||||
if (empty($context)) {
|
||||
$cm = get_coursemodule_from_instance('data', $data->id, 0, false, MUST_EXIST);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
}
|
||||
|
||||
if (has_capability('mod/data:manageentries', $context)) {
|
||||
@ -2377,7 +2377,7 @@ class data_preset_existing_importer extends data_preset_importer {
|
||||
public function __construct($course, $cm, $module, $fullname) {
|
||||
global $USER;
|
||||
list($userid, $shortname) = explode('/', $fullname, 2);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
if ($userid && ($userid != $USER->id) && !has_capability('mod/data:manageuserpresets', $context) && !has_capability('mod/data:viewalluserpresets', $context)) {
|
||||
throw new coding_exception('Invalid preset provided');
|
||||
}
|
||||
@ -2402,7 +2402,7 @@ class data_preset_existing_importer extends data_preset_importer {
|
||||
function data_preset_path($course, $userid, $shortname) {
|
||||
global $USER, $CFG;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$userid = (int)$userid;
|
||||
|
||||
@ -2512,7 +2512,7 @@ function data_reset_userdata($data) {
|
||||
if (!$cm = get_coursemodule_from_instance('data', $dataid)) {
|
||||
continue;
|
||||
}
|
||||
$datacontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$datacontext = context_module::instance($cm->id);
|
||||
|
||||
$ratingdeloptions->contextid = $datacontext->id;
|
||||
$rm->delete_ratings($ratingdeloptions);
|
||||
@ -2534,7 +2534,7 @@ function data_reset_userdata($data) {
|
||||
LEFT JOIN {user} u ON r.userid = u.id
|
||||
WHERE d.course = ? AND r.userid > 0";
|
||||
|
||||
$course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
|
||||
$course_context = context_course::instance($data->courseid);
|
||||
$notenrolled = array();
|
||||
$fields = array();
|
||||
$rs = $DB->get_recordset_sql($recordssql, array($data->courseid));
|
||||
@ -2545,7 +2545,7 @@ function data_reset_userdata($data) {
|
||||
if (!$cm = get_coursemodule_from_instance('data', $record->dataid)) {
|
||||
continue;
|
||||
}
|
||||
$datacontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$datacontext = context_module::instance($cm->id);
|
||||
$ratingdeloptions->contextid = $datacontext->id;
|
||||
$ratingdeloptions->itemid = $record->id;
|
||||
$rm->delete_ratings($ratingdeloptions);
|
||||
@ -2578,7 +2578,7 @@ function data_reset_userdata($data) {
|
||||
if (!$cm = get_coursemodule_from_instance('data', $dataid)) {
|
||||
continue;
|
||||
}
|
||||
$datacontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$datacontext = context_module::instance($cm->id);
|
||||
|
||||
$ratingdeloptions->contextid = $datacontext->id;
|
||||
$rm->delete_ratings($ratingdeloptions);
|
||||
@ -2998,7 +2998,7 @@ function data_extend_navigation($navigation, $course, $module, $cm) {
|
||||
|
||||
$numentries = data_numentries($data);
|
||||
/// Check the number of entries required against the number of entries already made (doesn't apply to teachers)
|
||||
if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', get_context_instance(CONTEXT_MODULE, $cm->id))) {
|
||||
if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', context_module::instance($cm->id))) {
|
||||
$data->entriesleft = $data->requiredentries - $numentries;
|
||||
$entriesnode = $navigation->add(get_string('entrieslefttoadd', 'data', $data));
|
||||
$entriesnode->add_class('note');
|
||||
@ -3360,7 +3360,7 @@ function data_comment_validate($comment_param) {
|
||||
if (!$data->comments) {
|
||||
throw new comment_exception('commentsoff', 'data');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
//check if approved
|
||||
if ($data->approval and !$record->approved and !data_isowner($record) and !has_capability('mod/data:approve', $context)) {
|
||||
|
@ -101,7 +101,7 @@ class data_portfolio_caller extends portfolio_module_caller_base {
|
||||
$this->records[] = $tmp;
|
||||
} else {
|
||||
$where = array('dataid' => $this->data->id);
|
||||
if (!has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
|
||||
if (!has_capability('mod/data:exportallentries', context_module::instance($this->cm->id))) {
|
||||
$where['userid'] = $USER->id; // get them all in case, we'll unset ones that aren't ours later if necessary
|
||||
}
|
||||
$tmp = $DB->get_records('data_records', $where);
|
||||
@ -241,14 +241,14 @@ class data_portfolio_caller extends portfolio_module_caller_base {
|
||||
public function check_permissions() {
|
||||
if ($this->recordid) {
|
||||
if (data_isowner($this->recordid)) {
|
||||
return has_capability('mod/data:exportownentry', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
return has_capability('mod/data:exportownentry', context_module::instance($this->cm->id));
|
||||
}
|
||||
return has_capability('mod/data:exportentry', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
return has_capability('mod/data:exportentry', context_module::instance($this->cm->id));
|
||||
}
|
||||
if ($this->has_export_config() && !$this->get_export_config('mineonly')) {
|
||||
return has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
return has_capability('mod/data:exportallentries', context_module::instance($this->cm->id));
|
||||
}
|
||||
return has_capability('mod/data:exportownentry', get_context_instance(CONTEXT_MODULE, $this->cm->id));
|
||||
return has_capability('mod/data:exportownentry', context_module::instance($this->cm->id));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,7 +284,6 @@ class data_portfolio_caller extends portfolio_module_caller_base {
|
||||
// Replacing tags
|
||||
$patterns = array();
|
||||
$replacement = array();
|
||||
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
|
||||
|
||||
$files = array();
|
||||
// Then we generate strings to replace for normal tags
|
||||
@ -385,7 +384,7 @@ class data_portfolio_caller extends portfolio_module_caller_base {
|
||||
return (empty($this->recordid) // multi-entry export
|
||||
&& $this->minecount > 0 // some of them are mine
|
||||
&& $this->minecount != count($this->records) // not all of them are mine
|
||||
&& has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->cm->id))); // they actually have a choice in the matter
|
||||
&& has_capability('mod/data:exportallentries', context_module::instance($this->cm->id))); // they actually have a choice in the matter
|
||||
}
|
||||
|
||||
public function export_config_form(&$mform, $instance) {
|
||||
|
@ -44,7 +44,7 @@
|
||||
$dataid = clean_param($args[3], PARAM_INT);
|
||||
$cm = get_coursemodule_from_instance('data', $dataid, 0, false, MUST_EXIST);
|
||||
if ($cm) {
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
|
||||
//context id from db should match the submitted one
|
||||
if ($context->id != $modcontext->id || !has_capability('mod/data:viewentry', $modcontext)) {
|
||||
@ -107,7 +107,7 @@
|
||||
array_push($items, $item);
|
||||
}
|
||||
$course = $DB->get_record('course', array('id'=>$data->course));
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
|
||||
// First all rss feeds common headers.
|
||||
|
@ -30,7 +30,7 @@
|
||||
print_error('cannotcallscript');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$inactive = NULL;
|
||||
$activetwo = NULL;
|
||||
|
@ -66,7 +66,7 @@ if ($id) {
|
||||
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
require_capability('mod/data:managetemplates', $context);
|
||||
|
||||
if (!$DB->count_records('data_fields', array('dataid'=>$data->id))) { // Brand new database!
|
||||
|
@ -84,7 +84,7 @@
|
||||
require_once($CFG->dirroot . '/comment/lib.php');
|
||||
comment::init();
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
require_capability('mod/data:viewentry', $context);
|
||||
|
||||
/// If we have an empty Database then redirect because this page is useless without data
|
||||
@ -275,7 +275,7 @@
|
||||
$USER->editing = $edit;
|
||||
}
|
||||
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
|
||||
|
||||
/// RSS and CSS and JS meta
|
||||
$meta = '';
|
||||
|
@ -48,9 +48,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
if ($course->id == SITEID) {
|
||||
require_login($course, true);
|
||||
|
@ -68,9 +68,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
@ -149,7 +147,7 @@ if ($courseitemfilter > 0) {
|
||||
$sep_thous = get_string('separator_thousand', 'feedback');
|
||||
|
||||
foreach ($courses as $c) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $c->course_id);
|
||||
$coursecontext = context_course::instance($c->course_id);
|
||||
$shortname = format_string($c->shortname, true, array('context' => $coursecontext));
|
||||
|
||||
echo '<tr>';
|
||||
|
@ -51,9 +51,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
@ -306,7 +304,7 @@ function feedback_excelprint_detailed_items(&$worksheet, $xls_formats,
|
||||
$worksheet->write_number($row_offset, $col_offset, $courseid, $xls_formats->default);
|
||||
$col_offset++;
|
||||
if (isset($courseid) AND $course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
$shortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$worksheet->write_string($row_offset, $col_offset, $shortname, $xls_formats->default);
|
||||
}
|
||||
|
@ -87,9 +87,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
|
@ -108,9 +108,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
|
@ -50,9 +50,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -43,9 +43,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -67,9 +67,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -57,9 +57,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -67,9 +67,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -47,9 +47,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -52,9 +52,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -35,9 +35,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_login($course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
@ -216,7 +216,7 @@ class feedback_item_info extends feedback_item_base {
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
@ -225,7 +225,7 @@ class feedback_item_info extends feedback_item_base {
|
||||
break;
|
||||
case 3:
|
||||
if ($coursecategory) {
|
||||
$category_context = get_context_instance(CONTEXT_COURSECAT, $coursecategory->id);
|
||||
$category_context = context_coursecat::instance($coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
@ -293,7 +293,7 @@ class feedback_item_info extends feedback_item_base {
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
@ -302,7 +302,7 @@ class feedback_item_info extends feedback_item_base {
|
||||
break;
|
||||
case 3:
|
||||
if ($coursecategory) {
|
||||
$category_context = get_context_instance(CONTEXT_COURSECAT, $coursecategory->id);
|
||||
$category_context = context_coursecat::instance($coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
|
@ -29,8 +29,6 @@ class feedback_label_form extends feedback_item_form {
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $common['cmid']);
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('hidden', 'required', 0);
|
||||
|
@ -59,7 +59,7 @@ class feedback_item_label extends feedback_item_base {
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$this->context = context_module::instance($cm->id);
|
||||
|
||||
//preparing the editor for new file-api
|
||||
$item->presentationformat = FORMAT_HTML;
|
||||
@ -148,12 +148,12 @@ class feedback_item_label extends feedback_item_base {
|
||||
if ($template->ispublic) {
|
||||
$context = get_system_context();
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $template->course);
|
||||
$context = context_course::instance($template->course);
|
||||
}
|
||||
$filearea = 'template';
|
||||
} else {
|
||||
$cm = get_coursemodule_from_instance('feedback', $item->feedback);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$filearea = 'item';
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ class feedback_item_label extends feedback_item_base {
|
||||
public function postupdate($item) {
|
||||
global $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $item->cmid);
|
||||
$context = context_module::instance($item->cmid);
|
||||
$item = file_postupdate_standard_editor($item,
|
||||
'presentation',
|
||||
$this->presentationoptions,
|
||||
|
@ -102,7 +102,7 @@ function feedback_add_instance($feedback) {
|
||||
$cm = get_coursemodule_from_id('feedback', $feedback->id);
|
||||
$feedback->coursemodule = $cm->id;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $feedback->coursemodule);
|
||||
$context = context_module::instance($feedback->coursemodule);
|
||||
|
||||
$editoroptions = feedback_get_editor_options();
|
||||
|
||||
@ -150,7 +150,7 @@ function feedback_update_instance($feedback) {
|
||||
//create or update the new events
|
||||
feedback_set_events($feedback);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $feedback->coursemodule);
|
||||
$context = context_module::instance($feedback->coursemodule);
|
||||
|
||||
$editoroptions = feedback_get_editor_options();
|
||||
|
||||
@ -416,7 +416,7 @@ function feedback_get_recent_mod_activity(&$activities, &$index,
|
||||
return;
|
||||
}
|
||||
|
||||
$cm_context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$cm_context = context_module::instance($cm->id);
|
||||
$accessallgroups = has_capability('moodle/site:accessallgroups', $cm_context);
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $cm_context);
|
||||
$groupmode = groups_get_activity_groupmode($cm, $course);
|
||||
@ -826,9 +826,7 @@ function feedback_get_context($cmid) {
|
||||
return $context;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cmid);
|
||||
return $context;
|
||||
}
|
||||
|
||||
@ -869,7 +867,7 @@ function feedback_get_incomplete_users($cm,
|
||||
|
||||
global $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
//first get all user who can complete this feedback
|
||||
$cap = 'mod/feedback:complete';
|
||||
@ -975,9 +973,7 @@ function feedback_get_complete_users($cm,
|
||||
|
||||
global $DB;
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$params = (array)$params;
|
||||
|
||||
@ -1023,9 +1019,7 @@ function feedback_get_complete_users($cm,
|
||||
*/
|
||||
function feedback_get_viewreports_users($cmid, $groups = false) {
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cmid);
|
||||
|
||||
//description of the call below:
|
||||
//get_users_by_capability($context, $capability, $fields='', $sort='', $limitfrom='',
|
||||
@ -1051,9 +1045,7 @@ function feedback_get_viewreports_users($cmid, $groups = false) {
|
||||
*/
|
||||
function feedback_get_receivemail_users($cmid, $groups = false) {
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cmid);
|
||||
|
||||
//description of the call below:
|
||||
//get_users_by_capability($context, $capability, $fields='', $sort='', $limitfrom='',
|
||||
@ -1126,10 +1118,10 @@ function feedback_save_as_template($feedback, $name, $ispublic = 0) {
|
||||
if ($ispublic) {
|
||||
$s_context = get_system_context();
|
||||
} else {
|
||||
$s_context = get_context_instance(CONTEXT_COURSE, $newtempl->course);
|
||||
$s_context = context_course::instance($newtempl->course);
|
||||
}
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$f_context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$f_context = context_module::instance($cm->id);
|
||||
|
||||
//create items of this new template
|
||||
//depend items we are storing temporary in an mapping list array(new id => dependitem)
|
||||
@ -1231,11 +1223,11 @@ function feedback_items_from_template($feedback, $templateid, $deleteold = false
|
||||
if ($template->ispublic) {
|
||||
$s_context = get_system_context();
|
||||
} else {
|
||||
$s_context = get_context_instance(CONTEXT_COURSE, $feedback->course);
|
||||
$s_context = context_course::instance($feedback->course);
|
||||
}
|
||||
$course = $DB->get_record('course', array('id'=>$feedback->course));
|
||||
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
|
||||
$f_context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$f_context = context_module::instance($cm->id);
|
||||
|
||||
//if deleteold then delete all old items before
|
||||
//get all items
|
||||
@ -1534,7 +1526,7 @@ function feedback_delete_item($itemid, $renumber = true, $template = false) {
|
||||
if ($template->ispublic) {
|
||||
$context = get_system_context();
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $template->course);
|
||||
$context = context_course::instance($template->course);
|
||||
}
|
||||
$templatefiles = $fs->get_area_files($context->id,
|
||||
'mod_feedback',
|
||||
@ -1550,7 +1542,7 @@ function feedback_delete_item($itemid, $renumber = true, $template = false) {
|
||||
if (!$cm = get_coursemodule_from_instance('feedback', $item->feedback)) {
|
||||
return false;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$itemfiles = $fs->get_area_files($context->id,
|
||||
'mod_feedback',
|
||||
@ -2985,7 +2977,7 @@ function feedback_send_email_anonym($cm, $feedback, $course) {
|
||||
* @return string the text you want to post
|
||||
*/
|
||||
function feedback_send_email_text($info, $course) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$posttext = $courseshortname.' -> '.get_string('modulenameplural', 'feedback').' -> '.
|
||||
$info->feedback."\n";
|
||||
@ -3006,7 +2998,7 @@ function feedback_send_email_text($info, $course) {
|
||||
*/
|
||||
function feedback_send_email_html($info, $course, $cm) {
|
||||
global $CFG;
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$course_url = $CFG->wwwroot.'/course/view.php?id='.$course->id;
|
||||
$feedback_all_url = $CFG->wwwroot.'/mod/feedback/index.php?id='.$course->id;
|
||||
@ -3046,7 +3038,7 @@ function feedback_extend_settings_navigation(settings_navigation $settings,
|
||||
|
||||
global $PAGE, $DB;
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id)) {
|
||||
if (!$context = context_module::instance($PAGE->cm->id, IGNORE_MISSING)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
|
@ -61,9 +61,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
@ -132,9 +130,9 @@ if ($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
|
||||
|
||||
$unmapurl = new moodle_url('/mod/feedback/unmapcourse.php');
|
||||
foreach ($coursemap as $cmap) {
|
||||
$cmapcontext = get_context_instance(CONTEXT_COURSE, $cmap->id);
|
||||
$cmapcontext = context_course::instance($cmap->id);
|
||||
$cmapshortname = format_string($cmap->shortname, true, array('context' => $cmapcontext));
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $cmap->courseid);
|
||||
$coursecontext = context_course::instance($cmap->courseid);
|
||||
$cmapfullname = format_string($cmap->fullname, true, array('context' => $coursecontext));
|
||||
$unmapurl->params(array('id'=>$id, 'cmapid'=>$cmap->id));
|
||||
$anker = '<a href="'.$unmapurl->out().'">';
|
||||
|
@ -41,9 +41,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -61,9 +61,7 @@ $url = new moodle_url('/mod/feedback/show_entries.php', array('id'=>$cm->id, 'do
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -52,9 +52,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id, IGNORE_MISSING);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -65,14 +65,10 @@ $url = new moodle_url('/mod/feedback/show_nonrespondents.php', array('id'=>$cm->
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
//we need the coursecontext to allow sending of mass mails
|
||||
if (!$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
@ -85,7 +81,7 @@ require_capability('mod/feedback:viewreports', $context);
|
||||
if ($action == 'sendmessage' AND has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$shortname = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
array('context' => $coursecontext));
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
|
||||
$htmlmessage = "<body id=\"email\">";
|
||||
|
@ -35,10 +35,7 @@ if (isset($cmid) AND intval($cmid) AND $cmid > 0) {
|
||||
$usedid = $id;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $usedid)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
$context = context_module::instance($usedid);
|
||||
|
||||
$courseid = optional_param('courseid', false, PARAM_INT);
|
||||
// $current_tab = $SESSION->feedback->current_tab;
|
||||
|
@ -46,9 +46,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_capability('mod/feedback:mapcourse', $context);
|
||||
|
||||
|
@ -52,9 +52,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
|
@ -41,9 +41,7 @@ if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user