MDL-65788 tool_policy: Prevent two modals rendering for guests.
[moodle.git] / blocks / myprofile / block_myprofile.php
CommitLineData
03d9401e 1<?php
03d9401e
MD
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/**
0ab727fb
PS
18 * Block displaying information about current logged-in user.
19 *
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.
03d9401e 23 *
f25a6839 24 * @package block_myprofile
03d9401e
MD
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
28 */
29
0ab727fb
PS
30defined('MOODLE_INTERNAL') || die();
31
03d9401e 32/**
0ab727fb 33 * Displays the current user's profile information.
03d9401e
MD
34 *
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
38 */
39class block_myprofile extends block_base {
40 /**
41 * block initializations
42 */
43 public function init() {
e3b53ef1 44 $this->title = get_string('pluginname', 'block_myprofile');
03d9401e
MD
45 }
46
47 /**
48 * block contents
49 *
50 * @return object
51 */
52 public function get_content() {
03d9401e
MD
53
54 if ($this->content !== NULL) {
55 return $this->content;
56 }
57
0ab727fb 58 if (!isloggedin() or isguestuser()) {
e3b53ef1
MG
59 // Only real users can access myprofile block.
60 return;
03d9401e
MD
61 }
62
e3b53ef1
MG
63 $renderable = new \block_myprofile\output\myprofile($this->config);
64 $renderer = $this->page->get_renderer('block_myprofile');
03d9401e 65
e3b53ef1
MG
66 $this->content = new stdClass();
67 $this->content->text = $renderer->render($renderable);
68 $this->content->footer = '';
03d9401e 69
03d9401e
MD
70 return $this->content;
71 }
72
73 /**
74 * allow the block to have a configuration page
75 *
76 * @return boolean
77 */
78 public function has_config() {
79 return false;
80 }
81
82 /**
83 * allow more than one instance of the block on a page
84 *
85 * @return boolean
86 */
87 public function instance_allow_multiple() {
88 //allow more than one instance on a page
89 return false;
90 }
91
92 /**
93 * allow instances to have their own configuration
94 *
95 * @return boolean
96 */
97 function instance_allow_config() {
98 //allow instances to have their own configuration
99 return false;
100 }
101
102 /**
103 * instance specialisations (must have instance allow config true)
104 *
105 */
106 public function specialization() {
107 }
108
03d9401e
MD
109 /**
110 * locations where block can be displayed
111 *
112 * @return array
113 */
114 public function applicable_formats() {
115 return array('all'=>true);
116 }
117
118 /**
119 * post install configurations
120 *
121 */
122 public function after_install() {
123 }
124
125 /**
126 * post delete configurations
127 *
128 */
129 public function before_delete() {
130 }
131
132}