bc8ccf6b |
1 | <?PHP //$Id$ |
2 | |
3 | class block_messages extends block_base { |
4 | function init() { |
5 | $this->title = get_string('messages','message'); |
6 | $this->content_type = BLOCK_TYPE_TEXT; |
7 | $this->version = 2004122800; |
8 | } |
9 | |
10 | function get_content() { |
11 | global $USER, $CFG; |
12 | |
13 | if ($this->content !== NULL) { |
14 | return $this->content; |
15 | } |
16 | |
17 | $this->content = new stdClass; |
18 | $this->content->text = ''; |
19 | $this->content->footer = '<a target="message" href="'.$CFG->wwwroot.'/message/index.php" onclick="return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'...</a>'; |
20 | |
21 | if (empty($this->instance) or empty($USER->id)) { |
22 | return $this->content; |
23 | } |
24 | |
25 | |
26 | $users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count, |
27 | u.firstname, u.lastname, u.picture |
28 | FROM {$CFG->prefix}user u, |
29 | {$CFG->prefix}message m |
30 | WHERE m.useridto = '$USER->id' |
31 | AND u.id = m.useridfrom |
32 | GROUP BY m.useridfrom"); |
33 | |
34 | |
35 | //Now, we have in users, the list of users to show |
36 | //Because they are online |
37 | if (!empty($users)) { |
38 | foreach ($users as $user) { |
39 | $this->content->text .= '<div style="text-align: left; font-size: 0.75em; padding-top: 5px;">'; |
40 | if ($user->picture) { |
41 | if ($CFG->slasharguments) { |
42 | $imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> '; |
43 | } else { |
44 | $imgtag = '<img src="'.$CFG->wwwroot.'/user/pix.php?file=/'.$user->id.'/f2.jpg" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> '; |
45 | } |
46 | $this->content->text .= $imgtag; |
47 | } else { |
48 | $this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width:16px; vertical-align: middle;" alt="" /> '; |
49 | } |
50 | $this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.fullname($user).'</a>'; |
51 | $this->content->text .= ' <a target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/user.php?id='.$user->id.'" onclick="return openpopup(\'/message/user.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img height="11" width="11" src="'.$CFG->pixpath.'/t/message.gif"> '.$user->count.'</a>'; |
52 | $this->content->text .= '</div>'; |
53 | } |
54 | } else { |
55 | $this->content->text .= "<center><font size=\"-1\">".get_string("nomessages")."</font></center>"; |
56 | } |
57 | |
58 | return $this->content; |
59 | } |
60 | } |
61 | |
62 | ?> |