ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilECSCategoryMappingRule Class Reference

Defines a rule for the assignment of ECS remote courses to categories. More...

+ Collaboration diagram for ilECSCategoryMappingRule:

Public Member Functions

 __construct ($a_mapping_id=0)
 Constructor. More...
 
 getMappingId ()
 get mapping id More...
 
 setContainerId ($a_id)
 set container id More...
 
 getContainerId ()
 get container id More...
 
 setDateRangeStart ($start)
 set date range start More...
 
 getDateRangeStart ()
 get date range start More...
 
 setDateRangeEnd ($end)
 set date range end More...
 
 getDateRangeEnd ()
 get date range end More...
 
 setFieldName ($a_field)
 set field name More...
 
 getFieldName ()
 get field name More...
 
 setMappingType ($a_type)
 set mapping type More...
 
 getMappingType ()
 get mapping type More...
 
 setMappingValue ($a_value)
 set mapping value More...
 
 getMappingValue ()
 get mapping value More...
 
 getMappingAsArray ()
 get mapping values as array More...
 
 setByType ($a_type)
 set mapping by type More...
 
 getByType ()
 get mapping by type More...
 
 delete ()
 delete rule More...
 
 update ()
 update More...
 
 save ()
 save More...
 
 validate ()
 validate rule More...
 
 conditionToString ()
 condition to string More...
 
 participantsToString ()
 get strong presentation of participants More...
 
 matches (array $a_matchable_content)
 Check if rule matches a specific econtent. More...
 

Data Fields

const ATTR_STRING = 1
 
const ATTR_INT = 2
 
const ATTR_ARRAY = 3
 
const TYPE_FIXED = 0
 
const TYPE_DURATION = 1
 
const TYPE_BY_TYPE = 2
 
const ERR_MISSING_VALUE = 'ecs_err_missing_value'
 
const ERR_INVALID_DATES = 'ecs_err_invalid_dates'
 
const ERR_INVALID_TYPE = 'ecs_err_invalid_type'
 
const ERR_MISSING_BY_TYPE = 'ecs_err_invalid_by_type'
 

Protected Member Functions

 setMappingId ($a_id)
 set mapping id More...
 
 matchesValue ($a_value, $a_type)
 Check if value matches. More...
 
 read ()
 Read entries. More...
 

Protected Attributes

 $db
 

Private Attributes

 $mapping_id
 
 $container_id
 
 $field_name
 
 $mapping_type
 
 $mapping_value
 
 $range_dt_start
 
 $range_dt_end
 
 $by_type
 

Detailed Description

Defines a rule for the assignment of ECS remote courses to categories.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 35 of file class.ilECSCategoryMappingRule.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCategoryMappingRule::__construct (   $a_mapping_id = 0)

Constructor.

Parameters
intmapping id

Definition at line 65 of file class.ilECSCategoryMappingRule.php.

66 {
67 global $ilDB;
68
69 $this->mapping_id = $a_mapping_id;
70
71 $this->db = $ilDB;
72 $this->read();
73 }
global $ilDB

References $ilDB, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ conditionToString()

ilECSCategoryMappingRule::conditionToString ( )

condition to string

Returns

Definition at line 362 of file class.ilECSCategoryMappingRule.php.

363 {
364 global $lng;
365
366 switch($this->getMappingType())
367 {
368 case self::TYPE_FIXED:
369
370 if($this->getFieldName() == 'part_id')
371 {
372 return $lng->txt('ecs_field_'.$this->getFieldName()).': '.$this->participantsToString();
373 }
374 return $lng->txt('ecs_field_'.$this->getFieldName()).': '.$this->getMappingValue();
375
377 include_once './Services/Calendar/classes/class.ilDatePresentation.php';
378 return $lng->txt('ecs_field_'.$this->getFieldName()).': '.ilDatePresentation::formatPeriod(
379 $this->getDateRangeStart(),
380 $this->getDateRangeEnd());
381
382 case self::TYPE_BY_TYPE:
383 return $lng->txt('type').': '.$lng->txt('obj_'.$this->getByType());
384 }
385 }
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
participantsToString()
get strong presentation of participants
global $lng
Definition: privfeed.php:40

References $lng, ilDatePresentation\formatPeriod(), getByType(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), participantsToString(), TYPE_BY_TYPE, TYPE_DURATION, and TYPE_FIXED.

+ Here is the call graph for this function:

◆ delete()

ilECSCategoryMappingRule::delete ( )

delete rule

Returns

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

247 {
248 $sta = $this->db->manipulateF('DELETE FROM ecs_container_mapping WHERE mapping_id = %s ',
249 array('integer'),
250 array($this->getMappingId())
251 );
252 }

References getMappingId().

+ Here is the call graph for this function:

◆ getByType()

ilECSCategoryMappingRule::getByType ( )

get mapping by type

Returns
string

Definition at line 237 of file class.ilECSCategoryMappingRule.php.

References $by_type.

Referenced by conditionToString(), save(), and update().

+ Here is the caller graph for this function:

◆ getContainerId()

ilECSCategoryMappingRule::getContainerId ( )

get container id

Returns

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

References $container_id.

Referenced by save(), update(), and validate().

+ Here is the caller graph for this function:

◆ getDateRangeEnd()

ilECSCategoryMappingRule::getDateRangeEnd ( )

get date range end

Returns

Definition at line 146 of file class.ilECSCategoryMappingRule.php.

147 {
148 if($this->range_dt_end)
149 {
150 return $this->range_dt_end;
151 }
152 $this->range_dt_end = $this->getDateRangeStart();
153 $this->range_dt_end->increment(IL_CAL_MONTH,6);
154 return $this->range_dt_end;
155 }
const IL_CAL_MONTH

References $range_dt_end, getDateRangeStart(), and IL_CAL_MONTH.

Referenced by conditionToString(), matchesValue(), save(), update(), and validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDateRangeStart()

ilECSCategoryMappingRule::getDateRangeStart ( )

get date range start

Returns

Definition at line 127 of file class.ilECSCategoryMappingRule.php.

128 {
129 return $this->range_dt_start ? $this->range_dt_start : new ilDate(time(),IL_CAL_UNIX);
130 }
const IL_CAL_UNIX
Class for single dates.

References IL_CAL_UNIX.

Referenced by conditionToString(), getDateRangeEnd(), matchesValue(), save(), update(), and validate().

+ Here is the caller graph for this function:

◆ getFieldName()

ilECSCategoryMappingRule::getFieldName ( )

get field name

Returns

Definition at line 171 of file class.ilECSCategoryMappingRule.php.

References $field_name.

Referenced by conditionToString(), matches(), save(), update(), and validate().

+ Here is the caller graph for this function:

◆ getMappingAsArray()

ilECSCategoryMappingRule::getMappingAsArray ( )

get mapping values as array

Returns

Definition at line 218 of file class.ilECSCategoryMappingRule.php.

219 {
220 return explode(',',$this->getMappingValue());
221 }

References getMappingValue().

Referenced by matchesValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMappingId()

ilECSCategoryMappingRule::getMappingId ( )

get mapping id

Returns

Definition at line 89 of file class.ilECSCategoryMappingRule.php.

References $mapping_id.

Referenced by delete(), read(), and update().

+ Here is the caller graph for this function:

◆ getMappingType()

ilECSCategoryMappingRule::getMappingType ( )

get mapping type

Returns

Definition at line 190 of file class.ilECSCategoryMappingRule.php.

References $mapping_type.

Referenced by conditionToString(), matchesValue(), read(), save(), update(), and validate().

+ Here is the caller graph for this function:

◆ getMappingValue()

ilECSCategoryMappingRule::getMappingValue ( )

get mapping value

Returns

Definition at line 209 of file class.ilECSCategoryMappingRule.php.

References $mapping_value.

Referenced by conditionToString(), getMappingAsArray(), participantsToString(), save(), update(), and validate().

+ Here is the caller graph for this function:

◆ matches()

ilECSCategoryMappingRule::matches ( array  $a_matchable_content)

Check if rule matches a specific econtent.

Parameters
array$a_matchable_content
Returns
bool

Definition at line 426 of file class.ilECSCategoryMappingRule.php.

427 {
428 if(isset($a_matchable_content[$this->getFieldName()]))
429 {
430 $value = $a_matchable_content[$this->getFieldName()];
431 return $this->matchesValue($value[0], $value[1]);
432 }
433 return false;
434 }
matchesValue($a_value, $a_type)
Check if value matches.

References getFieldName(), and matchesValue().

+ Here is the call graph for this function:

◆ matchesValue()

ilECSCategoryMappingRule::matchesValue (   $a_value,
  $a_type 
)
protected

Check if value matches.

