| Línea 391... |
Línea 391... |
| 391 |
public function is_view_allowed(): bool {
|
391 |
public function is_view_allowed(): bool {
|
| 392 |
// Plugins can overwrite this method in case they want to check something related to content properties.
|
392 |
// Plugins can overwrite this method in case they want to check something related to content properties.
|
| 393 |
global $USER;
|
393 |
global $USER;
|
| 394 |
$context = \context::instance_by_id($this->get_contextid());
|
394 |
$context = \context::instance_by_id($this->get_contextid());
|
| Línea -... |
Línea 395... |
| - |
|
395 |
|
| - |
|
396 |
$displaypreference = get_user_preferences('core_contentbank_displayunlisted', 1);
|
| - |
|
397 |
|
| - |
|
398 |
if (($this->get_visibility() == self::VISIBILITY_UNLISTED) && !$displaypreference) {
|
| - |
|
399 |
return false;
|
| - |
|
400 |
}
|
| 395 |
|
401 |
|
| 396 |
return $USER->id == $this->content->usercreated ||
|
402 |
return $USER->id == $this->content->usercreated ||
|
| 397 |
$this->get_visibility() == self::VISIBILITY_PUBLIC ||
|
403 |
$this->get_visibility() == self::VISIBILITY_PUBLIC ||
|
| 398 |
has_capability('moodle/contentbank:viewunlistedcontent', $context);
|
404 |
has_capability('moodle/contentbank:viewunlistedcontent', $context);
|
| - |
|
405 |
}
|
| - |
|
406 |
|
| - |
|
407 |
/**
|
| - |
|
408 |
* Checks if there are any custom field related to this content.
|
| - |
|
409 |
*
|
| - |
|
410 |
* @return bool True if there is at least one populated field.
|
| - |
|
411 |
*/
|
| - |
|
412 |
public function has_custom_fields(): bool {
|
| - |
|
413 |
$handler = \core_contentbank\customfield\content_handler::create();
|
| - |
|
414 |
return !empty($handler->get_instance_data($this->get_id()));
|
| 399 |
}
|
415 |
}
|