ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBadgeManagementGUI Class Reference

Class ilBadgeManagementGUI. More...

+ Collaboration diagram for ilBadgeManagementGUI:

Public Member Functions

 __construct ($a_parent_ref_id, $a_parent_obj_id=null, $a_parent_obj_type=null)
 Construct. More...
 
 executeCommand ()
 

Data Fields

const CLIPBOARD_ID = "bdgclpbrd"
 

Protected Member Functions

 setTabs ($a_active)
 
 hasWrite ()
 
 listBadges ()
 
 applyBadgeFilter ()
 
 resetBadgeFilter ()
 
 addBadge (ilPropertyFormGUI $a_form=null)
 
 initBadgeForm ($a_mode, ilBadgeType $a_type, $a_type_unique_id)
 
 saveBadge ()
 
 editBadge (ilPropertyFormGUI $a_form=null)
 
 setBadgeFormValues (ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
 
 updateBadge ()
 
 confirmDeleteBadges ()
 
 deleteBadges ()
 
 getBadgesFromMultiAction ()
 
 copyBadges ()
 
 clearClipboard ()
 
 getValidBadgesFromClipboard ()
 
 pasteBadges ()
 
 toggleBadges ($a_status)
 
 activateBadges ()
 
 deactivateBadges ()
 
 listUsers ()
 
 applyListUsers ()
 
 resetListUsers ()
 
 awardBadgeUserSelection ()
 
 applyAwardBadgeUserSelection ()
 
 resetAwardBadgeUserSelection ()
 
 assignBadge ()
 
 confirmDeassignBadge ()
 
 deassignBadge ()
 

Protected Attributes

 $lng
 
 $ctrl
 
 $tabs
 
 $access
 
 $toolbar
 
 $tpl
 
 $user
 
 $parent_ref_id
 
 $parent_obj_id
 
 $parent_obj_type
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBadgeManagementGUI::__construct (   $a_parent_ref_id,
  $a_parent_obj_id = null,
  $a_parent_obj_type = null 
)

Construct.

Parameters
int$a_parent_ref_id
int$a_parent_obj_id
string$a_parent_obj_type
Returns
self

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

64 {
65 global $DIC;
66
67 $this->lng = $DIC->language();
68 $this->ctrl = $DIC->ctrl();
69 $this->tabs = $DIC->tabs();
70 $this->access = $DIC->access();
71 $this->toolbar = $DIC->toolbar();
72 $this->tpl = $DIC["tpl"];
73 $this->user = $DIC->user();
74 $lng = $DIC->language();
75
76 $this->parent_ref_id = $a_parent_ref_id;
77 $this->parent_obj_id = $a_parent_obj_id
78 ? $a_parent_obj_id
79 : ilObject::_lookupObjId($a_parent_ref_id);
80 $this->parent_obj_type = $a_parent_obj_type
81 ? $a_parent_obj_type
82 : ilObject::_lookupType($this->parent_obj_id);
83
84 if (!ilBadgeHandler::getInstance()->isObjectActive($this->parent_obj_id)) {
85 throw new ilException("inactive object");
86 }
87
88 $lng->loadLanguageModule("badge");
89 }
user()
Definition: user.php:4
static getInstance()
Constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
global $DIC
Definition: goto.php:24

References $DIC, $lng, ilObject\_lookupObjId(), ilObject\_lookupType(), ilBadgeHandler\getInstance(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateBadges()

ilBadgeManagementGUI::activateBadges ( )
protected

Definition at line 664 of file class.ilBadgeManagementGUI.php.

665 {
666 $this->toggleBadges(true);
667 }

References toggleBadges().

+ Here is the call graph for this function:

◆ addBadge()

ilBadgeManagementGUI::addBadge ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 266 of file class.ilBadgeManagementGUI.php.

267 {
268 $ilCtrl = $this->ctrl;
270
271 $type_id = $_REQUEST["type"];
272 if (!$type_id ||
273 !$this->hasWrite()) {
274 $ilCtrl->redirect($this, "listBadges");
275 }
276
277 $ilCtrl->setParameter($this, "type", $type_id);
278
279 $handler = ilBadgeHandler::getInstance();
280 $type = $handler->getTypeInstanceByUniqueId($type_id);
281 if (!$type) {
282 $ilCtrl->redirect($this, "listBadges");
283 }
284
285 if (!$a_form) {
286 $a_form = $this->initBadgeForm("create", $type, $type_id);
287 }
288
289 $tpl->setContent($a_form->getHTML());
290 }
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
$type

References $ctrl, $tpl, $type, ilBadgeHandler\getInstance(), hasWrite(), and initBadgeForm().

Referenced by saveBadge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyAwardBadgeUserSelection()

ilBadgeManagementGUI::applyAwardBadgeUserSelection ( )
protected

Definition at line 758 of file class.ilBadgeManagementGUI.php.

759 {
760 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
761 $tbl->resetOffset();
762 $tbl->writeFilterToSession();
764 }
TableGUI class for badge user listing.

References awardBadgeUserSelection().

+ Here is the call graph for this function:

◆ applyBadgeFilter()

ilBadgeManagementGUI::applyBadgeFilter ( )
protected

Definition at line 245 of file class.ilBadgeManagementGUI.php.

246 {
247 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
248 $tbl->resetOffset();
249 $tbl->writeFilterToSession();
250 $this->listBadges();
251 }
TableGUI class for badge listing.

References hasWrite(), and listBadges().

+ Here is the call graph for this function:

◆ applyListUsers()

ilBadgeManagementGUI::applyListUsers ( )
protected

Definition at line 704 of file class.ilBadgeManagementGUI.php.

705 {
706 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
707 $tbl->resetOffset();
708 $tbl->writeFilterToSession();
709 $this->listUsers();
710 }

References listUsers().

+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

Definition at line 774 of file class.ilBadgeManagementGUI.php.

775 {
776 $ilCtrl = $this->ctrl;
779
780 $user_ids = $_POST["id"];
781 $badge_id = $_REQUEST["bid"];
782 if (!$user_ids ||
783 !$badge_id ||
784 !$this->hasWrite()) {
785 $ilCtrl->redirect($this, "listUsers");
786 }
787
788 $new_badges = array();
789 foreach ($user_ids as $user_id) {
790 if (!ilBadgeAssignment::exists($badge_id, $user_id)) {
791 $ass = new ilBadgeAssignment($badge_id, $user_id);
792 $ass->setAwardedBy($ilUser->getId());
793 $ass->store();
794
795 $new_badges[$user_id][] = $badge_id;
796 }
797 }
798
799 ilBadgeHandler::getInstance()->sendNotification($new_badges, $this->parent_ref_id);
800
801 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
802 $ilCtrl->redirect($this, "listUsers");
803 }
$_POST["username"]
Class ilBadgeAssignment.
static exists($a_badge_id, $a_user_id)
$ilUser
Definition: imgupload.php:18

References $_POST, $ctrl, $ilUser, $lng, $user, ilBadgeAssignment\exists(), ilBadgeHandler\getInstance(), and hasWrite().

+ Here is the call graph for this function:

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

Definition at line 720 of file class.ilBadgeManagementGUI.php.

721 {
722 $ilCtrl = $this->ctrl;
724 $ilTabs = $this->tabs;
726
727 $bid = (int) $_REQUEST["bid"];
728 if (!$bid ||
729 !$this->hasWrite()) {
730 $ilCtrl->redirect($this, "listUsers");
731 }
732
733 $manual = array_keys(ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type));
734 if (!in_array($bid, $manual)) {
735 $ilCtrl->redirect($this, "listUsers");
736 }
737
738 $back_target = "listUsers";
739 if ($_REQUEST["tgt"] == "bdgl") {
740 $ilCtrl->saveParameter($this, "tgt");
741 $back_target = "listBadges";
742 }
743
744 $ilTabs->clearTargets();
745 $ilTabs->setBackTarget(
746 $lng->txt("back"),
747 $ilCtrl->getLinkTarget($this, $back_target)
748 );
749
750 $ilCtrl->setParameter($this, "bid", $bid);
751
752 $badge = new ilBadge($bid);
753
754 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id, $badge);
755 $tpl->setContent($tbl->getHTML());
756 }
Class ilBadge.

References $ctrl, $lng, $tabs, $tpl, ilBadgeHandler\getInstance(), and hasWrite().

Referenced by applyAwardBadgeUserSelection(), and resetAwardBadgeUserSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearClipboard()

ilBadgeManagementGUI::clearClipboard ( )
protected

Definition at line 607 of file class.ilBadgeManagementGUI.php.

608 {
609 $ilCtrl = $this->ctrl;
610
611 unset($_SESSION[self::CLIPBOARD_ID]);
612 $ilCtrl->redirect($this, "listBadges");
613 }
$_SESSION["AccountId"]

References $_SESSION, and $ctrl.

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

Definition at line 805 of file class.ilBadgeManagementGUI.php.

806 {
807 $ilCtrl = $this->ctrl;
810 $ilTabs = $this->tabs;
811
812 $user_ids = $_POST["id"];
813 $badge_id = $_REQUEST["bid"];
814 if (!$user_ids ||
815 !$badge_id ||
816 !$this->hasWrite()) {
817 $ilCtrl->redirect($this, "listUsers");
818 }
819
820 $ilTabs->clearTargets();
821 $ilTabs->setBackTarget(
822 $lng->txt("back"),
823 $ilCtrl->getLinkTarget($this, "listUsers")
824 );
825
826 $badge = new ilBadge($badge_id);
827
828 $ilCtrl->setParameter($this, "bid", $badge->getId());
829
830 $confirmation_gui = new ilConfirmationGUI();
831 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
832 $confirmation_gui->setHeaderText(sprintf($lng->txt("badge_assignment_deletion_confirmation"), $badge->getTitle()));
833 $confirmation_gui->setCancel($lng->txt("cancel"), "listUsers");
834 $confirmation_gui->setConfirm($lng->txt("delete"), "deassignBadge");
835
836 $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
837
838 foreach ($user_ids as $user_id) {
839 if (in_array($user_id, $assigned_users)) {
840 $confirmation_gui->addItem(
841 "id[]",
842 $user_id,
843 ilUserUtil::getNamePresentation($user_id, false, false, "", true)
844 );
845 }
846 }
847
848 $tpl->setContent($confirmation_gui->getHTML());
849 }
static getAssignedUsers($a_badge_id)
Confirmation screen class.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:

References $_POST, $ctrl, $lng, $tabs, $tpl, ilBadgeAssignment\getAssignedUsers(), ilUserUtil\getNamePresentation(), and hasWrite().

+ Here is the call graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

Definition at line 530 of file class.ilBadgeManagementGUI.php.

531 {
532 $ilCtrl = $this->ctrl;
535 $ilTabs = $this->tabs;
536
537 $badge_ids = $this->getBadgesFromMultiAction();
538
539 $ilTabs->clearTargets();
540 $ilTabs->setBackTarget(
541 $lng->txt("back"),
542 $ilCtrl->getLinkTarget($this, "listBadges")
543 );
544
545 $confirmation_gui = new ilConfirmationGUI();
546 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
547 $confirmation_gui->setHeaderText($lng->txt("badge_deletion_confirmation"));
548 $confirmation_gui->setCancel($lng->txt("cancel"), "listBadges");
549 $confirmation_gui->setConfirm($lng->txt("delete"), "deleteBadges");
550
551 foreach ($badge_ids as $badge_id) {
552 $badge = new ilBadge($badge_id);
553 $confirmation_gui->addItem("id[]", $badge_id, $badge->getTitle() .
554 " (" . sizeof(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ")");
555 }
556
557 $tpl->setContent($confirmation_gui->getHTML());
558 }
static getInstancesByBadgeId($a_badge_id)

References $ctrl, $lng, $tabs, $tpl, getBadgesFromMultiAction(), and ilBadgeAssignment\getInstancesByBadgeId().

+ Here is the call graph for this function:

◆ copyBadges()

ilBadgeManagementGUI::copyBadges ( )
protected

Definition at line 594 of file class.ilBadgeManagementGUI.php.

595 {
596 $ilCtrl = $this->ctrl;
597
598 $badge_ids = $this->getBadgesFromMultiAction();
599
600 $_SESSION[self::CLIPBOARD_ID] = array_unique(
601 array_merge((array) $_SESSION[self::CLIPBOARD_ID], $badge_ids)
602 );
603
604 $ilCtrl->redirect($this, "listBadges");
605 }

References $_SESSION, $ctrl, CLIPBOARD_ID, and getBadgesFromMultiAction().

+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

Definition at line 669 of file class.ilBadgeManagementGUI.php.

670 {
671 $this->toggleBadges(false);
672 }

References toggleBadges().

+ Here is the call graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

Definition at line 851 of file class.ilBadgeManagementGUI.php.

852 {
853 $ilCtrl = $this->ctrl;
855
856 $user_ids = $_POST["id"];
857 $badge_id = $_REQUEST["bid"];
858 if (!$user_ids ||
859 !$badge_id ||
860 !$this->hasWrite()) {
861 $ilCtrl->redirect($this, "listUsers");
862 }
863
864 foreach ($user_ids as $user_id) {
865 $ass = new ilBadgeAssignment($badge_id, $user_id);
866 $ass->delete();
867 }
868
869 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
870 $ilCtrl->redirect($this, "listUsers");
871 }

References $_POST, $ctrl, $lng, and hasWrite().

+ Here is the call graph for this function:

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

Definition at line 560 of file class.ilBadgeManagementGUI.php.

561 {
562 $ilCtrl = $this->ctrl;
564
565 $badge_ids = $this->getBadgesFromMultiAction();
566
567 foreach ($badge_ids as $badge_id) {
568 $badge = new ilBadge($badge_id);
569 $badge->delete();
570 }
571
572 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
573 $ilCtrl->redirect($this, "listBadges");
574 }

References $ctrl, $lng, and getBadgesFromMultiAction().

+ Here is the call graph for this function:

◆ editBadge()

ilBadgeManagementGUI::editBadge ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 437 of file class.ilBadgeManagementGUI.php.

438 {
439 $ilCtrl = $this->ctrl;
442
443 $badge_id = $_REQUEST["bid"];
444 if (!$badge_id ||
445 !$this->hasWrite()) {
446 $ilCtrl->redirect($this, "listBadges");
447 }
448
449 $ilCtrl->setParameter($this, "bid", $badge_id);
450
451 $badge = new ilBadge($badge_id);
452
453 $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
454 if ($static_cnt) {
455 ilUtil::sendInfo(sprintf($lng->txt("badge_edit_with_published"), $static_cnt));
456 }
457
458 if (!$a_form) {
459 $type = $badge->getTypeInstance();
460 $a_form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
461 $this->setBadgeFormValues($a_form, $badge, $type);
462 }
463
464 $tpl->setContent($a_form->getHTML());
465 }
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $ctrl, $lng, $tpl, $type, ilBadgeHandler\getInstance(), hasWrite(), initBadgeForm(), ilUtil\sendInfo(), and setBadgeFormValues().

Referenced by updateBadge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeManagementGUI::executeCommand ( )

Definition at line 91 of file class.ilBadgeManagementGUI.php.

92 {
93 $ilCtrl = $this->ctrl;
94 $ilTabs = $this->tabs;
96
97 $next_class = $ilCtrl->getNextClass($this);
98 $cmd = $ilCtrl->getCmd("listBadges");
99
100 switch ($next_class) {
101 case "ilpropertyformgui":
102 // ajax - update
103 if ((int) $_REQUEST["bid"]) {
104 $badge = new ilBadge((int) $_REQUEST["bid"]);
105 $type = $badge->getTypeInstance();
106 $form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
107 $this->setBadgeFormValues($form, $badge, $type);
108 }
109 // ajax- create
110 else {
111 $type_id = $_REQUEST["type"];
112 $ilCtrl->setParameter($this, "type", $type_id);
113 $handler = ilBadgeHandler::getInstance();
114 $type = $handler->getTypeInstanceByUniqueId($type_id);
115 $form = $this->initBadgeForm("create", $type, $type_id);
116 }
117 $ilCtrl->forwardCommand($form);
118 break;
119
120 /*
121 case "illplistofsettingsgui":
122 $id = $_GET["lpid"];
123 if($id)
124 {
125 $ilCtrl->saveParameter($this, "bid");
126 $ilCtrl->saveParameter($this, "lpid");
127
128 $ilTabs->clearTargets();
129 $ilTabs->setBackTarget(
130 $lng->txt("back"),
131 $ilCtrl->getLinkTarget($this, "editBadge")
132 );
133 $lpgui = new ilLPListOfSettingsGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $id);
134 $ilCtrl->forwardCommand($lpgui);
135 break;
136 }
137 */
138
139 default:
140 $this->$cmd();
141 break;
142 }
143
144 return true;
145 }

References $ctrl, $lng, $tabs, $type, ilBadgeHandler\getInstance(), initBadgeForm(), and setBadgeFormValues().

+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected

Definition at line 581 of file class.ilBadgeManagementGUI.php.

582 {
583 $ilCtrl = $this->ctrl;
584
585 $badge_ids = $_REQUEST["id"];
586 if (!$badge_ids ||
587 !$this->hasWrite()) {
588 $ilCtrl->redirect($this, "listBadges");
589 }
590
591 return $badge_ids;
592 }

References $ctrl, and hasWrite().

Referenced by confirmDeleteBadges(), copyBadges(), deleteBadges(), and toggleBadges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidBadgesFromClipboard()

ilBadgeManagementGUI::getValidBadgesFromClipboard ( )
protected

Definition at line 615 of file class.ilBadgeManagementGUI.php.

616 {
617 $res = array();
618
619 $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
620
621 foreach ($_SESSION[self::CLIPBOARD_ID] as $badge_id) {
622 $badge = new ilBadge($badge_id);
623 if (in_array($badge->getTypeId(), $valid_types)) {
624 $res[] = $badge;
625 }
626 }
627
628 return $res;
629 }
foreach($_POST as $key=> $value) $res

References $_SESSION, $res, and ilBadgeHandler\getInstance().

Referenced by listBadges(), and pasteBadges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasWrite()

ilBadgeManagementGUI::hasWrite ( )
protected

Definition at line 168 of file class.ilBadgeManagementGUI.php.

169 {
170 $ilAccess = $this->access;
171 return $ilAccess->checkAccess("write", "", $this->parent_ref_id);
172 }

References $access.

Referenced by addBadge(), applyBadgeFilter(), assignBadge(), awardBadgeUserSelection(), confirmDeassignBadge(), deassignBadge(), editBadge(), getBadgesFromMultiAction(), listBadges(), listUsers(), pasteBadges(), resetBadgeFilter(), saveBadge(), and updateBadge().

+ Here is the caller graph for this function:

◆ initBadgeForm()

ilBadgeManagementGUI::initBadgeForm (   $a_mode,
ilBadgeType  $a_type,
  $a_type_unique_id 
)
protected

Definition at line 292 of file class.ilBadgeManagementGUI.php.

293 {
295 $ilCtrl = $this->ctrl;
296
297 $form = new ilPropertyFormGUI();
298 $form->setFormAction($ilCtrl->getFormAction($this, "saveBadge"));
299 $form->setTitle($lng->txt("badge_badge") . ' "' . $a_type->getCaption() . '"');
300
301 $active = new ilCheckboxInputGUI($lng->txt("active"), "act");
302 $form->addItem($active);
303
304 $title = new ilTextInputGUI($lng->txt("title"), "title");
305 $title->setRequired(true);
306 $form->addItem($title);
307
308 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
309 $desc->setRequired(true);
310 $form->addItem($desc);
311
312 $crit = new ilTextAreaInputGUI($lng->txt("badge_criteria"), "crit");
313 $crit->setRequired(true);
314 $form->addItem($crit);
315
316 if ($a_mode == "create") {
317 // upload
318
319 $img_mode = new ilRadioGroupInputGUI($lng->txt("image"), "img_mode");
320 $img_mode->setRequired(true);
321 $form->addItem($img_mode);
322
323 $img_mode_tmpl = new ilRadioOption($lng->txt("badge_image_from_template"), "tmpl");
324 $img_mode->addOption($img_mode_tmpl);
325
326 $img_mode_up = new ilRadioOption($lng->txt("badge_image_from_upload"), "up");
327 $img_mode->addOption($img_mode_up);
328
329 $img_upload = new ilImageFileInputGUI($lng->txt("file"), "img");
330 $img_upload->setRequired(true);
331 $img_upload->setSuffixes(array("png", "svg"));
332 $img_mode_up->addSubItem($img_upload);
333
334 // templates
335
336 $valid_templates = ilBadgeImageTemplate::getInstancesByType($a_type_unique_id);
337 if (sizeof($valid_templates)) {
338 $options = array();
339 $options[""] = $lng->txt("please_select");
340 foreach ($valid_templates as $tmpl) {
341 $options[$tmpl->getId()] = $tmpl->getTitle();
342 }
343
344 $tmpl = new ilSelectInputGUI($lng->txt("badge_image_template_form"), "tmpl");
345 $tmpl->setRequired(true);
346 $tmpl->setOptions($options);
347 $img_mode_tmpl->addSubItem($tmpl);
348 } else {
349 // no templates, activate upload
350 $img_mode_tmpl->setDisabled(true);
351 $img_mode->setValue("up");
352 }
353 } else {
354 $img_upload = new ilImageFileInputGUI($lng->txt("image"), "img");
355 $img_upload->setSuffixes(array("png", "svg"));
356 $img_upload->setALlowDeletion(false);
357 $img_upload->setUseCache(false);
358 $form->addItem($img_upload);
359 }
360
361 $valid = new ilTextInputGUI($lng->txt("badge_valid"), "valid");
362 $form->addItem($valid);
363
364 $custom = $a_type->getConfigGUIInstance();
365 if ($custom &&
366 $custom instanceof ilBadgeTypeGUI) {
367 $custom->initConfigForm($form, $this->parent_ref_id);
368 }
369
370 // :TODO: valid date/period
371
372 if ($a_mode == "create") {
373 $form->addCommandButton("saveBadge", $lng->txt("save"));
374 } else {
375 $form->addCommandButton("updateBadge", $lng->txt("save"));
376 }
377 $form->addCommandButton("listBadges", $lng->txt("cancel"));
378
379 return $form;
380 }
static getInstancesByType($a_type_unique_id)
This class represents a checkbox property in a property form.
This class represents an image file property in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$valid
Badge type gui interface.
getCaption()
Get caption.
getConfigGUIInstance()
Get GUI config instance.

References $ctrl, $lng, $valid, ilBadgeType\getCaption(), ilBadgeType\getConfigGUIInstance(), and ilBadgeImageTemplate\getInstancesByType().

Referenced by addBadge(), editBadge(), executeCommand(), saveBadge(), and updateBadge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listBadges()

ilBadgeManagementGUI::listBadges ( )
protected

Definition at line 174 of file class.ilBadgeManagementGUI.php.

175 {
176 $ilToolbar = $this->toolbar;
178 $ilCtrl = $this->ctrl;
180
181 $this->setTabs("badges");
182
183 if ($this->hasWrite()) {
184 $handler = ilBadgeHandler::getInstance();
185 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
186 if ($valid_types) {
187 $options = array();
188 foreach ($valid_types as $id => $type) {
189 $options[$id] = ($this->parent_obj_type != "bdga")
191 : $type->getCaption();
192 }
193 asort($options);
194
195 $drop = new ilSelectInputGUI($lng->txt("type"), "type");
196 $drop->setOptions($options);
197 $ilToolbar->addInputItem($drop, true);
198
199 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addBadge"));
200 $ilToolbar->addFormButton($lng->txt("create"), "addBadge");
201 } else {
202 ilUtil::sendInfo($lng->txt("badge_no_valid_types_for_obj"));
203 }
204
205 if (is_array($_SESSION[self::CLIPBOARD_ID])) {
206 if ($valid_types) {
207 $ilToolbar->addSeparator();
208 }
209
210 $tt = array();
211 foreach ($this->getValidBadgesFromClipboard() as $badge) {
212 $tt[] = $badge->getTitle();
213 }
214 $ttid = "bdgpst";
216 $ttid,
217 implode("<br />", $tt),
218 "",
219 "bottom center",
220 "top center",
221 false
222 );
223
224 $lng->loadLanguageModule("content");
225 $ilToolbar->addButton(
226 $lng->txt("cont_paste_from_clipboard") .
227 " (" . sizeof($tt) . ")",
228 $ilCtrl->getLinkTarget($this, "pasteBadges"),
229 "",
230 "",
231 "",
232 $ttid
233 );
234 $ilToolbar->addButton(
235 $lng->txt("clear_clipboard"),
236 $ilCtrl->getLinkTarget($this, "clearClipboard")
237 );
238 }
239 }
240
241 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
242 $tpl->setContent($tbl->getHTML());
243 }
static getExtendedTypeCaption(ilBadgeType $a_type)
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.

References $_SESSION, $ctrl, $lng, $toolbar, $tpl, $type, ilTooltipGUI\addTooltip(), ilBadge\getExtendedTypeCaption(), ilBadgeHandler\getInstance(), getValidBadgesFromClipboard(), hasWrite(), ilUtil\sendInfo(), and setTabs().

Referenced by applyBadgeFilter(), and resetBadgeFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listUsers()

ilBadgeManagementGUI::listUsers ( )
protected

Definition at line 679 of file class.ilBadgeManagementGUI.php.

680 {
682 $ilCtrl = $this->ctrl;
683 $ilToolbar = $this->toolbar;
685
686 $this->setTabs("users");
687
688 if ($this->hasWrite()) {
689 $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type);
690 if (sizeof($manual)) {
691 $drop = new ilSelectInputGUI($lng->txt("badge_badge"), "bid");
692 $drop->setOptions($manual);
693 $ilToolbar->addInputItem($drop, true);
694
695 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "awardBadgeUserSelection"));
696 $ilToolbar->addFormButton($lng->txt("badge_award_badge"), "awardBadgeUserSelection");
697 }
698 }
699
700 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
701 $tpl->setContent($tbl->getHTML());
702 }

References $ctrl, $lng, $toolbar, $tpl, ilBadgeHandler\getInstance(), hasWrite(), and setTabs().

Referenced by applyListUsers(), and resetListUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pasteBadges()

ilBadgeManagementGUI::pasteBadges ( )
protected

Definition at line 631 of file class.ilBadgeManagementGUI.php.

632 {
633 $ilCtrl = $this->ctrl;
634
635 if (!$this->hasWrite() ||
636 !is_array($_SESSION[self::CLIPBOARD_ID])) {
637 $ilCtrl->redirect($this, "listBadges");
638 }
639
640 foreach ($this->getValidBadgesFromClipboard() as $badge) {
641 $badge->copy($this->parent_obj_id);
642 }
643
644 $ilCtrl->redirect($this, "listBadges");
645 }

References $_SESSION, $ctrl, getValidBadgesFromClipboard(), and hasWrite().

+ Here is the call graph for this function:

◆ resetAwardBadgeUserSelection()

ilBadgeManagementGUI::resetAwardBadgeUserSelection ( )
protected

Definition at line 766 of file class.ilBadgeManagementGUI.php.

767 {
768 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
769 $tbl->resetOffset();
770 $tbl->resetFilter();
772 }

References awardBadgeUserSelection().

+ Here is the call graph for this function:

◆ resetBadgeFilter()

ilBadgeManagementGUI::resetBadgeFilter ( )
protected

Definition at line 253 of file class.ilBadgeManagementGUI.php.

254 {
255 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
256 $tbl->resetOffset();
257 $tbl->resetFilter();
258 $this->listBadges();
259 }

References hasWrite(), and listBadges().

+ Here is the call graph for this function:

◆ resetListUsers()

ilBadgeManagementGUI::resetListUsers ( )
protected

Definition at line 712 of file class.ilBadgeManagementGUI.php.

713 {
714 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
715 $tbl->resetOffset();
716 $tbl->resetFilter();
717 $this->listUsers();
718 }

References listUsers().

+ Here is the call graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected

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

383 {
384 $ilCtrl = $this->ctrl;
386
387 $type_id = $_REQUEST["type"];
388 if (!$type_id ||
389 !$this->hasWrite()) {
390 $ilCtrl->redirect($this, "listBadges");
391 }
392
393 $ilCtrl->setParameter($this, "type", $type_id);
394
395 $handler = ilBadgeHandler::getInstance();
396 $type = $handler->getTypeInstanceByUniqueId($type_id);
397 if (!$type) {
398 $ilCtrl->redirect($this, "listBadges");
399 }
400
401 $form = $this->initBadgeForm("create", $type, $type_id);
402 $custom = $type->getConfigGUIInstance();
403
404 if ($form->checkInput() &&
405 (!$custom || $custom->validateForm($form))) {
406 $badge = new ilBadge();
407 $badge->setParentId($this->parent_obj_id); // :TODO: ref_id?
408 $badge->setTypeId($type_id);
409 $badge->setActive($form->getInput("act"));
410 $badge->setTitle($form->getInput("title"));
411 $badge->setDescription($form->getInput("desc"));
412 $badge->setCriteria($form->getInput("crit"));
413 $badge->setValid($form->getInput("valid"));
414
415 if ($custom &&
416 $custom instanceof ilBadgeTypeGUI) {
417 $badge->setConfiguration($custom->getConfigFromForm($form));
418 }
419
420 $badge->create();
421
422 if ($form->getInput("img_mode") == "up") {
423 $badge->uploadImage($_FILES["img"]);
424 } else {
425 $tmpl = new ilBadgeImageTemplate($form->getInput("tmpl"));
426 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
427 }
428
429 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
430 $ilCtrl->redirect($this, "listBadges");
431 }
432
433 $form->setValuesByPost();
434 $this->addBadge($form);
435 }
addBadge(ilPropertyFormGUI $a_form=null)

References $ctrl, $lng, $type, addBadge(), ilBadgeHandler\getInstance(), hasWrite(), and initBadgeForm().

+ Here is the call graph for this function:

◆ setBadgeFormValues()

ilBadgeManagementGUI::setBadgeFormValues ( ilPropertyFormGUI  $a_form,
ilBadge  $a_badge,
ilBadgeType  $a_type 
)
protected

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

468 {
469 $a_form->getItemByPostVar("act")->setChecked($a_badge->isActive());
470 $a_form->getItemByPostVar("title")->setValue($a_badge->getTitle());
471 $a_form->getItemByPostVar("desc")->setValue($a_badge->getDescription());
472 $a_form->getItemByPostVar("crit")->setValue($a_badge->getCriteria());
473 $a_form->getItemByPostVar("img")->setValue($a_badge->getImage());
474 $a_form->getItemByPostVar("img")->setImage($a_badge->getImagePath());
475 $a_form->getItemByPostVar("valid")->setValue($a_badge->getValid());
476
477 $custom = $a_type->getConfigGUIInstance();
478 if ($custom &&
479 $custom instanceof ilBadgeTypeGUI) {
480 $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
481 }
482 }
getImagePath($a_full_path=true)
getConfiguration()
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilBadgeType\getConfigGUIInstance(), ilBadge\getConfiguration(), ilBadge\getCriteria(), ilBadge\getDescription(), ilBadge\getImage(), ilBadge\getImagePath(), ilPropertyFormGUI\getItemByPostVar(), ilBadge\getTitle(), ilBadge\getValid(), and ilBadge\isActive().

Referenced by editBadge(), and executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTabs()

ilBadgeManagementGUI::setTabs (   $a_active)
protected

Definition at line 147 of file class.ilBadgeManagementGUI.php.

148 {
149 $ilTabs = $this->tabs;
151 $ilCtrl = $this->ctrl;
152
153 $ilTabs->addSubTab(
154 "badges",
155 $lng->txt("obj_bdga"),
156 $ilCtrl->getLinkTarget($this, "listBadges")
157 );
158
159 $ilTabs->addSubTab(
160 "users",
161 $lng->txt("users"),
162 $ilCtrl->getLinkTarget($this, "listUsers")
163 );
164
165 $ilTabs->activateSubTab($a_active);
166 }

References $ctrl, $lng, and $tabs.

Referenced by listBadges(), and listUsers().

+ Here is the caller graph for this function:

◆ toggleBadges()

ilBadgeManagementGUI::toggleBadges (   $a_status)
protected

Definition at line 647 of file class.ilBadgeManagementGUI.php.

648 {
649 $ilCtrl = $this->ctrl;
651
652 $badge_ids = $this->getBadgesFromMultiAction();
653
654 foreach ($badge_ids as $badge_id) {
655 $badge = new ilBadge($badge_id);
656 $badge->setActive($a_status);
657 $badge->update();
658 }
659
660 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
661 $ilCtrl->redirect($this, "listBadges");
662 }

References $ctrl, $lng, and getBadgesFromMultiAction().

Referenced by activateBadges(), and deactivateBadges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateBadge()

ilBadgeManagementGUI::updateBadge ( )
protected

Definition at line 484 of file class.ilBadgeManagementGUI.php.

485 {
486 $ilCtrl = $this->ctrl;
488
489 $badge_id = $_REQUEST["bid"];
490 if (!$badge_id ||
491 !$this->hasWrite()) {
492 $ilCtrl->redirect($this, "listBadges");
493 }
494
495 $ilCtrl->setParameter($this, "bid", $badge_id);
496
497 $badge = new ilBadge($badge_id);
498 $type = $badge->getTypeInstance();
499 $custom = $type->getConfigGUIInstance();
500 if ($custom &&
501 !($custom instanceof ilBadgeTypeGUI)) {
502 $custom = null;
503 }
504 $form = $this->initBadgeForm("update", $type, $badge->getTypeId());
505 if ($form->checkInput() &&
506 (!$custom || $custom->validateForm($form))) {
507 $badge->setActive($form->getInput("act"));
508 $badge->setTitle($form->getInput("title"));
509 $badge->setDescription($form->getInput("desc"));
510 $badge->setCriteria($form->getInput("crit"));
511 $badge->setValid($form->getInput("valid"));
512
513 if ($custom) {
514 $badge->setConfiguration($custom->getConfigFromForm($form));
515 }
516
517 $badge->update();
518
519 $badge->uploadImage($_FILES["img"]);
520
521 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
522 $ilCtrl->redirect($this, "listBadges");
523 }
524
525 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
526 $form->setValuesByPost();
527 $this->editBadge($form);
528 }
editBadge(ilPropertyFormGUI $a_form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $ctrl, $lng, $type, editBadge(), hasWrite(), initBadgeForm(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilBadgeManagementGUI::$access
protected

Definition at line 32 of file class.ilBadgeManagementGUI.php.

Referenced by hasWrite().

◆ $ctrl

◆ $lng

◆ $parent_obj_id

ilBadgeManagementGUI::$parent_obj_id
protected

Definition at line 50 of file class.ilBadgeManagementGUI.php.

◆ $parent_obj_type

ilBadgeManagementGUI::$parent_obj_type
protected

Definition at line 51 of file class.ilBadgeManagementGUI.php.

◆ $parent_ref_id

ilBadgeManagementGUI::$parent_ref_id
protected

Definition at line 49 of file class.ilBadgeManagementGUI.php.

◆ $tabs

ilBadgeManagementGUI::$tabs
protected

◆ $toolbar

ilBadgeManagementGUI::$toolbar
protected

Definition at line 37 of file class.ilBadgeManagementGUI.php.

Referenced by listBadges(), and listUsers().

◆ $tpl

ilBadgeManagementGUI::$tpl
protected

◆ $user

ilBadgeManagementGUI::$user
protected

Definition at line 47 of file class.ilBadgeManagementGUI.php.

Referenced by assignBadge().

◆ CLIPBOARD_ID

const ilBadgeManagementGUI::CLIPBOARD_ID = "bdgclpbrd"

Definition at line 53 of file class.ilBadgeManagementGUI.php.

Referenced by copyBadges().


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