Parameters
mixed$a_valueEcontent value
int$a_typeParameter type
Returns

Definition at line 442 of file class.ilECSCategoryMappingRule.php.

443 {
444 global $ilLog;
445
446
447 switch($a_type)
448 {
449 case self::ATTR_ARRAY:
450 $values = explode(',',$a_value);
451 $ilLog->write(__METHOD__.': Checking for value: '. $a_value);
452 $ilLog->write(__METHOD__.': Checking against attribute values: '. $this->getMappingValue());
453 break;
454
455 case self::ATTR_INT:
456 $ilLog->write(__METHOD__.': Checking for value: '. $a_value);
457 $ilLog->write(__METHOD__.': Checking against attribute values: '. $this->getMappingValue());
458 $values = array($a_value);
459 break;
460
462 $values = array($a_value);
463 break;
464 }
465 $values = explode(',',$a_value);
466
467 foreach($values as $value)
468 {
469 $value = trim($value);
470 switch($this->getMappingType())
471 {
472 case self::TYPE_FIXED:
473
474 foreach($this->getMappingAsArray() as $attribute_value)
475 {
476 $attribute_value = trim($attribute_value);
477 if(strcasecmp($attribute_value,$value) == 0)
478 {
479 return true;
480 }
481 }
482 break;
483
485 include_once './Services/Calendar/classes/class.ilDateTime.php';
486 $tmp_date = new ilDate($a_value,IL_CAL_UNIX);
487 return ilDateTime::_after($tmp_date,$this->getDateRangeStart()) and
488 ilDateTime::_before($tmp_date,$this->getDateRangeEnd());
489 }
490 }
491 return false;
492 }
@classDescription Date and time handling
static _after(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
getMappingAsArray()
get mapping values as array

References $ilLog, ilDateTime\_after(), ilDateTime\_before(), ATTR_ARRAY, ATTR_INT, ATTR_STRING, getDateRangeEnd(), getDateRangeStart(), getMappingAsArray(), getMappingType(), IL_CAL_UNIX, TYPE_DURATION, and TYPE_FIXED.

Referenced by matches().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ participantsToString()

ilECSCategoryMappingRule::participantsToString ( )

get strong presentation of participants

Parameters

return

Definition at line 392 of file class.ilECSCategoryMappingRule.php.

393 {
394 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
395
396 $part_string = "";
397 $part = explode(',',$this->getMappingValue());
398 $counter = 0;
399 foreach($part as $part_id)
400 {
401 if($counter++)
402 {
403 $part_string .= ', ';
404 }
405 $part_string .= '"';
406
407 $part_id_arr = explode('_', $part_id);
408 if($name = ilECSUtils::lookupParticipantName($part_id_arr[1],$part_id_arr[0]))
409 {
410 $part_string .= $name;
411 }
412 else
413 {
414 $part_string .= $part_id;
415 }
416 $part_string .= '"';
417 }
418 return $part_string;
419 }
static lookupParticipantName($a_owner, $a_server_id)
Lookup participant name.

References getMappingValue(), and ilECSUtils\lookupParticipantName().

Referenced by conditionToString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilECSCategoryMappingRule::read ( )
protected

Read entries.

Returns

Definition at line 498 of file class.ilECSCategoryMappingRule.php.

499 {
500 if(!$this->getMappingId())
501 {
502 return false;
503 }
504 $res = $this->db->queryF('SELECT * FROM ecs_container_mapping WHERE mapping_id = %s',
505 array('integer'),
506 array($this->getMappingId())
507 );
508 while($row = $this->db->fetchObject($res))
509 {
510 $this->setMappingId($row->mapping_id);
511 $this->setDateRangeStart($row->date_range_start ? new ilDate($row->date_range_start,IL_CAL_UNIX) : null);
512 $this->setDateRangeEnd($row->date_range_end ? new ilDate($row->date_range_end,IL_CAL_UNIX) : null);
513 $this->setMappingType($row->mapping_type);
514 $this->setFieldName($row->field_name);
515 $this->setContainerId($row->container_id);
516
517 if($this->getMappingType() == self::TYPE_BY_TYPE)
518 {
519 $this->setByType($row->mapping_value);
520 }
521 else
522 {
523 $this->setMappingValue($row->mapping_value);
524 }
525
526 }
527 return true;
528 }
setDateRangeStart($start)
set date range start
setByType($a_type)
set mapping by type
setMappingValue($a_value)
set mapping value

References $res, $row, getMappingId(), getMappingType(), IL_CAL_UNIX, setByType(), setContainerId(), setDateRangeEnd(), setDateRangeStart(), setFieldName(), setMappingId(), setMappingType(), and setMappingValue().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilECSCategoryMappingRule::save ( )

save

Returns

Definition at line 294 of file class.ilECSCategoryMappingRule.php.

295 {
296 global $ilDB;
297
298 if($this->getMappingType() == self::TYPE_BY_TYPE)
299 {
300 $mapping_value = $this->getByType();
301 }
302 else
303 {
305 }
306
307 $mapping_id = $ilDB->nextId('ecs_container_mapping');
308 $sta = $this->db->manipulateF(
309 'INSERT INTO ecs_container_mapping '.
310 '(mapping_id,container_id,field_name,mapping_type,mapping_value,date_range_start,date_range_end) '.
311 'VALUES(%s,%s,%s,%s,%s,%s,%s) ',
312 array('integer','integer','text','integer','text','integer','integer'),
313 array(
315 $this->getContainerId(),
316 $this->getFieldName(),
317 $this->getMappingType(),
319 $this->getDateRangeStart()->get(IL_CAL_UNIX),
320 $this->getDateRangeEnd()->get(IL_CAL_UNIX))
321 );
322 }

References $ilDB, $mapping_id, $mapping_value, getByType(), getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ setByType()

ilECSCategoryMappingRule::setByType (   $a_type)

set mapping by type

Parameters
string$typeMapping type
Returns

Definition at line 228 of file class.ilECSCategoryMappingRule.php.

229 {
230 $this->by_type = $a_type;
231 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setContainerId()

ilECSCategoryMappingRule::setContainerId (   $a_id)

set container id

Parameters
int$a_id$a_container_id
Returns

Definition at line 99 of file class.ilECSCategoryMappingRule.php.

100 {
101 $this->container_id = $a_id;
102 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDateRangeEnd()

ilECSCategoryMappingRule::setDateRangeEnd (   $end)

set date range end

Parameters
object$startilDate
Returns

Definition at line 137 of file class.ilECSCategoryMappingRule.php.

138 {
139 $this->range_dt_end = $end;
140 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setDateRangeStart()

ilECSCategoryMappingRule::setDateRangeStart (   $start)

set date range start

Parameters
object$startilDate
Returns

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

119 {
120 $this->range_dt_start = $start;
121 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setFieldName()

ilECSCategoryMappingRule::setFieldName (   $a_field)

set field name

Parameters
string$a_fieldfield name
Returns

Definition at line 162 of file class.ilECSCategoryMappingRule.php.

163 {
164 $this->field_name = $a_field;
165 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMappingId()

ilECSCategoryMappingRule::setMappingId (   $a_id)
protected

set mapping id

Parameters
int$a_mapping_idmapping id
Returns
void

Definition at line 80 of file class.ilECSCategoryMappingRule.php.

81 {
82 $this->mapping_id = $a_id;
83 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMappingType()

ilECSCategoryMappingRule::setMappingType (   $a_type)

set mapping type

Parameters
int$typeMapping type
Returns

Definition at line 181 of file class.ilECSCategoryMappingRule.php.

182 {
183 $this->mapping_type = $a_type;
184 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMappingValue()

ilECSCategoryMappingRule::setMappingValue (   $a_value)

set mapping value

Parameters
string$valMapping value
Returns

Definition at line 200 of file class.ilECSCategoryMappingRule.php.

201 {
202 $this->mapping_value = $a_value;
203 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilECSCategoryMappingRule::update ( )

update

Returns

Definition at line 258 of file class.ilECSCategoryMappingRule.php.

259 {
260 if($this->getMappingType() == self::TYPE_BY_TYPE)
261 {
262 $mapping_value = $this->getByType();
263 }
264 else
265 {
267 }
268
269 $sta = $this->db->manipulateF(
270 'UPDATE ecs_container_mapping SET '.
271 'container_id = %s, '.
272 'field_name = %s, '.
273 'mapping_type = %s, '.
274 'mapping_value = %s, '.
275 'date_range_start = %s,'.
276 'date_range_end = %s '.
277 'WHERE mapping_id = %s',
278 array('integer','text','integer','text','integer','integer','integer'),
279 array(
280 $this->getContainerId(),
281 $this->getFieldName(),
282 $this->getMappingType(),
284 $this->getDateRangeStart()->get(IL_CAL_UNIX),
285 $this->getDateRangeEnd()->get(IL_CAL_UNIX),
286 $this->getMappingId())
287 );
288 }

References $mapping_value, getByType(), getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingId(), getMappingType(), getMappingValue(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ validate()

ilECSCategoryMappingRule::validate ( )

validate rule

Returns

Definition at line 328 of file class.ilECSCategoryMappingRule.php.

329 {
331 {
333 }
335 {
337 }
338 if($this->getMappingType() == self::TYPE_DURATION && !in_array($this->getFieldName(), array('begin', 'end')))
339 {
341 }
342 // handled by form gui?
343 if($this->getMappingType() == self::TYPE_FIXED and !$this->getMappingValue())
344 {
346 }
347 if($this->getMappingType() == self::TYPE_BY_TYPE && $this->getFieldName() != 'type')
348 {
350 }
351 if($this->getMappingType() != self::TYPE_BY_TYPE && $this->getFieldName() == 'type')
352 {
354 }
355 return 0;
356 }
const IL_CAL_DAY
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type

References ilDateTime\_after(), ilObject\_lookupObjId(), ilObject\_lookupType(), ERR_INVALID_DATES, ERR_INVALID_TYPE, ERR_MISSING_BY_TYPE, ERR_MISSING_VALUE, getContainerId(), getDateRangeEnd(), getDateRangeStart(), getFieldName(), getMappingType(), getMappingValue(), and IL_CAL_DAY.

+ Here is the call graph for this function:

Field Documentation

◆ $by_type

ilECSCategoryMappingRule::$by_type
private

Definition at line 59 of file class.ilECSCategoryMappingRule.php.

Referenced by getByType().

◆ $container_id

ilECSCategoryMappingRule::$container_id
private

Definition at line 53 of file class.ilECSCategoryMappingRule.php.

Referenced by getContainerId().

◆ $db

ilECSCategoryMappingRule::$db
protected

Definition at line 50 of file class.ilECSCategoryMappingRule.php.

◆ $field_name

ilECSCategoryMappingRule::$field_name
private

Definition at line 54 of file class.ilECSCategoryMappingRule.php.

Referenced by getFieldName().

◆ $mapping_id

ilECSCategoryMappingRule::$mapping_id
private

Definition at line 52 of file class.ilECSCategoryMappingRule.php.

Referenced by getMappingId(), and save().

◆ $mapping_type

ilECSCategoryMappingRule::$mapping_type
private

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

Referenced by getMappingType().

◆ $mapping_value

ilECSCategoryMappingRule::$mapping_value
private

Definition at line 56 of file class.ilECSCategoryMappingRule.php.

Referenced by getMappingValue(), save(), and update().

◆ $range_dt_end

ilECSCategoryMappingRule::$range_dt_end
private

Definition at line 58 of file class.ilECSCategoryMappingRule.php.

Referenced by getDateRangeEnd().

◆ $range_dt_start

ilECSCategoryMappingRule::$range_dt_start
private

Definition at line 57 of file class.ilECSCategoryMappingRule.php.

◆ ATTR_ARRAY

const ilECSCategoryMappingRule::ATTR_ARRAY = 3

◆ ATTR_INT

const ilECSCategoryMappingRule::ATTR_INT = 2

◆ ATTR_STRING

const ilECSCategoryMappingRule::ATTR_STRING = 1

◆ ERR_INVALID_DATES

const ilECSCategoryMappingRule::ERR_INVALID_DATES = 'ecs_err_invalid_dates'

Definition at line 46 of file class.ilECSCategoryMappingRule.php.

Referenced by validate().

◆ ERR_INVALID_TYPE

const ilECSCategoryMappingRule::ERR_INVALID_TYPE = 'ecs_err_invalid_type'

Definition at line 47 of file class.ilECSCategoryMappingRule.php.

Referenced by validate().

◆ ERR_MISSING_BY_TYPE

const ilECSCategoryMappingRule::ERR_MISSING_BY_TYPE = 'ecs_err_invalid_by_type'

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

Referenced by validate().

◆ ERR_MISSING_VALUE

const ilECSCategoryMappingRule::ERR_MISSING_VALUE = 'ecs_err_missing_value'

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

Referenced by validate().

◆ TYPE_BY_TYPE

◆ TYPE_DURATION

◆ TYPE_FIXED


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