Skip to content

Commit

Permalink
fixed some small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gustav_delius committed Dec 31, 2004
1 parent 84b3c15 commit 444f625
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
17 changes: 9 additions & 8 deletions message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ function message_print_contacts() {


/// get lists of contacts and unread messages
$onlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture
$onlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, mc.blocked
FROM {$CFG->prefix}user u, {$CFG->prefix}message_contacts mc
WHERE mc.userid='$USER->id' AND u.id=mc.contactid AND u.lastaccess>=$timefrom
AND mc.blocked='0'
ORDER BY u.lastaccess DESC");

$offlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture
$offlinecontacts = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.picture, mc.blocked
FROM {$CFG->prefix}user u, {$CFG->prefix}message_contacts mc
WHERE mc.userid='$USER->id' AND u.id=mc.contactid AND u.lastaccess<$timefrom
AND mc.blocked='0'
Expand Down Expand Up @@ -157,7 +157,7 @@ function message_print_contacts() {
/// link to add to contact list

$strcontact .= message_contact_link($messageuser->useridfrom, 'add', true);
$strblock .= message_contact_link($messageuser->useridfrom, 'block', true);
$strblock = message_contact_link($messageuser->useridfrom, 'block', true);

echo '<tr><td class="message_pic">';
print_user_picture($messageuser->useridfrom, SITEID, $messageuser->picture, 20, false, false);
Expand Down Expand Up @@ -197,7 +197,7 @@ function message_count_messages($messagearray, $field='', $value='') {


function message_print_search() {
global $USER;
global $ME, $USER;

if ($frm = data_submitted()) {

Expand Down Expand Up @@ -307,7 +307,7 @@ function message_get_contact($contactid) {


function message_print_search_results($frm) {
global $USER;
global $ME, $USER;

echo '<div align="center">';

Expand Down Expand Up @@ -591,25 +591,26 @@ function message_search_users($courseid, $searchtext, $sort='', $exceptions='')
}

$select = 'u.deleted = \'0\' AND u.confirmed = \'1\'';
$fields = 'u.id, u.firstname, u.lastname, u.picture';

if (!$courseid or $courseid == SITEID) {
return get_records_sql("SELECT u.id, u.firstname, u.lastname
return get_records_sql("SELECT $fields
FROM {$CFG->prefix}user u
WHERE $select
AND ($fullname $LIKE '%$searchtext%')
$except $order");
} else {


if (!$teachers = get_records_sql("SELECT u.id, u.firstname, u.lastname
if (!$teachers = get_records_sql("SELECT $fields
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_teachers s
WHERE $select AND s.course = '$courseid' AND s.userid = u.id
AND ($fullname $LIKE '%$searchtext%')
$except $order")) {
$teachers = array();
}
if (!$students = get_records_sql("SELECT u.id, u.firstname, u.lastname
if (!$students = get_records_sql("SELECT $fields
FROM {$CFG->prefix}user u,
{$CFG->prefix}user_students s
WHERE $select AND s.course = '$courseid' AND s.userid = u.id
Expand Down
8 changes: 6 additions & 2 deletions message/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="checkbox" name="mycourses" alt="<?php print_string('onlymycourses', 'message') ?>" /><?php print_string('onlymycourses', 'message') ?></td>
<td colspan="2">
<input type="hidden" name="mycourses" value="0" />
<input type="checkbox" name="mycourses" alt="<?php print_string('onlymycourses', 'message') ?>" /><?php print_string('onlymycourses', 'message') ?></td>
</tr>

<tr><td colspan="3"><hr /></td></tr>
Expand All @@ -32,7 +34,9 @@

<tr>
<td>&nbsp;</td>
<td colspan="2"><input type="checkbox" name="includeblocked" alt="<?php print_string('includeblockedusers', 'message') ?>" /><?php print_string('includeblockedusers', 'message') ?></td>
<td colspan="2">
<input type="hidden" name="includeblocked" value="0" />
<input type="checkbox" name="includeblocked" alt="<?php print_string('includeblockedusers', 'message') ?>" /><?php print_string('includeblockedusers', 'message') ?></td>
</tr>

<tr><td colspan="3"><input type="radio" name="keywordsoption" alt="<?php print_string('onlytome', 'message') ?>" value="tome" checked="checked" /><?php print_string('onlytome', 'message') ?></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion message/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
case 'edit': /// Print the bottom frame with the text editor

/// Check that the user is not blocking us!!
if ($contact = get_record('message_contacts', 'userid', $user->id, 'contact', $USER->id)) {
if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) {
if ($contact->blocked) {
print_heading(get_string('userisblockingyou', 'message'));
exit;
Expand Down

0 comments on commit 444f625

Please sign in to comment.