Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add view block capabilities 4.1 #76

Open
wants to merge 1 commit into
base: MOODLE_401_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions block_grade_me.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public function init() {
public function get_content() {
global $CFG, $USER, $COURSE, $DB, $OUTPUT, $PAGE;

$context = context_course::instance($this->page->course->id);
$isteacher = has_capability('block/grade_me:viewblock', $context);

if(!$isteacher) {
return $this->content;
}

if ($this->content !== null) {
return $this->content;
}
Expand Down
12 changes: 12 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,17 @@
),

'clonepermissionsfrom' => 'moodle/site:manageblocks'
),

'block/grade_me:viewblock' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,

'captype' => 'read',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'user' => CAP_ALLOW
),

'clonepermissionsfrom' => 'moodle/block:view'
)
);
1 change: 1 addition & 0 deletions lang/en/block_grade_me.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

$string['grade_me:addinstance'] = 'Add a new Grade Me block';
$string['grade_me:myaddinstance'] = 'Add a new Grade Me block to the My Moodle page';
$string['grade_me:viewblock'] = 'View block';
$string['expand'] = 'Collapse / Expand All';

$string['grade_me_tools'] = 'Tools';
Expand Down
1 change: 1 addition & 0 deletions lang/es/block_grade_me.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
$string['settings_configenablepre'] = '¿Debería el bloque Califícame mostrar actividades sin evaluar del módulo "{$a->plugin_name}" ?';
$string['grade_me:addinstance'] = 'Añadir un nuevo bloque Califícame';
$string['grade_me:myaddinstance'] = 'Añadir un nuevo bloque Califícame a mi página personal';
$string['grade_me:viewblock'] = 'Ver bloque';