ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjStudyProgrammeAutoMembershipsGUI Class Reference

Class ilObjStudyProgrammeAutoMembershipsGUI. More...

+ Collaboration diagram for ilObjStudyProgrammeAutoMembershipsGUI:

Public Member Functions

 __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)
 
 executeCommand ()
 
 setRefId (int $prg_ref_id)
 Set ref-id of StudyProgramme before using this GUI. More...
 
 setParentGUI (ilContainerGUI $a_parent_gui)
 Set this GUI's parent gui. More...
 

Data Fields

const CHECKBOX_SOURCE_IDS = 'c_amsids'
 
const CMD_GET_ASYNC_MODAL_OUTPUT = 'getAsynchModalOutput'
 
const CMD_NEXT_STEP = 'nextStep'
 
ilObjStudyProgramme $object = null
 
int $prg_ref_id
 

Protected Member Functions

 nextStep ()
 
 view (bool $profile_not_public=false)
 Render. More...
 
 save ()
 
 deleteConfirmation ()
 
 delete ()
 
 enable ()
 Enable single entry. More...
 
 disable ()
 Disable single entry. More...
 
 getObject ()
 Get current StudyProgramme-object. More...
 
 getModal (?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
 
 getAsynchModalOutput ()
 
 getForm (?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
 
 getSelectionForm (string $selected_source_type, string $selected_source, ?string $source_type=null, ?string $source_id=null)
 
 parseQueryString (string $string)
 
 getToolbar (Signal $add_cat_signal)
 Setup toolbar. More...
 
 getItemAction (string $src_id, Signal $signal, bool $is_enabled)
 
 getUserRepresentation (int $usr_id)
 
 getTitleRepresentation (ilStudyProgrammeAutoMembershipSource $ams)
 
 txt (string $code)
 

Protected Attributes

ilContainerGUI $parent_gui
 

Private Attributes

const ROLEFOLDER_REF_ID = 8
 
const F_SOURCE_TYPE = 'f_st'
 
const F_SOURCE_ID = 'f_sid'
 
const F_ORIGINAL_SOURCE_TYPE = 'f_st_org'
 
const F_ORIGINAL_SOURCE_ID = 'f_sid_org'
 
const F_SEARCH_RECURSIVE = "f_search_recursive"
 
const CMD_VIEW = 'view'
 
const CMD_SAVE = 'save'
 
const CMD_DELETE = 'delete'
 
const CMD_DELETE_CONFIRMATION = 'deleteConfirmation'
 
const CMD_ENABLE = 'enable'
 
const CMD_DISABLE = 'disable'
 
const CMD_PROFILE_NOT_PUBLIC = 'profile_not_public'
 

Static Private Attributes

static array $switch_to_ref_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjStudyProgrammeAutoMembershipsGUI::__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 
)

Definition at line 66 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\UICore\GlobalTemplate\addJavaScript().

80  {
81  // Add this js manually here because the modal contains a form that is
82  // loaded asynchronously later on, and this JS won't be pulled then for
83  // some reason.
84  $tpl->addJavaScript("assets/js/Form.js");
85  }
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilObjStudyProgrammeAutoMembershipsGUI::delete ( )
protected

Definition at line 278 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $id, ILIAS\Repository\ctrl(), getObject(), and ILIAS\Repository\lng().

278  : void
279  {
280  $field = self::CHECKBOX_SOURCE_IDS;
281  $get = $this->request->getQueryParams();
282 
283  if (!array_key_exists($field, $get)) {
284  $this->tpl->setOnScreenMessage("failure", $this->lng->txt('prg_delete_failure'), true);
285  $this->ctrl->redirect($this, self::CMD_VIEW);
286  }
287 
288  $type_ids = base64_decode($get[$field]);
289  $type_ids = explode(' ', trim($type_ids));
290 
291  foreach ($type_ids as $src_id) {
292  [$type, $id] = explode('-', $src_id);
293  $this->getObject()->deleteAutomaticMembershipSource((string) $type, (int) $id);
294  }
295 
296  $msg = $this->lng->txt('prg_delete_single_success');
297  if (count($type_ids) > 1) {
298  $msg = $this->lng->txt('prg_delete_success');
299  }
300 
301  $this->tpl->setOnScreenMessage("success", $msg, true);
302  $this->ctrl->redirect($this, self::CMD_VIEW);
303  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ deleteConfirmation()

ilObjStudyProgrammeAutoMembershipsGUI::deleteConfirmation ( )
protected

Definition at line 239 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $post, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

239  : void
240  {
241  $get = $this->request->getQueryParams();
242  $post = $this->request->getParsedBody();
243  $field = self::CHECKBOX_SOURCE_IDS;
244 
245  $field_ids_in_get = array_key_exists($field, $get);
246  $field_ids_in_post = array_key_exists($field, $post);
247 
248  $type_ids = '';
249  $msg = '';
250  if ($field_ids_in_get) {
251  $type_ids = $get[$field];
252  $msg = $this->lng->txt('prg_delete_single_confirmation');
253  } elseif ($field_ids_in_post) {
254  $type_ids = implode(' ', $post[$field]);
255  $msg = $this->lng->txt('prg_delete_confirmation');
256  } else {
257  $this->tpl->setOnScreenMessage("info", $this->lng->txt('prg_delete_nothing_selected'), true);
258  $this->ctrl->redirect($this, self::CMD_VIEW);
259  }
260 
261  $type_ids = base64_encode($type_ids);
262 
263  $this->ctrl->setParameterByClass(self::class, $field, $type_ids);
264  $delete = $this->ctrl->getFormActionByClass(self::class, self::CMD_DELETE);
265  $cancel = $this->ctrl->getFormActionByClass(self::class, self::CMD_VIEW);
266  $this->ctrl->clearParameterByClass(self::class, $field);
267 
268  $buttons = [
269  $this->button_factory->standard($this->lng->txt('prg_confirm_delete'), $delete),
270  $this->button_factory->standard($this->lng->txt('prg_cancel'), $cancel)
271  ];
272 
273  $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
274 
275  $this->tpl->setContent($this->ui_renderer->render($message_box));
276  }
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ disable()

ilObjStudyProgrammeAutoMembershipsGUI::disable ( )
protected

Disable single entry.

Definition at line 322 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $id, ILIAS\Repository\ctrl(), and getObject().

322  : void
323  {
324  $get = $this->request->getQueryParams();
325  $field = self::CHECKBOX_SOURCE_IDS;
326  if (array_key_exists($field, $get)) {
327  [$type, $id, $search_recursive] = explode('-', $get[$field]);
328  $this->getObject()->disableAutomaticMembershipSource((string) $type, (int) $id, (bool) $search_recursive);
329  }
330  $this->ctrl->redirect($this, self::CMD_VIEW);
331  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ enable()

ilObjStudyProgrammeAutoMembershipsGUI::enable ( )
protected

Enable single entry.

Definition at line 308 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $id, ILIAS\Repository\ctrl(), and getObject().

308  : void
309  {
310  $get = $this->request->getQueryParams();
311  $field = self::CHECKBOX_SOURCE_IDS;
312  if (array_key_exists($field, $get)) {
313  [$type, $id, $search_recursive] = explode('-', $get[$field]);
314  $this->getObject()->enableAutomaticMembershipSource((string) $type, (int) $id, (bool) $search_recursive);
315  }
316  $this->ctrl->redirect($this, self::CMD_VIEW);
317  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ executeCommand()

ilObjStudyProgrammeAutoMembershipsGUI::executeCommand ( )

Definition at line 86 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\ctrl(), and view().

86  : void
87  {
88  $cmd = $this->ctrl->getCmd();
89  switch ($cmd) {
90  case self::CMD_VIEW:
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:
96  case self::CMD_SAVE:
97  $this->$cmd();
98  break;
99  case self::CMD_ENABLE:
100  $this->$cmd();
101  $this->ctrl->redirect($this, self::CMD_VIEW);
102  break;
103  case self::CMD_PROFILE_NOT_PUBLIC:
104  $this->view(true);
105  break;
106  case 'handleExplorerCommand':
107  break;
108  default:
109  throw new ilException("ilObjStudyProgrammeAutoMembershipsGUI: Command not supported: $cmd");
110  }
111  }
+ Here is the call graph for this function:

◆ getAsynchModalOutput()

ilObjStudyProgrammeAutoMembershipsGUI::getAsynchModalOutput ( )
protected

Definition at line 382 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $id, ILIAS\Repository\ctrl(), exit, getForm(), null, ILIAS\Repository\refinery(), txt(), and ilStudyProgrammeAutoMembershipSource\TYPE_ORGU.

382  : void
383  {
384  $current_src_type = null;
385  if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
386  $current_src_type = $this->request_wrapper->retrieve(
387  self::F_ORIGINAL_SOURCE_TYPE,
388  $this->refinery->to()->string()
389  );
390  }
391 
392  $current_src_id = null;
393  if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
394  $current_src_id = $this->request_wrapper->retrieve(self::F_ORIGINAL_SOURCE_ID, $this->refinery->kindlyTo()->int());
395  }
396 
397  $search_recursive = false;
398  if ($this->request_wrapper->has(self::F_SEARCH_RECURSIVE)) {
399  $search_recursive = $this->request_wrapper->retrieve(self::F_SEARCH_RECURSIVE, $this->refinery->kindlyTo()->bool());
400  }
401  $form = $this->getForm($current_src_type, $current_src_id, $search_recursive);
402  $form_id = "form_" . $form->getId();
403 
404  $modal = $this->ui_factory->modal()->roundtrip(
405  $this->txt('modal_member_auto_select_title'),
406  $this->ui_factory->legacy()->content($form->getHtml())
407  );
408 
409  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, $current_src_type);
410  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $current_src_id);
411  $link = $this->ctrl->getLinkTarget($this, "nextStep", "", true);
412  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, null);
413  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, null);
414 
415  $replaceSignal = $modal->getReplaceSignal();
416  $signal_id = $replaceSignal->getId();
417  $f_selected_type = self::F_SOURCE_TYPE;
418  $f_selected_id = self::F_SOURCE_ID;
419  $submit = $this->ui_factory->button()->primary($this->txt('search'), "#")
420  ->withOnLoadCode(
421  function ($id) use ($form_id, $link, $signal_id, $f_selected_type, $f_selected_id) {
422  return
423  "$('#$id').click(function() {
424 
425  var checked = $(\"input[name='$f_selected_type']:checked\"). val();
426  if(checked == 'orgu' || typeof(checked) == \"undefined\") {
427  console.log('$(\'#$form_id\').submit()');
428  document.getElementById('$form_id').submit();
429  return false;
430  }
431 
432  var i_value = $(\"input[name='$f_selected_id\" + checked + \"']\"). val();
433  if(i_value == '' || typeof(i_value) == \"undefined\") {
434  document.getElementById('$form_id').submit();
435  return false;
436  }
437 
438  n_url = '$link' + '&$f_selected_type=' + checked + '&$f_selected_id=' + i_value;
439  $('#$id').attr(\"onclick\", function(event) {
440  $(this).trigger('$signal_id',
441  {
442  'id' : '$signal_id', 'event' : 'click',
443  'triggerer' : $(this),
444  'options' : JSON.parse('{\"url\":\"' + n_url + '\"}')
445  }
446  );
447  });
448  return false;
449  }
450  );";
451  }
452  );
453 
454  $modal = $modal->withActionButtons([$submit])
455  ->withAdditionalOnLoadCode(
456  function ($id) use ($form) {
457  $selector_post_var = self::F_SOURCE_ID . ilStudyProgrammeAutoMembershipSource::TYPE_ORGU;
458  $js = $form->getItemByPostVar($selector_post_var)->getOnloadCode();
459  return implode(';', $js);
460  }
461  );
462 
463  echo $this->ui_renderer->renderAsync($modal);
464  exit;
465  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getForm(?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getForm()

ilObjStudyProgrammeAutoMembershipsGUI::getForm ( ?string  $source_type = null,
?int  $source_id = null,
bool  $search_recursive = false 
)
protected

Definition at line 467 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\ctrl(), ilObjOrgUnit\getRootOrgRefId(), txt(), ilStudyProgrammeAutoMembershipSource\TYPE_COURSE, ilStudyProgrammeAutoMembershipSource\TYPE_GROUP, ilStudyProgrammeAutoMembershipSource\TYPE_ORGU, and ilStudyProgrammeAutoMembershipSource\TYPE_ROLE.

Referenced by getAsynchModalOutput(), and save().

472  $form = new ilPropertyFormGUI();
473 
474  if (is_null($source_type)) {
475  $source_type = "";
476  }
477 
478  $form->setId(uniqid($source_type . $source_id, true));
479  $form->setFormAction($this->ctrl->getFormAction($this, 'save'));
480 
481  $rgroup = new ilRadioGroupInputGUI($this->txt('membership_source_type'), self::F_SOURCE_TYPE);
482  $rgroup->setValue($source_type);
483  $form->addItem($rgroup);
484 
485  $radio_role = new ilRadioOption(
488  );
489 
490  $ni_role = new ilTextInputGUI(
493  );
494  $radio_role->addSubItem($ni_role);
495  $rgroup->addOption($radio_role);
496 
497  $radio_grp = new ilRadioOption(
500  );
501  $ni_grp = new ilTextInputGUI(
504  );
505  $radio_grp->addSubItem($ni_grp);
506  $rgroup->addOption($radio_grp);
507 
508  $radio_crs = new ilRadioOption(
511  );
512  $ni_crs = new ilTextInputGUI(
515  );
516  $radio_crs->addSubItem($ni_crs);
517  $rgroup->addOption($radio_crs);
518 
519  $radio_orgu = new ilRadioOption(
522  );
523  $orgu = new ilRepositorySelector2InputGUI(
524  "",
526  false,
527  $this
528  );
529  $orgu->getExplorerGUI()->setSelectableTypes(["orgu"]);
530  $orgu->getExplorerGUI()->setTypeWhiteList(["root", "orgu"]);
531  $orgu->getExplorerGUI()->setRootId(ilObjOrgUnit::getRootOrgRefId());
532  $orgu->getExplorerGUI()->setAjax(false);
533  $radio_orgu->addSubItem($orgu);
534 
535  $recurse = new ilCheckboxInputGUI($this->txt('search_for_orgu_members_recursive'), self::F_SEARCH_RECURSIVE);
536  $recurse->setValue('1');
537  $recurse->setChecked($search_recursive);
538  $radio_orgu->addSubItem($recurse);
539  $rgroup->addOption($radio_orgu);
540  if (
541  !is_null($source_type) &&
542  !is_null($source_id) &&
543  $source_type !== "" &&
544  $source_id !== ""
545  ) {
546  switch ($source_type) {
548  $ni_role->setValue($source_id);
549  break;
551  $ni_grp->setValue($source_id);
552  break;
554  $ni_crs->setValue($source_id);
555  break;
557  $orgu->setValue($source_id);
558  break;
559  default:
560  }
561  }
562 
563  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_TYPE);
564  $hi->setValue($source_type);
565  $form->addItem($hi);
566 
567  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_ID);
568  $hi->setValue((string) $source_id ?? '');
569  $form->addItem($hi);
570 
571  return $form;
572  }
This class represents an option in a radio group.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
static getRootOrgRefId()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItemAction()

ilObjStudyProgrammeAutoMembershipsGUI::getItemAction ( string  $src_id,
Signal  $signal,
bool  $is_enabled 
)
protected

Definition at line 646 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\ctrl(), and txt().

Referenced by view().

650  : Dropdown\Standard {
651  $items = [];
652 
653  $items[] = $this->ui_factory->button()->shy($this->txt('edit'), '')
654  ->withOnClick($signal);
655 
656  $this->ctrl->setParameter($this, self::CHECKBOX_SOURCE_IDS, $src_id);
657 
658  if ($is_enabled) {
659  $items[] = $this->ui_factory->button()->shy(
660  $this->txt('deactivate'),
661  $this->ctrl->getLinkTarget($this, self::CMD_DISABLE)
662  );
663  } else {
664  $items[] = $this->ui_factory->button()->shy(
665  $this->txt('activate'),
666  $this->ctrl->getLinkTarget($this, self::CMD_ENABLE)
667  );
668  }
669 
670  $items[] = $this->ui_factory->button()->shy(
671  $this->txt('delete'),
672  $this->ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION)
673  );
674 
675  $this->ctrl->clearParameters($this);
676 
677  return $this->ui_factory->dropdown()->standard($items);
678  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModal()

ilObjStudyProgrammeAutoMembershipsGUI::getModal ( ?string  $source_type = null,
?int  $source_id = null,
bool  $search_recursive = false 
)
protected

Definition at line 362 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\ctrl(), and null.

Referenced by view().

366  : RoundTrip {
367  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, $source_type);
368  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, $source_id);
369  $this->ctrl->setParameter($this, self::F_SEARCH_RECURSIVE, $search_recursive);
370  $link = $this->ctrl->getLinkTarget($this, "getAsynchModalOutput", "", true);
371  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_TYPE, null);
372  $this->ctrl->setParameter($this, self::F_ORIGINAL_SOURCE_ID, null);
373  $this->ctrl->setParameter($this, self::F_SEARCH_RECURSIVE, null);
374 
375  return $this->ui_factory->modal()->roundtrip(
376  '',
377  []
378  )
379  ->withAsyncRenderUrl($link);
380  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObject()

ilObjStudyProgrammeAutoMembershipsGUI::getObject ( )
protected

Get current StudyProgramme-object.

Definition at line 352 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $object, $prg_ref_id, ilObjStudyProgramme\getInstanceByRefId(), null, and ILIAS\Repository\object().

Referenced by delete(), disable(), enable(), save(), and view().

353  {
354  if ($this->object === null ||
355  $this->object->getRefId() !== $this->prg_ref_id
356  ) {
357  $this->object = ilObjStudyProgramme::getInstanceByRefId($this->prg_ref_id);
358  }
359  return $this->object;
360  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelectionForm()

ilObjStudyProgrammeAutoMembershipsGUI::getSelectionForm ( string  $selected_source_type,
string  $selected_source,
?string  $source_type = null,
?string  $source_id = null 
)
protected

Definition at line 574 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ilObject\_lookupDescription(), ilObject\_lookupTitle(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), parseQueryString(), and txt().

Referenced by nextStep().

580  $form = new ilPropertyFormGUI();
581  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
582 
583  $query_parser = $this->parseQueryString($selected_source);
584  $object_search = new ilLikeObjectSearch($query_parser);
585  $object_search->setFilter(array($selected_source_type));
586  $entries = $object_search->performSearch()->getEntries();
587 
588  $rgoup = new ilRadioGroupInputGUI(
589  $this->txt("prg_auto_member_select_" . $selected_source_type),
590  self::F_SOURCE_ID . $selected_source_type
591  );
592  $form->addItem($rgoup);
593  foreach ($entries as $entry) {
594  $obj_id = (int) $entry['obj_id'];
595  $title = ilObject::_lookupTitle($obj_id);
596  $description = ilObject::_lookupDescription($obj_id);
597 
598  $option = new ilRadioOption($title, (string) $obj_id, $description);
599  $rgoup->addOption($option);
600  }
601 
602  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_TYPE);
603  $hi->setValue($source_type ?? '');
604  $form->addItem($hi);
605 
606  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_ID);
607  $hi->setValue((string) $source_id);
608  $form->addItem($hi);
609 
610  $hi = new ilHiddenInputGUI(self::F_SOURCE_TYPE);
611  $hi->setValue($selected_source_type);
612  $form->addItem($hi);
613 
614  return $form;
615  }
This class represents an option in a radio group.
This class represents a hidden form property in a property form.
This class represents a property in a property form.
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitleRepresentation()

ilObjStudyProgrammeAutoMembershipsGUI::getTitleRepresentation ( ilStudyProgrammeAutoMembershipSource  $ams)
protected

Definition at line 702 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $c, $path, $url, ilLink\_getStaticLink(), ilObject\_lookupTitle(), ilObject\_lookupType(), ILIAS\Repository\ctrl(), ilStudyProgrammeAutoMembershipSource\getSourceId(), ilStudyProgrammeAutoMembershipSource\getSourceType(), ilStudyProgrammeAutoMembershipSource\TYPE_COURSE, ilStudyProgrammeAutoMembershipSource\TYPE_GROUP, ilStudyProgrammeAutoMembershipSource\TYPE_ORGU, and ilStudyProgrammeAutoMembershipSource\TYPE_ROLE.

Referenced by view().

704  : Link\Standard {
705  $src_id = $ams->getSourceId();
706 
707  switch ($ams->getSourceType()) {
709  $title = ilObjRole::_lookupTitle($src_id) ?? "-";
710 
711  if ($this->rbac_review->isGlobalRole($src_id)) {
712  $parent_ref = self::ROLEFOLDER_REF_ID;
713  $path = ['ilAdministrationGUI'];
714  $this->ctrl->setParameterByClass('ilObjRoleGUI', 'admin_mode', 'settings');
715  } else {
716  $parent_ref = $this->rbac_review->getObjectReferenceOfRole($src_id);
717  $parent_type = ilObject::_lookupType($parent_ref, true);
718  $path = ['ilRepositoryGUI','ilObjCategoryGUI'];
719  if ($parent_type == 'orgu') {
720  $path = ['ilAdministrationGUI','ilObjOrgUnitGUI'];
721  }
722  $path[] = 'ilPermissionGUI';
723  }
724  $path[] = 'ilObjRoleGUI';
725  $this->ctrl->setParameterByClass('ilObjRoleGUI', 'ref_id', $parent_ref);
726  $this->ctrl->setParameterByClass('ilObjRoleGUI', 'obj_id', $src_id);
727  $url = $this->ctrl->getLinkTargetByClass($path, 'userassignment');
728  $this->ctrl->clearParametersByClass('ilObjRoleGUI');
729  break;
730 
732  $url = ilLink::_getStaticLink($src_id, 'crs');
733  // no break
735  $url = ilLink::_getStaticLink($src_id, 'grp');
736  $hops = array_map(
737  static function (array $c): string {
738  return ilObject::_lookupTitle((int) $c["obj_id"]);
739  },
740  $this->tree->getPathFull($src_id)
741  );
742  $hops = array_slice($hops, 1);
743  $title = implode(' > ', $hops) ?? "-";
744  break;
745 
747  $hops = array_map(
748  static function (array $c): string {
749  return ilObject::_lookupTitle((int) $c["obj_id"]);
750  },
751  $this->tree->getPathFull($src_id)
752  );
753  $hops = array_slice($hops, 3);
754  $title = implode(' > ', $hops) ?? "-";
755  $url = ilLink::_getStaticLink($src_id, $ams->getSourceType());
756  break;
757  default:
758  throw new LogicException("This should not happen. Forgot a case in the switch?");
759  }
760 
761  return $this->ui_factory->link()->standard($title, $url);
762  }
$url
Definition: shib_logout.php:66
$c
Definition: deliver.php:25
$path
Definition: ltiservices.php:29
static _lookupTitle(int $obj_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getToolbar()

ilObjStudyProgrammeAutoMembershipsGUI::getToolbar ( Signal  $add_cat_signal)
protected

Setup toolbar.

Definition at line 637 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\toolbar(), and txt().

Referenced by view().

637  : void
638  {
639  $btn = $this->ui_factory->button()->primary($this->txt('add_automembership_source'), '')
640  ->withOnClick($add_cat_signal);
641  $this->toolbar->addComponent($btn);
642  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserRepresentation()

ilObjStudyProgrammeAutoMembershipsGUI::getUserRepresentation ( int  $usr_id)
protected

Definition at line 680 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $url, ilObjUser\_lookupName(), ILIAS\Repository\ctrl(), and ilObjectFactory\getInstanceByObjId().

Referenced by view().

680  : Link\Standard
681  {
682  $username = ilObjUser::_lookupName($usr_id);
683  $editor = implode(' ', [
684  $username['firstname'],
685  $username['lastname'],
686  '(' . $username['login'] . ')'
687  ]);
688 
689  $back_url = $this->ctrl->getLinkTarget($this, self::CMD_VIEW);
690  $this->ctrl->setParameterByClass('ilPublicUserProfileGUI', 'back_url', urlencode($back_url));
691  $this->ctrl->setParameterByClass('ilPublicUserProfileGUI', 'user_id', $usr_id);
692  $url = $this->ctrl->getLinkTargetByClass('ilPublicUserProfileGUI', 'view');
693 
694  $usr = ilObjectFactory::getInstanceByObjId($usr_id);
695  if (!$usr->hasPublicProfile()) {
696  $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
697  }
698  return $this->ui_factory->link()->standard($editor, $url);
699  }
static _lookupName(int $a_user_id)
lookup user name
$url
Definition: shib_logout.php:66
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextStep()

ilObjStudyProgrammeAutoMembershipsGUI::nextStep ( )
protected

Definition at line 113 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $id, exit, getSelectionForm(), null, ILIAS\Repository\refinery(), and txt().

113  : void
114  {
115  $current_src_type = null;
116  if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_TYPE)) {
117  $current_src_type = $this->request_wrapper->retrieve(
118  self::F_ORIGINAL_SOURCE_TYPE,
119  $this->refinery->to()->string()
120  );
121  }
122 
123  $current_src_id = null;
124  if ($this->request_wrapper->has(self::F_ORIGINAL_SOURCE_ID)) {
125  $current_src_id = $this->request_wrapper->retrieve(
126  self::F_ORIGINAL_SOURCE_ID,
127  $this->refinery->to()->string()
128  );
129  }
130 
131  $selected_src_type = $this->request_wrapper->retrieve(self::F_SOURCE_TYPE, $this->refinery->kindlyTo()->string());
132  $selected_src = $this->request_wrapper->retrieve(self::F_SOURCE_ID, $this->refinery->kindlyTo()->string());
133 
134  $form = $this->getSelectionForm(
135  $selected_src_type,
136  $selected_src,
137  $current_src_type,
138  $current_src_id
139  );
140  $form_id = "form_" . $form->getId();
141 
142  $modal = $this->ui_factory->modal()->roundtrip(
143  $this->txt('modal_member_auto_select_title'),
144  $this->ui_factory->legacy()->content($form->getHtml())
145  );
146 
147  $submit = $this->ui_factory->button()->primary($this->txt('add'), "#")->withOnLoadCode(
148  function ($id) use ($form_id) {
149  return "$('#$id').click(function() { $('#$form_id').submit(); return false; });";
150  }
151  );
152 
153  $modal = $modal->withActionButtons([$submit]);
154 
155  echo $this->ui_renderer->renderAsync($modal);
156  exit;
157  }
getSelectionForm(string $selected_source_type, string $selected_source, ?string $source_type=null, ?string $source_id=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ parseQueryString()

ilObjStudyProgrammeAutoMembershipsGUI::parseQueryString ( string  $string)
protected
Returns
ilQueryParser|string

Definition at line 620 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ilQueryParser\QP_COMBINATION_AND, and ilUtil\stripSlashes().

Referenced by getSelectionForm().

621  {
622  $query_parser = new ilQueryParser(ilUtil::stripSlashes($string));
623  $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
624  $query_parser->setMinWordLength(1);
625  $query_parser->setGlobalMinLength(3); // #14768
626  $query_parser->parse();
627 
628  if (!$query_parser->validate()) {
629  return $query_parser->getMessage();
630  }
631  return $query_parser;
632  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilObjStudyProgrammeAutoMembershipsGUI::save ( )
protected

Definition at line 199 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $post, ilObject\_getAllReferences(), ILIAS\Repository\ctrl(), getForm(), getObject(), ILIAS\Repository\int(), null, and txt().

199  : void
200  {
201  $form = $this->getForm();
202  $form->checkInput();
203 
204  $post = $this->request->getParsedBody();
205  $form->setValuesByArray($post);
206  $src_type = $post[self::F_SOURCE_TYPE];
207  $src_id = $post[self::F_SOURCE_ID . $src_type] ?? null;
208  $search_recursive = (bool) ($post[self::F_SEARCH_RECURSIVE] ?? false);
209 
210  if (
211  (is_null($src_type) || $src_type === "") ||
212  (is_null($src_id) || $src_id === 0)
213  ) {
214  $this->tpl->setOnScreenMessage("failure", $this->txt('no_srctype_or_id'), true);
215  $this->ctrl->redirect($this, self::CMD_VIEW);
216  return;
217  }
218 
219  if (in_array($src_type, self::$switch_to_ref_id)) {
220  $refs = ilObject::_getAllReferences((int) $src_id);
221  $src_id = (int) array_shift($refs);
222  }
223 
224  if (
225  array_key_exists(self::F_ORIGINAL_SOURCE_TYPE, $post) &&
226  array_key_exists(self::F_ORIGINAL_SOURCE_ID, $post)
227  ) {
228  $this->getObject()->deleteAutomaticMembershipSource(
229  (string) $post[self::F_ORIGINAL_SOURCE_TYPE],
230  (int) $post[self::F_ORIGINAL_SOURCE_ID]
231  );
232  }
233 
234  $this->getObject()->storeAutomaticMembershipSource($src_type, (int) $src_id, $search_recursive);
235  $this->tpl->setOnScreenMessage("success", $this->txt("auto_add_success"), true);
236  $this->ctrl->redirect($this, self::CMD_VIEW);
237  }
static _getAllReferences(int $id)
get all reference ids for object ID
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getForm(?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ setParentGUI()

ilObjStudyProgrammeAutoMembershipsGUI::setParentGUI ( ilContainerGUI  $a_parent_gui)

Set this GUI's parent gui.

Definition at line 344 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

344  : void
345  {
346  $this->parent_gui = $a_parent_gui;
347  }

◆ setRefId()

ilObjStudyProgrammeAutoMembershipsGUI::setRefId ( int  $prg_ref_id)

Set ref-id of StudyProgramme before using this GUI.

Definition at line 336 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $prg_ref_id.

336  : void
337  {
338  $this->prg_ref_id = $prg_ref_id;
339  }

◆ txt()

ilObjStudyProgrammeAutoMembershipsGUI::txt ( string  $code)
protected

Definition at line 764 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References ILIAS\Repository\lng().

Referenced by getAsynchModalOutput(), getForm(), getItemAction(), getSelectionForm(), getToolbar(), nextStep(), and save().

764  : string
765  {
766  return $this->lng->txt($code);
767  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilObjStudyProgrammeAutoMembershipsGUI::view ( bool  $profile_not_public = false)
protected

Render.

Definition at line 162 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References $data, getItemAction(), getModal(), getObject(), getTitleRepresentation(), getToolbar(), getUserRepresentation(), and ILIAS\Repository\lng().

Referenced by executeCommand().

162  : void
163  {
164  if ($profile_not_public) {
165  $this->tpl->setOnScreenMessage("info", $this->lng->txt('prg_profile_not_public'));
166  }
167  $collected_modals = [];
168  $modal = $this->getModal();
169  $this->getToolbar($modal->getShowSignal());
170  $collected_modals[] = $modal;
171  $data = [];
172  foreach ($this->getObject()->getAutomaticMembershipSources() as $ams) {
173  $title = $this->getTitleRepresentation($ams);
174  $usr = $this->getUserRepresentation($ams->getLastEditorId()) ?? $this->ui_factory->legacy()->content('-');
175  $modal = $this->getModal($ams->getSourceType(), $ams->getSourceId(), $ams->isSearchRecursive());
176  $collected_modals[] = $modal;
177  $src_id = $ams->getSourceType() . '-' . $ams->getSourceId() . '-' . $ams->isSearchRecursive();
178  $actions = $this->getItemAction(
179  $src_id,
180  $modal->getShowSignal(),
181  $ams->isEnabled()
182  );
183 
184  $data[] = [
185  $ams,
186  $this->ui_renderer->render($title),
187  $this->ui_renderer->render($usr),
188  $this->ui_renderer->render($actions)
189  ];
190  }
191  $table = new ilStudyProgrammeAutoMembershipsTableGUI($this, "view", "");
192  $table->setData($data);
193  $this->tpl->setContent(
194  $this->ui_renderer->render($collected_modals)
195  . $table->getHTML()
196  );
197  }
getItemAction(string $src_id, Signal $signal, bool $is_enabled)
getTitleRepresentation(ilStudyProgrammeAutoMembershipSource $ams)
getModal(?string $source_type=null, ?int $source_id=null, bool $search_recursive=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $object

ilObjStudyProgramme ilObjStudyProgrammeAutoMembershipsGUI::$object = null

Definition at line 62 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

Referenced by getObject().

◆ $parent_gui

ilContainerGUI ilObjStudyProgrammeAutoMembershipsGUI::$parent_gui
protected

◆ $prg_ref_id

int ilObjStudyProgrammeAutoMembershipsGUI::$prg_ref_id

Definition at line 63 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

Referenced by getObject(), and setRefId().

◆ $switch_to_ref_id

array ilObjStudyProgrammeAutoMembershipsGUI::$switch_to_ref_id
staticprivate

◆ CHECKBOX_SOURCE_IDS

const ilObjStudyProgrammeAutoMembershipsGUI::CHECKBOX_SOURCE_IDS = 'c_amsids'

◆ CMD_DELETE

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_DELETE = 'delete'
private

◆ CMD_DELETE_CONFIRMATION

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_DELETE_CONFIRMATION = 'deleteConfirmation'
private

◆ CMD_DISABLE

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_DISABLE = 'disable'
private

◆ CMD_ENABLE

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_ENABLE = 'enable'
private

◆ CMD_GET_ASYNC_MODAL_OUTPUT

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_GET_ASYNC_MODAL_OUTPUT = 'getAsynchModalOutput'

◆ CMD_NEXT_STEP

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_NEXT_STEP = 'nextStep'

◆ CMD_PROFILE_NOT_PUBLIC

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_PROFILE_NOT_PUBLIC = 'profile_not_public'
private

◆ CMD_SAVE

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_SAVE = 'save'
private

◆ CMD_VIEW

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_VIEW = 'view'
private

◆ F_ORIGINAL_SOURCE_ID

const ilObjStudyProgrammeAutoMembershipsGUI::F_ORIGINAL_SOURCE_ID = 'f_sid_org'
private

◆ F_ORIGINAL_SOURCE_TYPE

const ilObjStudyProgrammeAutoMembershipsGUI::F_ORIGINAL_SOURCE_TYPE = 'f_st_org'
private

◆ F_SEARCH_RECURSIVE

const ilObjStudyProgrammeAutoMembershipsGUI::F_SEARCH_RECURSIVE = "f_search_recursive"
private

◆ F_SOURCE_ID

const ilObjStudyProgrammeAutoMembershipsGUI::F_SOURCE_ID = 'f_sid'
private

◆ F_SOURCE_TYPE

const ilObjStudyProgrammeAutoMembershipsGUI::F_SOURCE_TYPE = 'f_st'
private

◆ ROLEFOLDER_REF_ID

const ilObjStudyProgrammeAutoMembershipsGUI::ROLEFOLDER_REF_ID = 8
private

The documentation for this class was generated from the following file: