MDL-32239 question bank: wrong cap checks editing/viewing quesitions
None of these problems affect the default roles. They only occur when the permissions have been edited to allow restricted subsets of the question capabilities. In some cases, things that the restriced subset of capabilities should have allowed were blocked by errors. In other cases, users were allowed to do more than they should bave been due to failures to check the right capabilities in the right places. For full details, see the bug report. Two of the bugs were previously reported separately as MDL-26395 and MDL-27232.
This commit is contained in:
@@ -605,7 +605,8 @@ abstract class question_bank_action_column_base extends question_bank_column_bas
|
||||
}
|
||||
|
||||
public function get_required_fields() {
|
||||
return array('q.id');
|
||||
// createdby is required for permission checks.
|
||||
return array('q.id, q.createdby');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,10 +632,9 @@ class question_bank_edit_action_column extends question_bank_action_column_base
|
||||
}
|
||||
|
||||
protected function display_content($question, $rowclasses) {
|
||||
if (question_has_capability_on($question, 'edit') ||
|
||||
question_has_capability_on($question, 'move')) {
|
||||
if (question_has_capability_on($question, 'edit')) {
|
||||
$this->print_icon('t/edit', $this->stredit, $this->qbank->edit_question_url($question->id));
|
||||
} else {
|
||||
} else if (question_has_capability_on($question, 'view')) {
|
||||
$this->print_icon('i/info', $this->strview, $this->qbank->edit_question_url($question->id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user