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
a3da85e4
Commit
a3da85e4
authored
Mar 07, 2017
by
Dan Poltawski
Browse files
Merge branch 'MDL-58040' of
git://github.com/timhunt/moodle
parents
44c4f148
898da28a
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/blocklib.php
View file @
a3da85e4
...
...
@@ -215,7 +215,7 @@ class block_manager {
}
$unaddableblocks
=
self
::
get_undeletable_block_types
();
$requiredbythemeblocks
=
self
::
get_required_by_theme_block_types
();
$requiredbythemeblocks
=
$this
->
get_required_by_theme_block_types
();
$pageformat
=
$this
->
page
->
pagetype
;
foreach
(
$allblocks
as
$block
)
{
if
(
!
$bi
=
block_instance
(
$block
->
name
))
{
...
...
@@ -246,7 +246,7 @@ class block_manager {
return
false
;
}
$requiredbythemeblocks
=
self
::
get_required_by_theme_block_types
();
$requiredbythemeblocks
=
$this
->
get_required_by_theme_block_types
();
foreach
(
$this
->
blockinstances
as
$region
)
{
foreach
(
$region
as
$instance
)
{
if
(
empty
(
$instance
->
instance
->
blockname
))
{
...
...
@@ -380,11 +380,10 @@ class block_manager {
/**
* @return array names of block types that must exist on every page with this theme.
*/
public
static
function
get_required_by_theme_block_types
()
{
global
$CFG
,
$PAGE
;
public
function
get_required_by_theme_block_types
()
{
$requiredbythemeblocks
=
false
;
if
(
isset
(
$
PAGE
->
theme
->
requiredblocks
))
{
$requiredbythemeblocks
=
$
PAGE
->
theme
->
requiredblocks
;
if
(
isset
(
$
this
->
page
->
theme
->
requiredblocks
))
{
$requiredbythemeblocks
=
$
this
->
page
->
theme
->
requiredblocks
;
}
if
(
$requiredbythemeblocks
===
false
)
{
...
...
@@ -457,7 +456,7 @@ class block_manager {
* @return array names of block types that cannot be added or deleted. E.g. array('navigation','settings').
*/
public
static
function
get_undeletable_block_types
()
{
global
$CFG
,
$PAGE
;
global
$CFG
;
$undeletableblocks
=
false
;
if
(
isset
(
$CFG
->
undeletableblocktypes
))
{
$undeletableblocks
=
$CFG
->
undeletableblocktypes
;
...
...
@@ -1072,7 +1071,6 @@ class block_manager {
* so they are only visible on themes that require them.
*/
public
function
create_all_block_instances
()
{
global
$PAGE
;
$missing
=
false
;
// If there are any un-removable blocks that were not created - force them.
...
...
@@ -1359,7 +1357,7 @@ class block_manager {
return
$this
->
page
->
user_can_edit_blocks
()
&&
$block
->
user_can_edit
()
&&
$block
->
user_can_addto
(
$this
->
page
)
&&
!
in_array
(
$block
->
instance
->
blockname
,
self
::
get_undeletable_block_types
())
&&
!
in_array
(
$block
->
instance
->
blockname
,
self
::
get_required_by_theme_block_types
());
!
in_array
(
$block
->
instance
->
blockname
,
$this
->
get_required_by_theme_block_types
());
}
/**
...
...
lib/tests/blocklib_test.php
View file @
a3da85e4
...
...
@@ -598,7 +598,7 @@ class core_blocklib_testcase extends advanced_testcase {
// Assert that protecting a block does not make it auto-created.
$this
->
assertCount
(
2
,
$blocks
);
$requiredbytheme
=
block
_
manager
::
get_required_by_theme_block_types
();
$requiredbytheme
=
$
blockmanager
->
get_required_by_theme_block_types
();
foreach
(
$requiredbytheme
as
$blockname
)
{
$instance
=
$DB
->
get_record
(
'block_instances'
,
array
(
'blockname'
=>
$blockname
));
$this
->
assertEquals
(
1
,
$instance
->
requiredbytheme
);
...
...
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