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();
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
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(
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"));
270 $form->addItem($active);
273 $title->setRequired(
true);
274 $form->addItem($title);
277 $desc->setRequired(
true);
278 $form->addItem($desc);
281 $crit->setRequired(
true);
282 $form->addItem($crit);
284 if ($a_mode ===
"create") {
288 $img_mode->setRequired(
true);
289 $img_mode->setValue(
"tmpl");
290 $form->addItem($img_mode);
293 $img_mode->addOption($img_mode_tmpl);
296 $img_mode->addOption($img_mode_up);
299 $img_upload->setRequired(
true);
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");
324 $img_upload->setSuffixes([
"png",
"svg"]);
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"));
352 $ilCtrl = $this->ctrl;
355 $type_id = $this->request->getType();
357 !$this->hasWrite()) {
358 $ilCtrl->redirect($this,
"listBadges");
361 $ilCtrl->setParameter($this,
"type", $type_id);
364 $type = $handler->getTypeInstanceByUniqueId($type_id);
366 $ilCtrl->redirect($this,
"listBadges");
369 $form = $this->initBadgeForm(
"create",
$type, $type_id);
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();
422 $this->addBadge($form);
427 $ilCtrl = $this->ctrl;
431 $badge_id = $this->request->getBadgeId();
433 !$this->hasWrite()) {
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();
448 $a_form = $this->initBadgeForm(
"edit",
$type, $badge->getTypeId());
449 $this->setBadgeFormValues($a_form, $badge,
$type);
452 $tpl->setContent($a_form->getHTML());
460 $a_form->getItemByPostVar(
"act")->setChecked($a_badge->isActive());
476 $ilCtrl = $this->ctrl;
479 $badge_id = $this->request->getBadgeId();
481 !$this->hasWrite()) {
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();
494 $form = $this->initBadgeForm(
"update",
$type, $badge->getTypeId());
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();
524 $this->editBadge($form);
529 $ilCtrl = $this->ctrl;
532 $ilTabs = $this->tabs;
534 $badge_ids = $this->getBadgesFromMultiAction();
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());
559 $ilCtrl = $this->ctrl;
562 $badge_ids = $this->getBadgesFromMultiAction();
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");
583 $ilCtrl = $this->ctrl;
585 $badge_ids = $this->request->getIds();
587 !$this->hasWrite()) {
588 $ilCtrl->redirect($this,
"listBadges");
596 $ilCtrl = $this->ctrl;
598 $badge_ids = $this->getBadgesFromMultiAction();
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");
611 $ilCtrl = $this->ctrl;
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)) {
638 $ilCtrl = $this->ctrl;
640 $clip_ids = $this->session_repo->getBadgeIds();
641 if (!$this->hasWrite() || count($clip_ids) === 0) {
642 $ilCtrl->redirect($this,
"listBadges");
645 foreach ($this->getValidBadgesFromClipboard() as $badge) {
646 $badge->copy($this->parent_obj_id);
649 $ilCtrl->redirect($this,
"listBadges");
654 $ilCtrl = $this->ctrl;
657 $badge_ids = $this->getBadgesFromMultiAction();
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");
671 $this->toggleBadges(
true);
676 $this->toggleBadges(
false);
687 $ilCtrl = $this->ctrl;
688 $ilToolbar = $this->toolbar;
691 $this->setTabs(
"users");
693 if ($this->hasWrite()) {
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");
706 $tpl->setContent($tbl->getHTML());
713 $tbl->writeFilterToSession();
727 $ilCtrl = $this->ctrl;
729 $ilTabs = $this->tabs;
732 $bid = $this->request->getBadgeId();
734 !$this->hasWrite()) {
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);
760 $tpl->setContent($tbl->getHTML());
767 $tbl->writeFilterToSession();
768 $this->awardBadgeUserSelection();
776 $this->awardBadgeUserSelection();
781 $ilCtrl = $this->ctrl;
785 $user_ids = $this->request->getIds();
786 $badge_id = $this->request->getBadgeId();
789 !$this->hasWrite()) {
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");
812 $ilCtrl = $this->ctrl;
815 $ilTabs = $this->tabs;
817 $user_ids = $this->request->getIds();
818 $badge_id = $this->request->getBadgeId();
821 !$this->hasWrite()) {
822 $ilCtrl->redirect($this,
"listUsers");
825 $ilTabs->clearTargets();
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());
858 $ilCtrl = $this->ctrl;
861 $user_ids = $this->request->getIds();
862 $badge_id = $this->request->getBadgeId();
865 !$this->hasWrite()) {
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");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstancesByBadgeId(int $a_badge_id)
static getAssignedUsers(int $a_badge_id)
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...
static getInstancesByType(string $a_type_unique_id)
Class ilBadgeManagementGUI.
awardBadgeUserSelection()
resetAwardBadgeUserSelection()
applyAwardBadgeUserSelection()
ilGlobalTemplateInterface $tpl
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
addBadge(ilPropertyFormGUI $a_form=null)
setTabs(string $a_active)
getBadgesFromMultiAction()
editBadge(ilPropertyFormGUI $a_form=null)
getValidBadgesFromClipboard()
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
ilBadgeGUIRequest $request
ilBadgeManagementSessionRepository $session_repo
toggleBadges(bool $a_status)
__construct(int $a_parent_ref_id, int $a_parent_obj_id=null, string $a_parent_obj_type=null)
Stores repository clipboard data.
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...
getImagePath(bool $a_full_path=true)
static getExtendedTypeCaption(ilBadgeType $a_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
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...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_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.
This class represents a text property in a property form.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getConfigGUIInstance()
Get GUI config instance.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
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)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl