ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 300 of file class.ilTimerDetector.php.

301 {
302 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
303 ilWorkflowDbHelper::deleteDetector($this);
304 }

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 258 of file class.ilTimerDetector.php.

259 {
260 if ($this->db_id != null)
261 {
262 return $this->db_id;
263 }
264 else
265 {
266 require_once './Services/WorkflowEngine/exceptions/ilWorkflowObjectStateException.php';
267 throw new ilWorkflowObjectStateException('No database ID set.');
268 }
269 }
@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 311 of file class.ilTimerDetector.php.

312 {
313 return array('type' => $this->event_type, 'content' => $this->event_content);
314 }

◆ 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 331 of file class.ilTimerDetector.php.

332 {
333 return array('type' => $this->event_context_type, 'identifier' => $this->event_context_identifier);
334 }

◆ 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 321 of file class.ilTimerDetector.php.

322 {
323 return array('type' => $this->event_subject_type, 'identifier' => $this->event_subject_identifier);
324 }

◆ 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 340 of file class.ilTimerDetector.php.

341 {
342 return array ('listening_start' => $this->listening_start, 'listening_end' => $this->listening_end);
343 }

◆ 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 276 of file class.ilTimerDetector.php.

277 {
278 if ($this->db_id == null)
279 {
280 return false;
281 }
282
283 return true;
284 }

◆ isListening()

ilTimerDetector::isListening ( )

Returns if the detector is currently listening.

Returns
boolean

Implements ilExternalDetector.

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

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

◆ isTimerRelative()

ilTimerDetector::isTimerRelative ( )
Returns
bool

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

349 {
351 }

References $timer_relative.

◆ onActivate()

ilTimerDetector::onActivate ( )

Method called on activation.

Reimplemented from ilSimpleDetector.

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

211 {
212 if($this->timer_relative)
213 {
214 if($this->timer_start == 0)
215 {
216 $this->listening_start = time();
217 }
218 else
219 {
220 $this->listening_start = $this->timer_start;
221 }
222 if($this->timer_limit != 0)
223 {
224 $this->listening_end = $this->listening_start + $this->timer_limit;
225 }
226 else
227 {
228 $this->listening_end = 0;
229 }
230 }
231 $this->setDetectorState(false);
232 $this->writeDetectorToDb();
233 }
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 238 of file class.ilTimerDetector.php.

238 {
239 $this->setDetectorState(false);
240 $this->deleteDetectorFromDb();
241 }
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 248 of file class.ilTimerDetector.php.

249 {
250 $this->db_id = $a_id;
251 }

◆ 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 194 of file class.ilTimerDetector.php.

195 {
196 $this->listening_start = $listening_start;
197
198 if ($this->listening_start > $listening_end && $listening_end != 0)
199 {
200 require_once './Services/WorkflowEngine/exceptions/ilWorkflowInvalidArgumentException.php';
201 throw new ilWorkflowInvalidArgumentException('Listening timeframe is (start vs. end) is invalid.');
202 }
203
204 $this->listening_end = $listening_end;
205 }

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 356 of file class.ilTimerDetector.php.

357 {
358 $this->timer_relative = $timer_relative;
359 }

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 {
147 return false;
148 }
149
150 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
151 if ($this->timer_limit + $this->timer_start <= ilWorkflowUtils::time())
152 {
153 $this->setDetectorState(true);
154 }
155 return true;
156 }
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 290 of file class.ilTimerDetector.php.

291 {
292 require_once './Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
293 ilWorkflowDbHelper::writeDetector($this);
294 }

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: