. /** * Utility class for browsing of content bank files in the system context. * * @package repository_contentbank * @copyright 2020 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace repository_contentbank\browser; /** * Represents the content bank browser in the system context. * * @package repository_contentbank * @copyright 2020 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class contentbank_browser_context_system extends contentbank_browser { /** * Constructor. * * @param \context_system $context The current context */ public function __construct(\context_system $context) { $this->context = $context; } /** * Define the allowed child context levels. * * @return int[] The array containing the relevant child context levels */ protected function allowed_child_context_levels(): array { // The expected child context in the system context level is the course category context. return [\CONTEXT_COURSECAT]; } /** * The required condition to enable the user to view/access the content bank content in this context. * * @return bool Whether the user can view/access the content bank content in the context */ public function can_access_content(): bool { // When the following conditions are met, the user would be able to share the content created in the system // context level all over the site. // The content from the system context level should be available to: // * Every user that has a capability to access the 'general' content. return has_capability('repository/contentbank:accessgeneralcontent', $this->context); } }