1 | <?php |
||
15 | abstract class AbstractMessage extends Model |
||
16 | { |
||
17 | use Timestamp; |
||
18 | |||
19 | /** |
||
20 | * The ID of the conversation where the event took place |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $conversation; |
||
24 | |||
25 | /** |
||
26 | * The type of the event, or null if it's a message |
||
27 | * |
||
28 | * @var string|null |
||
29 | */ |
||
30 | protected $type; |
||
31 | |||
32 | /** |
||
33 | * The status of the event |
||
34 | * |
||
35 | * Can be 'visible', 'hidden', 'deleted' or 'reported' |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $status; |
||
39 | |||
40 | /** |
||
41 | * The name of the database table used for queries |
||
42 | */ |
||
43 | const TABLE = "messages"; |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 1 | protected function assignResult($event) |
|
49 | { |
||
50 | 1 | $this->conversation = $event['conversation_to']; |
|
51 | 1 | $this->type = $event['event_type']; |
|
52 | 1 | $this->timestamp = TimeDate::fromMysql($event['timestamp']); |
|
53 | 1 | $this->status = $event['status']; |
|
54 | 1 | } |
|
55 | |||
56 | /** |
||
57 | * Get the conversation where the event took place |
||
58 | * @return Conversation |
||
59 | */ |
||
60 | public function getConversation() |
||
61 | { |
||
62 | return Conversation::get($this->conversation); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Find out whether the event is a message and not a generic conversation event |
||
67 | * (such as a rename or member join) |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | abstract public function isMessage(); |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public static function getActiveStatuses() |
|
77 | { |
||
78 | 1 | return array('visible', 'reported'); |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 1 | public static function getQueryBuilder() |
|
94 | |||
95 | /** |
||
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | 1 | protected static function chooseModelFromDatabase($id) |
|
119 | } |
||
120 |