19 declare(strict_types=1);
48 $on_load_code =
function (
$id) {
49 return "document.getElementById('$id')" 50 .
'.addEventListener("click", ' 51 .
'(e) => {e.preventDefault();' 52 .
'e.target.setAttribute("name", "cmd[editAvailabilityPeriod]");' 53 .
'e.target.form.requestSubmit(e.target);});';
56 return $this->ui_factory->button()->standard(
57 $this->
language->txt(
'edit_availability_period'),
66 if ($ref_ids === []) {
67 $this->tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'no_objects_selected'));
71 $this->object_reference_properties_repo->preload($ref_ids);
72 $this->properties_agregator->preload($ref_ids);
76 $post_url = $this->
ctrl->getFormAction($parent_gui,
'saveAvailabilityPeriod');
86 $post_url = $this->
ctrl->getFormAction($parent_gui,
'saveAvailabilityPeriod');
87 $availability_period_modal = $this->
buildModal($post_url)
88 ->withRequest($request);
89 $data = $availability_period_modal->getData();
91 return $availability_period_modal;
94 explode(
',',
$data[
'affected_items'])
97 if (!$check_access($ref_ids)) {
101 $availability_period_property =
$data[
'enable_availability_period'];
108 ?array $items =
null,
109 ?array $ref_ids =
null,
110 bool $all_settings_are_equal =
false 112 $ref_id_for_value =
null;
114 if ($ref_ids !==
null && $all_settings_are_equal) {
115 $ref_id_for_value = $ref_ids[0];
117 $modal_factory = $this->ui_factory->modal();
120 $input_fields = $this->
buildForm($ref_id_for_value);
122 if ($ref_ids !==
null) {
123 $input_fields[
'affected_items'] = $input_fields[
'affected_items']->withValue(implode(
',', $ref_ids));
126 if ($ref_ids !==
null && !$all_settings_are_equal) {
128 $this->ui_factory->messageBox()->info($this->
language->txt(
'unequal_items_for_availability_period_message')),
131 return $modal_factory->roundtrip($this->
language->txt(
'edit_availability_period'), $content, $input_fields, $post_url);
138 private function buildForm(?
int $ref_id_for_values): array
141 $date_format = $this->
user->getDateFormat();
143 'user_time_zone' => $this->
user->getTimeZone(),
144 'user_date_format' => $data_factory->dateFormat()->withTime24($date_format)
148 $input_fields[
'enable_availability_period'] = $this->object_reference_properties_repo
149 ->getFor($ref_id_for_values)->getPropertyAvailabilityPeriod()->toForm(
151 $this->ui_factory->input()->field(),
155 $input_fields[
'affected_items'] = $this->ui_factory->input()->field()->hidden();
157 return $input_fields;
161 array $object_reference_ids,
164 foreach ($object_reference_ids as $object_reference_id) {
165 $this->object_reference_properties_repo->storePropertyAvailabilityPeriod(
176 $previous_element = $this->object_reference_properties_repo->getFor(array_shift($ref_ids))->getPropertyAvailabilityPeriod();
177 foreach ($ref_ids as
$ref_id) {
178 $current_element = $this->object_reference_properties_repo->getFor($ref_id)->getPropertyAvailabilityPeriod();
179 if ($current_element->getAvailabilityPeriodEnabled() ===
false 180 && $previous_element->getAvailabilityPeriodEnabled() ===
false) {
184 if ($current_element->getAvailabilityPeriodEnabled() !== $previous_element->getAvailabilityPeriodEnabled()
185 || $current_element->getAvailabilityPeriodStart() != $previous_element->getAvailabilityPeriodStart()
186 || $current_element->getAvailabilityPeriodEnd() != $previous_element->getAvailabilityPeriodEnd()
187 || $current_element->getVisibleWhenDisabled() !== $previous_element->getVisibleWhenDisabled()) {
201 foreach ($object_reference_ids as $object_reference_id) {
202 $object_id = $this->object_reference_properties_repo->getFor(
205 $object_properties = $this->properties_agregator->getFor(
208 $title = $object_properties->getPropertyTitleAndDescription()->getTitle();
209 $icon = $this->ui_factory->symbol()->icon()->custom(
210 \ilObject::getIconForReference($object_reference_id, $object_id,
''),
213 $key =
'obj_' . $object_reference_id;
214 $items[$key] = $this->ui_factory->item()->shy($title)->withLeadIcon($icon);
getAvailabilityPeriodButton()
withAdditionalOnLoadCode(Closure $binder)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getItemsForRefIds(array $object_reference_ids)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectGUI Basic methods of all Output classes.
withObjectReferenceId(int $object_reference_id)
areAllElementsEqual(array $ref_ids)
saveEditAvailabilityPeriodPropertiesModal(\ilObjectGUI $parent_gui, \Closure $check_access, ServerRequestInterface $request)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getEditAvailabilityPeriodPropertiesModal(array $ref_ids, \ilObjectGUI $parent_gui)
language()
description: > Example for rendring a language glyph.
buildForm(?int $ref_id_for_values)
buildModal(string $post_url, ?array $items=null, ?array $ref_ids=null, bool $all_settings_are_equal=false)
__construct(private readonly ObjectReferencePropertiesRepository $object_reference_properties_repo, private readonly \ilObjectPropertiesAgregator $properties_agregator, private readonly \ilLanguage $language, private readonly \ilCtrlInterface $ctrl, private readonly \ilObjUser $user, private readonly UIFactory $ui_factory, private readonly \ilGlobalTemplateInterface $tpl, private readonly Refinery $refinery)
saveAvailabilityPeriodPropertyForObjectRefIds(array $object_reference_ids, ObjectAvailabilityPeriodProperty $property)