MDL-77762 contentbank: always provide exit button when appropriate.
If the current user can access the content bank in the context of the current item, then provide link back to it.
This commit is contained in:
@@ -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 <[email protected]>
|
||||
* @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) {
|
||||
|
||||
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user