ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.SettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
29 {
30  protected \ilSetting $global_settings;
31 
32  public function __construct(
33  protected InternalDataService $data,
34  protected InternalDomainService $domain,
35  protected InternalGUIService $gui,
36  protected int $obj_id,
37  protected int $ref_id
38  ) {
39  }
40 
41  public function executeCommand(): void
42  {
43  $ctrl = $this->gui->ctrl();
44  $next_class = $ctrl->getNextClass($this);
45  $cmd = $ctrl->getCmd("edit");
46 
47  switch ($next_class) {
48  default:
49  if (in_array($cmd, ["edit", "save"])) {
50  $this->$cmd();
51  }
52  }
53  }
54 
55  protected function edit(): void
56  {
57  $mt = $this->gui->ui()->mainTemplate();
58  $form = $this->getEditForm();
59  $mt->setContent($form->render());
60  }
61 
62  protected function getEditForm(): FormAdapterGUI
63  {
64  //$settings = $this->domain->mediapoolSettings()->getById($this->obj_id);
65  $lng = $this->domain->lng();
66 
67  $form = $this->gui
68  ->form(self::class, "save")
69  ->section("general", $lng->txt("properties"))
70  ->addStdTitleAndDescription($this->obj_id, "spl")
71  ->section("avail", $lng->txt("rep_activation_availability"))
72  ->addOnline($this->obj_id, "spl")
73  ->addStdAvailability($this->ref_id, "spl")
74  ->section("presentation", $lng->txt("obj_presentation"))
75  ->addStdTile($this->obj_id, "spl");
76  return $form;
77  }
78 
79  protected function save(): void
80  {
81  $mt = $this->gui->ui()->mainTemplate();
82  $form = $this->getEditForm();
83  $ctrl = $this->gui->ctrl();
84  $lng = $this->domain->lng();
85 
86  if ($form->isValid()) {
87 
88  $form->saveStdTitleAndDescription($this->obj_id, "spl");
89  $form->saveStdTile($this->obj_id, "spl");
90  $form->saveOnline($this->obj_id, "spl");
91  $form->saveStdAvailability($this->ref_id);
92 
93  // we still need the svy_qpl record for now
94  // but it may be abandoned in the future, if it does not contain new properties
95  $pool = new \ilObjSurveyQuestionPool($this->ref_id);
96  $pool->saveToDb();
97 
98  $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
99  $ctrl->redirectByClass(self::class, "edit");
100  } else {
101  $mt = $this->gui->ui()->mainTemplate();
102  $mt->setContent($form->render());
103  }
104  }
105 }
$ref_id
Definition: ltiauth.php:65
Survey question pool internal data service.
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected int $ref_id)
addStdTitleAndDescription(int $obj_id, string $type)
addStdTile(int $obj_id, string $type)
global $lng
Definition: privfeed.php:31
addOnline(int $obj_id, string $type)