~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to mod/chat/users.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
include("../../config.php");
4
 
include("lib.php");
5
 
 
6
 
require_variable($chat_sid);
7
 
optional_variable($groupid, 0);
8
 
 
9
 
if (!$chatuser = get_record("chat_users", "sid", $chat_sid)) {
10
 
    echo "Not logged in!";
11
 
    die;
12
 
}
13
 
 
14
 
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
15
 
    error("No chat found");
16
 
}
17
 
 
18
 
require_login($chat->course);
19
 
 
20
 
 
21
 
if (!$chat = get_record("chat", "id", $chatuser->chatid)) {
22
 
    error("Could not find chat! id = $chatuser->chatid");
23
 
}
24
 
 
25
 
if (isset($_GET['chat_enter'])) {
26
 
    $message->chatid = $chatuser->chatid;
27
 
    $message->userid = $chatuser->userid;
28
 
    $message->groupid = $groupid;
29
 
    $message->message = "enter";
30
 
    $message->system = 1;
31
 
    $message->timestamp = time();
32
 
 
33
 
    if (!insert_record("chat_messages", $message)) {
34
 
        error("Could not insert a chat message!");
35
 
    }
36
 
}
37
 
 
38
 
if (isset($_GET['beep'])) {
39
 
    $message->chatid = $chatuser->chatid;
40
 
    $message->userid = $chatuser->userid;
41
 
    $message->groupid = $groupid;
42
 
    $message->message = "beep $beep";
43
 
    $message->system = 0;
44
 
    $message->timestamp = time();
45
 
 
46
 
    if (!insert_record("chat_messages", $message)) {
47
 
        error("Could not insert a chat message!");
48
 
    }
49
 
 
50
 
    $chatuser->lastmessageping = time();          // A beep is a ping  ;-)
51
 
    update_record("chat_users", $chatuser);
52
 
}
53
 
 
54
 
$chatuser->lastping = time();
55
 
update_record("chat_users", $chatuser);
56
 
 
57
 
/// Delete users who are using text version and are old
58
 
 
59
 
chat_delete_old_users();
60
 
 
61
 
 
62
 
/// Print headers
63
 
 
64
 
header("Expires: Wed, 4 Oct 1978 09:32:45 GMT");
65
 
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
66
 
header("Cache-Control: no-cache, must-revalidate");
67
 
header("Pragma: no-cache");
68
 
header("Content-Type: text/html");
69
 
header("Refresh: $CFG->chat_refresh_userlist; URL=users.php?chat_sid=$chat_sid&groupid=$groupid");
70
 
 
71
 
print_header();
72
 
 
73
 
$timenow = time();
74
 
 
75
 
$stridle   = get_string("idle", "chat");
76
 
$strbeep   = get_string("beep", "chat");
77
 
$str->day   = get_string("day");
78
 
$str->days  = get_string("days");
79
 
$str->hour  = get_string("hour");
80
 
$str->hours = get_string("hours");
81
 
$str->min   = get_string("min");
82
 
$str->mins  = get_string("mins");
83
 
$str->sec   = get_string("sec");
84
 
$str->secs  = get_string("secs");
85
 
 
86
 
/// Get list of users
87
 
 
88
 
if (!$chatusers = chat_get_users($chatuser->chatid, $groupid)) {
89
 
    print_string("errornousers", "chat");
90
 
    exit;
91
 
}
92
 
 
93
 
 
94
 
echo "<table width=\"100%\">";
95
 
foreach ($chatusers as $chatuser) {
96
 
    $lastping = $timenow - $chatuser->lastmessageping;
97
 
    echo "<tr><td width=35>";
98
 
    echo "<a target=\"_new\" onClick=\"return openpopup('/user/view.php?id=$chatuser->id&course=$chat->course','user$chatuser->id','');\" href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&course=$chat->course\">";
99
 
    print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false);
100
 
    echo "</a></td><td valign=center>";
101
 
    echo "<p><font size=1>";
102
 
    echo fullname($chatuser)."<br />";
103
 
    echo "<font color=\"#888888\">$stridle: ".format_time($lastping, $str)."</font>";
104
 
    echo " <a href=\"users.php?chat_sid=$chat_sid&beep=$chatuser->id&groupid=$groupid\">$strbeep</a>";
105
 
    echo "</font></p>";
106
 
    echo "<td></tr>";
107
 
}
108
 
echo "</table>";
109
 
 
110
 
?>