19declare(strict_types=1);
32 public function __construct(
int $a_id = 0,
int $a_id_type = self::REPOSITORY_NODE_ID,
int $a_parent_node_id = 0)
35 $this->
lng->loadLanguageModule(
'buddysystem');
46 $this->tabs_gui->addTarget(
48 $this->
ctrl->getLinkTarget($this,
'showConfigurationForm'),
49 [
'',
'view',
'showConfigurationForm',
'saveConfigurationForm'],
55 $this->tabs_gui->addTarget(
57 $this->
ctrl->getLinkTargetByClass([self::class, ilPermissionGUI::class],
'perm'),
58 [
'perm',
'info',
'owner'],
59 ilPermissionGUI::class
66 $next_class = $this->
ctrl->getNextClass($this) ??
'';
67 $cmd = $this->
ctrl->getCmd() ??
'';
70 switch (strtolower($next_class)) {
71 case strtolower(ilPermissionGUI::class):
73 $this->
ctrl->forwardCommand($perm_gui);
77 if ($cmd ===
'' || $cmd ===
'view') {
78 $cmd =
'showConfigurationForm';
87 $notification = $this->ui_factory->input()->field()->checkbox(
88 $this->
lng->txt(
'buddy_use_osd'),
89 $this->lng->txt(
'buddy_use_osd_info')
93 $contact_request_default = $this->ui_factory->input()->field()->select(
94 $this->
lng->txt(
'buddy_allow_to_contact_me'),
96 'y' => $this->lng->txt(
'buddy_allow_to_contact_me_yes'),
97 'n' => $this->lng->txt(
'buddy_allow_to_contact_me_no')
99 $this->lng->txt(
'buddy_allow_to_contact_me_default_info')
104 $cfg = ilNotificationDatabaseHandler::loadUserConfig(-1);
105 $checkbox = $this->ui_factory->input()->field()->optionalGroup(
107 'use_osd' => $notification,
108 'allow_contact_request_default' => $contact_request_default
110 $this->
lng->txt(
'buddy_enable'),
111 $this->lng->txt(
'buddy_enable_info')
115 'use_osd' => isset($cfg[
'buddysystem_request']) &&
116 in_array(
'osd', $cfg[
'buddysystem_request'],
true),
117 'allow_contact_request_default' => $this->
settings->get(
'bs_allow_to_contact_me',
'n')
123 $checkbox = $checkbox->withValue(
null);
126 return $this->ui_factory->input()->container()->form()->standard(
127 $this->
ctrl->getFormAction($this,
'saveConfigurationForm'),
129 'enable' => $checkbox,
138 if (!$this->rbac_system->checkAccess(
'visible,read', $this->object->getRefId())) {
139 $this->
error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
142 if (!$form instanceof StandardForm) {
146 $this->tpl->setContent($this->ui_renderer->render($form));
154 $form = $form->withRequest($this->request);
155 if ($form->getError()) {
161 $data = $form->getData();
165 (
string) (isset(
$data[
'enable']) &&
$data[
'enable'] ? 1 : 0)
168 $cfg = ilNotificationDatabaseHandler::loadUserConfig(-1);
171 foreach ($cfg as
$type => $channels) {
172 $new_cfg[
$type] = [];
173 foreach ($channels as $channel) {
174 $new_cfg[
$type][$channel] =
true;
178 if (!isset($new_cfg[
'buddysystem_request']) || !is_array($new_cfg[
'buddysystem_request'])) {
179 $new_cfg[
'buddysystem_request'] = [];
182 if (!array_key_exists(
'osd', $new_cfg[
'buddysystem_request']) &&
183 isset(
$data[
'enable'][
'use_osd']) &&
$data[
'enable'][
'use_osd'] ===
true) {
184 $new_cfg[
'buddysystem_request'][
'osd'] =
true;
186 array_key_exists(
'osd', $new_cfg[
'buddysystem_request']) &&
187 isset(
$data[
'enable']) &&
188 (!isset(
$data[
'enable'][
'use_osd']) ||
$data[
'enable'][
'use_osd'] ===
false)
190 $new_cfg[
'buddysystem_request'][
'osd'] =
false;
193 ilNotificationDatabaseHandler::setUserConfig(-1, $new_cfg);
195 if (isset(
$data[
'enable'][
'allow_contact_request_default'])
196 && in_array(
$data[
'enable'][
'allow_contact_request_default'], [
'y',
'n'])) {
198 'bs_allow_to_contact_me',
199 $data[
'enable'][
'allow_contact_request_default']
203 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
204 $this->
ctrl->redirect($this);
New implementation of ilObjectGUI.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc