18 declare(strict_types=1);
61 $this->db = $DIC->database();
63 $this->
logger = $DIC->logger()->wsrv();
65 $this->mapping_id = $a_mapping_id;
77 $this->mapping_id = $a_id;
96 $this->container_id = $a_id;
113 $this->range_dt_start = $start;
131 $this->range_dt_end = $end;
140 if ($this->range_dt_end) {
155 $this->field_name = $a_field;
173 $this->mapping_type = $a_type;
190 $this->mapping_value = $a_value;
218 $this->by_type = $a_type;
235 public function delete():
void 237 $this->db->manipulateF(
238 'DELETE FROM ecs_container_mapping WHERE mapping_id = %s ',
256 $this->db->manipulateF(
257 'UPDATE ecs_container_mapping SET ' .
258 'container_id = %s, ' .
259 'field_name = %s, ' .
260 'mapping_type = %s, ' .
261 'mapping_value = %s, ' .
262 'date_range_start = %s,' .
263 'date_range_end = %s ' .
264 'WHERE mapping_id = %s',
265 array(
'integer',
'text',
'integer',
'text',
'integer',
'integer',
'integer'),
289 $mapping_id = $this->db->nextId(
'ecs_container_mapping');
290 $this->db->manipulateF(
291 'INSERT INTO ecs_container_mapping ' .
292 '(mapping_id,container_id,field_name,mapping_type,mapping_value,date_range_start,date_range_end) ' .
293 'VALUES(%s,%s,%s,%s,%s,%s,%s) ',
294 array(
'integer',
'integer',
'text',
'integer',
'text',
'integer',
'integer'),
312 return self::ERR_INVALID_TYPE;
315 return self::ERR_INVALID_DATES;
318 return self::ERR_MISSING_VALUE;
322 return self::ERR_MISSING_VALUE;
325 return self::ERR_MISSING_BY_TYPE;
328 return self::ERR_MISSING_VALUE;
340 case self::TYPE_FIXED:
347 case self::TYPE_DURATION:
353 case self::TYPE_BY_TYPE:
367 foreach ($part as $part_id) {
369 $part_string .=
', ';
373 $part_id_arr = explode(
'_', $part_id);
375 ->getParticipantNameByMid((
int) $part_id_arr[1]) :
"Broken mapping entry in database";
377 $part_string .=
$name;
379 $part_string .= $part_id;
389 public function matches(array $a_matchable_content): bool
391 if (isset($a_matchable_content[$this->
getFieldName()])) {
407 case self::ATTR_ARRAY:
408 $values = explode(
',', $a_value);
409 $this->
logger->info(__METHOD__ .
': Checking for value: ' . $a_value);
410 $this->
logger->info(__METHOD__ .
': Checking against attribute values: ' . $this->
getMappingValue());
414 $this->
logger->info(__METHOD__ .
': Checking for value: ' . $a_value);
415 $this->
logger->info(__METHOD__ .
': Checking against attribute values: ' . $this->
getMappingValue());
416 $values = array((
string) $a_value);
419 case self::ATTR_STRING:
420 $values = array($a_value);
424 foreach ($values as $value) {
425 $value = trim($value);
427 case self::TYPE_FIXED:
430 $attribute_value = trim($attribute_value);
431 if (strcasecmp($attribute_value, $value) === 0) {
437 case self::TYPE_DURATION:
449 protected function read(): bool
454 $res = $this->db->queryF(
455 'SELECT * FROM ecs_container_mapping WHERE mapping_id = %s',
459 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)
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
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false)
Format a period of two dates Shows: 14.
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
static _lookupType(int $id, bool $reference=false)