ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.
Base class for ILIAS Exception handling.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
$DIC
Definition: xapitoken.php:46

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 663 of file class.ilBadgeManagementGUI.php.

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

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 {
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)
global $ilCtrl
Definition: ilias.php:18
$type

References $ctrl, $ilCtrl, $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 757 of file class.ilBadgeManagementGUI.php.

758 {
759 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
760 $tbl->resetOffset();
761 $tbl->writeFilterToSession();
763 }
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 703 of file class.ilBadgeManagementGUI.php.

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

References listUsers().

+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

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

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

References $ctrl, $ilCtrl, $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 606 of file class.ilBadgeManagementGUI.php.

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

References $_SESSION, $ctrl, and $ilCtrl.

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

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

805 {
809 $ilTabs = $this->tabs;
810
811 $user_ids = $_POST["id"];
812 $badge_id = $_REQUEST["bid"];
813 if (!$user_ids ||
814 !$badge_id ||
815 !$this->hasWrite()) {
816 $ilCtrl->redirect($this, "listUsers");
817 }
818
819 $ilTabs->clearTargets();
820 $ilTabs->setBackTarget(
821 $lng->txt("back"),
822 $ilCtrl->getLinkTarget($this, "listUsers")
823 );
824
825 $badge = new ilBadge($badge_id);
826
827 $ilCtrl->setParameter($this, "bid", $badge->getId());
828
829 $confirmation_gui = new ilConfirmationGUI();
830 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
831 $confirmation_gui->setHeaderText(sprintf($lng->txt("badge_assignment_deletion_confirmation"), $badge->getTitle()));
832 $confirmation_gui->setCancel($lng->txt("cancel"), "listUsers");
833 $confirmation_gui->setConfirm($lng->txt("delete"), "deassignBadge");
834
835 $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
836
837 foreach ($user_ids as $user_id) {
838 if (in_array($user_id, $assigned_users)) {
839 $confirmation_gui->addItem(
840 "id[]",
841 $user_id,
842 ilUserUtil::getNamePresentation($user_id, false, false, "", true)
843 );
844 }
845 }
846
847 $tpl->setContent($confirmation_gui->getHTML());
848 }
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, $ilCtrl, $lng, $tabs, $tpl, ilBadgeAssignment\getAssignedUsers(), ilUserUtil\getNamePresentation(), and hasWrite().

+ Here is the call graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ copyBadges()

ilBadgeManagementGUI::copyBadges ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

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

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

References toggleBadges().

+ Here is the call graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

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

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

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

+ Here is the call graph for this function:

◆ editBadge()

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

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

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

References $ctrl, $ilCtrl, $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 {
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, $ilCtrl, $lng, $tabs, $type, ilBadgeHandler\getInstance(), initBadgeForm(), and setBadgeFormValues().

+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected

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

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

References $ctrl, $ilCtrl, 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 614 of file class.ilBadgeManagementGUI.php.

615 {
616 $res = array();
617
618 $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
619
620 foreach ($_SESSION[self::CLIPBOARD_ID] as $badge_id) {
621 $badge = new ilBadge($badge_id);
622 if (in_array($badge->getTypeId(), $valid_types)) {
623 $res[] = $badge;
624 }
625 }
626
627 return $res;
628 }
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 {
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 $form->addItem($img_upload);
358 }
359
360 $valid = new ilTextInputGUI($lng->txt("badge_valid"), "valid");
361 $form->addItem($valid);
362
363 $custom = $a_type->getConfigGUIInstance();
364 if ($custom &&
365 $custom instanceof ilBadgeTypeGUI) {
366 $custom->initConfigForm($form, $this->parent_ref_id);
367 }
368
369 // :TODO: valid date/period
370
371 if ($a_mode == "create") {
372 $form->addCommandButton("saveBadge", $lng->txt("save"));
373 } else {
374 $form->addCommandButton("updateBadge", $lng->txt("save"));
375 }
376 $form->addCommandButton("listBadges", $lng->txt("cancel"));
377
378 return $form;
379 }
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.
$a_type
Definition: workflow.php:92

References $a_type, $ctrl, $ilCtrl, $lng, $valid, 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;
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, $ilCtrl, $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 678 of file class.ilBadgeManagementGUI.php.

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

References $ctrl, $ilCtrl, $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 630 of file class.ilBadgeManagementGUI.php.

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

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

+ Here is the call graph for this function:

◆ resetAwardBadgeUserSelection()

ilBadgeManagementGUI::resetAwardBadgeUserSelection ( )
protected

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

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

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 711 of file class.ilBadgeManagementGUI.php.

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

References listUsers().

+ Here is the call graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected

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

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

References $ctrl, $ilCtrl, $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 466 of file class.ilBadgeManagementGUI.php.

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

References $a_type, 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;
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, $ilCtrl, $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 646 of file class.ilBadgeManagementGUI.php.

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

References $ctrl, $ilCtrl, $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 483 of file class.ilBadgeManagementGUI.php.

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

References $ctrl, $ilCtrl, $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: