MDL-62660 tool_dataprivacy: Add scheduled task to expire data requests
[moodle.git] / blocks / myprofile / block_myprofile.php
blobb596f15aea40d095cafec1991ebebd0f4c1ce979
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() {
53 global $CFG, $USER, $DB, $OUTPUT, $PAGE;
55 if ($this->content !== NULL) {
56 return $this->content;
59 if (!isloggedin() or isguestuser()) {
60 return ''; // Never useful unless you are logged in as real users
63 $this->content = new stdClass;
64 $this->content->text = '';
65 $this->content->footer = '';
67 $course = $this->page->course;
69 if (!isset($this->config->display_picture) || $this->config->display_picture == 1) {
70 $this->content->text .= '<div class="myprofileitem picture">';
71 $this->content->text .= $OUTPUT->user_picture($USER, array('courseid'=>$course->id, 'size'=>'100', 'class'=>'profilepicture')); // The new class makes CSS easier
72 $this->content->text .= '</div>';
75 $this->content->text .= '<div class="myprofileitem fullname">'.fullname($USER).'</div>';
77 if(!isset($this->config->display_country) || $this->config->display_country == 1) {
78 $countries = get_string_manager()->get_list_of_countries(true);
79 if (isset($countries[$USER->country])) {
80 $this->content->text .= '<div class="myprofileitem country">';
81 $this->content->text .= get_string('country') . ': ' . $countries[$USER->country];
82 $this->content->text .= '</div>';
86 if(!isset($this->config->display_city) || $this->config->display_city == 1) {
87 $this->content->text .= '<div class="myprofileitem city">';
88 $this->content->text .= get_string('city') . ': ' . format_string($USER->city);
89 $this->content->text .= '</div>';
92 if(!isset($this->config->display_email) || $this->config->display_email == 1) {
93 $this->content->text .= '<div class="myprofileitem email">';
94 $this->content->text .= obfuscate_mailto($USER->email, '');
95 $this->content->text .= '</div>';
98 if(!empty($this->config->display_icq) && !empty($USER->icq)) {
99 $this->content->text .= '<div class="myprofileitem icq">';
100 $this->content->text .= 'ICQ: ' . s($USER->icq);
101 $this->content->text .= '</div>';
104 if(!empty($this->config->display_skype) && !empty($USER->skype)) {
105 $this->content->text .= '<div class="myprofileitem skype">';
106 $this->content->text .= 'Skype: ' . s($USER->skype);
107 $this->content->text .= '</div>';
110 if(!empty($this->config->display_yahoo) && !empty($USER->yahoo)) {
111 $this->content->text .= '<div class="myprofileitem yahoo">';
112 $this->content->text .= 'Yahoo: ' . s($USER->yahoo);
113 $this->content->text .= '</div>';
116 if(!empty($this->config->display_aim) && !empty($USER->aim)) {
117 $this->content->text .= '<div class="myprofileitem aim">';
118 $this->content->text .= 'AIM: ' . s($USER->aim);
119 $this->content->text .= '</div>';
122 if(!empty($this->config->display_msn) && !empty($USER->msn)) {
123 $this->content->text .= '<div class="myprofileitem msn">';
124 $this->content->text .= 'MSN: ' . s($USER->msn);
125 $this->content->text .= '</div>';
128 if(!empty($this->config->display_phone1) && !empty($USER->phone1)) {
129 $this->content->text .= '<div class="myprofileitem phone1">';
130 $this->content->text .= get_string('phone1').': ' . s($USER->phone1);
131 $this->content->text .= '</div>';
134 if(!empty($this->config->display_phone2) && !empty($USER->phone2)) {
135 $this->content->text .= '<div class="myprofileitem phone2">';
136 $this->content->text .= get_string('phone2').': ' . s($USER->phone2);
137 $this->content->text .= '</div>';
140 if(!empty($this->config->display_institution) && !empty($USER->institution)) {
141 $this->content->text .= '<div class="myprofileitem institution">';
142 $this->content->text .= format_string($USER->institution);
143 $this->content->text .= '</div>';
146 if(!empty($this->config->display_address) && !empty($USER->address)) {
147 $this->content->text .= '<div class="myprofileitem address">';
148 $this->content->text .= format_string($USER->address);
149 $this->content->text .= '</div>';
152 if(!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) {
153 $this->content->text .= '<div class="myprofileitem firstaccess">';
154 $this->content->text .= get_string('firstaccess').': ' . userdate($USER->firstaccess);
155 $this->content->text .= '</div>';
158 if(!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) {
159 $this->content->text .= '<div class="myprofileitem lastaccess">';
160 $this->content->text .= get_string('lastaccess').': ' . userdate($USER->lastaccess);
161 $this->content->text .= '</div>';
164 if(!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) {
165 $this->content->text .= '<div class="myprofileitem currentlogin">';
166 $this->content->text .= get_string('login').': ' . userdate($USER->currentlogin);
167 $this->content->text .= '</div>';
170 if(!empty($this->config->display_lastip) && !empty($USER->lastip)) {
171 $this->content->text .= '<div class="myprofileitem lastip">';
172 $this->content->text .= 'IP: ' . $USER->lastip;
173 $this->content->text .= '</div>';
176 return $this->content;
180 * allow the block to have a configuration page
182 * @return boolean
184 public function has_config() {
185 return false;
189 * allow more than one instance of the block on a page
191 * @return boolean
193 public function instance_allow_multiple() {
194 //allow more than one instance on a page
195 return false;
199 * allow instances to have their own configuration
201 * @return boolean
203 function instance_allow_config() {
204 //allow instances to have their own configuration
205 return false;
209 * instance specialisations (must have instance allow config true)
212 public function specialization() {
216 * locations where block can be displayed
218 * @return array
220 public function applicable_formats() {
221 return array('all'=>true);
225 * post install configurations
228 public function after_install() {
232 * post delete configurations
235 public function before_delete() {