19declare(strict_types=1);
76 protected Psr\Http\Message\ServerRequestInterface $request,
89 $cmd = $this->
ctrl->getCmd();
102 $this->
ctrl->redirect($this, self::CMD_VIEW);
107 case 'handleExplorerCommand':
110 throw new ilException(
"ilObjStudyProgrammeAutoMembershipsGUI: Command not supported: $cmd");
116 $current_src_type =
null;
117 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
118 $current_src_type = $this->request_wrapper->retrieve(
119 self::F_ORIGINAL_SOURCE_TYPE,
124 $current_src_id =
null;
125 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
126 $current_src_id = $this->request_wrapper->retrieve(
127 self::F_ORIGINAL_SOURCE_ID,
132 $selected_src_type = $this->request_wrapper->retrieve(self::F_SOURCE_TYPE, $this->
refinery->kindlyTo()->string());
133 $selected_src = $this->request_wrapper->retrieve(self::F_SOURCE_ID, $this->
refinery->kindlyTo()->string());
141 $form_id =
"form_" . $form->getId();
143 $modal = $this->ui_factory->modal()->roundtrip(
144 $this->
txt(
'modal_member_auto_select_title'),
145 $this->ui_factory->legacy()->content($form->getHtml())
148 $submit = $this->ui_factory->button()->primary($this->
txt(
'add'),
"#")->withOnLoadCode(
149 function (
$id) use ($form_id) {
150 return "$('#$id').click(function() { $('#$form_id').submit(); return false; });";
154 $modal = $modal->withActionButtons([$submit]);
156 echo $this->ui_renderer->renderAsync($modal);
163 protected function view(
bool $profile_not_public =
false): void
165 if ($profile_not_public) {
166 $this->tpl->setOnScreenMessage(
"info", $this->
lng->txt(
'prg_profile_not_public'));
168 $collected_modals = [];
171 $collected_modals[] = $modal;
173 foreach ($this->
getObject()->getAutomaticMembershipSources() as $ams) {
175 $usr = $this->
getUserRepresentation($ams->getLastEditorId()) ?? $this->ui_factory->legacy()->content(
'-');
176 $modal = $this->
getModal($ams->getSourceType(), $ams->getSourceId(), $ams->isSearchRecursive());
177 $collected_modals[] = $modal;
178 $src_id = $ams->getSourceType() .
'-' . $ams->getSourceId() .
'-' . $ams->isSearchRecursive();
181 $modal->getShowSignal(),
187 $this->ui_renderer->render($title),
188 $this->ui_renderer->render($usr),
189 $this->ui_renderer->render($actions)
193 $table->setData(
$data);
194 $this->tpl->setContent(
195 $this->ui_renderer->render($collected_modals)
200 protected function save(): void
205 $post = $this->request->getParsedBody();
206 $form->setValuesByArray(
$post);
208 $src_id =
$post[self::F_SOURCE_ID . $src_type] ??
null;
209 $search_recursive = (bool) (
$post[self::F_SEARCH_RECURSIVE] ??
false);
212 (is_null($src_type) || $src_type ===
"") ||
213 (is_null($src_id) || $src_id === 0)
215 $this->tpl->setOnScreenMessage(
"failure", $this->
txt(
'no_srctype_or_id'),
true);
216 $this->
ctrl->redirect($this, self::CMD_VIEW);
220 if (in_array($src_type, self::$switch_to_ref_id)) {
222 $src_id = (
int) array_shift($refs);
226 array_key_exists(self::F_ORIGINAL_SOURCE_TYPE,
$post) &&
227 array_key_exists(self::F_ORIGINAL_SOURCE_ID,
$post)
229 $this->
getObject()->deleteAutomaticMembershipSource(
230 (
string)
$post[self::F_ORIGINAL_SOURCE_TYPE],
231 (
int)
$post[self::F_ORIGINAL_SOURCE_ID]
235 $this->
getObject()->storeAutomaticMembershipSource($src_type, (
int) $src_id, $search_recursive);
236 $this->tpl->setOnScreenMessage(
"success", $this->
txt(
"auto_add_success"),
true);
237 $this->
ctrl->redirect($this, self::CMD_VIEW);
242 $get = $this->request->getQueryParams();
243 $post = $this->request->getParsedBody();
246 $field_ids_in_get = array_key_exists($field, $get);
247 $field_ids_in_post = array_key_exists($field,
$post);
251 if ($field_ids_in_get) {
252 $type_ids = $get[$field];
253 $msg = $this->
lng->txt(
'prg_delete_single_confirmation');
254 } elseif ($field_ids_in_post) {
255 $type_ids = implode(
' ',
$post[$field]);
256 $msg = $this->
lng->txt(
'prg_delete_confirmation');
258 $this->tpl->setOnScreenMessage(
"info", $this->
lng->txt(
'prg_delete_nothing_selected'),
true);
259 $this->
ctrl->redirect($this, self::CMD_VIEW);
262 $type_ids = base64_encode($type_ids);
264 $this->
ctrl->setParameterByClass(self::class, $field, $type_ids);
265 $delete = $this->
ctrl->getFormActionByClass(self::class, self::CMD_DELETE);
266 $cancel = $this->
ctrl->getFormActionByClass(self::class, self::CMD_VIEW);
267 $this->
ctrl->clearParameterByClass(self::class, $field);
270 $this->button_factory->standard($this->
lng->txt(
'prg_confirm_delete'), $delete),
271 $this->button_factory->standard($this->
lng->txt(
'prg_cancel'), $cancel)
274 $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
276 $this->tpl->setContent($this->ui_renderer->render($message_box));
279 protected function delete():
void
282 $get = $this->request->getQueryParams();
284 if (!array_key_exists($field, $get)) {
285 $this->tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
'prg_delete_failure'),
true);
286 $this->
ctrl->redirect($this, self::CMD_VIEW);
289 $type_ids = base64_decode($get[$field]);
290 $type_ids = explode(
' ', trim($type_ids));
292 foreach ($type_ids as $src_id) {
293 [$type,
$id] = explode(
'-', $src_id);
294 $this->
getObject()->deleteAutomaticMembershipSource((
string) $type, (
int)
$id);
297 $msg = $this->
lng->txt(
'prg_delete_single_success');
298 if (count($type_ids) > 1) {
299 $msg = $this->
lng->txt(
'prg_delete_success');
302 $this->tpl->setOnScreenMessage(
"success", $msg,
true);
303 $this->
ctrl->redirect($this, self::CMD_VIEW);
311 $get = $this->request->getQueryParams();
313 if (array_key_exists($field, $get)) {
314 [$type,
$id, $search_recursive] = explode(
'-', $get[$field]);
315 $this->
getObject()->enableAutomaticMembershipSource((
string) $type, (
int)
$id, (
bool) $search_recursive);
317 $this->
ctrl->redirect($this, self::CMD_VIEW);
325 $get = $this->request->getQueryParams();
327 if (array_key_exists($field, $get)) {
328 [$type,
$id, $search_recursive] = explode(
'-', $get[$field]);
329 $this->
getObject()->disableAutomaticMembershipSource((
string) $type, (
int)
$id, (
bool) $search_recursive);
331 $this->
ctrl->redirect($this, self::CMD_VIEW);
347 $this->parent_gui = $a_parent_gui;
355 if ($this->
object ===
null ||
356 $this->
object->getRefId() !== $this->prg_ref_id
364 ?
string $source_type =
null,
365 ?
int $source_id =
null,
366 bool $search_recursive =
false
369 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $source_id);
370 $this->
ctrl->setParameter($this, self::F_SEARCH_RECURSIVE, $search_recursive);
371 $link = $this->
ctrl->getLinkTarget($this,
"getAsynchModalOutput",
"",
true);
372 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE,
null);
373 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID,
null);
374 $this->
ctrl->setParameter($this, self::F_SEARCH_RECURSIVE,
null);
376 return $this->ui_factory->modal()->roundtrip(
380 ->withAsyncRenderUrl($link);
385 $current_src_type =
null;
386 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
387 $current_src_type = $this->request_wrapper->retrieve(
388 self::F_ORIGINAL_SOURCE_TYPE,
393 $current_src_id =
null;
394 if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
395 $current_src_id = $this->request_wrapper->retrieve(self::F_ORIGINAL_SOURCE_ID, $this->
refinery->kindlyTo()->int());
398 $search_recursive =
false;
399 if ($this->request_wrapper->has(self::F_SEARCH_RECURSIVE)) {
400 $search_recursive = $this->request_wrapper->retrieve(self::F_SEARCH_RECURSIVE, $this->
refinery->kindlyTo()->bool());
402 $form = $this->getForm($current_src_type, $current_src_id, $search_recursive);
403 $form_id =
"form_" . $form->getId();
405 $modal = $this->ui_factory->modal()->roundtrip(
406 $this->txt(
'modal_member_auto_select_title'),
407 $this->ui_factory->legacy()->content($form->getHtml())
410 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, $current_src_type);
411 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $current_src_id);
412 $link = $this->
ctrl->getLinkTarget($this,
"nextStep",
"",
true);
413 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE,
null);
414 $this->
ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID,
null);
416 $replaceSignal = $modal->getReplaceSignal();
417 $signal_id = $replaceSignal->getId();
418 $f_selected_type = self::F_SOURCE_TYPE;
419 $f_selected_id = self::F_SOURCE_ID;
420 $submit = $this->ui_factory->button()->primary($this->txt(
'search'),
"#")
422 function (
$id) use ($form_id, $link, $signal_id, $f_selected_type, $f_selected_id) {
424 "$('#$id').click(function() {
426 var checked = $(\"input[name='$f_selected_type']:checked\"). val();
427 if(checked == 'orgu' || typeof(checked) == \"undefined\") {
428 console.log('$(\'#$form_id\').submit()');
429 document.getElementById('$form_id').submit();
433 var i_value = $(\"input[name='$f_selected_id\" + checked + \"']\"). val();
434 if(i_value == '' || typeof(i_value) == \"undefined\") {
435 document.getElementById('$form_id').submit();
439 n_url = '$link' + '&$f_selected_type=' + checked + '&$f_selected_id=' + i_value;
440 $('#$id').attr(\"onclick\", function(event) {
441 $(this).trigger('$signal_id',
443 'id' : '$signal_id', 'event' : 'click',
444 'triggerer' : $(this),
445 'options' : JSON.parse('{\"url\":\"' + n_url + '\"}')
455 $modal = $modal->withActionButtons([$submit])
456 ->withAdditionalOnLoadCode(
457 function (
$id) use ($form) {
459 $js = $form->getItemByPostVar($selector_post_var)->getOnloadCode();
460 return implode(
';', $js);
464 echo $this->ui_renderer->renderAsync($modal);
469 ?
string $source_type =
null,
470 ?
int $source_id =
null,
471 bool $search_recursive =
false
475 if (is_null($source_type)) {
479 $form->
setId(uniqid($source_type . $source_id,
true));
480 $form->setFormAction($this->
ctrl->getFormAction($this,
'save'));
483 $rgroup->setValue($source_type);
484 $form->addItem($rgroup);
495 $radio_role->addSubItem($ni_role);
496 $rgroup->addOption($radio_role);
506 $radio_grp->addSubItem($ni_grp);
507 $rgroup->addOption($radio_grp);
517 $radio_crs->addSubItem($ni_crs);
518 $rgroup->addOption($radio_crs);
530 $orgu->getExplorerGUI()->setSelectableTypes([
"orgu"]);
531 $orgu->getExplorerGUI()->setTypeWhiteList([
"root",
"orgu"]);
533 $orgu->getExplorerGUI()->setAjax(
false);
534 $radio_orgu->addSubItem($orgu);
536 $recurse =
new ilCheckboxInputGUI($this->txt(
'search_for_orgu_members_recursive'), self::F_SEARCH_RECURSIVE);
537 $recurse->setValue(
'1');
538 $recurse->setChecked($search_recursive);
539 $radio_orgu->addSubItem($recurse);
540 $rgroup->addOption($radio_orgu);
542 !is_null($source_type) &&
543 !is_null($source_id) &&
544 $source_type !==
"" &&
547 switch ($source_type) {
549 $ni_role->setValue($source_id);
552 $ni_grp->setValue($source_id);
555 $ni_crs->setValue($source_id);
558 $orgu->setValue($source_id);
565 $hi->setValue($source_type);
569 $hi->setValue((
string) $source_id ??
'');
576 string $selected_source_type,
577 string $selected_source,
578 ?
string $source_type =
null,
579 ?
string $source_id =
null
584 $query_parser = $this->parseQueryString($selected_source);
586 $object_search->setFilter(array($selected_source_type));
587 $entries = $object_search->performSearch()->getEntries();
590 $this->txt(
"prg_auto_member_select_" . $selected_source_type),
591 self::F_SOURCE_ID . $selected_source_type
593 $form->addItem($rgoup);
594 foreach ($entries as $entry) {
595 $obj_id = (
int) $entry[
'obj_id'];
599 $option =
new ilRadioOption($title, (
string) $obj_id, $description);
600 $rgoup->addOption($option);
604 $hi->setValue($source_type ??
'');
608 $hi->setValue((
string) $source_id);
612 $hi->setValue($selected_source_type);
625 $query_parser->setMinWordLength(1);
626 $query_parser->setGlobalMinLength(3);
627 $query_parser->parse();
629 if (!$query_parser->validate()) {
630 return $query_parser->getMessage();
632 return $query_parser;
640 $btn = $this->ui_factory->button()->primary($this->txt(
'add_automembership_source'),
'')
641 ->withOnClick($add_cat_signal);
642 $this->
toolbar->addComponent($btn);
654 $items[] = $this->ui_factory->button()->shy($this->txt(
'edit'),
'')
655 ->withOnClick($signal);
657 $this->
ctrl->setParameter($this, self::CHECKBOX_SOURCE_IDS, $src_id);
660 $items[] = $this->ui_factory->button()->shy(
661 $this->txt(
'deactivate'),
662 $this->
ctrl->getLinkTarget($this, self::CMD_DISABLE)
665 $items[] = $this->ui_factory->button()->shy(
666 $this->txt(
'activate'),
667 $this->
ctrl->getLinkTarget($this, self::CMD_ENABLE)
671 $items[] = $this->ui_factory->button()->shy(
672 $this->txt(
'delete'),
673 $this->
ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION)
676 $this->
ctrl->clearParameters($this);
678 return $this->ui_factory->dropdown()->standard($items);
684 $editor = implode(
' ', [
685 $username[
'firstname'],
686 $username[
'lastname'],
687 '(' . $username[
'login'] .
')'
690 $back_url = $this->
ctrl->getLinkTarget($this, self::CMD_VIEW);
691 $this->
ctrl->setParameterByClass(PublicProfileGUI::class,
'back_url', urlencode($back_url));
692 $this->
ctrl->setParameterByClass(PublicProfileGUI::class,
'user_id', $usr_id);
693 $url = $this->
ctrl->getLinkTargetByClass(PublicProfileGUI::class,
'view');
696 if (!$usr->hasPublicProfile()) {
697 $url = $this->
ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
699 return $this->ui_factory->link()->standard($editor,
$url);
706 $src_id = $ams->getSourceId();
712 if ($this->rbac_review->isGlobalRole($src_id)) {
713 $parent_ref = self::ROLEFOLDER_REF_ID;
714 $path = [
'ilAdministrationGUI'];
715 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'admin_mode',
'settings');
717 $parent_ref = $this->rbac_review->getObjectReferenceOfRole($src_id);
719 $path = [
'ilRepositoryGUI',
'ilObjCategoryGUI'];
720 if ($parent_type ==
'orgu') {
721 $path = [
'ilAdministrationGUI',
'ilObjOrgUnitGUI'];
723 $path[] =
'ilPermissionGUI';
725 $path[] =
'ilObjRoleGUI';
726 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'ref_id', $parent_ref);
727 $this->
ctrl->setParameterByClass(
'ilObjRoleGUI',
'obj_id', $src_id);
728 $url = $this->
ctrl->getLinkTargetByClass(
$path,
'userassignment');
729 $this->
ctrl->clearParametersByClass(
'ilObjRoleGUI');
738 static function (array
$c):
string {
741 $this->tree->getPathFull($src_id)
743 $hops = array_slice($hops, 1);
744 $title = implode(
' > ', $hops) ??
"-";
749 static function (array
$c):
string {
752 $this->tree->getPathFull($src_id)
754 $hops = array_slice($hops, 3);
755 $title = implode(
' > ', $hops) ??
"-";
759 throw new LogicException(
"This should not happen. Forgot a case in the switch?");
762 return $this->ui_factory->link()->standard($title,
$url);
765 protected function txt(
string $code): string
767 return $this->
lng->txt($code);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
GUI class for public user profile presentation.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
Class ilCtrl provides processing control methods.
Base class for ILIAS Exception handling.
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
Class ilObjStudyProgrammeAutoMembershipsGUI.
const CMD_GET_ASYNC_MODAL_OUTPUT
ilObjStudyProgramme $object
const CMD_DELETE_CONFIRMATION
getObject()
Get current StudyProgramme-object.
const CMD_PROFILE_NOT_PUBLIC
getToolbar(Signal $add_cat_signal)
Setup toolbar.
getModal(?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
getForm(?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
__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)
getUserRepresentation(int $usr_id)
getTitleRepresentation(ilStudyProgrammeAutoMembershipSource $ams)
getItemAction(string $src_id, Signal $signal, bool $is_enabled)
const F_ORIGINAL_SOURCE_ID
static array $switch_to_ref_id
enable()
Enable single entry.
setRefId(int $prg_ref_id)
Set ref-id of StudyProgramme before using this GUI.
parseQueryString(string $string)
disable()
Disable single entry.
view(bool $profile_not_public=false)
Render.
const F_ORIGINAL_SOURCE_TYPE
setParentGUI(ilContainerGUI $a_parent_gui)
Set this GUI's parent gui.
ilContainerGUI $parent_gui
const CHECKBOX_SOURCE_IDS
getSelectionForm(string $selected_source_type, string $selected_source, ?string $source_type=null, ?string $source_id=null)
static getInstanceByRefId($ref_id)
static _lookupName(int $a_user_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
This class represents an option in a radio group.
class ilRbacReview Contains Review functions of core Rbac.
Class ilStudyProgrammeAutoMembershipSource.
Class ilStudyProgrammeAutoMembershipsTableGUI.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
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.
This describes commonalities between all types of Dropdowns.
An entity that renders components to a string output.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.