2010-03-15 06:41:02 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manage user private area files
|
|
|
|
*
|
2010-07-03 13:37:13 +00:00
|
|
|
* @package block_private_files
|
2010-05-19 08:05:36 +00:00
|
|
|
* @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
|
2010-03-15 06:41:02 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
class block_private_files extends block_base {
|
|
|
|
|
|
|
|
function init() {
|
2012-02-24 14:54:20 +08:00
|
|
|
$this->title = get_string('pluginname', 'block_private_files');
|
2010-03-15 06:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function specialization() {
|
|
|
|
}
|
2010-07-19 13:21:16 +00:00
|
|
|
|
2010-03-15 06:41:02 +00:00
|
|
|
function applicable_formats() {
|
|
|
|
return array('all' => true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function instance_allow_multiple() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_content() {
|
2010-07-03 13:37:13 +00:00
|
|
|
|
2010-03-15 06:41:02 +00:00
|
|
|
if ($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
if (empty($this->instance)) {
|
|
|
|
return null;
|
|
|
|
}
|
2010-07-03 13:37:13 +00:00
|
|
|
|
2012-01-15 13:37:53 +01:00
|
|
|
$this->content = new stdClass();
|
2010-03-15 06:41:02 +00:00
|
|
|
$this->content->text = '';
|
|
|
|
$this->content->footer = '';
|
|
|
|
if (isloggedin() && !isguestuser()) { // Show the block
|
2010-09-21 08:10:17 +00:00
|
|
|
$this->content = new stdClass();
|
2010-07-03 13:37:13 +00:00
|
|
|
|
|
|
|
//TODO: add capability check here!
|
|
|
|
|
2010-07-07 05:20:46 +00:00
|
|
|
$renderer = $this->page->get_renderer('block_private_files');
|
|
|
|
$this->content->text = $renderer->private_files_tree();
|
2010-07-22 09:05:13 +00:00
|
|
|
if (has_capability('moodle/user:manageownfiles', $this->context)) {
|
2014-08-15 11:14:23 -07:00
|
|
|
$this->content->footer = html_writer::link(
|
2020-11-19 17:46:28 +01:00
|
|
|
new moodle_url('/user/files.php'),
|
|
|
|
get_string('privatefilesmanage') . '...',
|
|
|
|
['data-action' => 'manageprivatefiles']);
|
|
|
|
$this->page->requires->js_call_amd(
|
|
|
|
'core_user/private_files',
|
|
|
|
'initModal',
|
|
|
|
['[data-action=manageprivatefiles]', \core_user\form\private_files::class]
|
|
|
|
);
|
2010-07-22 09:05:13 +00:00
|
|
|
}
|
2010-03-15 06:41:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
}
|