ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTimerDetector Class Reference

@noinspection PhpIncludeInspection More...

+ Inheritance diagram for ilTimerDetector:
+ Collaboration diagram for ilTimerDetector:

Public Member Functions

 __construct ($context)
 Default constructor, passing the context to the parent constructor. More...
 
 setTimerStart ($timer_start)
 Sets the timers start datetime. More...
 
 getTimerStart ()
 Returns the currently set timer start. More...
 
 setTimerLimit ($timer_limit)
 Sets the timers limit. More...
 
 getTimerLimit ()
 Returns the currently set timers limit. More...
 
 trigger ($params)
 Trigger this detector. More...
 
 isListening ()
 Returns if the detector is currently listening. More...
 
 setListeningTimeframe ($listening_start, $listening_end)
 Sets the timeframe, in which the detector is listening. More...
 
 onActivate ()
 Method called on activation. More...
 
 onDeactivate ()
 Method called on deactivation. More...
 
 setDbId ($a_id)
 Sets the database id of the detector. More...
 
 getDbId ()
 Returns the database id of the detector if set. More...
 
 hasDbId ()
 Returns, if the detector has a database id. More...
 
 writeDetectorToDb ()
 Passes this detector to the ilWorkflowDBHelper in order to write or update the detector data to the database. More...
 
 deleteDetectorFromDb ()
 Passes this detector to the ilWorkflowDbHelper in order to remove the detector data from the database. More...
 
 getEvent ()
 Returns the event type and content currently set to the detector. More...
 
 getEventSubject ()
 Get the event subject set to the detector. More...
 
 getEventContext ()
 Get the event context set to the detector. More...
 
 getListeningTimeframe ()
 Returns the listening timefrage of the detector. More...
 
 isTimerRelative ()
 
 setTimerRelative ($timer_relative)
 
- Public Member Functions inherited from ilSimpleDetector
 __construct (ilNode $context)
 Default constructor. More...
 
 getContext ()
 Returns the parent object. More...
 
 trigger ($params)
 Trigger this detector. More...
 
 getDetectorState ()
 Returns if the current detector state is satisfied or not. More...
 
 setDetectorState ($new_state)
 Sets a new detector state. More...
 
 onActivate ()
 Method is called, when the parent node is activated. More...
 
 onDeactivate ()
 Method is called, when the parent node is deactivated. More...
 
 getActivated ()
 
 setName ($name)
 
 getName ()
 
 getSourceNode ()
 
 setSourceNode ($source_node)
 
 trigger ($params)
 
 getDetectorState ()
 
 onActivate ()
 
 onDeactivate ()
 
 getContext ()
 This method returns the context of the element. More...
 
 setName ($name)
 
 getName ()
 
 setDbId ($a_id)
 
 getDbId ()
 
 hasDbId ()
 
 writeDetectorToDb ()
 
 deleteDetectorFromDb ()
 
 isListening ()
 
 getListeningTimeframe ()
 
 setListeningTimeframe ($listening_start, $listening_end)
 
 getEvent ()
 
 getEventSubject ()
 
 getEventContext ()
 

Private Attributes

 $event_type = 'time_passed'
 Holds the type of the event to listen for. More...
 
 $event_content = 'time_passed'
 
 $event_subject_type = 'none'
 
 $event_subject_identifier = '0'
 
 $event_context_type = 'none'
 
 $event_context_identifier = '0'
 
 $timer_relative
 
 $timer_start = 0
 
 $timer_limit = 0
 
 $listening_start = 0
 
 $listening_end = 0
 
 $db_id = null
 

Additional Inherited Members

- Protected Attributes inherited from ilSimpleDetector
 $name
 
 $source_node
 

Detailed Description

@noinspection PhpIncludeInspection

@noinspection PhpIncludeInspection ilTimerDetector is part of the petri net based workflow engine.

This detector implements a timer-feature. It has a start (date)time and a time limit.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 20 of file class.ilTimerDetector.php.

Constructor & Destructor Documentation

◆ __construct()

ilTimerDetector::__construct (   $context)

Default constructor, passing the context to the parent constructor.

Parameters
ilNode$context

Definition at line 88 of file class.ilTimerDetector.php.

89 {
90 parent::__construct($context);
91 }

References ilSimpleDetector\$context.

Member Function Documentation

◆ deleteDetectorFromDb()

ilTimerDetector::deleteDetectorFromDb ( )

Passes this detector to the ilWorkflowDbHelper in order to remove the detector data from the database.

Implements ilExternalDetector.

Definition at line 284 of file class.ilTimerDetector.php.

285 {
286 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
287 ilWorkflowDbHelper::deleteDetector($this);
288 }

Referenced by onDeactivate().

+ Here is the caller graph for this function:

◆ getDbId()

ilTimerDetector::getDbId ( )

Returns the database id of the detector if set.

Returns
integer

Implements ilExternalDetector.

Definition at line 246 of file class.ilTimerDetector.php.

247 {
248 if ($this->db_id != null) {
249 return $this->db_id;
250 } else {
251 require_once './Services/WorkflowEngine/exceptions/ilWorkflowObjectStateException.php';
252 throw new ilWorkflowObjectStateException('No database ID set.');
253 }
254 }
@noinspection PhpIncludeInspection

References $db_id.

◆ getEvent()

ilTimerDetector::getEvent ( )

Returns the event type and content currently set to the detector.

Returns
array array('type' => $this->event_type, 'content' => $this->event_content)

Implements ilExternalDetector.

Definition at line 295 of file class.ilTimerDetector.php.

296 {
297 return array('type' => $this->event_type, 'content' => $this->event_content);
298 }

◆ getEventContext()

ilTimerDetector::getEventContext ( )

Get the event context set to the detector.

Returns
array array('type' => $this->event_context_type, 'identifier' => $this->event_context_identifier)

Implements ilExternalDetector.

Definition at line 315 of file class.ilTimerDetector.php.

316 {
317 return array('type' => $this->event_context_type, 'identifier' => $this->event_context_identifier);
318 }

◆ getEventSubject()

ilTimerDetector::getEventSubject ( )

Get the event subject set to the detector.

Returns
array array('type' => $this->event_subject_type, 'identifier' => $this->event_subject_identifier)

Implements ilExternalDetector.

Definition at line 305 of file class.ilTimerDetector.php.

306 {
307 return array('type' => $this->event_subject_type, 'identifier' => $this->event_subject_identifier);
308 }

◆ getListeningTimeframe()

ilTimerDetector::getListeningTimeframe ( )

Returns the listening timefrage of the detector.

Returns
array array ('listening_start' => $this->listening_start, 'listening_end' => $this->listening_end)

Implements ilExternalDetector.

Definition at line 324 of file class.ilTimerDetector.php.

325 {
326 return array('listening_start' => $this->listening_start, 'listening_end' => $this->listening_end);
327 }

◆ getTimerLimit()

ilTimerDetector::getTimerLimit ( )

Returns the currently set timers limit.

Returns
integer Seconds of the timers limit.

Definition at line 128 of file class.ilTimerDetector.php.

129 {
130 return $this->timer_limit;
131 }

References $timer_limit.

◆ getTimerStart()

ilTimerDetector::getTimerStart ( )

Returns the currently set timer start.

Returns
integer Unix timestamp of the timers start.

Definition at line 108 of file class.ilTimerDetector.php.

109 {
110 return $this->timer_start;
111 }

References $timer_start.

◆ hasDbId()

ilTimerDetector::hasDbId ( )

Returns, if the detector has a database id.

Returns
boolean If a database id is set.

Implements ilExternalDetector.

Definition at line 261 of file class.ilTimerDetector.php.

262 {
263 if ($this->db_id == null) {
264 return false;
265 }
266
267 return true;
268 }

◆ isListening()

ilTimerDetector::isListening ( )

Returns if the detector is currently listening.

Returns
boolean

Implements ilExternalDetector.

Definition at line 161 of file class.ilTimerDetector.php.

162 {
163 // No listening phase = always listening.
164 if ($this->listening_start == 0 && $this->listening_end == 0) {
165 return true;
166 }
167
168 // Listening started?
169 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
170 if ($this->listening_start < ilWorkflowUtils::time()) {
171 // Listening not ended or infinite?
172 if ($this->listening_end > ilWorkflowUtils::time()
173 || $this->listening_end == 0) {
174 return true;
175 }
176 }
177
178 return false;
179 }

◆ isTimerRelative()

ilTimerDetector::isTimerRelative ( )
Returns
bool

Definition at line 332 of file class.ilTimerDetector.php.

333 {
335 }

References $timer_relative.

◆ onActivate()

ilTimerDetector::onActivate ( )

Method called on activation.

Reimplemented from ilSimpleDetector.

Definition at line 204 of file class.ilTimerDetector.php.

205 {
206 if ($this->timer_relative) {
207 if ($this->timer_start == 0) {
208 $this->listening_start = time();
209 } else {
210 $this->listening_start = $this->timer_start;
211 }
212 if ($this->timer_limit != 0) {
213 $this->listening_end = $this->listening_start + $this->timer_limit;
214 } else {
215 $this->listening_end = 0;
216 }
217 }
218 $this->setDetectorState(false);
219 $this->writeDetectorToDb();
220 }
setDetectorState($new_state)
Sets a new detector state.
writeDetectorToDb()
Passes this detector to the ilWorkflowDBHelper in order to write or update the detector data to the d...

References $timer_limit, $timer_start, ilSimpleDetector\setDetectorState(), and writeDetectorToDb().

+ Here is the call graph for this function:

◆ onDeactivate()

ilTimerDetector::onDeactivate ( )

Method called on deactivation.

Reimplemented from ilSimpleDetector.

Definition at line 225 of file class.ilTimerDetector.php.

226 {
227 $this->setDetectorState(false);
228 $this->deleteDetectorFromDb();
229 }
deleteDetectorFromDb()
Passes this detector to the ilWorkflowDbHelper in order to remove the detector data from the database...

References deleteDetectorFromDb(), and ilSimpleDetector\setDetectorState().

+ Here is the call graph for this function:

◆ setDbId()

ilTimerDetector::setDbId (   $a_id)

Sets the database id of the detector.

Parameters
integer$a_id

Implements ilExternalDetector.

Definition at line 236 of file class.ilTimerDetector.php.

237 {
238 $this->db_id = $a_id;
239 }

◆ setListeningTimeframe()

ilTimerDetector::setListeningTimeframe (   $listening_start,
  $listening_end 
)

Sets the timeframe, in which the detector is listening.

Parameters
integer$listening_startUnix timestamp start of listening period.
integer$listening_endUnix timestamp end of listening period.
Exceptions

ilWorkflowInvalidArgumentException

Implements ilExternalDetector.

Definition at line 189 of file class.ilTimerDetector.php.

190 {
191 $this->listening_start = $listening_start;
192
193 if ($this->listening_start > $listening_end && $listening_end != 0) {
194 require_once './Services/WorkflowEngine/exceptions/ilWorkflowInvalidArgumentException.php';
195 throw new ilWorkflowInvalidArgumentException('Listening timeframe is (start vs. end) is invalid.');
196 }
197
198 $this->listening_end = $listening_end;
199 }

References $listening_end, and $listening_start.

◆ setTimerLimit()

ilTimerDetector::setTimerLimit (   $timer_limit)

Sets the timers limit.

Parameters
integer$timer_limitSeconds of the timers runtime.

Definition at line 118 of file class.ilTimerDetector.php.

119 {
120 $this->timer_limit = (int) $timer_limit;
121 }

References $timer_limit.

◆ setTimerRelative()

ilTimerDetector::setTimerRelative (   $timer_relative)
Parameters
bool$timer_relative

Definition at line 340 of file class.ilTimerDetector.php.

341 {
342 $this->timer_relative = $timer_relative;
343 }

References $timer_relative.

◆ setTimerStart()

ilTimerDetector::setTimerStart (   $timer_start)

Sets the timers start datetime.

Parameters
integer$timer_startUnix timestamp.

Definition at line 98 of file class.ilTimerDetector.php.

99 {
100 $this->timer_start = (int) $timer_start;
101 }

References $timer_start.

◆ trigger()

ilTimerDetector::trigger (   $params)

Trigger this detector.

Params are an array. These are part of the interface but ignored here.

Todo:
Handle ignored $params.
Parameters
array$params
Returns
boolean False, if detector was already satisfied before.

Reimplemented from ilSimpleDetector.

Definition at line 143 of file class.ilTimerDetector.php.

144 {
145 if ($this->getDetectorState() == true) {
146 return false;
147 }
148
149 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
150 if ($this->timer_limit + $this->timer_start <= ilWorkflowUtils::time()) {
151 $this->setDetectorState(true);
152 }
153 return true;
154 }
getDetectorState()
Returns if the current detector state is satisfied or not.

References ilSimpleDetector\getDetectorState(), and ilSimpleDetector\setDetectorState().

+ Here is the call graph for this function:

◆ writeDetectorToDb()

ilTimerDetector::writeDetectorToDb ( )

Passes this detector to the ilWorkflowDBHelper in order to write or update the detector data to the database.

Implements ilExternalDetector.

Definition at line 274 of file class.ilTimerDetector.php.

275 {
276 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
277 ilWorkflowDbHelper::writeDetector($this);
278 }

Referenced by onActivate().

+ Here is the caller graph for this function:

Field Documentation

◆ $db_id

ilTimerDetector::$db_id = null
private

Definition at line 81 of file class.ilTimerDetector.php.

Referenced by getDbId().

◆ $event_content

string ilTimerDetector::$event_content = 'time_passed'
private

Definition at line 33 of file class.ilTimerDetector.php.

◆ $event_context_identifier

ilTimerDetector::$event_context_identifier = '0'
private

Definition at line 45 of file class.ilTimerDetector.php.

◆ $event_context_type

string ilTimerDetector::$event_context_type = 'none'
private

Definition at line 42 of file class.ilTimerDetector.php.

◆ $event_subject_identifier

ilTimerDetector::$event_subject_identifier = '0'
private

Definition at line 39 of file class.ilTimerDetector.php.

◆ $event_subject_type

string ilTimerDetector::$event_subject_type = 'none'
private

Definition at line 36 of file class.ilTimerDetector.php.

◆ $event_type

string ilTimerDetector::$event_type = 'time_passed'
private

Holds the type of the event to listen for.

In case of this detector class, it is set up to listen to a default 'time passed' event. It has no means of modifying it.

See also
class.ilEventDetector for detailed information on these values.

Definition at line 30 of file class.ilTimerDetector.php.

◆ $listening_end

ilTimerDetector::$listening_end = 0
private

Definition at line 74 of file class.ilTimerDetector.php.

Referenced by setListeningTimeframe().

◆ $listening_start

ilTimerDetector::$listening_start = 0
private

Definition at line 68 of file class.ilTimerDetector.php.

Referenced by setListeningTimeframe().

◆ $timer_limit

ilTimerDetector::$timer_limit = 0
private

Definition at line 62 of file class.ilTimerDetector.php.

Referenced by getTimerLimit(), onActivate(), and setTimerLimit().

◆ $timer_relative

ilTimerDetector::$timer_relative
private

Definition at line 48 of file class.ilTimerDetector.php.

Referenced by isTimerRelative(), and setTimerRelative().

◆ $timer_start

ilTimerDetector::$timer_start = 0
private

Definition at line 55 of file class.ilTimerDetector.php.

Referenced by getTimerStart(), onActivate(), and setTimerStart().


The documentation for this class was generated from the following file: