43         private readonly 
int $parent_ref_id,
    44         int $a_parent_obj_id = null,
    45         string $a_parent_obj_type = null
    49         $this->
lng = $DIC->language();
    50         $this->
ctrl = $DIC->ctrl();
    51         $this->
tabs = $DIC->tabs();
    52         $this->
access = $DIC->access();
    53         $this->
toolbar = $DIC->toolbar();
    54         $this->ui_factory = $DIC->ui()->factory();
    55         $this->tpl = $DIC[
'tpl'];
    56         $this->
user = $DIC->user();
    57         $lng = $DIC->language();
    58         $this->parent_obj_id = $a_parent_obj_id
    60         $this->parent_obj_type = $a_parent_obj_type
    82         $cmd = $ilCtrl->getCmd(
'listBadges');
    84         switch ($next_class) {
    85             case 'ilpropertyformgui':
    87                 if ($this->request->getBadgeId()) {
    88                     $badge = 
new ilBadge($this->request->getBadgeId());
    89                     $type = $badge->getTypeInstance();
    94                     $type_id = $this->request->getType();
    95                     $ilCtrl->setParameter($this, 
'type', $type_id);
    97                     $type = 
$handler->getTypeInstanceByUniqueId($type_id);
   100                 $ilCtrl->forwardCommand($form);
   109     protected function setTabs(
string $a_active): void
   117             $lng->
txt(
'obj_bdga'),
   118             $ilCtrl->getLinkTarget($this, 
'listBadges')
   124             $ilCtrl->getLinkTarget($this, 
'listUsers')
   127         $ilTabs->activateSubTab($a_active);
   133         return $ilAccess->
checkAccess(
'write', 
'', $this->parent_ref_id);
   147             $valid_types = 
$handler->getAvailableTypesForObjType($this->parent_obj_type);
   150                 foreach ($valid_types as 
$id => $type) {
   151                     $ilCtrl->setParameter($this, 
'type', 
$id);
   152                     $options[
$id] = $this->ui_factory->link()->standard(
   155                         $ilCtrl->getLinkTarget($this, 
'addBadge')
   157                     $ilCtrl->setParameter($this, 
'type', null);
   160                 $options = array_values($options);
   162                 $ilToolbar->addComponent(
   163                     $this->ui_factory->dropdown()->standard($options)->withLabel($lng->
txt(
'badge_create'))
   166                 $this->tpl->setOnScreenMessage(
'info', $lng->
txt(
'badge_no_valid_types_for_obj'));
   169             $clip_ids = $this->session_repo->getBadgeIds();
   170             if (count($clip_ids) > 0) {
   172                     $ilToolbar->addSeparator();
   177                     $tt[] = $badge->getTitle();
   182                     implode(
'<br />', $tt),
   190                 $ilToolbar->addButton(
   191                     $lng->
txt(
'cont_paste_from_clipboard') .
   192                     ' (' . count($tt) . 
')',
   193                     $ilCtrl->getLinkTarget($this, 
'pasteBadges'),
   199                 $ilToolbar->addButton(
   200                     $lng->
txt(
'clear_clipboard'),
   201                     $ilCtrl->getLinkTarget($this, 
'clearClipboard')
   214         $tbl->writeFilterToSession();
   236         $type_id = $this->request->getType();
   239             $ilCtrl->redirect($this, 
'listBadges');
   242         $ilCtrl->setParameter($this, 
'type', $type_id);
   245         $type = 
$handler->getTypeInstanceByUniqueId($type_id);
   247             $ilCtrl->redirect($this, 
'listBadges');
   260         string $a_type_unique_id
   266         $form->setFormAction($ilCtrl->getFormAction($this, 
'saveBadge'));
   267         $form->setTitle($lng->
txt(
'badge_badge') . 
' "' . $a_type->
getCaption() . 
'"');
   270         $form->addItem($active);
   273         $title->setMaxLength(255);
   274         $title->setRequired(
true);
   275         $form->addItem($title);
   279         $desc->setRequired(
true);
   280         $form->addItem($desc);
   284         $crit->setRequired(
true);
   285         $form->addItem($crit);
   287         if ($a_mode === 
'create') {
   292             $img_mode->setValue(
'tmpl');
   293             $form->addItem($img_mode);
   295             $img_mode_tmpl = 
new ilRadioOption($lng->
txt(
'badge_image_from_template'), 
'tmpl');
   296             $img_mode->addOption($img_mode_tmpl);
   298             $img_mode_up = 
new ilRadioOption($lng->
txt(
'badge_image_from_upload'), 
'up');
   299             $img_mode->addOption($img_mode_up);
   303             $img_upload->setSuffixes([
'png', 
'svg']);
   304             $img_mode_up->addSubItem($img_upload);
   309             if (count($valid_templates)) {
   311                 $options[
''] = $lng->
txt(
'please_select');
   312                 foreach ($valid_templates as $tmpl) {
   313                     $options[$tmpl->getId()] = $tmpl->getTitle();
   318                 $tmpl->setOptions($options);
   319                 $img_mode_tmpl->addSubItem($tmpl);
   322                 $img_mode_tmpl->setDisabled(
true);
   323                 $img_mode->setValue(
'up');
   328             $img_upload->setAllowDeletion(
false);
   329             $img_upload->setUseCache(
false);
   330             $form->addItem($img_upload);
   334         $valid->setMaxLength(255);
   339             $custom->initConfigForm($form, $this->parent_ref_id);
   344         if ($a_mode === 
'create') {
   345             $form->addCommandButton(
'saveBadge', $lng->
txt(
'save'));
   347             $form->addCommandButton(
'updateBadge', $lng->
txt(
'save'));
   349         $form->addCommandButton(
'listBadges', $lng->
txt(
'cancel'));
   359         $type_id = $this->request->getType();
   362             $ilCtrl->redirect($this, 
'listBadges');
   365         $ilCtrl->setParameter($this, 
'type', $type_id);
   368         $type = 
$handler->getTypeInstanceByUniqueId($type_id);
   370             $ilCtrl->redirect($this, 
'listBadges');
   374         $custom = $type->getConfigGUIInstance();
   376         if ($form->checkInput() &&
   377             (!$custom || $custom->validateForm($form))) {
   379             $badge->setParentId($this->parent_obj_id); 
   380             $badge->setTypeId($type_id);
   381             $badge->setActive($form->getInput(
'act'));
   382             $badge->setTitle($form->getInput(
'title'));
   383             $badge->setDescription($form->getInput(
'desc'));
   384             $badge->setCriteria($form->getInput(
'crit'));
   385             $badge->setValid($form->getInput(
'valid'));
   388                 $badge->setConfiguration($custom->getConfigFromForm($form));
   396                 if ($form->getInput(
'img_mode') === 
'up') {
   397                     $badge->uploadImage($_FILES[
'img']);
   400                     $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
   404                 switch ($e->getCode()) {
   405                     case BadgeException::EXCEPTION_FILE_NOT_FOUND:
   406                         $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_uploaded_image_file_not_found'), 
true);
   409                     case BadgeException::EXCEPTION_MOVE_UPLOADED_IMAGE_FAILED:
   410                         $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_create_image_processing_failed'), 
true);
   417                     $ilCtrl->redirect($this, 
"listBadges");
   421             $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   422             $ilCtrl->redirect($this, 
'listBadges');
   425         $form->setValuesByPost();
   435         $badge_id = $this->request->getBadgeId();
   438             $ilCtrl->redirect($this, 
'listBadges');
   441         $ilCtrl->setParameter($this, 
'bid', $badge_id);
   443         $badge = 
new ilBadge($badge_id);
   447             $this->tpl->setOnScreenMessage(
'info', sprintf($lng->
txt(
'badge_edit_with_published'), $static_cnt));
   451             $type = $badge->getTypeInstance();
   452             $a_form = $this->
initBadgeForm(
'edit', $type, $badge->getTypeId());
   483         $badge_id = $this->request->getBadgeId();
   486             $ilCtrl->redirect($this, 
'listBadges');
   489         $ilCtrl->setParameter($this, 
'bid', $badge_id);
   491         $badge = 
new ilBadge($badge_id);
   492         $type = $badge->getTypeInstance();
   493         $custom = $type->getConfigGUIInstance();
   498         $form = $this->
initBadgeForm(
'update', $type, $badge->getTypeId());
   499         if ($form->checkInput() &&
   500             (!$custom || $custom->validateForm($form))) {
   501             $badge->setActive($form->getInput(
'act'));
   502             $badge->setTitle($form->getInput(
'title'));
   503             $badge->setDescription($form->getInput(
'desc'));
   504             $badge->setCriteria($form->getInput(
'crit'));
   505             $badge->setValid($form->getInput(
'valid'));
   508                 $badge->setConfiguration($custom->getConfigFromForm($form));
   514                 $badge->uploadImage($_FILES[
"img"]);
   516                 if ($e->getCode() === BadgeException::EXCEPTION_MOVE_UPLOADED_IMAGE_FAILED) {
   517                     $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_update_image_processing_failed'), 
true);
   518                     $ilCtrl->redirect($this, 
"listBadges");
   522             $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   523             $ilCtrl->redirect($this, 
'listBadges');
   526         $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'form_input_not_valid'));
   527         $form->setValuesByPost();
   540         $ilTabs->clearTargets();
   541         $ilTabs->setBackTarget(
   543             $ilCtrl->getLinkTarget($this, 
'listBadges')
   547         $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
   548         $confirmation_gui->setHeaderText($lng->
txt(
'badge_deletion_confirmation'));
   549         $confirmation_gui->setCancel($lng->
txt(
'cancel'), 
'listBadges');
   550         $confirmation_gui->setConfirm($lng->
txt(
'delete'), 
'deleteBadges');
   552         foreach ($badge_ids as $badge_id) {
   553             $badge = 
new ilBadge($badge_id);
   554             $confirmation_gui->addItem(
   562         $tpl->
setContent($confirmation_gui->getHTML());
   572         foreach ($badge_ids as $badge_id) {
   573             $badge = 
new ilBadge($badge_id);
   577         $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   578         $ilCtrl->redirect($this, 
'listBadges');
   593         $badge_ids = $this->request->getIds();
   596             $ilCtrl->
redirect($this, 
'listBadges');
   608         $clip_ids = $this->session_repo->getBadgeIds();
   609         $clip_ids = array_unique(
   610             array_merge($clip_ids, $badge_ids)
   612         $this->session_repo->setBadgeIds($clip_ids);
   614         $ilCtrl->redirect($this, 
'listBadges');
   621         $this->session_repo->clear();
   622         $ilCtrl->
redirect($this, 
'listBadges');
   634         foreach ($this->session_repo->getBadgeIds() as $badge_id) {
   635             $badge = 
new ilBadge($badge_id);
   636             if (in_array($badge->getTypeId(), $valid_types, 
true)) {
   648         $clip_ids = $this->session_repo->getBadgeIds();
   649         if (!$this->
hasWrite() || count($clip_ids) === 0) {
   650             $ilCtrl->
redirect($this, 
'listBadges');
   654             $badge->copy($this->parent_obj_id);
   657         $ilCtrl->redirect($this, 
'listBadges');
   667         foreach ($badge_ids as $badge_id) {
   668             $badge = 
new ilBadge($badge_id);
   669             $badge->setActive($a_status);
   673         $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   674         $ilCtrl->redirect($this, 
'listBadges');
   703                 $this->parent_obj_id,
   704                 $this->parent_obj_type
   706             if (count($manual)) {
   709                 $ilToolbar->addInputItem($drop, 
true);
   711                 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, 
'awardBadgeUserSelection'));
   712                 $ilToolbar->addFormButton($lng->
txt(
'badge_award_badge'), 
'awardBadgeUserSelection');
   724         $tbl->writeFilterToSession();
   743         $bid = $this->request->getBadgeId();
   746             $ilCtrl->redirect($this, 
'listUsers');
   749         $manual = array_keys(
   752         if (!in_array($bid, $manual, 
true)) {
   753             $ilCtrl->redirect($this, 
'listUsers');
   756         $back_target = 
'listUsers';
   757         if ($this->request->getTgt() === 
'bdgl') {
   758             $ilCtrl->saveParameter($this, 
'tgt');
   759             $back_target = 
'listBadges';
   762         $ilTabs->clearTargets();
   763         $ilTabs->setBackTarget(
   765             $ilCtrl->getLinkTarget($this, $back_target)
   768         $ilCtrl->setParameter($this, 
'bid', $bid);
   772         $tbl = 
new ilBadgeUserTableGUI($this, 
'awardBadgeUserSelection', $this->parent_ref_id, $badge);
   780         $tbl->writeFilterToSession();
   798         $user_ids = $this->request->getIds();
   799         $badge_id = $this->request->getBadgeId();
   803             $ilCtrl->redirect($this, 
'listUsers');
   807         foreach ($user_ids as $user_id) {
   810                 $ass->setAwardedBy($ilUser->getId());
   813                 $new_badges[$user_id][] = $badge_id;
   819         $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   820         $ilCtrl->redirect($this, 
'listUsers');
   830         $user_ids = $this->request->getIds();
   831         $badge_id = $this->request->getBadgeId();
   835             $ilCtrl->redirect($this, 
'listUsers');
   839         $ilTabs->setBackTarget(
   841             $ilCtrl->getLinkTarget($this, 
'listUsers')
   844         $badge = 
new ilBadge($badge_id);
   846         $ilCtrl->setParameter($this, 
'bid', $badge->getId());
   849         $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
   850         $confirmation_gui->setHeaderText(
   851             sprintf($lng->
txt(
'badge_assignment_deletion_confirmation'), $badge->getTitle())
   853         $confirmation_gui->setCancel($lng->
txt(
'cancel'), 
'listUsers');
   854         $confirmation_gui->setConfirm($lng->
txt(
'delete'), 
'deassignBadge');
   858         foreach ($user_ids as $user_id) {
   859             if (in_array($user_id, $assigned_users)) {
   860                 $confirmation_gui->addItem(
   868         $tpl->
setContent($confirmation_gui->getHTML());
   876         $user_ids = $this->request->getIds();
   877         $badge_id = $this->request->getBadgeId();
   881             $ilCtrl->redirect($this, 
'listUsers');
   884         foreach ($user_ids as $user_id) {
   889         $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
'settings_saved'), 
true);
   890         $ilCtrl->redirect($this, 
'listUsers');
 
__construct(private readonly int $parent_ref_id, int $a_parent_obj_id=null, string $a_parent_obj_type=null)
 
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Class ilBadgeManagementGUI. 
 
static getInstancesByType(string $a_type_unique_id)
 
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...
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
ilBadgeGUIRequest $request
 
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
 
resetAwardBadgeUserSelection()
 
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
toggleBadges(bool $a_status)
 
getConfigGUIInstance()
Get GUI config instance. 
 
Stores repository clipboard data. 
 
editBadge(ilPropertyFormGUI $a_form=null)
 
ilBadgeManagementSessionRepository $session_repo
 
static getAssignedUsers(int $a_badge_id)
 
loadLanguageModule(string $a_module)
Load language module. 
 
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
 
applyAwardBadgeUserSelection()
 
static _lookupObjId(int $ref_id)
 
getNextClass($a_gui_class=null)
 
addBadge(ilPropertyFormGUI $a_form=null)
 
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is: 
 
setContent(string $a_html)
Sets content for standard template. 
 
static getExtendedTypeCaption(ilBadgeType $a_type)
 
static getInstancesByBadgeId(int $a_badge_id)
 
getImagePath(bool $a_full_path=true)
 
ilGlobalTemplateInterface $tpl
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
clearTargets()
clear all targets 
 
static exists(int $a_badge_id, int $a_user_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setMaxNumOfChars(int $a_number)
 
TableGUI class for badge listing. 
 
This class represents a text area property in a property form. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
ILIAS UI Factory $ui_factory
 
getBadgesFromMultiAction()
 
getValidBadgesFromClipboard()
 
awardBadgeUserSelection()
 
static _lookupType(int $id, bool $reference=false)
 
setTabs(string $a_active)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...