Merge branch 'MDL-63214-master' of git://github.com/sarjona/moodle
[moodle.git] / blocks / myprofile / block_myprofile.php
blob4b9013fa5df43e491e81104d616abbaf9ac6d9a7
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.
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/>.
17 /**
18 * Block displaying information about current logged-in user.
20 * This block can be used as anti cheating measure, you
21 * can easily check the logged-in user matches the person
22 * operating the computer.
24 * @package block_myprofile
25 * @copyright 2010 Remote-Learner.net
26 * @author Olav Jordan <olav.jordan@remote-learner.ca>
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 defined('MOODLE_INTERNAL') || die();
32 /**
33 * Displays the current user's profile information.
35 * @copyright 2010 Remote-Learner.net
36 * @author Olav Jordan <olav.jordan@remote-learner.ca>
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 class block_myprofile extends block_base {
40 /**
41 * block initializations
43 public function init() {
44 $this->title = get_string('pluginname', 'block_myprofile');
47 /**
48 * block contents
50 * @return object
52 public function get_content() {
54 if ($this->content !== NULL) {
55 return $this->content;
58 if (!isloggedin() or isguestuser()) {
59 // Only real users can access myprofile block.
60 return;
63 $renderable = new \block_myprofile\output\myprofile($this->config);
64 $renderer = $this->page->get_renderer('block_myprofile');
66 $this->content = new stdClass();
67 $this->content->text = $renderer->render($renderable);
68 $this->content->footer = '';
70 return $this->content;
73 /**
74 * allow the block to have a configuration page
76 * @return boolean
78 public function has_config() {
79 return false;
82 /**
83 * allow more than one instance of the block on a page
85 * @return boolean
87 public function instance_allow_multiple() {
88 //allow more than one instance on a page
89 return false;
92 /**
93 * allow instances to have their own configuration
95 * @return boolean
97 function instance_allow_config() {
98 //allow instances to have their own configuration
99 return false;
103 * instance specialisations (must have instance allow config true)
106 public function specialization() {
110 * locations where block can be displayed
112 * @return array
114 public function applicable_formats() {
115 return array('all'=>true);
119 * post install configurations
122 public function after_install() {
126 * post delete configurations
129 public function before_delete() {