19 declare(strict_types=1);
62 $this->db = $DIC->database();
64 $this->
logger = $DIC->logger()->wsrv();
66 $this->mapping_id = $a_mapping_id;
78 $this->mapping_id = $a_id;
97 $this->container_id = $a_id;
114 $this->range_dt_start = $start;
132 $this->range_dt_end = $end;
141 if ($this->range_dt_end) {
156 $this->field_name = $a_field;
174 $this->mapping_type = $a_type;
191 $this->mapping_value = $a_value;
219 $this->by_type = $a_type;
236 public function delete():
void 238 $this->db->manipulateF(
239 'DELETE FROM ecs_container_mapping WHERE mapping_id = %s ',
257 $this->db->manipulateF(
258 'UPDATE ecs_container_mapping SET ' .
259 'container_id = %s, ' .
260 'field_name = %s, ' .
261 'mapping_type = %s, ' .
262 'mapping_value = %s, ' .
263 'date_range_start = %s,' .
264 'date_range_end = %s ' .
265 'WHERE mapping_id = %s',
266 array(
'integer',
'text',
'integer',
'text',
'integer',
'integer',
'integer'),
290 $mapping_id = $this->db->nextId(
'ecs_container_mapping');
291 $this->db->manipulateF(
292 'INSERT INTO ecs_container_mapping ' .
293 '(mapping_id,container_id,field_name,mapping_type,mapping_value,date_range_start,date_range_end) ' .
294 'VALUES(%s,%s,%s,%s,%s,%s,%s) ',
295 array(
'integer',
'integer',
'text',
'integer',
'text',
'integer',
'integer'),
313 return self::ERR_INVALID_TYPE;
316 return self::ERR_INVALID_DATES;
319 return self::ERR_MISSING_VALUE;
323 return self::ERR_MISSING_VALUE;
326 return self::ERR_MISSING_BY_TYPE;
329 return self::ERR_MISSING_VALUE;
341 case self::TYPE_FIXED:
348 case self::TYPE_DURATION:
354 case self::TYPE_BY_TYPE:
368 foreach ($part as $part_id) {
370 $part_string .=
', ';
374 $part_id_arr = explode(
'_', $part_id);
376 ->getParticipantNameByMid((
int) $part_id_arr[1]) :
"Broken mapping entry in database";
378 $part_string .= $name;
380 $part_string .= $part_id;
390 public function matches(array $a_matchable_content): bool
392 if (isset($a_matchable_content[$this->
getFieldName()])) {
408 case self::ATTR_ARRAY:
409 $values = explode(
',', $a_value);
410 $this->
logger->info(__METHOD__ .
': Checking for value: ' . $a_value);
411 $this->
logger->info(__METHOD__ .
': Checking against attribute values: ' . $this->
getMappingValue());
415 $this->
logger->info(__METHOD__ .
': Checking for value: ' . $a_value);
416 $this->
logger->info(__METHOD__ .
': Checking against attribute values: ' . $this->
getMappingValue());
417 $values = array((
string)$a_value);
420 case self::ATTR_STRING:
421 $values = array($a_value);
425 foreach ($values as $value) {
426 $value = trim($value);
428 case self::TYPE_FIXED:
431 $attribute_value = trim($attribute_value);
432 if (strcasecmp($attribute_value, $value) === 0) {
438 case self::TYPE_DURATION:
450 protected function read(): bool
455 $res = $this->db->queryF(
456 'SELECT * FROM ecs_container_mapping WHERE mapping_id = %s',
460 while ($row = $this->db->fetchObject(
$res)) {
getMappingValue()
get mapping value
__construct(int $a_mapping_id=0)
Constructor.
setDateRangeEnd(ilDate $end)
set date range end
static _before(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
getFieldName()
get field name
setFieldName(string $a_field)
set field name
Defines a rule for the assignment of ECS remote courses to categories.
setMappingId(int $a_id)
set mapping id
getMappingAsArray()
get mapping values as array
matches(array $a_matchable_content)
Check if rule matches a specific econtent.
getContainerId()
get container id
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
conditionToString()
condition to string
static _after(ilDateTime $start, ilDateTime $end, string $a_compare_field='', string $a_tz='')
compare two dates and check start is after end This method does not consider tz offsets.
setMappingValue(string $a_value)
set mapping value
getByType()
get mapping by type
getMappingId()
get mapping id
participantsToString()
get string presentation of participants
getDateRangeStart()
get date range start
getDateRangeEnd()
get date range end
setMappingType(int $a_type)
set mapping type
setByType(string $a_type)
set mapping by type
matchesValue($a_value, int $a_type)
Check if value matches.
getMappingType()
get mapping type
setDateRangeStart(ilDate $start)
set date range start
const ERR_MISSING_BY_TYPE
setContainerId(int $a_id)
set container id
language()
description: > Example for rendring a language glyph.
static _lookupType(int $id, bool $reference=false)
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.