Línea 155... |
Línea 155... |
155 |
* @param string $capability An optional capability to check.
|
155 |
* @param string $capability An optional capability to check.
|
156 |
* @return bool
|
156 |
* @return bool
|
157 |
* @throws \coding_exception
|
157 |
* @throws \coding_exception
|
158 |
* @throws \dml_exception
|
158 |
* @throws \dml_exception
|
159 |
*/
|
159 |
*/
|
160 |
public function can_access(\context $context = null, string $capability = ''): bool {
|
160 |
public function can_access(?\context $context = null, string $capability = ''): bool {
|
161 |
if ($capability == '') {
|
161 |
if ($capability == '') {
|
162 |
if ($this->has_course_filters()) {
|
162 |
if ($this->has_course_filters()) {
|
163 |
$capability = accessibility::get_capability_name('viewcoursetools');
|
163 |
$capability = accessibility::get_capability_name('viewcoursetools');
|
164 |
} else {
|
164 |
} else {
|
165 |
$capability = accessibility::get_capability_name('viewsystemtools');
|
165 |
$capability = accessibility::get_capability_name('viewsystemtools');
|
Línea 174... |
Línea 174... |
174 |
* @param null $context
|
174 |
* @param null $context
|
175 |
* @return bool
|
175 |
* @return bool
|
176 |
* @throws \coding_exception
|
176 |
* @throws \coding_exception
|
177 |
* @throws \dml_exception
|
177 |
* @throws \dml_exception
|
178 |
*/
|
178 |
*/
|
179 |
public function has_capability_in_context(string $capability, \context $context = null): bool {
|
179 |
public function has_capability_in_context(string $capability, ?\context $context = null): bool {
|
180 |
$coursefiltersvalid = $this->has_course_filters();
|
180 |
$coursefiltersvalid = $this->has_course_filters();
|
181 |
if ($context === null) {
|
181 |
if ($context === null) {
|
182 |
// If the filter is using a list of courses ($this->>courseids), use the system context.
|
182 |
// If the filter is using a list of courses ($this->>courseids), use the system context.
|
183 |
if ($coursefiltersvalid && !empty($this->courseid)) {
|
183 |
if ($coursefiltersvalid && !empty($this->courseid)) {
|
184 |
if (!empty($this->categoryid)) {
|
184 |
if (!empty($this->categoryid)) {
|