19 declare(strict_types=1);
75 protected Psr\Http\Message\ServerRequestInterface $request,
88 $cmd = $this->
ctrl->getCmd();
91 case self::CMD_DELETE:
92 case self::CMD_DELETE_CONFIRMATION:
93 case self::CMD_DISABLE:
94 case self::CMD_GET_ASYNC_MODAL_OUTPUT:
95 case self::CMD_NEXT_STEP:
99 case self::CMD_ENABLE:
101 $this->
ctrl->redirect($this, self::CMD_VIEW);
103 case self::CMD_PROFILE_NOT_PUBLIC:
107 throw new ilException(
"ilObjStudyProgrammeAutoMembershipsGUI: Command not supported: $cmd");
113 $current_src_type = null;
114 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
115 $current_src_type = $this->request_wrapper->retrieve(
116 self::F_ORIGINAL_SOURCE_TYPE,
121 $current_src_id = null;
122 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
123 $current_src_id = $this->request_wrapper->retrieve(
124 self::F_ORIGINAL_SOURCE_ID,
129 $selected_src_type = $this->request_wrapper->retrieve(self::F_SOURCE_TYPE, $this->
refinery->kindlyTo()->string());
130 $selected_src = $this->request_wrapper->retrieve(self::F_SOURCE_ID, $this->
refinery->kindlyTo()->string());
138 $form_id =
"form_" . $form->getId();
140 $modal = $this->ui_factory->modal()->roundtrip(
141 $this->
txt(
'modal_member_auto_select_title'),
142 $this->ui_factory->legacy($form->getHtml())
145 $submit = $this->ui_factory->button()->primary($this->
txt(
'add'),
"#")->withOnLoadCode(
146 function (
$id) use ($form_id) {
147 return "$('#$id').click(function() { $('#$form_id').submit(); return false; });";
151 $modal = $modal->withActionButtons([$submit]);
153 echo $this->ui_renderer->renderAsync($modal);
160 protected function view(
bool $profile_not_public =
false): void
162 if ($profile_not_public) {
163 $this->tpl->setOnScreenMessage(
"info", $this->
lng->txt(
'prg_profile_not_public'));
165 $collected_modals = [];
168 $collected_modals[] = $modal;
170 foreach ($this->
getObject()->getAutomaticMembershipSources() as $ams) {
173 $modal = $this->
getModal($ams->getSourceType(), $ams->getSourceId());
174 $collected_modals[] = $modal;
176 $src_id = $ams->getSourceType() .
'-' . $ams->getSourceId();
179 $modal->getShowSignal(),
185 $this->ui_renderer->render($title),
186 $this->ui_renderer->render($usr),
187 $this->ui_renderer->render($actions)
191 $table->setData(
$data);
192 $this->tpl->setContent(
193 $this->ui_renderer->render($collected_modals)
198 protected function save(): void
203 $post = $this->request->getParsedBody();
204 $form->setValuesByArray(
$post);
205 $src_type =
$post[self::F_SOURCE_TYPE];
206 $src_id =
$post[self::F_SOURCE_ID . $src_type];
209 (is_null($src_type) || $src_type ===
"") ||
210 (is_null($src_id) || $src_id === 0)
212 $this->tpl->setOnScreenMessage(
"failure", $this->
txt(
'no_srctype_or_id'),
true);
213 $this->
ctrl->redirect($this, self::CMD_VIEW);
217 if (in_array($src_type, self::$switch_to_ref_id)) {
219 $src_id = (
int) array_shift($refs);
223 array_key_exists(self::F_ORIGINAL_SOURCE_TYPE,
$post) &&
224 array_key_exists(self::F_ORIGINAL_SOURCE_ID,
$post)
226 $this->
getObject()->deleteAutomaticMembershipSource(
227 (
string)
$post[self::F_ORIGINAL_SOURCE_TYPE],
228 (
int)
$post[self::F_ORIGINAL_SOURCE_ID]
232 $this->
getObject()->storeAutomaticMembershipSource($src_type, (
int) $src_id);
233 $this->tpl->setOnScreenMessage(
"success", $this->
txt(
"auto_add_success"),
true);
234 $this->
ctrl->redirect($this, self::CMD_VIEW);
239 $get = $this->request->getQueryParams();
240 $post = $this->request->getParsedBody();
241 $field = self::CHECKBOX_SOURCE_IDS;
243 $field_ids_in_get = array_key_exists($field, $get);
244 $field_ids_in_post = array_key_exists($field,
$post);
248 if ($field_ids_in_get) {
249 $type_ids = $get[$field];
250 $msg = $this->
lng->txt(
'prg_delete_single_confirmation');
251 } elseif ($field_ids_in_post) {
252 $type_ids = implode(
' ',
$post[$field]);
253 $msg = $this->
lng->txt(
'prg_delete_confirmation');
255 $this->tpl->setOnScreenMessage(
"info", $this->
lng->txt(
'prg_delete_nothing_selected'),
true);
256 $this->
ctrl->redirect($this, self::CMD_VIEW);
259 $type_ids = base64_encode($type_ids);
261 $this->
ctrl->setParameterByClass(self::class, $field, $type_ids);
262 $delete = $this->
ctrl->getFormActionByClass(self::class, self::CMD_DELETE);
263 $cancel = $this->
ctrl->getFormActionByClass(self::class, self::CMD_VIEW);
264 $this->
ctrl->clearParameterByClass(self::class, $field);
267 $this->button_factory->standard($this->
lng->txt(
'prg_confirm_delete'), $delete),
268 $this->button_factory->standard($this->lng->txt(
'prg_cancel'), $cancel)
271 $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
273 $this->tpl->setContent($this->ui_renderer->render($message_box));
276 protected function delete():
void 278 $field = self::CHECKBOX_SOURCE_IDS;
279 $get = $this->request->getQueryParams();
281 if (!array_key_exists($field, $get)) {
282 $this->tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
'prg_delete_failure'),
true);
283 $this->
ctrl->redirect($this, self::CMD_VIEW);
286 $type_ids = base64_decode($get[$field]);
287 $type_ids = explode(
' ', trim($type_ids));
289 foreach ($type_ids as $src_id) {
290 [$type,
$id] = explode(
'-', $src_id);
291 $this->
getObject()->deleteAutomaticMembershipSource((
string) $type, (
int)
$id);
294 $msg = $this->
lng->txt(
'prg_delete_single_success');
295 if (count($type_ids) > 1) {
296 $msg = $this->
lng->txt(
'prg_delete_success');
299 $this->tpl->setOnScreenMessage(
"success", $msg,
true);
300 $this->
ctrl->redirect($this, self::CMD_VIEW);
308 $get = $this->request->getQueryParams();
309 $field = self::CHECKBOX_SOURCE_IDS;
310 if (array_key_exists($field, $get)) {
311 [$type,
$id] = explode(
'-', $get[$field]);
312 $this->
getObject()->enableAutomaticMembershipSource((
string) $type, (
int)
$id);
314 $this->
ctrl->redirect($this, self::CMD_VIEW);
322 $get = $this->request->getQueryParams();
323 $field = self::CHECKBOX_SOURCE_IDS;
324 if (array_key_exists($field, $get)) {
325 [$type,
$id] = explode(
'-', $get[$field]);
326 $this->
getObject()->disableAutomaticMembershipSource((
string) $type, (
int)
$id);
328 $this->
ctrl->redirect($this, self::CMD_VIEW);
344 $this->parent_gui = $a_parent_gui;
352 if ($this->
object === null ||
362 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, $source_type);
363 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $source_id);
364 $link = $this->
ctrl->getLinkTarget($this,
"getAsynchModalOutput",
"",
true);
365 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, null);
366 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, null);
368 return $this->ui_factory->modal()->roundtrip(
372 ->withAsyncRenderUrl($link);
377 $current_src_type = null;
378 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
379 $current_src_type = $this->request_wrapper->retrieve(
380 self::F_ORIGINAL_SOURCE_TYPE,
385 $current_src_id = null;
386 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
387 $current_src_id = $this->request_wrapper->retrieve(self::F_ORIGINAL_SOURCE_ID, $this->
refinery->to()->string());
390 $form = $this->
getForm($current_src_type, $current_src_id);
391 $form_id =
"form_" . $form->getId();
393 $modal = $this->ui_factory->modal()->roundtrip(
394 $this->
txt(
'modal_member_auto_select_title'),
395 $this->ui_factory->legacy($form->getHtml())
398 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, $current_src_type);
399 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $current_src_id);
400 $link = $this->
ctrl->getLinkTarget($this,
"nextStep",
"",
true);
401 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, null);
402 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, null);
404 $replaceSignal = $modal->getReplaceSignal();
405 $signal_id = $replaceSignal->getId();
406 $f_selected_type = self::F_SOURCE_TYPE;
407 $f_selected_id = self::F_SOURCE_ID;
408 $submit = $this->ui_factory->button()->primary($this->
txt(
'search'),
"#")
410 function (
$id) use ($form_id, $link, $signal_id, $f_selected_type, $f_selected_id) {
412 "$('#$id').click(function() { 414 var checked = $(\"input[name='$f_selected_type']:checked\"). val(); 415 if(checked == 'orgu' || typeof(checked) == \"undefined\") { 416 console.log('$(\'#$form_id\').submit()'); 417 document.getElementById('$form_id').submit(); 421 var i_value = $(\"input[name='$f_selected_id\" + checked + \"']\"). val(); 422 if(i_value == '' || typeof(i_value) == \"undefined\") { 423 document.getElementById('$form_id').submit(); 427 n_url = '$link' + '&$f_selected_type=' + checked + '&$f_selected_id=' + i_value; 428 $('#$id').attr(\"onclick\", function(event) { 429 $(this).trigger('$signal_id', 431 'id' : '$signal_id', 'event' : 'click', 432 'triggerer' : $(this), 433 'options' : JSON.parse('{\"url\":\"' + n_url + '\"}') 443 $modal = $modal->withActionButtons([$submit])
444 ->withAdditionalOnLoadCode(
445 function (
$id) use ($form) {
447 $js = $form->getItemByPostVar($selector_post_var)->getOnloadCode();
448 return implode(
';', $js);
452 echo $this->ui_renderer->renderAsync($modal);
460 if (is_null($source_type)) {
464 $form->setId(uniqid($source_type . $source_id,
true));
465 $form->setFormAction($this->
ctrl->getFormAction($this,
'save'));
468 $rgroup->setValue($source_type);
469 $form->addItem($rgroup);
480 $radio_role->addSubItem($ni_role);
481 $rgroup->addOption($radio_role);
491 $radio_grp->addSubItem($ni_grp);
492 $rgroup->addOption($radio_grp);
502 $radio_crs->addSubItem($ni_crs);
503 $rgroup->addOption($radio_crs);
515 $orgu->getExplorerGUI()->setSelectableTypes([
"orgu"]);
516 $orgu->getExplorerGUI()->setTypeWhiteList([
"root",
"orgu"]);
518 $orgu->getExplorerGUI()->setAjax(
false);
519 $radio_orgu->addSubItem($orgu);
520 $rgroup->addOption($radio_orgu);
522 !is_null($source_type) &&
523 !is_null($source_id) &&
524 $source_type !==
"" &&
527 switch ($source_type) {
529 $ni_role->setValue($source_id);
532 $ni_grp->setValue($source_id);
535 $ni_crs->setValue($source_id);
538 $orgu->setValue($source_id);
545 $hi->setValue($source_type);
549 $hi->setValue($source_id ??
'');
556 string $selected_source_type,
557 string $selected_source,
558 string $source_type = null,
559 string $source_id = null
562 $form->setFormAction($this->
ctrl->getFormAction($this,
"save"));
566 $object_search->setFilter(array($selected_source_type));
567 $entries = $object_search->performSearch()->getEntries();
570 $this->
txt(
"prg_auto_member_select_" . $selected_source_type),
571 self::F_SOURCE_ID . $selected_source_type
573 $form->addItem($rgoup);
574 foreach ($entries as $entry) {
575 $obj_id = (
int) $entry[
'obj_id'];
579 $option =
new ilRadioOption($title, (
string) $obj_id, $description);
580 $rgoup->addOption($option);
584 $hi->setValue($source_type ??
'');
588 $hi->setValue((
string) $source_id);
592 $hi->setValue($selected_source_type);
605 $query_parser->setMinWordLength(1);
606 $query_parser->setGlobalMinLength(3);
607 $query_parser->parse();
609 if (!$query_parser->validate()) {
610 return $query_parser->getMessage();
612 return $query_parser;
620 $btn = $this->ui_factory->button()->primary($this->
txt(
'add_automembership_source'),
'')
621 ->withOnClick($add_cat_signal);
622 $this->
toolbar->addComponent($btn);
634 $items[] = $this->ui_factory->button()->shy($this->
txt(
'edit'),
'')
635 ->withOnClick($signal);
637 $this->
ctrl->setParameter($this, self::CHECKBOX_SOURCE_IDS, $src_id);
640 $items[] = $this->ui_factory->button()->shy(
641 $this->
txt(
'deactivate'),
642 $this->
ctrl->getLinkTarget($this, self::CMD_DISABLE)
645 $items[] = $this->ui_factory->button()->shy(
646 $this->
txt(
'activate'),
647 $this->
ctrl->getLinkTarget($this, self::CMD_ENABLE)
651 $items[] = $this->ui_factory->button()->shy(
652 $this->
txt(
'delete'),
653 $this->
ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION)
656 $this->
ctrl->clearParameters($this);
658 return $this->ui_factory->dropdown()->standard($items);
664 if(array_filter($username) === []) {
668 $editor = implode(
' ', [
669 $username[
'firstname'],
670 $username[
'lastname'],
671 '(' . $username[
'login'] .
')' 674 $back_url = $this->
ctrl->getLinkTarget($this, self::CMD_VIEW);
675 $this->
ctrl->setParameterByClass(
'ilPublicUserProfileGUI',
'back_url', urlencode($back_url));
676 $this->
ctrl->setParameterByClass(
'ilPublicUserProfileGUI',
'user_id', $usr_id);
677 $url = $this->
ctrl->getLinkTargetByClass(
'ilPublicUserProfileGUI',
'view');
680 if (!$usr->hasPublicProfile()) {
681 $url = $this->
ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
683 return $this->ui_factory->link()->standard($editor,
$url);
696 if($this->rbac_review->isGlobalRole($src_id)) {
697 $parent_ref = self::ROLEFOLDER_REF_ID;
698 $path = [
'ilAdministrationGUI'];
699 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'admin_mode',
'settings');
701 $parent_ref = $this->rbac_review->getObjectReferenceOfRole($src_id);
703 $path = [
'ilRepositoryGUI',
'ilObjCategoryGUI'];
704 if($parent_type ==
'orgu') {
705 $path = [
'ilAdministrationGUI',
'ilObjOrgUnitGUI'];
707 $path[] =
'ilPermissionGUI';
709 $path[] =
'ilObjRoleGUI';
710 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'ref_id', $parent_ref);
711 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'obj_id', $src_id);
712 $url = $this->
ctrl->getLinkTargetByClass(
$path,
'userassignment');
713 $this->
ctrl->clearParametersByClass(
'ilObjRoleGUI');
722 static function (array
$c):
string {
725 $this->tree->getPathFull($src_id)
727 $hops = array_slice($hops, 1);
728 $title = implode(
' > ', $hops) ??
"-";
733 static function (array $c):
string {
736 $this->tree->getPathFull($src_id)
738 $hops = array_slice($hops, 3);
739 $title = implode(
' > ', $hops) ??
"-";
743 throw new LogicException(
"This should not happen. Forgot a case in the switch?");
746 return $this->ui_factory->link()->standard($title,
$url);
749 protected function txt(
string $code): string
751 return $this->
lng->txt($code);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParentGUI(ilContainerGUI $a_parent_gui)
Set this GUI's parent gui.
Class ChatMainBarProvider .
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
enable()
Enable single entry.
static _getAllReferences(int $id)
get all reference ids for object ID
const CHECKBOX_SOURCE_IDS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId($ref_id)
static _lookupName(int $a_user_id)
lookup user name
getForm(string $source_type=null, ?string $source_id='')
setRefId(int $prg_ref_id)
Set ref-id of StudyProgramme before using this GUI.
__construct(public ilGlobalTemplateInterface $tpl, public ilCtrl $ctrl, public ilToolbarGUI $toolbar, public ilLanguage $lng, public Factory $ui_factory, protected MessageBox\Factory $message_box_factory, protected Button\Factory $button_factory, protected Renderer $ui_renderer, protected Psr\Http\Message\ServerRequestInterface $request, protected ilTree $tree, protected ILIAS\HTTP\Wrapper\RequestWrapper $request_wrapper, protected ILIAS\Refinery\Factory $refinery, protected ilRbacReview $rbac_review)
This describes commonalities between all types of Dropdowns.
view(bool $profile_not_public=false)
Render.
getItemAction(string $src_id, Signal $signal, bool $is_enabled)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
disable()
Disable single entry.
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
const CMD_GET_ASYNC_MODAL_OUTPUT
parseQueryString(string $string)
const CMD_PROFILE_NOT_PUBLIC
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
static _lookupDescription(int $obj_id)
const CMD_DELETE_CONFIRMATION
getTitleRepresentation(ilStudyProgrammeAutoMembershipSource $ams)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
ilObjStudyProgramme $object
getModal(string $source_type=null, int $source_id=null)
Class ilObjStudyProgrammeAutoMembershipsGUI.
getSelectionForm(string $selected_source_type, string $selected_source, string $source_type=null, string $source_id=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
const F_ORIGINAL_SOURCE_TYPE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
const F_ORIGINAL_SOURCE_ID
getObject()
Get current StudyProgramme-object.
getUserRepresentation(int $usr_id)
getToolbar(Signal $add_cat_signal)
Setup toolbar.
static array $switch_to_ref_id
ilContainerGUI $parent_gui
Refinery Factory $refinery