ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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'
 
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)
 
 getAsynchModalOutput ()
 
 getForm (string $source_type=null, ?string $source_id='')
 
 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 CMD_VIEW = 'view'
 
const CMD_SAVE = 'save'
 
const CMD_DELETE = 'delete'
 
const CMD_DELETE_CONFIRMATION = 'deleteConfirmation'
 
const CMD_GET_ASYNC_MODAL_OUTPUT = 'getAsynchModalOutput'
 
const CMD_NEXT_STEP = 'nextStep'
 
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 ilGlobalTemplateInterface\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("Services/Form/js/Form.js");
85  }
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilObjStudyProgrammeAutoMembershipsGUI::delete ( )
protected

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

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

276  : void
277  {
278  $field = self::CHECKBOX_SOURCE_IDS;
279  $get = $this->request->getQueryParams();
280 
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);
284  }
285 
286  $type_ids = base64_decode($get[$field]);
287  $type_ids = explode(' ', trim($type_ids));
288 
289  foreach ($type_ids as $src_id) {
290  [$type, $id] = explode('-', $src_id);
291  $this->getObject()->deleteAutomaticMembershipSource((string) $type, (int) $id);
292  }
293 
294  $msg = $this->lng->txt('prg_delete_single_success');
295  if (count($type_ids) > 1) {
296  $msg = $this->lng->txt('prg_delete_success');
297  }
298 
299  $this->tpl->setOnScreenMessage("success", $msg, true);
300  $this->ctrl->redirect($this, self::CMD_VIEW);
301  }
$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 237 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

237  : void
238  {
239  $get = $this->request->getQueryParams();
240  $post = $this->request->getParsedBody();
241  $field = self::CHECKBOX_SOURCE_IDS;
242 
243  $field_ids_in_get = array_key_exists($field, $get);
244  $field_ids_in_post = array_key_exists($field, $post);
245 
246  $type_ids = '';
247  $msg = '';
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');
254  } else {
255  $this->tpl->setOnScreenMessage("info", $this->lng->txt('prg_delete_nothing_selected'), true);
256  $this->ctrl->redirect($this, self::CMD_VIEW);
257  }
258 
259  $type_ids = base64_encode($type_ids);
260 
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);
265 
266  $buttons = [
267  $this->button_factory->standard($this->lng->txt('prg_confirm_delete'), $delete),
268  $this->button_factory->standard($this->lng->txt('prg_cancel'), $cancel)
269  ];
270 
271  $message_box = $this->message_box_factory->confirmation($msg)->withButtons($buttons);
272 
273  $this->tpl->setContent($this->ui_renderer->render($message_box));
274  }
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ disable()

ilObjStudyProgrammeAutoMembershipsGUI::disable ( )
protected

Disable single entry.

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

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

320  : void
321  {
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);
327  }
328  $this->ctrl->redirect($this, self::CMD_VIEW);
329  }
$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 306 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

306  : void
307  {
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);
313  }
314  $this->ctrl->redirect($this, self::CMD_VIEW);
315  }
$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  default:
107  throw new ilException("ilObjStudyProgrammeAutoMembershipsGUI: Command not supported: $cmd");
108  }
109  }
+ Here is the call graph for this function:

◆ getAsynchModalOutput()

ilObjStudyProgrammeAutoMembershipsGUI::getAsynchModalOutput ( )
protected

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

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

375  : void
376  {
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,
381  $this->refinery->to()->string()
382  );
383  }
384 
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());
388  }
389 
390  $form = $this->getForm($current_src_type, $current_src_id);
391  $form_id = "form_" . $form->getId();
392 
393  $modal = $this->ui_factory->modal()->roundtrip(
394  $this->txt('modal_member_auto_select_title'),
395  $this->ui_factory->legacy($form->getHtml())
396  );
397 
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);
403 
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'), "#")
409  ->withOnLoadCode(
410  function ($id) use ($form_id, $link, $signal_id, $f_selected_type, $f_selected_id) {
411  return
412  "$('#$id').click(function() {
413 
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();
418  return false;
419  }
420 
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();
424  return false;
425  }
426 
427  n_url = '$link' + '&$f_selected_type=' + checked + '&$f_selected_id=' + i_value;
428  $('#$id').attr(\"onclick\", function(event) {
429  $(this).trigger('$signal_id',
430  {
431  'id' : '$signal_id', 'event' : 'click',
432  'triggerer' : $(this),
433  'options' : JSON.parse('{\"url\":\"' + n_url + '\"}')
434  }
435  );
436  });
437  return false;
438  }
439  );";
440  }
441  );
442 
443  $modal = $modal->withActionButtons([$submit])
444  ->withAdditionalOnLoadCode(
445  function ($id) use ($form) {
446  $selector_post_var = self::F_SOURCE_ID . ilStudyProgrammeAutoMembershipSource::TYPE_ORGU;
447  $js = $form->getItemByPostVar($selector_post_var)->getOnloadCode();
448  return implode(';', $js);
449  }
450  );
451 
452  echo $this->ui_renderer->renderAsync($modal);
453  exit;
454  }
exit
Definition: login.php:29
getForm(string $source_type=null, ?string $source_id='')
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getForm()

ilObjStudyProgrammeAutoMembershipsGUI::getForm ( string  $source_type = null,
?string  $source_id = '' 
)
protected

Definition at line 456 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().

457  {
458  $form = new ilPropertyFormGUI();
459 
460  if (is_null($source_type)) {
461  $source_type = "";
462  }
463 
464  $form->setId(uniqid($source_type . $source_id, true));
465  $form->setFormAction($this->ctrl->getFormAction($this, 'save'));
466 
467  $rgroup = new ilRadioGroupInputGUI($this->txt('membership_source_type'), self::F_SOURCE_TYPE);
468  $rgroup->setValue($source_type);
469  $form->addItem($rgroup);
470 
471  $radio_role = new ilRadioOption(
474  );
475 
476  $ni_role = new ilTextInputGUI(
479  );
480  $radio_role->addSubItem($ni_role);
481  $rgroup->addOption($radio_role);
482 
483  $radio_grp = new ilRadioOption(
486  );
487  $ni_grp = new ilTextInputGUI(
490  );
491  $radio_grp->addSubItem($ni_grp);
492  $rgroup->addOption($radio_grp);
493 
494  $radio_crs = new ilRadioOption(
497  );
498  $ni_crs = new ilTextInputGUI(
501  );
502  $radio_crs->addSubItem($ni_crs);
503  $rgroup->addOption($radio_crs);
504 
505  $radio_orgu = new ilRadioOption(
508  );
509  $orgu = new ilRepositorySelector2InputGUI(
510  "",
512  false,
513  $this
514  );
515  $orgu->getExplorerGUI()->setSelectableTypes(["orgu"]);
516  $orgu->getExplorerGUI()->setTypeWhiteList(["root", "orgu"]);
517  $orgu->getExplorerGUI()->setRootId(ilObjOrgUnit::getRootOrgRefId());
518  $orgu->getExplorerGUI()->setAjax(false);
519  $radio_orgu->addSubItem($orgu);
520  $rgroup->addOption($radio_orgu);
521  if (
522  !is_null($source_type) &&
523  !is_null($source_id) &&
524  $source_type !== "" &&
525  $source_id !== ""
526  ) {
527  switch ($source_type) {
529  $ni_role->setValue($source_id);
530  break;
532  $ni_grp->setValue($source_id);
533  break;
535  $ni_crs->setValue($source_id);
536  break;
538  $orgu->setValue($source_id);
539  break;
540  default:
541  }
542  }
543 
544  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_TYPE);
545  $hi->setValue($source_type);
546  $form->addItem($hi);
547 
548  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_ID);
549  $hi->setValue($source_id ?? '');
550  $form->addItem($hi);
551 
552  return $form;
553  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 627 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

Referenced by view().

631  : Dropdown\Standard {
632  $items = [];
633 
634  $items[] = $this->ui_factory->button()->shy($this->txt('edit'), '')
635  ->withOnClick($signal);
636 
637  $this->ctrl->setParameter($this, self::CHECKBOX_SOURCE_IDS, $src_id);
638 
639  if ($is_enabled) {
640  $items[] = $this->ui_factory->button()->shy(
641  $this->txt('deactivate'),
642  $this->ctrl->getLinkTarget($this, self::CMD_DISABLE)
643  );
644  } else {
645  $items[] = $this->ui_factory->button()->shy(
646  $this->txt('activate'),
647  $this->ctrl->getLinkTarget($this, self::CMD_ENABLE)
648  );
649  }
650 
651  $items[] = $this->ui_factory->button()->shy(
652  $this->txt('delete'),
653  $this->ctrl->getLinkTarget($this, self::CMD_DELETE_CONFIRMATION)
654  );
655 
656  $this->ctrl->clearParameters($this);
657 
658  return $this->ui_factory->dropdown()->standard($items);
659  }
+ 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 
)
protected

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

References ILIAS\Repository\ctrl().

Referenced by view().

360  : RoundTrip
361  {
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);
367 
368  return $this->ui_factory->modal()->roundtrip(
369  '',
370  []
371  )
372  ->withAsyncRenderUrl($link);
373  }
+ 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 350 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

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

351  {
352  if ($this->object === null ||
353  $this->object->getRefId() !== $this->prg_ref_id
354  ) {
355  $this->object = ilObjStudyProgramme::getInstanceByRefId($this->prg_ref_id);
356  }
357  return $this->object;
358  }
+ 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 555 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

Referenced by nextStep().

561  $form = new ilPropertyFormGUI();
562  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
563 
564  $query_parser = $this->parseQueryString($selected_source);
565  $object_search = new ilLikeObjectSearch($query_parser);
566  $object_search->setFilter(array($selected_source_type));
567  $entries = $object_search->performSearch()->getEntries();
568 
569  $rgoup = new ilRadioGroupInputGUI(
570  $this->txt("prg_auto_member_select_" . $selected_source_type),
571  self::F_SOURCE_ID . $selected_source_type
572  );
573  $form->addItem($rgoup);
574  foreach ($entries as $entry) {
575  $obj_id = (int) $entry['obj_id'];
576  $title = ilObject::_lookupTitle($obj_id);
577  $description = ilObject::_lookupDescription($obj_id);
578 
579  $option = new ilRadioOption($title, (string) $obj_id, $description);
580  $rgoup->addOption($option);
581  }
582 
583  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_TYPE);
584  $hi->setValue($source_type ?? '');
585  $form->addItem($hi);
586 
587  $hi = new ilHiddenInputGUI(self::F_ORIGINAL_SOURCE_ID);
588  $hi->setValue((string) $source_id);
589  $form->addItem($hi);
590 
591  $hi = new ilHiddenInputGUI(self::F_SOURCE_TYPE);
592  $hi->setValue($selected_source_type);
593  $form->addItem($hi);
594 
595  return $form;
596  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 687 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

References Vendor\Package\$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().

689  : Link\Standard {
690  $src_id = $ams->getSourceId();
691 
692  switch ($ams->getSourceType()) {
694  $title = ilObjRole::_lookupTitle($src_id) ?? "-";
695 
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');
700  } else {
701  $parent_ref = $this->rbac_review->getObjectReferenceOfRole($src_id);
702  $parent_type = ilObject::_lookupType($parent_ref, true);
703  $path = ['ilRepositoryGUI','ilObjCategoryGUI'];
704  if($parent_type == 'orgu') {
705  $path = ['ilAdministrationGUI','ilObjOrgUnitGUI'];
706  }
707  $path[] = 'ilPermissionGUI';
708  }
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');
714  break;
715 
717  $url = ilLink::_getStaticLink($src_id, 'crs');
718  // no break
720  $url = ilLink::_getStaticLink($src_id, 'grp');
721  $hops = array_map(
722  static function (array $c): string {
723  return ilObject::_lookupTitle((int) $c["obj_id"]);
724  },
725  $this->tree->getPathFull($src_id)
726  );
727  $hops = array_slice($hops, 1);
728  $title = implode(' > ', $hops) ?? "-";
729  break;
730 
732  $hops = array_map(
733  static function (array $c): string {
734  return ilObject::_lookupTitle((int)$c["obj_id"]);
735  },
736  $this->tree->getPathFull($src_id)
737  );
738  $hops = array_slice($hops, 3);
739  $title = implode(' > ', $hops) ?? "-";
740  $url = ilLink::_getStaticLink($src_id, $ams->getSourceType());
741  break;
742  default:
743  throw new LogicException("This should not happen. Forgot a case in the switch?");
744  }
745 
746  return $this->ui_factory->link()->standard($title, $url);
747  }
$path
Definition: ltiservices.php:32
static _lookupTitle(int $obj_id)
$url
Definition: ltiregstart.php:35
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 618 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

Referenced by view().

618  : void
619  {
620  $btn = $this->ui_factory->button()->primary($this->txt('add_automembership_source'), '')
621  ->withOnClick($add_cat_signal);
622  $this->toolbar->addComponent($btn);
623  }
+ 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 661 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

Referenced by view().

661  : ?Link\Standard
662  {
663  $username = ilObjUser::_lookupName($usr_id);
664  if(array_filter($username) === []) {
665  return null;
666  }
667 
668  $editor = implode(' ', [
669  $username['firstname'],
670  $username['lastname'],
671  '(' . $username['login'] . ')'
672  ]);
673 
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');
678 
679  $usr = ilObjectFactory::getInstanceByObjId($usr_id);
680  if (!$usr->hasPublicProfile()) {
681  $url = $this->ctrl->getLinkTarget($this, self::CMD_PROFILE_NOT_PUBLIC);
682  }
683  return $this->ui_factory->link()->standard($editor, $url);
684  }
static _lookupName(int $a_user_id)
lookup user name
$url
Definition: ltiregstart.php:35
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 111 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

111  : void
112  {
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,
117  $this->refinery->to()->string()
118  );
119  }
120 
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,
125  $this->refinery->to()->string()
126  );
127  }
128 
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());
131 
132  $form = $this->getSelectionForm(
133  $selected_src_type,
134  $selected_src,
135  $current_src_type,
136  $current_src_id
137  );
138  $form_id = "form_" . $form->getId();
139 
140  $modal = $this->ui_factory->modal()->roundtrip(
141  $this->txt('modal_member_auto_select_title'),
142  $this->ui_factory->legacy($form->getHtml())
143  );
144 
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; });";
148  }
149  );
150 
151  $modal = $modal->withActionButtons([$submit]);
152 
153  echo $this->ui_renderer->renderAsync($modal);
154  exit;
155  }
exit
Definition: login.php:29
getSelectionForm(string $selected_source_type, string $selected_source, string $source_type=null, string $source_id=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ parseQueryString()

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

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

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

Referenced by getSelectionForm().

602  {
603  $query_parser = new ilQueryParser(ilUtil::stripSlashes($string));
604  $query_parser->setCombination(ilQueryParser::QP_COMBINATION_AND);
605  $query_parser->setMinWordLength(1);
606  $query_parser->setGlobalMinLength(3); // #14768
607  $query_parser->parse();
608 
609  if (!$query_parser->validate()) {
610  return $query_parser->getMessage();
611  }
612  return $query_parser;
613  }
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 198 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

198  : void
199  {
200  $form = $this->getForm();
201  $form->checkInput();
202 
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];
207 
208  if (
209  (is_null($src_type) || $src_type === "") ||
210  (is_null($src_id) || $src_id === 0)
211  ) {
212  $this->tpl->setOnScreenMessage("failure", $this->txt('no_srctype_or_id'), true);
213  $this->ctrl->redirect($this, self::CMD_VIEW);
214  return;
215  }
216 
217  if (in_array($src_type, self::$switch_to_ref_id)) {
218  $refs = ilObject::_getAllReferences((int) $src_id);
219  $src_id = (int) array_shift($refs);
220  }
221 
222  if (
223  array_key_exists(self::F_ORIGINAL_SOURCE_TYPE, $post) &&
224  array_key_exists(self::F_ORIGINAL_SOURCE_ID, $post)
225  ) {
226  $this->getObject()->deleteAutomaticMembershipSource(
227  (string) $post[self::F_ORIGINAL_SOURCE_TYPE],
228  (int) $post[self::F_ORIGINAL_SOURCE_ID]
229  );
230  }
231 
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);
235  }
static _getAllReferences(int $id)
get all reference ids for object ID
getForm(string $source_type=null, ?string $source_id='')
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ setParentGUI()

ilObjStudyProgrammeAutoMembershipsGUI::setParentGUI ( ilContainerGUI  $a_parent_gui)

Set this GUI's parent gui.

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

342  : void
343  {
344  $this->parent_gui = $a_parent_gui;
345  }

◆ setRefId()

ilObjStudyProgrammeAutoMembershipsGUI::setRefId ( int  $prg_ref_id)

Set ref-id of StudyProgramme before using this GUI.

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

References $prg_ref_id.

334  : void
335  {
336  $this->prg_ref_id = $prg_ref_id;
337  }

◆ txt()

ilObjStudyProgrammeAutoMembershipsGUI::txt ( string  $code)
protected

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

References ILIAS\Repository\lng().

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

749  : string
750  {
751  return $this->lng->txt($code);
752  }
+ 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 160 of file class.ilObjStudyProgrammeAutoMembershipsGUI.php.

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

Referenced by executeCommand().

160  : void
161  {
162  if ($profile_not_public) {
163  $this->tpl->setOnScreenMessage("info", $this->lng->txt('prg_profile_not_public'));
164  }
165  $collected_modals = [];
166  $modal = $this->getModal();
167  $this->getToolbar($modal->getShowSignal());
168  $collected_modals[] = $modal;
169  $data = [];
170  foreach ($this->getObject()->getAutomaticMembershipSources() as $ams) {
171  $title = $this->getTitleRepresentation($ams);
172  $usr = $this->getUserRepresentation($ams->getLastEditorId()) ?? $this->ui_factory->legacy('-');
173  $modal = $this->getModal($ams->getSourceType(), $ams->getSourceId());
174  $collected_modals[] = $modal;
175 
176  $src_id = $ams->getSourceType() . '-' . $ams->getSourceId();
177  $actions = $this->getItemAction(
178  $src_id,
179  $modal->getShowSignal(),
180  $ams->isEnabled()
181  );
182 
183  $data[] = [
184  $ams,
185  $this->ui_renderer->render($title),
186  $this->ui_renderer->render($usr),
187  $this->ui_renderer->render($actions)
188  ];
189  }
190  $table = new ilStudyProgrammeAutoMembershipsTableGUI($this, "view", "");
191  $table->setData($data);
192  $this->tpl->setContent(
193  $this->ui_renderer->render($collected_modals)
194  . $table->getHTML()
195  );
196  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getItemAction(string $src_id, Signal $signal, bool $is_enabled)
getTitleRepresentation(ilStudyProgrammeAutoMembershipSource $ams)
getModal(string $source_type=null, int $source_id=null)
+ 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'
private

◆ CMD_NEXT_STEP

const ilObjStudyProgrammeAutoMembershipsGUI::CMD_NEXT_STEP = 'nextStep'
private

◆ 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_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: