Merge branch 'MDL-77762-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE

This commit is contained in:
Sara Arjona 2023-03-30 13:45:18 +02:00
commit 3794210019
2 changed files with 18 additions and 22 deletions

View File

@ -14,16 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class containing data for a content view.
*
* @package core_contentbank
* @copyright 2020 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_contentbank\output;
use context;
use core_contentbank\content;
use core_contentbank\contenttype;
use moodle_url;
@ -180,8 +174,13 @@ class viewcontent implements renderable, templatable {
$data->editcontenturl = $editcontenturl->out(false);
}
$closeurl = new moodle_url('/contentbank/index.php', ['contextid' => $this->content->get_contextid()]);
$data->closeurl = $closeurl->out(false);
// Close/exit link for those users who can access that context.
$context = context::instance_by_id($this->content->get_contextid());
if (has_capability('moodle/contentbank:access', $context)) {
$closeurl = new moodle_url('/contentbank/index.php', ['contextid' => $context->id]);
$data->closeurl = $closeurl->out(false);
}
$data->actionmenu = $this->get_edit_actions_dropdown();
$data->heading = $this->content->get_name();
if ($this->content->get_visibility() == content::VISIBILITY_UNLISTED) {

View File

@ -54,31 +54,28 @@ along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}
}}
{{#heading}}<h2>{{heading}}</h2>{{/heading}}
{{#usercanedit}}
<div class="cb-toolbar-container container-fluid my-2">
<div class="row">
<div class="d-flex">
{{#usercanedit}}
<div class="d-flex mr-3">
<a href="{{editcontenturl}}" class="btn btn-primary" data-action="edit-content">
{{#str}}edit{{/str}}
</a>
</div>
{{/usercanedit}}
{{#actionmenu}}
<div class="ml-3">
{{> core_contentbank/contentbankmenu }}
</div>
{{/actionmenu}}
{{#actionmenu}}
<div>
{{> core_contentbank/contentbankmenu }}
</div>
{{/actionmenu}}
{{#closeurl}}
<div class="ml-auto">
<a href="{{closeurl}}" class="btn btn-secondary" data-action="close-content">
{{#str}}exit, core_contentbank{{/str}}
</a>
</div>
{{/closeurl}}
</div>
</div>
{{/usercanedit}}
{{^usercanedit}}
{{#actionmenu}}
{{> core_contentbank/contentbankmenu }}
{{/actionmenu}}
{{/usercanedit}}