mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-10573 - Added a capability for viewing blocks, this allows role-based control of block
display. Changed context capability check so that CONTEXT_BLOCK capabilities can also come from the moodle core capability definitions
This commit is contained in:
parent
94783496f1
commit
7e874772a3
@ -195,10 +195,18 @@ class block_base {
|
||||
|
||||
/**
|
||||
* Returns true or false, depending on whether this block has any content to display
|
||||
* and whether the user has permission to view the block
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function is_empty() {
|
||||
|
||||
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
|
||||
|
||||
if ( !has_capability('moodle/block:view', $context) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->get_content();
|
||||
return(empty($this->content->text) && empty($this->content->footer));
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ $string['blog:manageentries'] = 'Edit and manage entries';
|
||||
$string['blog:manageofficialtags'] = 'Manage official tags';
|
||||
$string['blog:managepersonaltags'] = 'Manage personal tags';
|
||||
$string['blog:view'] = 'View blog entries';
|
||||
$string['block:view'] = 'View block';
|
||||
$string['calendar:manageentries'] = 'Manage any calendar entries';
|
||||
$string['calendar:manageownentries'] = 'Manage own calendar entries';
|
||||
$string['capabilities'] = 'Capabilities';
|
||||
|
@ -2917,7 +2917,7 @@ function fetch_context_capabilities($context) {
|
||||
$block = get_record('block', 'id', $cb->blockid);
|
||||
|
||||
$SQL = "select * from {$CFG->prefix}capabilities where contextlevel = ".CONTEXT_BLOCK."
|
||||
and component = 'block/$block->name'";
|
||||
and ( component = 'block/$block->name' or component = 'moodle')";
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -3396,7 +3396,11 @@ function get_component_string($component, $contextlevel) {
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK:
|
||||
$string = get_string('blockname', 'block_'.basename($component));
|
||||
if( $component == 'moodle' ){
|
||||
$string = get_string('block');
|
||||
}else{
|
||||
$string = get_string('blockname', 'block_'.basename($component));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1145,6 +1145,15 @@ $moodle_capabilities = array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'moodle/block:view' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_BLOCK,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_ALLOW,
|
||||
'user' => CAP_ALLOW
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// This is compared against the values stored in the database to determine
|
||||
// whether upgrades should be performed (see lib/db/*.php)
|
||||
|
||||
$version = 2007081001; // YYYYMMDD = date
|
||||
$version = 2007081301; // YYYYMMDD = date
|
||||
// XY = increments within a single day
|
||||
|
||||
$release = '1.9 dev'; // Human-friendly version name
|
||||
|
Loading…
x
Reference in New Issue
Block a user