ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
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 \ILIAS\Notes\DomainService $notes;
31  protected \ilSetting $global_settings;
32 
33  public function __construct(
34  protected InternalDataService $data,
35  protected InternalDomainService $domain,
36  protected InternalGUIService $gui,
37  protected int $obj_id,
38  protected bool $in_repository,
39  protected int $ref_id = 0
40  ) {
41  $this->notes = $domain->notes();
42  }
43 
44  public function executeCommand(): void
45  {
46  $ctrl = $this->gui->ctrl();
47  $next_class = $ctrl->getNextClass($this);
48  $cmd = $ctrl->getCmd("edit");
49 
50  switch ($next_class) {
51  default:
52  if (in_array($cmd, ["edit", "save"])) {
53  $this->$cmd();
54  }
55  }
56  }
57 
58  protected function edit(): void
59  {
60  $mt = $this->gui->ui()->mainTemplate();
61  $form = $this->getEditForm();
62  $mt->setContent($form->render());
63  }
64 
65  protected function getEditForm(): FormAdapterGUI
66  {
67  $settings = $this->domain->portfolioSettings()->getById($this->obj_id);
68  $lng = $this->domain->lng();
69 
70  $lng->loadLanguageModule("rep");
71 
72  $form = $this->gui
73  ->form(self::class, "save")
74  ->section("general", $lng->txt("prtf_edit_portfolio"));
75  if ($this->in_repository) {
76  $form = $form
77  ->addStdTitleAndDescription($this->obj_id, "prtf");
78  } else {
79  $form = $form
80  ->addStdTitle($this->obj_id, "prtf");
81  }
82  $form = $form
83  ->section("avail", $lng->txt("rep_activation_availability"))
84  ->addOnline($this->obj_id, "prtf");
85  if ($this->in_repository) {
86  $form = $form->addStdAvailability($this->ref_id);
87  }
88  $form = $form
89  ->section("presentation", $lng->txt("obj_presentation"))
90  ->checkbox(
91  "ppic",
92  $lng->txt("prtf_profile_picture"),
93  "",
94  $settings->getShowPersonalPicture()
95  );
96  if ($this->in_repository) {
97  $form = $form
98  ->addStdTile($this->obj_id, "prtf");
99  }
100  if ($this->in_repository) {
101  $form = $form
102  ->addAdditionalFeatures(
103  $this->obj_id,
104  [
106  ]
107  );
108  }
109  $form = $form
110  ->checkbox(
111  "comments",
112  $lng->txt("prtf_public_comments"),
113  "",
114  $this->notes->commentsActive($this->obj_id)
115  );
116 
117  return $form;
118  }
119 
120  protected function save(): void
121  {
122  $mt = $this->gui->ui()->mainTemplate();
123  $form = $this->getEditForm();
124  $ctrl = $this->gui->ctrl();
125  $lng = $this->domain->lng();
126 
127  $old_settings = $this->domain->portfolioSettings()->getById($this->obj_id);
128 
129  if ($form->isValid()) {
130  if ($this->in_repository) {
131  $form->saveStdTitleAndDescription($this->obj_id, "prtf");
132  $form->saveStdTile($this->obj_id, "mep");
133  $form->saveAdditionalFeatures(
134  $this->obj_id,
135  [
137  ]
138  );
139  } else {
140  $form->saveStdTitle($this->obj_id, "prtf");
141  }
142  $form->saveOnline($this->obj_id, "mep");
143 
144  $this->notes->activateComments(
145  $this->obj_id,
146  $form->getData("comments")
147  );
148 
149  $settings = $this->data->settings(
150  $this->obj_id,
151  (bool) $form->getData("ppic")
152  );
153  $this->domain->portfolioSettings()->update($settings);
154 
155  if ($this->in_repository) {
156  $form->saveStdAvailability($this->ref_id);
157  }
158 
159  $mt->setOnScreenMessage("success", $lng->txt("msg_obj_modified"), true);
160  $ctrl->redirectByClass(self::class, "edit");
161  } else {
162  $mt = $this->gui->ui()->mainTemplate();
163  $mt->setContent($form->render());
164  }
165  }
166 }
$ref_id
Definition: ltiauth.php:65
global $lng
Definition: privfeed.php:31
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected int $obj_id, protected bool $in_repository, protected int $ref_id=0)
addOnline(int $obj_id, string $type)