ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBuddySystemRelation.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Contact/BuddySystem/interfaces/interface.ilBuddySystemRelationState.php';
5
11{
15 protected $is_owned_by_request = false;
16
20 protected $user_id;
21
25 protected $buddy_user_id;
26
30 protected $timestamp;
31
35 protected $state;
36
40 protected $prior_state;
41
46 {
47 $this->setState($state, false);
48 }
49
55 public function setState(ilBuddySystemRelationState $state, $remember_prior_state = true)
56 {
57 if ($remember_prior_state) {
58 $this->setPriorState($this->getState());
59 }
60
61 $this->state = $state;
62 return $this;
63 }
64
68 public function getState()
69 {
70 return $this->state;
71 }
72
76 public function getPriorState()
77 {
78 return $this->prior_state;
79 }
80
84 private function setPriorState($prior_state)
85 {
86 $this->prior_state = $prior_state;
87 }
88
92 public function isOwnedByRequest()
93 {
95 }
96
101 {
102 $this->is_owned_by_request = $is_owned_by_request;
103 }
104
108 public function getBuddyUserId()
109 {
111 }
112
118 {
119 $this->buddy_user_id = $buddy_user_id;
120 return $this;
121 }
122
126 public function getUserId()
127 {
128 return $this->user_id;
129 }
130
135 public function setUserId($user_id)
136 {
137 $this->user_id = $user_id;
138 return $this;
139 }
140
144 public function getTimestamp()
145 {
146 return $this->timestamp;
147 }
148
153 public function setTimestamp($timestamp)
154 {
155 $this->timestamp = $timestamp;
156 return $this;
157 }
158
163 {
164 require_once 'Services/Contact/BuddySystem/classes/states/class.ilBuddySystemRelationStateFilterRuleFactory.php';
165 $state_filter = ilBuddySystemRelationStateFilterRuleFactory::getInstance()->getFilterRuleByRelation($this);
166 return $state_filter->getStates();
167 }
168
173 public function link()
174 {
175 if ($this->getUserId() == $this->getBuddyUserId()) {
176 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
177 }
178
179 $this->getState()->link($this);
180 return $this;
181 }
182
187 public function unlink()
188 {
189 if ($this->getUserId() == $this->getBuddyUserId()) {
190 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
191 }
192
193 $this->getState()->unlink($this);
194 return $this;
195 }
196
201 public function request()
202 {
203 if ($this->getUserId() == $this->getBuddyUserId()) {
204 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
205 }
206
207 $this->getState()->request($this);
208 return $this;
209 }
210
215 public function ignore()
216 {
217 if ($this->getUserId() == $this->getBuddyUserId()) {
218 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
219 }
220
221 $this->getState()->ignore($this);
222 return $this;
223 }
224
228 public function isLinked()
229 {
230 return $this->getState() instanceof ilBuddySystemLinkedRelationState;
231 }
232
236 public function isUnlinked()
237 {
238 return $this->getState() instanceof ilBuddySystemUnlinkedRelationState;
239 }
240
244 public function isRequested()
245 {
246 return $this->getState() instanceof ilBuddySystemRequestedRelationState;
247 }
248
252 public function isIgnored()
253 {
254 return $this->getState() instanceof ilBuddySystemIgnoredRequestRelationState;
255 }
256
260 public function wasLinked()
261 {
262 return $this->getPriorState() instanceof ilBuddySystemLinkedRelationState;
263 }
264
268 public function wasUnlinked()
269 {
270 return $this->getPriorState() instanceof ilBuddySystemUnlinkedRelationState;
271 }
272
276 public function wasRequested()
277 {
278 return $this->getPriorState() instanceof ilBuddySystemRequestedRelationState;
279 }
280
284 public function wasIgnored()
285 {
287 }
288}
An exception for terminatinating execution or to throw for unit testing.
Class ilBuddySystemRelation.
setIsOwnedByRequest($is_owned_by_request)
setState(ilBuddySystemRelationState $state, $remember_prior_state=true)
__construct(ilBuddySystemRelationState $state)
Interface ilBuddySystemRelationState.