From: moodler Date: Tue, 28 Dec 2004 16:34:13 +0000 (+0000) Subject: First quick go at a Messages block. Needs polishing but seems to work. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bc8ccf6b188805107a28fb58cbbad826e9c26146;p=moodle.git First quick go at a Messages block. Needs polishing but seems to work. --- diff --git a/blocks/messages/block_messages.php b/blocks/messages/block_messages.php new file mode 100644 index 0000000000..b070f93e5f --- /dev/null +++ b/blocks/messages/block_messages.php @@ -0,0 +1,62 @@ +title = get_string('messages','message'); + $this->content_type = BLOCK_TYPE_TEXT; + $this->version = 2004122800; + } + + function get_content() { + global $USER, $CFG; + + if ($this->content !== NULL) { + return $this->content; + } + + $this->content = new stdClass; + $this->content->text = ''; + $this->content->footer = ''.get_string('messages', 'message').'...'; + + if (empty($this->instance) or empty($USER->id)) { + return $this->content; + } + + + $users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count, + u.firstname, u.lastname, u.picture + FROM {$CFG->prefix}user u, + {$CFG->prefix}message m + WHERE m.useridto = '$USER->id' + AND u.id = m.useridfrom + GROUP BY m.useridfrom"); + + + //Now, we have in users, the list of users to show + //Because they are online + if (!empty($users)) { + foreach ($users as $user) { + $this->content->text .= '
'; + if ($user->picture) { + if ($CFG->slasharguments) { + $imgtag = ' '; + } else { + $imgtag = ' '; + } + $this->content->text .= $imgtag; + } else { + $this->content->text .= ' '; + } + $this->content->text .= ''.fullname($user).''; + $this->content->text .= '  '.$user->count.''; + $this->content->text .= '
'; + } + } else { + $this->content->text .= "
".get_string("nomessages")."
"; + } + + return $this->content; + } +} + +?> diff --git a/lang/en/message.php b/lang/en/message.php index c2f0707611..4fa3876e55 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -17,6 +17,7 @@ $string['messaging'] = 'Messaging'; $string['mycontacts'] = 'My Contacts'; $string['newsearch'] = 'New search'; $string['nosearchresults'] = 'There were no results from your search'; +$string['nomessages'] = 'No messages waiting'; $string['offlinecontacts'] = 'Offline Contacts ($a)'; $string['onlinecontacts'] = 'Online Contacts ($a)'; $string['onlyfromme'] = 'Only messages from me';