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
fe2fdd11
Commit
fe2fdd11
authored
Jul 23, 2012
by
Frederic Massart
Browse files
MDL-34456 Librairies: Replaced deprecated get_context_instance()
parent
bdaff201
Changes
31
Hide whitespace changes
Inline
Side-by-side
blocks/admin_bookmarks/block_admin_bookmarks.php
View file @
fe2fdd11
...
...
@@ -61,7 +61,7 @@ class block_admin_bookmarks extends block_base {
* @return array
*/
function
applicable_formats
()
{
if
(
has_capability
(
'moodle/site:config'
,
get_
context_instance
(
CONTEXT_SYSTEM
)))
{
if
(
has_capability
(
'moodle/site:config'
,
context_
system
::
instance
()))
{
return
array
(
'all'
=>
true
);
}
else
{
return
array
(
'site'
=>
true
);
...
...
blocks/admin_bookmarks/create.php
View file @
fe2fdd11
...
...
@@ -4,7 +4,7 @@ require('../../config.php');
require_once
(
$CFG
->
libdir
.
'/adminlib.php'
);
require_login
();
$context
=
get_
context_instance
(
CONTEXT_SYSTEM
);
$context
=
context_
system
::
instance
();
$PAGE
->
set_context
(
$context
);
$adminroot
=
admin_get_root
(
false
,
false
);
// settings not required - only pages
...
...
blocks/admin_bookmarks/delete.php
View file @
fe2fdd11
...
...
@@ -5,7 +5,7 @@ require('../../config.php');
require_once
(
$CFG
->
libdir
.
'/adminlib.php'
);
require_login
();
$context
=
get_
context_instance
(
CONTEXT_SYSTEM
);
$context
=
context_
system
::
instance
();
$PAGE
->
set_context
(
$context
);
$adminroot
=
admin_get_root
(
false
,
false
);
// settings not required - only pages
...
...
blocks/blog_menu/block_blog_menu.php
View file @
fe2fdd11
...
...
@@ -98,7 +98,7 @@ class block_blog_menu extends block_base {
$this
->
content
->
text
=
html_writer
::
alist
(
$menulist
,
array
(
'class'
=>
'list'
));
// Prepare the footer for this block
if
(
has_capability
(
'moodle/blog:search'
,
get_
context_instance
(
CONTEXT_SYSTEM
)))
{
if
(
has_capability
(
'moodle/blog:search'
,
context_
system
::
instance
()))
{
// Full-text search field
$form
=
html_writer
::
tag
(
'label'
,
get_string
(
'search'
,
'admin'
),
array
(
'for'
=>
'blogsearchquery'
,
'class'
=>
'accesshide'
));
$form
.
=
html_writer
::
empty_tag
(
'input'
,
array
(
'id'
=>
'blogsearchquery'
,
'type'
=>
'text'
,
'name'
=>
'search'
));
...
...
blocks/blog_tags/block_blog_tags.php
View file @
fe2fdd11
...
...
@@ -118,7 +118,7 @@ class block_blog_tags extends block_base {
// admins should be able to read all tags
$type
=
''
;
if
(
!
has_capability
(
'moodle/user:readuserblogs'
,
get_
context_instance
(
CONTEXT_SYSTEM
)))
{
if
(
!
has_capability
(
'moodle/user:readuserblogs'
,
context_
system
::
instance
()))
{
$type
=
" AND (p.publishstate = 'site' or p.publishstate='public')"
;
}
...
...
blocks/calendar_upcoming/block_calendar_upcoming.php
View file @
fe2fdd11
...
...
@@ -28,7 +28,7 @@ class block_calendar_upcoming extends block_base {
$this
->
content
->
footer
=
'<div class="gotocal"><a href="'
.
$CFG
->
wwwroot
.
'/calendar/view.php?view=upcoming&course='
.
$courseshown
.
'">'
.
get_string
(
'gotocalendar'
,
'calendar'
)
.
'</a>...</div>'
;
$context
=
get_
context_instance
(
CONTEXT_COURSE
,
$courseshown
);
$context
=
context_
course
::
instance
(
$courseshown
);
if
(
has_any_capability
(
array
(
'moodle/calendar:manageentries'
,
'moodle/calendar:manageownentries'
),
$context
))
{
$this
->
content
->
footer
.
=
'<div class="newevent"><a href="'
.
$CFG
->
wwwroot
.
'/calendar/event.php?action=new&course='
.
$courseshown
.
'">'
.
...
...
blocks/community/communitycourse.php
View file @
fe2fdd11
...
...
@@ -36,7 +36,7 @@ require_login();
$courseid
=
required_param
(
'courseid'
,
PARAM_INT
);
//if no courseid is given
$parentcourse
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$courseid
),
'*'
,
MUST_EXIST
);
$context
=
get_
context_instance
(
CONTEXT_COURSE
,
$courseid
);
$context
=
context_
course
::
instance
(
$courseid
);
$PAGE
->
set_course
(
$parentcourse
);
$PAGE
->
set_url
(
'/blocks/community/communitycourse.php'
);
$PAGE
->
set_heading
(
$SITE
->
fullname
);
...
...
blocks/community/forms.php
View file @
fe2fdd11
...
...
@@ -191,7 +191,7 @@ class community_hub_search_form extends moodleform {
//display enrol/download select box if the USER has the download capability on the course
if
(
has_capability
(
'moodle/community:download'
,
get_
context_instance
(
CONTEXT_COURSE
,
$this
->
_customdata
[
'courseid'
])))
{
context_
course
::
instance
(
$this
->
_customdata
[
'courseid'
])))
{
$options
=
array
(
0
=>
get_string
(
'enrollable'
,
'block_community'
),
1
=>
get_string
(
'downloadable'
,
'block_community'
));
$mform
->
addElement
(
'select'
,
'downloadable'
,
get_string
(
'enroldownload'
,
'block_community'
),
...
...
blocks/community/locallib.php
View file @
fe2fdd11
...
...
@@ -113,7 +113,7 @@ class block_community_manager {
$fs
=
get_file_storage
();
$record
=
new
stdClass
();
$record
->
contextid
=
get_
context_instance
(
CONTEXT_USER
,
$USER
->
id
)
->
id
;
$record
->
contextid
=
context_
user
::
instance
(
$USER
->
id
)
->
id
;
$record
->
component
=
'user'
;
$record
->
filearea
=
'private'
;
$record
->
itemid
=
0
;
...
...
blocks/completionstatus/block_completionstatus.php
View file @
fe2fdd11
...
...
@@ -51,7 +51,7 @@ class block_completionstatus extends block_base {
$this
->
content
=
new
stdClass
;
// Can edit settings?
$can_edit
=
has_capability
(
'moodle/course:update'
,
get_
context_instance
(
CONTEXT_COURSE
,
$this
->
page
->
course
->
id
));
$can_edit
=
has_capability
(
'moodle/course:update'
,
context_
course
::
instance
(
$this
->
page
->
course
->
id
));
// Get course completion data
$info
=
new
completion_info
(
$this
->
page
->
course
);
...
...
@@ -84,7 +84,7 @@ class block_completionstatus extends block_base {
// Check this user is enroled
if
(
!
$info
->
is_tracked_user
(
$USER
->
id
))
{
// If not enrolled, but are can view the report:
if
(
has_capability
(
'report/completion:view'
,
get_
context_instance
(
CONTEXT_COURSE
,
$COURSE
->
id
)))
{
if
(
has_capability
(
'report/completion:view'
,
context_
course
::
instance
(
$COURSE
->
id
)))
{
$this
->
content
->
text
=
'<a href="'
.
$CFG
->
wwwroot
.
'/report/completion/index.php?course='
.
$COURSE
->
id
.
'">'
.
get_string
(
'viewcoursereport'
,
'completion'
)
.
'</a>'
;
return
$this
->
content
;
...
...
blocks/completionstatus/details.php
View file @
fe2fdd11
...
...
@@ -52,8 +52,8 @@ if ($userid) {
// Check permissions
require_login
(
$course
);
$coursecontext
=
get_
context_instance
(
CONTEXT_COURSE
,
$course
->
id
);
$personalcontext
=
get_
context_instance
(
CONTEXT_USER
,
$user
->
id
);
$coursecontext
=
context_
course
::
instance
(
$course
->
id
);
$personalcontext
=
context_
user
::
instance
(
$user
->
id
);
$can_view
=
false
;
...
...
blocks/course_list/block_course_list.php
View file @
fe2fdd11
...
...
@@ -33,17 +33,17 @@ class block_course_list extends block_list {
}
if
(
empty
(
$CFG
->
disablemycourses
)
and
isloggedin
()
and
!
isguestuser
()
and
!
(
has_capability
(
'moodle/course:update'
,
get_
context_instance
(
CONTEXT_SYSTEM
))
and
$adminseesall
))
{
// Just print My Courses
!
(
has_capability
(
'moodle/course:update'
,
context_
system
::
instance
())
and
$adminseesall
))
{
// Just print My Courses
if
(
$courses
=
enrol_get_my_courses
(
NULL
,
'visible DESC, fullname ASC'
))
{
foreach
(
$courses
as
$course
)
{
$coursecontext
=
get_
context_instance
(
CONTEXT_COURSE
,
$course
->
id
);
$coursecontext
=
context_
course
::
instance
(
$course
->
id
);
$linkcss
=
$course
->
visible
?
""
:
" class=
\"
dimmed
\"
"
;
$this
->
content
->
items
[]
=
"<a
$linkcss
title=
\"
"
.
format_string
(
$course
->
shortname
,
true
,
array
(
'context'
=>
$coursecontext
))
.
"
\"
"
.
"href=
\"
$CFG->wwwroot
/course/view.php?id=
$course->id
\"
>"
.
$icon
.
format_string
(
$course
->
fullname
)
.
"</a>"
;
}
$this
->
title
=
get_string
(
'mycourses'
);
/// If we can update any course of the view all isn't hidden, show the view all courses link
if
(
has_capability
(
'moodle/course:update'
,
get_
context_instance
(
CONTEXT_SYSTEM
))
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
if
(
has_capability
(
'moodle/course:update'
,
context_
system
::
instance
())
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
$this
->
content
->
footer
=
"<a href=
\"
$CFG->wwwroot
/course/index.php
\"
>"
.
get_string
(
"fulllistofcourses"
)
.
"</a> ..."
;
}
}
...
...
@@ -57,12 +57,12 @@ class block_course_list extends block_list {
if
(
$categories
)
{
//Check we have categories
if
(
count
(
$categories
)
>
1
||
(
count
(
$categories
)
==
1
&&
$DB
->
count_records
(
'course'
)
>
200
))
{
// Just print top level category links
foreach
(
$categories
as
$category
)
{
$categoryname
=
format_string
(
$category
->
name
,
true
,
array
(
'context'
=>
get_
context_
instance
(
CONTEXT_COURSECAT
,
$category
->
id
)));
$categoryname
=
format_string
(
$category
->
name
,
true
,
array
(
'context'
=>
context_
coursecat
::
instance
(
$category
->
id
)));
$linkcss
=
$category
->
visible
?
""
:
" class=
\"
dimmed
\"
"
;
$this
->
content
->
items
[]
=
"<a
$linkcss
href=
\"
$CFG->wwwroot
/course/category.php?id=
$category->id
\"
>"
.
$icon
.
$categoryname
.
"</a>"
;
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if
(
has_capability
(
'moodle/course:update'
,
get_
context_instance
(
CONTEXT_SYSTEM
))
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
if
(
has_capability
(
'moodle/course:update'
,
context_
system
::
instance
())
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
$this
->
content
->
footer
.
=
"<a href=
\"
$CFG->wwwroot
/course/index.php
\"
>"
.
get_string
(
'fulllistofcourses'
)
.
'</a> ...'
;
}
$this
->
title
=
get_string
(
'categories'
);
...
...
@@ -72,16 +72,16 @@ class block_course_list extends block_list {
if
(
$courses
)
{
foreach
(
$courses
as
$course
)
{
$coursecontext
=
get_
context_instance
(
CONTEXT_COURSE
,
$course
->
id
);
$coursecontext
=
context_
course
::
instance
(
$course
->
id
);
$linkcss
=
$course
->
visible
?
""
:
" class=
\"
dimmed
\"
"
;
$this
->
content
->
items
[]
=
"<a
$linkcss
title=
\"
"
.
format_string
(
$course
->
shortname
,
true
,
array
(
'context'
=>
$coursecontext
))
.
"
\"
"
.
"href=
\"
$CFG->wwwroot
/course/view.php?id=
$course->id
\"
>"
.
$icon
.
format_string
(
$course
->
fullname
,
true
,
array
(
'context'
=>
get_
context_instance
(
CONTEXT_COURSE
,
$course
->
id
)))
.
"</a>"
;
.
$icon
.
format_string
(
$course
->
fullname
,
true
,
array
(
'context'
=>
context_
course
::
instance
(
$course
->
id
)))
.
"</a>"
;
}
/// If we can update any course of the view all isn't hidden, show the view all courses link
if
(
has_capability
(
'moodle/course:update'
,
get_
context_instance
(
CONTEXT_SYSTEM
))
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
if
(
has_capability
(
'moodle/course:update'
,
context_
system
::
instance
())
||
empty
(
$CFG
->
block_course_list_hideallcourseslink
))
{
$this
->
content
->
footer
.
=
"<a href=
\"
$CFG->wwwroot
/course/index.php
\"
>"
.
get_string
(
'fulllistofcourses'
)
.
'</a> ...'
;
}
$this
->
get_remote_courses
();
...
...
@@ -89,7 +89,7 @@ class block_course_list extends block_list {
$this
->
content
->
icons
[]
=
''
;
$this
->
content
->
items
[]
=
get_string
(
'nocoursesyet'
);
if
(
has_capability
(
'moodle/course:create'
,
get_
context_
instance
(
CONTEXT_COURSECAT
,
$category
->
id
)))
{
if
(
has_capability
(
'moodle/course:create'
,
context_
coursecat
::
instance
(
$category
->
id
)))
{
$this
->
content
->
footer
=
'<a href="'
.
$CFG
->
wwwroot
.
'/course/edit.php?category='
.
$category
->
id
.
'">'
.
get_string
(
"addnewcourse"
)
.
'</a> ...'
;
}
$this
->
get_remote_courses
();
...
...
@@ -120,7 +120,7 @@ class block_course_list extends block_list {
$this
->
content
->
items
[]
=
get_string
(
'remotecourses'
,
'mnet'
);
$this
->
content
->
icons
[]
=
''
;
foreach
(
$courses
as
$course
)
{
$coursecontext
=
get_
context_instance
(
CONTEXT_COURSE
,
$course
->
id
);
$coursecontext
=
context_
course
::
instance
(
$course
->
id
);
$this
->
content
->
items
[]
=
"<a title=
\"
"
.
format_string
(
$course
->
shortname
,
true
,
array
(
'context'
=>
$coursecontext
))
.
"
\"
"
.
"href=
\"
{
$CFG
->
wwwroot
}
/auth/mnet/jump.php?hostid=
{
$course
->
hostid
}
&wantsurl=/course/view.php?id=
{
$course
->
remoteid
}
\"
>"
.
$icon
.
format_string
(
$course
->
fullname
)
.
"</a>"
;
...
...
blocks/course_summary/block_course_summary.php
View file @
fe2fdd11
...
...
@@ -28,7 +28,7 @@ class block_course_summary extends block_base {
$options
=
new
stdClass
();
$options
->
noclean
=
true
;
// Don't clean Javascripts etc
$options
->
overflowdiv
=
true
;
$context
=
get_
context_instance
(
CONTEXT_COURSE
,
$this
->
page
->
course
->
id
);
$context
=
context_
course
::
instance
(
$this
->
page
->
course
->
id
);
$this
->
page
->
course
->
summary
=
file_rewrite_pluginfile_urls
(
$this
->
page
->
course
->
summary
,
'pluginfile.php'
,
$context
->
id
,
'course'
,
'summary'
,
NULL
);
$this
->
content
->
text
=
format_text
(
$this
->
page
->
course
->
summary
,
$this
->
page
->
course
->
summaryformat
,
$options
);
if
(
$this
->
page
->
user_is_editing
())
{
...
...
blocks/edit_form.php
View file @
fe2fdd11
...
...
@@ -265,7 +265,7 @@ class block_edit_form extends moodleform {
$defaults
->
bui_subpagepattern
=
'%@NULL@%'
;
}
$systemcontext
=
get_
context_instance
(
CONTEXT_SYSTEM
);
$systemcontext
=
context_
system
::
instance
();
if
(
$defaults
->
parentcontextid
==
$systemcontext
->
id
)
{
$defaults
->
bui_contexts
=
BUI_CONTEXTS_ENTIRE_SITE
;
// System-wide and sticky
}
else
{
...
...
blocks/glossary_random/block_glossary_random.php
View file @
fe2fdd11
...
...
@@ -45,7 +45,7 @@ class block_glossary_random extends block_base {
if
(
!
$cm
=
get_coursemodule_from_instance
(
"glossary"
,
$this
->
config
->
glossary
,
$this
->
course
->
id
))
{
return
false
;
}
$glossaryctx
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$glossaryctx
=
context_
module
::
instance
(
$cm
->
id
);
$limitfrom
=
0
;
$limitnum
=
1
;
...
...
@@ -131,7 +131,7 @@ class block_glossary_random extends block_base {
$glossaryid
=
$this
->
config
->
glossary
;
$cm
=
$modinfo
->
instances
[
'glossary'
][
$glossaryid
];
if
(
!
has_capability
(
'mod/glossary:view'
,
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
)))
{
if
(
!
has_capability
(
'mod/glossary:view'
,
context_
module
::
instance
(
$cm
->
id
)))
{
return
''
;
}
...
...
@@ -162,7 +162,7 @@ class block_glossary_random extends block_base {
//Obtain the visible property from the instance
if
(
$cm
->
uservisible
)
{
if
(
has_capability
(
'mod/glossary:write'
,
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
)))
{
if
(
has_capability
(
'mod/glossary:write'
,
context_
module
::
instance
(
$cm
->
id
)))
{
$this
->
content
->
footer
=
'<a href="'
.
$CFG
->
wwwroot
.
'/mod/glossary/edit.php?cmid='
.
$cm
->
id
.
'" title="'
.
$this
->
config
->
addentry
.
'">'
.
$this
->
config
->
addentry
.
'</a><br />'
;
}
else
{
...
...
blocks/mnet_hosts/block_mnet_hosts.php
View file @
fe2fdd11
...
...
@@ -10,7 +10,7 @@ class block_mnet_hosts extends block_list {
}
function
applicable_formats
()
{
if
(
has_capability
(
'moodle/site:mnetlogintoremote'
,
get_
context_instance
(
CONTEXT_SYSTEM
),
NULL
,
false
))
{
if
(
has_capability
(
'moodle/site:mnetlogintoremote'
,
context_
system
::
instance
(),
NULL
,
false
))
{
return
array
(
'all'
=>
true
,
'mod'
=>
false
,
'tag'
=>
false
);
}
else
{
return
array
(
'site'
=>
true
);
...
...
@@ -59,7 +59,7 @@ class block_mnet_hosts extends block_list {
}
}
if
(
!
has_capability
(
'moodle/site:mnetlogintoremote'
,
get_
context_instance
(
CONTEXT_SYSTEM
),
NULL
,
false
))
{
if
(
!
has_capability
(
'moodle/site:mnetlogintoremote'
,
context_
system
::
instance
(),
NULL
,
false
))
{
if
(
debugging
()
and
!
empty
(
$CFG
->
debugdisplay
))
{
$this
->
content
=
new
stdClass
();
$this
->
content
->
footer
=
html_writer
::
tag
(
'span'
,
...
...
blocks/moodleblock.class.php
View file @
fe2fdd11
...
...
@@ -418,7 +418,7 @@ class block_base {
$this
->
config
=
unserialize
(
base64_decode
(
$instance
->
configdata
));
}
$this
->
instance
=
$instance
;
$this
->
context
=
get_
context_instance
(
CONTEXT_BLOCK
,
$instance
->
id
);
$this
->
context
=
context_
block
::
instance
(
$instance
->
id
);
$this
->
page
=
$page
;
$this
->
specialization
();
}
...
...
blocks/news_items/block_news_items.php
View file @
fe2fdd11
...
...
@@ -41,7 +41,7 @@ class block_news_items extends block_base {
return
''
;
}
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
/// User must have perms to view discussions in that forum
if
(
!
has_capability
(
'mod/forum:viewdiscussion'
,
$context
))
{
...
...
blocks/participants/block_participants.php
View file @
fe2fdd11
...
...
@@ -26,7 +26,7 @@ class block_participants extends block_list {
$this
->
content
=
''
;
return
$this
->
content
;
}
else
if
(
$this
->
page
->
course
->
id
==
SITEID
)
{
if
(
!
has_capability
(
'moodle/site:viewparticipants'
,
get_
context_instance
(
CONTEXT_SYSTEM
)))
{
if
(
!
has_capability
(
'moodle/site:viewparticipants'
,
context_
system
::
instance
()))
{
$this
->
content
=
''
;
return
$this
->
content
;
}
...
...
blocks/private_files/edit.php
View file @
fe2fdd11
...
...
@@ -33,7 +33,7 @@ if (isguestuser()) {
}
//TODO: add capability check here!
$context
=
get_
context_instance
(
CONTEXT_USER
,
$USER
->
id
);
$context
=
context_
user
::
instance
(
$USER
->
id
);
$title
=
get_string
(
'privatefiles'
,
'block_private_files'
);
$struser
=
get_string
(
'user'
);
...
...
Prev
1
2
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