19 declare(strict_types=1);
36 private ?
int $object_reference_id =
null,
37 private ?
bool $availability_period_enabled =
null,
40 private ?
bool $visible_when_disabled =
false 46 return $this->object_reference_id;
51 return $this->availability_period_enabled ===
true;
56 return $this->time_limit_start;
61 return $this->time_limit_end;
66 return $this->visible_when_disabled;
71 if ($this->availability_period_enabled ===
false) {
75 $timing_start_utc = $this->timing_start->setTimezone(
new \
DateTimeZone(
'UTC'));
76 $timing_end_utc = $this->timing_end->setTimezone(
new \
DateTimeZone(
'UTC'));
77 $now_utc = new \DateTimeImmutable(
'now',
new \
DateTimeZone(
'UTC'));
79 if ($timing_start_utc < $now_utc && $now_utc < $timing_end_utc) {
89 $clone->object_reference_id = $object_reference_id;
97 ?array $environment =
null 108 $inputs[
'time_limit_start'] = $field_factory->dateTime($language->
txt(
'rep_activation_limited_start'))
109 ->withTimezone($environment[
'user_time_zone'])
110 ->withFormat($environment[
'user_date_format'])
112 $inputs[
'time_limit_end'] = $field_factory->dateTime($language->
txt(
'rep_activation_limited_end'))
113 ->withTimezone($environment[
'user_time_zone'])
114 ->withFormat($environment[
'user_date_format'])
116 $inputs[
'visible_when_disabled'] = $field_factory->checkbox(
117 $language->
txt(
'activation_visible_when_disabled'),
118 $language->
txt(
'activation_visible_when_disabled_info')
121 return $field_factory->optionalGroup(
123 $language->
txt(
'rep_time_based_availability'),
124 $language->
txt(
'rep_time_based_availability_info')
126 ->withAdditionalTransformation($trafo)
132 return $refinery->custom()->transformation(
133 function (?array $vs):
self {
135 || $vs[
'time_limit_start'] ===
null 136 && $vs[
'time_limit_end'] ===
null) {
143 $vs[
'time_limit_start']?->setTimezone(
new \
DateTimeZone(
'UTC')),
144 $vs[
'time_limit_end']?->setTimezone(
new \
DateTimeZone(
'UTC')),
145 $vs[
'visible_when_disabled']
155 return $refinery->custom()->constraint(
156 function (?array $vs):
bool {
158 || $vs[
'time_limit_start'] ===
null 159 || $vs[
'time_limit_end'] ===
null) {
163 if ($vs[
'time_limit_start'] > $vs[
'time_limit_end']) {
169 $language->
txt(
'duration_end_must_not_be_earlier_than_start')
getValueForActivationLimitedOptionalGroup(\DateTimeZone $timezone)
getAvailabilityPeriodEnd()
getAvailabilityPeriodStart()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
toForm(\ilLanguage $language, FieldFactory $field_factory, Refinery $refinery, ?array $environment=null)
A constraint encodes some resrtictions on values.
__construct(private ?int $object_reference_id=null, private ?bool $availability_period_enabled=null, private ?\DateTimeImmutable $time_limit_start=null, private ?\DateTimeImmutable $time_limit_end=null, private ?bool $visible_when_disabled=false)
getConstraintForActivationLimitedOptionalGroup(Refinery $refinery, \ilLanguage $language)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getAvailabilityPeriodEnabled()
withObjectReferenceId(int $object_reference_id)
getTransformationForActivationLimitedOptionalGroup(Refinery $refinery)