Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
ab7632b7
Commit
ab7632b7
authored
Jun 18, 2013
by
sam marshall
Browse files
MDL-39876 Change get_record('course') calls to get_course
parent
838d78a9
Changes
189
Hide whitespace changes
Inline
Side-by-side
admin/roles/assign.php
View file @
ab7632b7
...
...
@@ -39,7 +39,7 @@ if ($course) {
}
else
{
$isfrontpage
=
false
;
if
(
$context
->
contextlevel
==
CONTEXT_USER
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
))
,
'*'
,
MUST_EXIST
)
;
$course
=
get_course
(
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
));
$user
=
$DB
->
get_record
(
'user'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$url
->
param
(
'courseid'
,
$course
->
id
);
$url
->
param
(
'userid'
,
$user
->
id
);
...
...
admin/roles/check.php
View file @
ab7632b7
...
...
@@ -35,7 +35,7 @@ if ($course) {
}
else
{
$isfrontpage
=
false
;
if
(
$context
->
contextlevel
==
CONTEXT_USER
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
))
,
'*'
,
MUST_EXIST
)
;
$course
=
get_course
(
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
));
$user
=
$DB
->
get_record
(
'user'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$url
->
param
(
'courseid'
,
$course
->
id
);
$url
->
param
(
'userid'
,
$user
->
id
);
...
...
admin/roles/override.php
View file @
ab7632b7
...
...
@@ -36,7 +36,7 @@ if ($course) {
}
else
{
$isfrontpage
=
false
;
if
(
$context
->
contextlevel
==
CONTEXT_USER
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
))
,
'*'
,
MUST_EXIST
)
;
$course
=
get_course
(
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
));
$user
=
$DB
->
get_record
(
'user'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$url
->
param
(
'courseid'
,
$course
->
id
);
$url
->
param
(
'userid'
,
$user
->
id
);
...
...
admin/roles/permissions.php
View file @
ab7632b7
...
...
@@ -43,7 +43,7 @@ if ($course) {
}
else
{
$isfrontpage
=
false
;
if
(
$context
->
contextlevel
==
CONTEXT_USER
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
))
,
'*'
,
MUST_EXIST
)
;
$course
=
get_course
(
optional_param
(
'courseid'
,
SITEID
,
PARAM_INT
));
$user
=
$DB
->
get_record
(
'user'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$url
->
param
(
'courseid'
,
$course
->
id
);
$url
->
param
(
'userid'
,
$user
->
id
);
...
...
admin/roles/usersroles.php
View file @
ab7632b7
...
...
@@ -32,7 +32,7 @@ $courseid = required_param('courseid', PARAM_INT);
// Validate them and get the corresponding objects.
$user
=
$DB
->
get_record
(
'user'
,
array
(
'id'
=>
$userid
),
'*'
,
MUST_EXIST
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$usercontext
=
context_user
::
instance
(
$user
->
id
);
$coursecontext
=
context_course
::
instance
(
$course
->
id
);
...
...
backup/backup.php
View file @
ab7632b7
...
...
@@ -40,7 +40,7 @@ $PAGE->set_pagelayout('admin');
$id
=
$courseid
;
$cm
=
null
;
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$type
=
backup
::
TYPE_1COURSE
;
if
(
!
is_null
(
$sectionid
))
{
$section
=
$DB
->
get_record
(
'course_sections'
,
array
(
'course'
=>
$course
->
id
,
'id'
=>
$sectionid
),
'*'
,
MUST_EXIST
);
...
...
backup/import.php
View file @
ab7632b7
...
...
@@ -17,7 +17,7 @@ $searchcourses = optional_param('searchcourses', false, PARAM_BOOL);
$restoretarget
=
optional_param
(
'target'
,
backup
::
TARGET_CURRENT_ADDING
,
PARAM_INT
);
// Load the course and context
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$context
=
context_course
::
instance
(
$courseid
);
// Must pass login
...
...
@@ -51,7 +51,7 @@ if ($importcourseid === false || $searchcourses) {
}
// Load the course +context to import from
$importcourse
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$importcourseid
),
'*'
,
MUST_EXIST
);
$importcourse
=
get_course
(
$importcourseid
);
$importcontext
=
context_course
::
instance
(
$importcourseid
);
// Make sure the user can backup from that course
...
...
backup/moodle2/backup_section_task.class.php
View file @
ab7632b7
...
...
@@ -148,7 +148,7 @@ class backup_section_task extends backup_task {
// All these are common settings to be shared by all sections
$section
=
$DB
->
get_record
(
'course_sections'
,
array
(
'id'
=>
$this
->
sectionid
),
'*'
,
MUST_EXIST
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$section
->
course
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$section
->
course
);
// Define section_included (to decide if the whole task must be really executed)
$settingname
=
$settingprefix
.
'included'
;
...
...
backup/moodle2/restore_stepslib.php
View file @
ab7632b7
...
...
@@ -1632,7 +1632,7 @@ class restore_default_enrolments_step extends restore_execution_step {
public
function
define_execution
()
{
global
$DB
;
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$this
->
get_courseid
())
,
'*'
,
MUST_EXIST
)
;
$course
=
get_course
(
$this
->
get_courseid
());
if
(
$DB
->
record_exists
(
'enrol'
,
array
(
'courseid'
=>
$this
->
get_courseid
(),
'enrol'
=>
'manual'
)))
{
// Something already added instances, do not add default instances.
...
...
@@ -1849,7 +1849,7 @@ class restore_fix_restorer_access_step extends restore_execution_step {
return
;
}
if
(
!
$DB
->
record_exists
(
'enrol'
,
array
(
'enrol'
=>
'manual'
,
'courseid'
=>
$courseid
)))
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$fields
=
array
(
'status'
=>
ENROL_INSTANCE_ENABLED
,
'enrolperiod'
=>
$enrol
->
get_config
(
'enrolperiod'
,
0
),
'roleid'
=>
$enrol
->
get_config
(
'roleid'
,
0
));
$enrol
->
add_instance
(
$course
,
$fields
);
}
...
...
backup/util/checks/backup_check.class.php
View file @
ab7632b7
...
...
@@ -109,7 +109,7 @@ abstract class backup_check {
$typecapstocheck
=
array
();
switch
(
$type
)
{
case
backup
::
TYPE_1COURSE
:
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$id
),
'*'
,
MUST_EXIST
);
// course exists
get_course
(
$id
);
// course exists
$typecapstocheck
[
'moodle/backup:backupcourse'
]
=
$coursectx
;
break
;
case
backup
::
TYPE_1SECTION
:
...
...
blocks/community/communitycourse.php
View file @
ab7632b7
...
...
@@ -34,7 +34,7 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
require_login
();
$courseid
=
required_param
(
'courseid'
,
PARAM_INT
);
//if no courseid is given
$parentcourse
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$parentcourse
=
get_course
(
$courseid
);
$context
=
context_course
::
instance
(
$courseid
);
$PAGE
->
set_course
(
$parentcourse
);
...
...
blocks/completionstatus/details.php
View file @
ab7632b7
...
...
@@ -32,7 +32,7 @@ $id = required_param('course', PARAM_INT);
$userid
=
optional_param
(
'user'
,
0
,
PARAM_INT
);
// Load course.
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$id
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$id
);
// Load user.
if
(
$userid
)
{
...
...
blocks/rss_client/editfeed.php
View file @
ab7632b7
...
...
@@ -154,7 +154,7 @@ if ($courseid == SITEID) {
$courseid
=
0
;
}
if
(
$courseid
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$PAGE
->
set_course
(
$course
);
$context
=
$PAGE
->
context
;
}
else
{
...
...
blocks/rss_client/managefeeds.php
View file @
ab7632b7
...
...
@@ -36,7 +36,7 @@ if ($courseid == SITEID) {
$courseid
=
0
;
}
if
(
$courseid
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$PAGE
->
set_course
(
$course
);
$context
=
$PAGE
->
context
;
}
else
{
...
...
blocks/rss_client/viewfeed.php
View file @
ab7632b7
...
...
@@ -39,7 +39,7 @@ if ($courseid = SITEID) {
$courseid
=
0
;
}
if
(
$courseid
)
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$PAGE
->
set_course
(
$course
);
$context
=
$PAGE
->
context
;
}
else
{
...
...
calendar/event.php
View file @
ab7632b7
...
...
@@ -81,7 +81,7 @@ $PAGE->set_url($url);
$PAGE
->
set_pagelayout
(
'standard'
);
if
(
$courseid
!=
SITEID
&&
!
empty
(
$courseid
))
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$courses
=
array
(
$course
->
id
=>
$course
);
$issite
=
false
;
}
else
{
...
...
calendar/lib.php
View file @
ab7632b7
...
...
@@ -1817,7 +1817,7 @@ function calendar_get_allowed_types(&$allowed, $course = null) {
if
(
!
empty
(
$course
))
{
if
(
!
is_object
(
$course
))
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$course
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$course
);
}
if
(
$course
->
id
!=
SITEID
)
{
$coursecontext
=
context_course
::
instance
(
$course
->
id
);
...
...
calendar/preferences.php
View file @
ab7632b7
...
...
@@ -7,7 +7,7 @@ require_once($CFG->dirroot.'/calendar/lib.php');
require_once
(
$CFG
->
dirroot
.
'/calendar/preferences_form.php'
);
$courseid
=
required_param
(
'course'
,
PARAM_INT
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$PAGE
->
set_url
(
new
moodle_url
(
'/calendar/preferences.php'
,
array
(
'course'
=>
$courseid
)));
$PAGE
->
set_pagelayout
(
'standard'
);
...
...
course/changenumsections.php
View file @
ab7632b7
...
...
@@ -30,7 +30,7 @@ require_once($CFG->dirroot.'/course/lib.php');
$courseid
=
required_param
(
'courseid'
,
PARAM_INT
);
$increase
=
optional_param
(
'increase'
,
true
,
PARAM_BOOL
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$course
=
get_course
(
$courseid
);
$courseformatoptions
=
course_get_format
(
$course
)
->
get_format_options
();
$PAGE
->
set_url
(
'/course/changenumsections.php'
,
array
(
'courseid'
=>
$courseid
));
...
...
course/dnduploadlib.php
View file @
ab7632b7
...
...
@@ -460,7 +460,7 @@ class dndupload_ajax_processor {
throw
new
coding_exception
(
'dndupload_ajax_processor should only be used within AJAX requests'
);
}
$this
->
course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$this
->
course
=
get_course
(
$courseid
);
require_login
(
$this
->
course
,
false
);
$this
->
context
=
context_course
::
instance
(
$this
->
course
->
id
);
...
...
Prev
1
2
3
4
5
…
10
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment