SHINDIG-1058 by Jinhui Du - Finishing 0.9 messaging changes & adds unit tests
[shindig.git] / php / src / social / model / Message.php
bloba18f6664de3a84d1d9ede36b608d1324f4ad0eb2
1 <?php
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
21 /**
22 * see
23 * http://opensocial-resources.googlecode.com/svn/spec/draft/OpenSocial-Specification.xml#opensocial.Message.Field
25 class Message {
26 // These fields should be referenced via getters and setters. 'public' only for json_encode.
27 public $appUrl;
28 public $body;
29 public $bodyId;
30 public $collectionIds;
31 public $id;
32 public $inReplyTo;
33 public $recipients;
34 public $replies;
35 public $senderId;
36 public $status;
37 public $timeSent;
38 public $title;
39 public $titleId;
40 public $type;
41 public $updated;
42 public $urls;
44 public static $DEFAULT_FIELDS = array('appUrl', 'body', 'bodyId',
45 'collectionIds', 'id', 'inReplyTo', 'recipients', 'replies',
46 'senderId', 'status', 'timeSent', 'title', 'titleId', 'type',
47 'updated', 'urls');
49 public static $TYPES = array(
50 /* An email */
51 'EMAIL',
52 /* A short private message */
53 'NOTIFICATION',
54 /* A message to a specific user that can be seen only by that user */
55 'PRIVATE_MESSAGE',
56 /* A message to a specific user that can be seen by more than that user */
57 'PUBLIC_MESSAGE');
59 public static $STATUS = array('NEW', 'READ', 'DELETED');
61 public function __construct($id, $title) {
62 $this->setId($id);
63 $this->setTitle($title);
66 public function getAppUrl() {
67 return $this->appUrl;
70 public function setAppUrl($url) {
71 $this->url = $url;
74 public function getBody() {
75 return $this->body;
78 public function setBody($body) {
79 $this->body = $body;
82 public function getBodyId() {
83 return $this->bodyId;
86 public function setBodyId($bodyId) {
87 $this->bodyId = $bodyId;
90 public function getCollectionIds() {
91 return $this->collectionIds;
94 public function setCollectionIds($collectionIds) {
95 $this->$collectionIds = $collectionIds;
98 public function getId() {
99 return $this->id;
102 public function setId($id) {
103 $this->id = $id;
106 public function getInReplyTo() {
107 return $this->inReplyTo;
110 public function setInReplyTo($inReplyTo) {
111 $this->inReplyTo = $inReplyTo;
114 public function getRecipients() {
115 return $this->recipients;
118 public function setRecipients($recipients) {
119 $this->recipients = $recipients;
122 public function getReplies() {
123 return $this->replies;
126 public function setReplies($replies) {
127 $this->replies = $replies;
130 public function getStatus() {
131 return $this->status;
134 public function setStatus($status) {
135 $this->status = $status;
138 public function getSenderId() {
139 return $this->senderId;
142 public function setSenderId($senderId) {
143 $this->senderId = $senderId;
146 public function getTimeSent() {
147 return $this->timeSent;
150 public function setTimeSent($timeSent) {
151 $this->timeSent = $timeSent;
154 public function getTitle() {
155 return $this->title;
158 public function setTitle($title) {
159 $this->title = $title;
162 public function getTitleId() {
163 return $this->titleId;
166 public function setTitleId($titleId) {
167 $this->titleId = $titleId;
170 public function getType() {
171 return $this->type;
174 public function setType($type) {
175 $this->type = $type;
178 public function getUpdated() {
179 return $this->updated;
182 public function setUpdated($updated) {
183 $this->updated = $updated;
187 * Gets the URLs related to the message
188 * @return the URLs related to the person, their webpages, or feeds
190 public function getUrls() {
191 return $this->urls;
195 * Sets the URLs related to the message
196 * @param urls the URLs related to the person, their webpages, or feeds
198 public function setUrls($urls) {
199 $this->urls = $urls;
203 * TODO implement either a standard 'sanitizing' facility or
204 * define an interface that can be set on this class so
205 * others can plug in their own.
206 * @param htmlStr String to be sanitized.
207 * @return the sanitized HTML String
209 public function sanitizeHTML($htmlStr) {
210 return $htmlStr;