ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
59 $this->setPriorState($this->getState());
60 }
61
62 $this->state = $state;
63 return $this;
64 }
65
69 public function getState()
70 {
71 return $this->state;
72 }
73
77 public function getPriorState()
78 {
79 return $this->prior_state;
80 }
81
85 private function setPriorState($prior_state)
86 {
87 $this->prior_state = $prior_state;
88 }
89
93 public function isOwnedByRequest()
94 {
96 }
97
102 {
103 $this->is_owned_by_request = $is_owned_by_request;
104 }
105
109 public function getBuddyUserId()
110 {
112 }
113
119 {
120 $this->buddy_user_id = $buddy_user_id;
121 return $this;
122 }
123
127 public function getUserId()
128 {
129 return $this->user_id;
130 }
131
136 public function setUserId($user_id)
137 {
138 $this->user_id = $user_id;
139 return $this;
140 }
141
145 public function getTimestamp()
146 {
147 return $this->timestamp;
148 }
149
154 public function setTimestamp($timestamp)
155 {
156 $this->timestamp = $timestamp;
157 return $this;
158 }
159
164 {
165 require_once 'Services/Contact/BuddySystem/classes/states/class.ilBuddySystemRelationStateFilterRuleFactory.php';
166 $state_filter = ilBuddySystemRelationStateFilterRuleFactory::getInstance()->getFilterRuleByRelation($this);
167 return $state_filter->getStates();
168 }
169
174 public function link()
175 {
176 if($this->getUserId() == $this->getBuddyUserId())
177 {
178 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
179 }
180
181 $this->getState()->link($this);
182 return $this;
183 }
184
189 public function unlink()
190 {
191 if($this->getUserId() == $this->getBuddyUserId())
192 {
193 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
194 }
195
196 $this->getState()->unlink($this);
197 return $this;
198 }
199
204 public function request()
205 {
206 if($this->getUserId() == $this->getBuddyUserId())
207 {
208 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
209 }
210
211 $this->getState()->request($this);
212 return $this;
213 }
214
219 public function ignore()
220 {
221 if($this->getUserId() == $this->getBuddyUserId())
222 {
223 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
224 }
225
226 $this->getState()->ignore($this);
227 return $this;
228 }
229
233 public function isLinked()
234 {
235 return $this->getState() instanceof ilBuddySystemLinkedRelationState;
236 }
237
241 public function isUnlinked()
242 {
243 return $this->getState() instanceof ilBuddySystemUnlinkedRelationState;
244 }
245
249 public function isRequested()
250 {
251 return $this->getState() instanceof ilBuddySystemRequestedRelationState;
252 }
253
257 public function isIgnored()
258 {
259 return $this->getState() instanceof ilBuddySystemIgnoredRequestRelationState;
260 }
261
265 public function wasLinked()
266 {
267 return $this->getPriorState() instanceof ilBuddySystemLinkedRelationState;
268 }
269
273 public function wasUnlinked()
274 {
275 return $this->getPriorState() instanceof ilBuddySystemUnlinkedRelationState;
276 }
277
281 public function wasRequested()
282 {
283 return $this->getPriorState() instanceof ilBuddySystemRequestedRelationState;
284 }
285
289 public function wasIgnored()
290 {
292 }
293}
Class ilBuddySystemRelation.
setIsOwnedByRequest($is_owned_by_request)
setState(ilBuddySystemRelationState $state, $remember_prior_state=true)
__construct(ilBuddySystemRelationState $state)
Interface ilBuddySystemRelationState.