|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00031 defined('MOODLE_INTERNAL') || die(); 00032 00040 class block_myprofile extends block_base { 00044 public function init() { 00045 $this->title = get_string('pluginname', 'block_myprofile'); 00046 } 00047 00053 public function get_content() { 00054 global $CFG, $USER, $DB, $OUTPUT, $PAGE; 00055 00056 if ($this->content !== NULL) { 00057 return $this->content; 00058 } 00059 00060 if (!isloggedin() or isguestuser()) { 00061 return ''; // Never useful unless you are logged in as real users 00062 } 00063 00064 $this->content = new stdClass; 00065 $this->content->text = ''; 00066 $this->content->footer = ''; 00067 00068 $course = $this->page->course; 00069 00070 if (!isset($this->config->display_picture) || $this->config->display_picture == 1) { 00071 $this->content->text .= '<div class="myprofileitem picture">'; 00072 $this->content->text .= $OUTPUT->user_picture($USER, array('courseid'=>$course->id, 'size'=>'100', 'class'=>'profilepicture')); // The new class makes CSS easier 00073 $this->content->text .= '</div>'; 00074 } 00075 00076 $this->content->text .= '<div class="myprofileitem fullname">'.fullname($USER).'</div>'; 00077 00078 if(!isset($this->config->display_country) || $this->config->display_country == 1) { 00079 $countries = get_string_manager()->get_list_of_countries(); 00080 if (isset($countries[$USER->country])) { 00081 $this->content->text .= '<div class="myprofileitem country">'; 00082 $this->content->text .= get_string('country') . ': ' . $countries[$USER->country]; 00083 $this->content->text .= '</div>'; 00084 } 00085 } 00086 00087 if(!isset($this->config->display_city) || $this->config->display_city == 1) { 00088 $this->content->text .= '<div class="myprofileitem city">'; 00089 $this->content->text .= get_string('city') . ': ' . format_string($USER->city); 00090 $this->content->text .= '</div>'; 00091 } 00092 00093 if(!isset($this->config->display_email) || $this->config->display_email == 1) { 00094 $this->content->text .= '<div class="myprofileitem email">'; 00095 $this->content->text .= obfuscate_mailto($USER->email, ''); 00096 $this->content->text .= '</div>'; 00097 } 00098 00099 if(!empty($this->config->display_icq) && !empty($USER->icq)) { 00100 $this->content->text .= '<div class="myprofileitem icq">'; 00101 $this->content->text .= 'ICQ: ' . s($USER->icq); 00102 $this->content->text .= '</div>'; 00103 } 00104 00105 if(!empty($this->config->display_skype) && !empty($USER->skype)) { 00106 $this->content->text .= '<div class="myprofileitem skype">'; 00107 $this->content->text .= 'Skype: ' . s($USER->skype); 00108 $this->content->text .= '</div>'; 00109 } 00110 00111 if(!empty($this->config->display_yahoo) && !empty($USER->yahoo)) { 00112 $this->content->text .= '<div class="myprofileitem yahoo">'; 00113 $this->content->text .= 'Yahoo: ' . s($USER->yahoo); 00114 $this->content->text .= '</div>'; 00115 } 00116 00117 if(!empty($this->config->display_aim) && !empty($USER->aim)) { 00118 $this->content->text .= '<div class="myprofileitem aim">'; 00119 $this->content->text .= 'AIM: ' . s($USER->aim); 00120 $this->content->text .= '</div>'; 00121 } 00122 00123 if(!empty($this->config->display_msn) && !empty($USER->msn)) { 00124 $this->content->text .= '<div class="myprofileitem msn">'; 00125 $this->content->text .= 'MSN: ' . s($USER->msn); 00126 $this->content->text .= '</div>'; 00127 } 00128 00129 if(!empty($this->config->display_phone1) && !empty($USER->phone1)) { 00130 $this->content->text .= '<div class="myprofileitem phone1">'; 00131 $this->content->text .= get_string('phone').': ' . s($USER->phone1); 00132 $this->content->text .= '</div>'; 00133 } 00134 00135 if(!empty($this->config->display_phone2) && !empty($USER->phone2)) { 00136 $this->content->text .= '<div class="myprofileitem phone2">'; 00137 $this->content->text .= get_string('phone').': ' . s($USER->phone2); 00138 $this->content->text .= '</div>'; 00139 } 00140 00141 if(!empty($this->config->display_institution) && !empty($USER->institution)) { 00142 $this->content->text .= '<div class="myprofileitem institution">'; 00143 $this->content->text .= format_string($USER->institution); 00144 $this->content->text .= '</div>'; 00145 } 00146 00147 if(!empty($this->config->display_address) && !empty($USER->address)) { 00148 $this->content->text .= '<div class="myprofileitem address">'; 00149 $this->content->text .= format_string($USER->address); 00150 $this->content->text .= '</div>'; 00151 } 00152 00153 if(!empty($this->config->display_firstaccess) && !empty($USER->firstaccess)) { 00154 $this->content->text .= '<div class="myprofileitem firstaccess">'; 00155 $this->content->text .= get_string('firstaccess').': ' . userdate($USER->firstaccess); 00156 $this->content->text .= '</div>'; 00157 } 00158 00159 if(!empty($this->config->display_lastaccess) && !empty($USER->lastaccess)) { 00160 $this->content->text .= '<div class="myprofileitem lastaccess">'; 00161 $this->content->text .= get_string('lastaccess').': ' . userdate($USER->lastaccess); 00162 $this->content->text .= '</div>'; 00163 } 00164 00165 if(!empty($this->config->display_currentlogin) && !empty($USER->currentlogin)) { 00166 $this->content->text .= '<div class="myprofileitem currentlogin">'; 00167 $this->content->text .= get_string('login').': ' . userdate($USER->currentlogin); 00168 $this->content->text .= '</div>'; 00169 } 00170 00171 if(!empty($this->config->display_lastip) && !empty($USER->lastip)) { 00172 $this->content->text .= '<div class="myprofileitem lastip">'; 00173 $this->content->text .= 'IP: ' . $USER->lastip; 00174 $this->content->text .= '</div>'; 00175 } 00176 00177 return $this->content; 00178 } 00179 00185 public function has_config() { 00186 return false; 00187 } 00188 00194 public function instance_allow_multiple() { 00195 //allow more than one instance on a page 00196 return false; 00197 } 00198 00204 function instance_allow_config() { 00205 //allow instances to have their own configuration 00206 return false; 00207 } 00208 00213 public function specialization() { 00214 } 00215 00221 function instance_config_print() { 00222 return false; 00223 00224 /* 00225 global $CFG; 00226 00227 $form = new block_myprofile.phpConfigForm(null, array($this->config)); 00228 $form->display(); 00229 00230 return true; 00231 */ 00232 } 00233 00239 public function applicable_formats() { 00240 return array('all'=>true); 00241 } 00242 00247 public function after_install() { 00248 } 00249 00254 public function before_delete() { 00255 } 00256 00257 }