-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.PM.php
75 lines (61 loc) · 1.46 KB
/
class.PM.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/* A class representing a single private message. Each message belongs to a
user.
Each message has a sender, a recipient, a date, a boolean variable indicating
whether it is read or not, a subject, a message and a message id.
The object is constructed from a string in the following format:
sender~recipient~date~isRead~subject~message~messageId
Each message is a line in a file in db/PMs based on the recipient's username:
db/PMs/<username>.dat
*/
class PM
{
private $sender;
private $recipient;
private $date;
private $read;
private $subject;
private $message;
private $messageId;
public function __construct($str)
{
$arr = explode("~",$str);
$this->messageId = $arr[0];
$this->sender = $arr[1];
$this->recipient = $arr[2];
$this->date = $arr[3];
$this->read = $arr[4];
$this->subject = $arr[5];
$this->message = $arr[6];
}
public function getMessageId()
{
return $this->messageId;
}
public function getMessage()
{
return $this->message;
}
/* Loads a User object of the user who created this message */
public function getSender()
{
return new User(file_get_contents("db/Users/".$this->sender.".dat"));
}
public function getRecipient()
{
return $this->recipient;
}
public function getDate()
{
return $this->date;
}
public function getSubject()
{
return $this->subject;
}
public function isRead()
{
return $this->read;
}
}
?>