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->tpl = $DIC[
"tpl"];
55 $this->
user = $DIC->user();
56 $lng = $DIC->language();
58 $this->parent_ref_id = $a_parent_ref_id;
59 $this->parent_obj_id = $a_parent_obj_id
61 $this->parent_obj_type = $a_parent_obj_type
83 $cmd = $ilCtrl->getCmd(
"listBadges");
85 switch ($next_class) {
86 case "ilpropertyformgui":
88 if ($this->request->getBadgeId()) {
89 $badge =
new ilBadge($this->request->getBadgeId());
90 $type = $badge->getTypeInstance();
96 $type_id = $this->request->getType();
97 $ilCtrl->setParameter($this,
"type", $type_id);
99 $type = $handler->getTypeInstanceByUniqueId($type_id);
102 $ilCtrl->forwardCommand($form);
111 protected function setTabs(
string $a_active): void
119 $lng->
txt(
"obj_bdga"),
120 $ilCtrl->getLinkTarget($this,
"listBadges")
126 $ilCtrl->getLinkTarget($this,
"listUsers")
129 $ilTabs->activateSubTab($a_active);
135 return $ilAccess->
checkAccess(
"write",
"", $this->parent_ref_id);
149 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
152 foreach ($valid_types as
$id =>
$type) {
153 $options[
$id] = ($this->parent_obj_type !==
"bdga")
155 :
$type->getCaption();
160 $drop->setOptions($options);
161 $ilToolbar->addInputItem($drop,
true);
163 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"addBadge"));
164 $ilToolbar->addFormButton($lng->
txt(
"create"),
"addBadge");
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->setRequired(
true);
274 $form->addItem($title);
278 $form->addItem($desc);
282 $form->addItem($crit);
284 if ($a_mode ===
"create") {
289 $img_mode->setValue(
"tmpl");
290 $form->addItem($img_mode);
292 $img_mode_tmpl =
new ilRadioOption($lng->
txt(
"badge_image_from_template"),
"tmpl");
293 $img_mode->addOption($img_mode_tmpl);
295 $img_mode_up =
new ilRadioOption($lng->
txt(
"badge_image_from_upload"),
"up");
296 $img_mode->addOption($img_mode_up);
300 $img_upload->setSuffixes([
"png",
"svg"]);
301 $img_mode_up->addSubItem($img_upload);
306 if (count($valid_templates)) {
308 $options[
""] = $lng->
txt(
"please_select");
309 foreach ($valid_templates as $tmpl) {
310 $options[$tmpl->getId()] = $tmpl->getTitle();
314 $tmpl->setRequired(
true);
315 $tmpl->setOptions($options);
316 $img_mode_tmpl->addSubItem($tmpl);
319 $img_mode_tmpl->setDisabled(
true);
320 $img_mode->setValue(
"up");
325 $img_upload->setAllowDeletion(
false);
326 $img_upload->setUseCache(
false);
327 $form->addItem($img_upload);
335 $custom->initConfigForm($form, $this->parent_ref_id);
340 if ($a_mode ===
"create") {
341 $form->addCommandButton(
"saveBadge", $lng->
txt(
"save"));
343 $form->addCommandButton(
"updateBadge", $lng->
txt(
"save"));
345 $form->addCommandButton(
"listBadges", $lng->
txt(
"cancel"));
355 $type_id = $this->request->getType();
358 $ilCtrl->redirect($this,
"listBadges");
361 $ilCtrl->setParameter($this,
"type", $type_id);
364 $type = $handler->getTypeInstanceByUniqueId($type_id);
366 $ilCtrl->redirect($this,
"listBadges");
370 $custom =
$type->getConfigGUIInstance();
372 if ($form->checkInput() &&
373 (!$custom || $custom->validateForm($form))) {
375 $badge->setParentId($this->parent_obj_id);
376 $badge->setTypeId($type_id);
377 $badge->setActive($form->getInput(
"act"));
378 $badge->setTitle($form->getInput(
"title"));
379 $badge->setDescription($form->getInput(
"desc"));
380 $badge->setCriteria($form->getInput(
"crit"));
381 $badge->setValid($form->getInput(
"valid"));
384 $badge->setConfiguration($custom->getConfigFromForm($form));
392 if ($form->getInput(
'img_mode') ===
'up') {
393 $badge->uploadImage($_FILES[
'img']);
396 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
400 switch ($e->getCode()) {
401 case BadgeException::EXCEPTION_FILE_NOT_FOUND:
402 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_uploaded_image_file_not_found'),
true);
405 case BadgeException::EXCEPTION_MOVE_UPLOADED_IMAGE_FAILED:
406 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_create_image_processing_failed'),
true);
413 $ilCtrl->redirect($this,
"listBadges");
417 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
418 $ilCtrl->redirect($this,
"listBadges");
421 $form->setValuesByPost();
431 $badge_id = $this->request->getBadgeId();
434 $ilCtrl->redirect($this,
"listBadges");
437 $ilCtrl->setParameter($this,
"bid", $badge_id);
439 $badge =
new ilBadge($badge_id);
443 $this->tpl->setOnScreenMessage(
'info', sprintf($lng->
txt(
"badge_edit_with_published"), $static_cnt));
447 $type = $badge->getTypeInstance();
479 $badge_id = $this->request->getBadgeId();
482 $ilCtrl->redirect($this,
"listBadges");
485 $ilCtrl->setParameter($this,
"bid", $badge_id);
487 $badge =
new ilBadge($badge_id);
488 $type = $badge->getTypeInstance();
489 $custom =
$type->getConfigGUIInstance();
495 if ($form->checkInput() &&
496 (!$custom || $custom->validateForm($form))) {
497 $badge->setActive($form->getInput(
"act"));
498 $badge->setTitle($form->getInput(
"title"));
499 $badge->setDescription($form->getInput(
"desc"));
500 $badge->setCriteria($form->getInput(
"crit"));
501 $badge->setValid($form->getInput(
"valid"));
504 $badge->setConfiguration($custom->getConfigFromForm($form));
510 $badge->uploadImage($_FILES[
"img"]);
512 if ($e->getCode() === BadgeException::EXCEPTION_MOVE_UPLOADED_IMAGE_FAILED) {
513 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'badge_update_image_processing_failed'),
true);
514 $ilCtrl->redirect($this,
"listBadges");
518 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
519 $ilCtrl->redirect($this,
"listBadges");
522 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"form_input_not_valid"));
523 $form->setValuesByPost();
536 $ilTabs->clearTargets();
537 $ilTabs->setBackTarget(
539 $ilCtrl->getLinkTarget($this,
"listBadges")
543 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
544 $confirmation_gui->setHeaderText($lng->
txt(
"badge_deletion_confirmation"));
545 $confirmation_gui->setCancel($lng->
txt(
"cancel"),
"listBadges");
546 $confirmation_gui->setConfirm($lng->
txt(
"delete"),
"deleteBadges");
548 foreach ($badge_ids as $badge_id) {
549 $badge =
new ilBadge($badge_id);
550 $confirmation_gui->addItem(
"id[]", (
string) $badge_id, $badge->getTitle() .
554 $tpl->
setContent($confirmation_gui->getHTML());
564 foreach ($badge_ids as $badge_id) {
565 $badge =
new ilBadge($badge_id);
569 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
570 $ilCtrl->redirect($this,
"listBadges");
585 $badge_ids = $this->request->getIds();
588 $ilCtrl->
redirect($this,
"listBadges");
600 $clip_ids = $this->session_repo->getBadgeIds();
601 $clip_ids = array_unique(
602 array_merge($clip_ids, $badge_ids)
604 $this->session_repo->setBadgeIds($clip_ids);
606 $ilCtrl->redirect($this,
"listBadges");
613 $this->session_repo->clear();
614 $ilCtrl->
redirect($this,
"listBadges");
626 foreach ($this->session_repo->getBadgeIds() as $badge_id) {
627 $badge =
new ilBadge($badge_id);
628 if (in_array($badge->getTypeId(), $valid_types,
true)) {
640 $clip_ids = $this->session_repo->getBadgeIds();
641 if (!$this->
hasWrite() || count($clip_ids) === 0) {
642 $ilCtrl->
redirect($this,
"listBadges");
646 $badge->copy($this->parent_obj_id);
649 $ilCtrl->redirect($this,
"listBadges");
659 foreach ($badge_ids as $badge_id) {
660 $badge =
new ilBadge($badge_id);
661 $badge->setActive($a_status);
665 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
666 $ilCtrl->redirect($this,
"listBadges");
695 if (count($manual)) {
697 $drop->setOptions($manual);
698 $ilToolbar->addInputItem($drop,
true);
700 $ilToolbar->setFormAction($ilCtrl->getFormAction($this,
"awardBadgeUserSelection"));
701 $ilToolbar->addFormButton($lng->
txt(
"badge_award_badge"),
"awardBadgeUserSelection");
713 $tbl->writeFilterToSession();
732 $bid = $this->request->getBadgeId();
735 $ilCtrl->redirect($this,
"listUsers");
739 if (!in_array($bid, $manual,
true)) {
740 $ilCtrl->redirect($this,
"listUsers");
743 $back_target =
"listUsers";
744 if ($this->request->getTgt() ===
"bdgl") {
745 $ilCtrl->saveParameter($this,
"tgt");
746 $back_target =
"listBadges";
749 $ilTabs->clearTargets();
750 $ilTabs->setBackTarget(
752 $ilCtrl->getLinkTarget($this, $back_target)
755 $ilCtrl->setParameter($this,
"bid", $bid);
759 $tbl =
new ilBadgeUserTableGUI($this,
"awardBadgeUserSelection", $this->parent_ref_id, $badge);
767 $tbl->writeFilterToSession();
785 $user_ids = $this->request->getIds();
786 $badge_id = $this->request->getBadgeId();
790 $ilCtrl->redirect($this,
"listUsers");
794 foreach ($user_ids as $user_id) {
797 $ass->setAwardedBy(
$ilUser->getId());
800 $new_badges[$user_id][] = $badge_id;
806 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
807 $ilCtrl->redirect($this,
"listUsers");
817 $user_ids = $this->request->getIds();
818 $badge_id = $this->request->getBadgeId();
822 $ilCtrl->redirect($this,
"listUsers");
826 $ilTabs->setBackTarget(
828 $ilCtrl->getLinkTarget($this,
"listUsers")
831 $badge =
new ilBadge($badge_id);
833 $ilCtrl->setParameter($this,
"bid", $badge->getId());
836 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
837 $confirmation_gui->setHeaderText(sprintf($lng->
txt(
"badge_assignment_deletion_confirmation"), $badge->getTitle()));
838 $confirmation_gui->setCancel($lng->
txt(
"cancel"),
"listUsers");
839 $confirmation_gui->setConfirm($lng->
txt(
"delete"),
"deassignBadge");
843 foreach ($user_ids as $user_id) {
844 if (in_array($user_id, $assigned_users)) {
845 $confirmation_gui->addItem(
853 $tpl->
setContent($confirmation_gui->getHTML());
861 $user_ids = $this->request->getIds();
862 $badge_id = $this->request->getBadgeId();
866 $ilCtrl->redirect($this,
"listUsers");
869 foreach ($user_ids as $user_id) {
874 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"settings_saved"),
true);
875 $ilCtrl->redirect($this,
"listUsers");
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)
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:
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()
__construct(int $a_parent_ref_id, int $a_parent_obj_id=null, string $a_parent_obj_type=null)
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)
setContent(string $a_html)
Sets content for standard template.
static getExtendedTypeCaption(ilBadgeType $a_type)
static getInstancesByBadgeId(int $a_badge_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...