1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Utility class for browsing of content bank files in the course context. 19 * 20 * @package repository_contentbank 21 * @copyright 2020 Mihail Geshoski <mihail@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace repository_contentbank\browser; 26 27 /** 28 * Represents the content bank browser in the course context. 29 * 30 * @package repository_contentbank 31 * @copyright 2020 Mihail Geshoski <mihail@moodle.com> 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class contentbank_browser_context_course extends contentbank_browser { 35 36 /** 37 * Constructor. 38 * 39 * @param \context_course $context The current context 40 */ 41 public function __construct(\context_course $context) { 42 $this->context = $context; 43 } 44 45 /** 46 * Define the allowed child context levels. 47 * 48 * @return int[] The array containing the relevant child context levels 49 */ 50 protected function allowed_child_context_levels(): array { 51 // The course context is the last relevant context level, therefore child context levels are not being returned. 52 return []; 53 } 54 55 /** 56 * The required condition to enable the user to view/access the content bank content in this context. 57 * 58 * @return bool Whether the user can view/access the content bank content in the context 59 */ 60 public function can_access_content(): bool { 61 // When the following conditions are met, the user would be able to share the content created in the course 62 // context level all over the site. 63 // The content from the course context level should be available to: 64 // * Every user which has capability to access the content of a given course. 65 66 return has_capability('repository/contentbank:accesscoursecontent', $this->context); 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body