ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBadgeManagementGUI Class Reference
+ 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

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

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

66 {
67 global $DIC;
68
69 $this->lng = $DIC->language();
70 $this->ctrl = $DIC->ctrl();
71 $this->tabs = $DIC->tabs();
72 $this->access = $DIC->access();
73 $this->toolbar = $DIC->toolbar();
74 $this->tpl = $DIC["tpl"];
75 $this->user = $DIC->user();
76 $lng = $DIC->language();
77
78 $this->parent_ref_id = $a_parent_ref_id;
79 $this->parent_obj_id = $a_parent_obj_id
80 ? $a_parent_obj_id
81 : ilObject::_lookupObjId($a_parent_ref_id);
82 $this->parent_obj_type = $a_parent_obj_type
83 ? $a_parent_obj_type
84 : ilObject::_lookupType($this->parent_obj_id);
85
86 if (!ilBadgeHandler::getInstance()->isObjectActive($this->parent_obj_id)) {
87 throw new ilException("inactive object");
88 }
89
90 $lng->loadLanguageModule("badge");
91 }
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
global $DIC
Definition: saml.php:7

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

685 {
686 $this->toggleBadges(true);
687 }

References toggleBadges().

+ Here is the call graph for this function:

◆ addBadge()

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

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

277 {
280
281 $type_id = $_REQUEST["type"];
282 if (!$type_id ||
283 !$this->hasWrite()) {
284 $ilCtrl->redirect($this, "listBadges");
285 }
286
287 $ilCtrl->setParameter($this, "type", $type_id);
288
290 $type = $handler->getTypeInstanceByUniqueId($type_id);
291 if (!$type) {
292 $ilCtrl->redirect($this, "listBadges");
293 }
294
295 if (!$a_form) {
296 $a_form = $this->initBadgeForm("create", $type, $type_id);
297 }
298
299 $tpl->setContent($a_form->getHTML());
300 }
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
global $ilCtrl
Definition: ilias.php:18
$type
$handler

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

785 {
786 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
787 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
788 $tbl->resetOffset();
789 $tbl->writeFilterToSession();
791 }
TableGUI class for badge user listing.
$tbl
Definition: example_048.php:81

References $tbl, and awardBadgeUserSelection().

+ Here is the call graph for this function:

◆ applyBadgeFilter()

ilBadgeManagementGUI::applyBadgeFilter ( )
protected

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

254 {
255 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
256 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
257 $tbl->resetOffset();
258 $tbl->writeFilterToSession();
259 $this->listBadges();
260 }
TableGUI class for badge listing.

References $tbl, hasWrite(), and listBadges().

+ Here is the call graph for this function:

◆ applyListUsers()

ilBadgeManagementGUI::applyListUsers ( )
protected

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

727 {
728 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
729 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
730 $tbl->resetOffset();
731 $tbl->writeFilterToSession();
732 $this->listUsers();
733 }

References $tbl, and listUsers().

+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

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

803 {
807
808 $user_ids = $_POST["id"];
809 $badge_id = $_REQUEST["bid"];
810 if (!$user_ids ||
811 !$badge_id ||
812 !$this->hasWrite()) {
813 $ilCtrl->redirect($this, "listUsers");
814 }
815
816 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
817 $new_badges = array();
818 foreach ($user_ids as $user_id) {
819 if (!ilBadgeAssignment::exists($badge_id, $user_id)) {
820 $ass = new ilBadgeAssignment($badge_id, $user_id);
821 $ass->setAwardedBy($ilUser->getId());
822 $ass->store();
823
824 $new_badges[$user_id][] = $badge_id;
825 }
826 }
827
828 ilBadgeHandler::getInstance()->sendNotification($new_badges, $this->parent_ref_id);
829
830 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
831 $ilCtrl->redirect($this, "listUsers");
832 }
$_POST["username"]
static exists($a_badge_id, $a_user_id)
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$ilUser
Definition: imgupload.php:18

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

+ Here is the call graph for this function:

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

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

745 {
748 $ilTabs = $this->tabs;
750
751 $bid = (int) $_REQUEST["bid"];
752 if (!$bid ||
753 !$this->hasWrite()) {
754 $ilCtrl->redirect($this, "listUsers");
755 }
756
757 $manual = array_keys(ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type));
758 if (!in_array($bid, $manual)) {
759 $ilCtrl->redirect($this, "listUsers");
760 }
761
762 $back_target = "listUsers";
763 if ($_REQUEST["tgt"] == "bdgl") {
764 $ilCtrl->saveParameter($this, "tgt");
765 $back_target = "listBadges";
766 }
767
768 $ilTabs->clearTargets();
769 $ilTabs->setBackTarget(
770 $lng->txt("back"),
771 $ilCtrl->getLinkTarget($this, $back_target)
772 );
773
774 $ilCtrl->setParameter($this, "bid", $bid);
775
776 include_once "./Services/Badge/classes/class.ilBadge.php";
777 $badge = new ilBadge($bid);
778
779 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
780 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id, $badge);
781 $tpl->setContent($tbl->getHTML());
782 }

References $ctrl, $ilCtrl, $lng, $tabs, $tbl, $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 625 of file class.ilBadgeManagementGUI.php.

626 {
628
629 unset($_SESSION[self::CLIPBOARD_ID]);
630 $ilCtrl->redirect($this, "listBadges");
631 }
$_SESSION["AccountId"]

References $_SESSION, $ctrl, and $ilCtrl.

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

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

835 {
839 $ilTabs = $this->tabs;
840
841 $user_ids = $_POST["id"];
842 $badge_id = $_REQUEST["bid"];
843 if (!$user_ids ||
844 !$badge_id ||
845 !$this->hasWrite()) {
846 $ilCtrl->redirect($this, "listUsers");
847 }
848
849 $ilTabs->clearTargets();
850 $ilTabs->setBackTarget(
851 $lng->txt("back"),
852 $ilCtrl->getLinkTarget($this, "listUsers")
853 );
854
855 include_once "Services/Badge/classes/class.ilBadge.php";
856 $badge = new ilBadge($badge_id);
857
858 $ilCtrl->setParameter($this, "bid", $badge->getId());
859
860 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
861 $confirmation_gui = new ilConfirmationGUI();
862 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
863 $confirmation_gui->setHeaderText(sprintf($lng->txt("badge_assignment_deletion_confirmation"), $badge->getTitle()));
864 $confirmation_gui->setCancel($lng->txt("cancel"), "listUsers");
865 $confirmation_gui->setConfirm($lng->txt("delete"), "deassignBadge");
866
867 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
868 $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
869
870 include_once "Services/User/classes/class.ilUserUtil.php";
871 foreach ($user_ids as $user_id) {
872 if (in_array($user_id, $assigned_users)) {
873 $confirmation_gui->addItem(
874 "id[]",
875 $user_id,
876 ilUserUtil::getNamePresentation($user_id, false, false, "", true)
877 );
878 }
879 }
880
881 $tpl->setContent($confirmation_gui->getHTML());
882 }
sprintf('%.4f', $callTime)
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(), hasWrite(), and sprintf.

+ Here is the call graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

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

545 {
549 $ilTabs = $this->tabs;
550
551 $badge_ids = $this->getBadgesFromMultiAction();
552
553 $ilTabs->clearTargets();
554 $ilTabs->setBackTarget(
555 $lng->txt("back"),
556 $ilCtrl->getLinkTarget($this, "listBadges")
557 );
558
559 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
560 $confirmation_gui = new ilConfirmationGUI();
561 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
562 $confirmation_gui->setHeaderText($lng->txt("badge_deletion_confirmation"));
563 $confirmation_gui->setCancel($lng->txt("cancel"), "listBadges");
564 $confirmation_gui->setConfirm($lng->txt("delete"), "deleteBadges");
565
566 include_once "Services/Badge/classes/class.ilBadge.php";
567 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
568 foreach ($badge_ids as $badge_id) {
569 $badge = new ilBadge($badge_id);
570 $confirmation_gui->addItem("id[]", $badge_id, $badge->getTitle() .
571 " (" . sizeof(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ")");
572 }
573
574 $tpl->setContent($confirmation_gui->getHTML());
575 }
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 612 of file class.ilBadgeManagementGUI.php.

613 {
615
616 $badge_ids = $this->getBadgesFromMultiAction();
617
618 $_SESSION[self::CLIPBOARD_ID] = array_unique(
619 array_merge((array) $_SESSION[self::CLIPBOARD_ID], $badge_ids)
620 );
621
622 $ilCtrl->redirect($this, "listBadges");
623 }

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

+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

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

690 {
691 $this->toggleBadges(false);
692 }

References toggleBadges().

+ Here is the call graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

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

885 {
888
889 $user_ids = $_POST["id"];
890 $badge_id = $_REQUEST["bid"];
891 if (!$user_ids ||
892 !$badge_id ||
893 !$this->hasWrite()) {
894 $ilCtrl->redirect($this, "listUsers");
895 }
896
897 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
898 foreach ($user_ids as $user_id) {
899 $ass = new ilBadgeAssignment($badge_id, $user_id);
900 $ass->delete();
901 }
902
903 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
904 $ilCtrl->redirect($this, "listUsers");
905 }

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

+ Here is the call graph for this function:

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

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

578 {
581
582 $badge_ids = $this->getBadgesFromMultiAction();
583
584 include_once "Services/Badge/classes/class.ilBadge.php";
585 foreach ($badge_ids as $badge_id) {
586 $badge = new ilBadge($badge_id);
587 $badge->delete();
588 }
589
590 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
591 $ilCtrl->redirect($this, "listBadges");
592 }

References $ctrl, $ilCtrl, $lng, getBadgesFromMultiAction(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ editBadge()

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

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

450 {
454
455 $badge_id = $_REQUEST["bid"];
456 if (!$badge_id ||
457 !$this->hasWrite()) {
458 $ilCtrl->redirect($this, "listBadges");
459 }
460
461 $ilCtrl->setParameter($this, "bid", $badge_id);
462
463 include_once "./Services/Badge/classes/class.ilBadge.php";
464 $badge = new ilBadge($badge_id);
465
466 $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
467 if ($static_cnt) {
468 ilUtil::sendInfo(sprintf($lng->txt("badge_edit_with_published"), $static_cnt));
469 }
470
471 if (!$a_form) {
472 $type = $badge->getTypeInstance();
473 $a_form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
474 $this->setBadgeFormValues($a_form, $badge, $type);
475 }
476
477 $tpl->setContent($a_form->getHTML());
478 }
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(), setBadgeFormValues(), and sprintf.

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

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

References $ctrl, $form, $handler, $ilCtrl, $lng, $tabs, $type, ilBadgeHandler\getInstance(), and initBadgeForm().

+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected

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

600 {
602
603 $badge_ids = $_REQUEST["id"];
604 if (!$badge_ids ||
605 !$this->hasWrite()) {
606 $ilCtrl->redirect($this, "listBadges");
607 }
608
609 return $badge_ids;
610 }

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

634 {
635 $res = array();
636
637 $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
638
639 include_once "Services/Badge/classes/class.ilBadge.php";
640 foreach ($_SESSION[self::CLIPBOARD_ID] as $badge_id) {
641 $badge = new ilBadge($badge_id);
642 if (in_array($badge->getTypeId(), $valid_types)) {
643 $res[] = $badge;
644 }
645 }
646
647 return $res;
648 }
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 172 of file class.ilBadgeManagementGUI.php.

173 {
174 $ilAccess = $this->access;
175 return $ilAccess->checkAccess("write", "", $this->parent_ref_id);
176 }

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

303 {
306
307 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
308 $form = new ilPropertyFormGUI();
309 $form->setFormAction($ilCtrl->getFormAction($this, "saveBadge"));
310 $form->setTitle($lng->txt("badge_badge") . ' "' . $a_type->getCaption() . '"');
311
312 $active = new ilCheckboxInputGUI($lng->txt("active"), "act");
313 $form->addItem($active);
314
315 $title = new ilTextInputGUI($lng->txt("title"), "title");
316 $title->setRequired(true);
317 $form->addItem($title);
318
319 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
320 $desc->setRequired(true);
321 $form->addItem($desc);
322
323 $crit = new ilTextAreaInputGUI($lng->txt("badge_criteria"), "crit");
324 $crit->setRequired(true);
325 $form->addItem($crit);
326
327 if ($a_mode == "create") {
328 // upload
329
330 $img_mode = new ilRadioGroupInputGUI($lng->txt("image"), "img_mode");
331 $img_mode->setRequired(true);
332 $form->addItem($img_mode);
333
334 $img_mode_tmpl = new ilRadioOption($lng->txt("badge_image_from_template"), "tmpl");
335 $img_mode->addOption($img_mode_tmpl);
336
337 $img_mode_up = new ilRadioOption($lng->txt("badge_image_from_upload"), "up");
338 $img_mode->addOption($img_mode_up);
339
340 $img_upload = new ilImageFileInputGUI($lng->txt("file"), "img");
341 $img_upload->setRequired(true);
342 $img_upload->setSuffixes(array("png", "svg"));
343 $img_mode_up->addSubItem($img_upload);
344
345 // templates
346
347 include_once "Services/Badge/classes/class.ilBadgeImageTemplate.php";
348 $valid_templates = ilBadgeImageTemplate::getInstancesByType($a_type_unique_id);
349 if (sizeof($valid_templates)) {
350 $options = array();
351 $options[""] = $lng->txt("please_select");
352 foreach ($valid_templates as $tmpl) {
353 $options[$tmpl->getId()] = $tmpl->getTitle();
354 }
355
356 $tmpl = new ilSelectInputGUI($lng->txt("badge_image_template_form"), "tmpl");
357 $tmpl->setRequired(true);
358 $tmpl->setOptions($options);
359 $img_mode_tmpl->addSubItem($tmpl);
360 } else {
361 // no templates, activate upload
362 $img_mode_tmpl->setDisabled(true);
363 $img_mode->setValue("up");
364 }
365 } else {
366 $img_upload = new ilImageFileInputGUI($lng->txt("image"), "img");
367 $img_upload->setSuffixes(array("png", "svg"));
368 $img_upload->setALlowDeletion(false);
369 $form->addItem($img_upload);
370 }
371
372 $valid = new ilTextInputGUI($lng->txt("badge_valid"), "valid");
373 $form->addItem($valid);
374
375 $custom = $a_type->getConfigGUIInstance();
376 if ($custom &&
377 $custom instanceof ilBadgeTypeGUI) {
378 $custom->initConfigForm($form, $this->parent_ref_id);
379 }
380
381 // :TODO: valid date/period
382
383 if ($a_mode == "create") {
384 $form->addCommandButton("saveBadge", $lng->txt("save"));
385 } else {
386 $form->addCommandButton("updateBadge", $lng->txt("save"));
387 }
388 $form->addCommandButton("listBadges", $lng->txt("cancel"));
389
390 return $form;
391 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
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, $form, $ilCtrl, $lng, $options, $title, $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 178 of file class.ilBadgeManagementGUI.php.

179 {
180 $ilToolbar = $this->toolbar;
184
185 $this->setTabs("badges");
186
187 if ($this->hasWrite()) {
189 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
190 if ($valid_types) {
191 include_once "Services/Badge/classes/class.ilBadge.php";
192 $options = array();
193 foreach ($valid_types as $id => $type) {
194 $options[$id] = ($this->parent_obj_type != "bdga")
196 : $type->getCaption();
197 }
198 asort($options);
199
200 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
201 $drop = new ilSelectInputGUI($lng->txt("type"), "type");
202 $drop->setOptions($options);
203 $ilToolbar->addInputItem($drop, true);
204
205 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addBadge"));
206 $ilToolbar->addFormButton($lng->txt("create"), "addBadge");
207 } else {
208 ilUtil::sendInfo($lng->txt("badge_no_valid_types_for_obj"));
209 }
210
211 if (is_array($_SESSION[self::CLIPBOARD_ID])) {
212 if ($valid_types) {
213 $ilToolbar->addSeparator();
214 }
215
216 $tt = array();
217 foreach ($this->getValidBadgesFromClipboard() as $badge) {
218 $tt[] = $badge->getTitle();
219 }
220 $ttid = "bdgpst";
221 include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
223 $ttid,
224 implode("<br />", $tt),
225 "",
226 "bottom center",
227 "top center",
228 false
229 );
230
231 $lng->loadLanguageModule("content");
232 $ilToolbar->addButton(
233 $lng->txt("cont_paste_from_clipboard") .
234 " (" . sizeof($tt) . ")",
235 $ilCtrl->getLinkTarget($this, "pasteBadges"),
236 "",
237 "",
238 "",
239 $ttid
240 );
241 $ilToolbar->addButton(
242 $lng->txt("clear_clipboard"),
243 $ilCtrl->getLinkTarget($this, "clearClipboard")
244 );
245 }
246 }
247
248 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
249 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
250 $tpl->setContent($tbl->getHTML());
251 }
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.
if(!array_key_exists('StateId', $_REQUEST)) $id

References $_SESSION, $ctrl, $handler, $id, $ilCtrl, $lng, $options, $tbl, $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 699 of file class.ilBadgeManagementGUI.php.

700 {
703 $ilToolbar = $this->toolbar;
705
706 $this->setTabs("users");
707
708 if ($this->hasWrite()) {
709 $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type);
710 if (sizeof($manual)) {
711 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
712 $drop = new ilSelectInputGUI($lng->txt("badge_badge"), "bid");
713 $drop->setOptions($manual);
714 $ilToolbar->addInputItem($drop, true);
715
716 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "awardBadgeUserSelection"));
717 $ilToolbar->addFormButton($lng->txt("badge_award_badge"), "awardBadgeUserSelection");
718 }
719 }
720
721 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
722 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
723 $tpl->setContent($tbl->getHTML());
724 }

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

651 {
653
654 if (!$this->hasWrite() ||
655 !is_array($_SESSION[self::CLIPBOARD_ID])) {
656 $ilCtrl->redirect($this, "listBadges");
657 }
658
659 foreach ($this->getValidBadgesFromClipboard() as $badge) {
660 $badge->copy($this->parent_obj_id);
661 }
662
663 $ilCtrl->redirect($this, "listBadges");
664 }

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

+ Here is the call graph for this function:

◆ resetAwardBadgeUserSelection()

ilBadgeManagementGUI::resetAwardBadgeUserSelection ( )
protected

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

794 {
795 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
796 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
797 $tbl->resetOffset();
798 $tbl->resetFilter();
800 }

References $tbl, and awardBadgeUserSelection().

+ Here is the call graph for this function:

◆ resetBadgeFilter()

ilBadgeManagementGUI::resetBadgeFilter ( )
protected

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

263 {
264 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
265 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
266 $tbl->resetOffset();
267 $tbl->resetFilter();
268 $this->listBadges();
269 }

References $tbl, hasWrite(), and listBadges().

+ Here is the call graph for this function:

◆ resetListUsers()

ilBadgeManagementGUI::resetListUsers ( )
protected

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

736 {
737 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
738 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
739 $tbl->resetOffset();
740 $tbl->resetFilter();
741 $this->listUsers();
742 }

References $tbl, and listUsers().

+ Here is the call graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected

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

394 {
397
398 $type_id = $_REQUEST["type"];
399 if (!$type_id ||
400 !$this->hasWrite()) {
401 $ilCtrl->redirect($this, "listBadges");
402 }
403
404 $ilCtrl->setParameter($this, "type", $type_id);
405
407 $type = $handler->getTypeInstanceByUniqueId($type_id);
408 if (!$type) {
409 $ilCtrl->redirect($this, "listBadges");
410 }
411
412 $form = $this->initBadgeForm("create", $type, $type_id);
413 $custom = $type->getConfigGUIInstance();
414
415 if ($form->checkInput() &&
416 (!$custom || $custom->validateForm($form))) {
417 include_once "Services/Badge/classes/class.ilBadge.php";
418 $badge = new ilBadge();
419 $badge->setParentId($this->parent_obj_id); // :TODO: ref_id?
420 $badge->setTypeId($type_id);
421 $badge->setActive($form->getInput("act"));
422 $badge->setTitle($form->getInput("title"));
423 $badge->setDescription($form->getInput("desc"));
424 $badge->setCriteria($form->getInput("crit"));
425 $badge->setValid($form->getInput("valid"));
426
427 if ($custom &&
428 $custom instanceof ilBadgeTypeGUI) {
429 $badge->setConfiguration($custom->getConfigFromForm($form));
430 }
431
432 $badge->create();
433
434 if ($form->getInput("img_mode") == "up") {
435 $badge->uploadImage($_FILES["img"]);
436 } else {
437 $tmpl = new ilBadgeImageTemplate($form->getInput("tmpl"));
438 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
439 }
440
441 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
442 $ilCtrl->redirect($this, "listBadges");
443 }
444
445 $form->setValuesByPost();
446 $this->addBadge($form);
447 }
addBadge(ilPropertyFormGUI $a_form=null)

References $ctrl, $form, $handler, $ilCtrl, $lng, $type, addBadge(), ilBadgeHandler\getInstance(), hasWrite(), initBadgeForm(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ setBadgeFormValues()

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

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

481 {
482 $a_form->getItemByPostVar("act")->setChecked($a_badge->isActive());
483 $a_form->getItemByPostVar("title")->setValue($a_badge->getTitle());
484 $a_form->getItemByPostVar("desc")->setValue($a_badge->getDescription());
485 $a_form->getItemByPostVar("crit")->setValue($a_badge->getCriteria());
486 $a_form->getItemByPostVar("img")->setValue($a_badge->getImage());
487 $a_form->getItemByPostVar("img")->setImage($a_badge->getImagePath());
488 $a_form->getItemByPostVar("valid")->setValue($a_badge->getValid());
489
490 $custom = $a_type->getConfigGUIInstance();
491 if ($custom &&
492 $custom instanceof ilBadgeTypeGUI) {
493 $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
494 }
495 }
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().

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

152 {
153 $ilTabs = $this->tabs;
156
157 $ilTabs->addSubTab(
158 "badges",
159 $lng->txt("obj_bdga"),
160 $ilCtrl->getLinkTarget($this, "listBadges")
161 );
162
163 $ilTabs->addSubTab(
164 "users",
165 $lng->txt("users"),
166 $ilCtrl->getLinkTarget($this, "listUsers")
167 );
168
169 $ilTabs->activateSubTab($a_active);
170 }

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

667 {
670
671 $badge_ids = $this->getBadgesFromMultiAction();
672
673 include_once "Services/Badge/classes/class.ilBadge.php";
674 foreach ($badge_ids as $badge_id) {
675 $badge = new ilBadge($badge_id);
676 $badge->setActive($a_status);
677 $badge->update();
678 }
679
680 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
681 $ilCtrl->redirect($this, "listBadges");
682 }

References $ctrl, $ilCtrl, $lng, getBadgesFromMultiAction(), and ilUtil\sendSuccess().

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

498 {
501
502 $badge_id = $_REQUEST["bid"];
503 if (!$badge_id ||
504 !$this->hasWrite()) {
505 $ilCtrl->redirect($this, "listBadges");
506 }
507
508 $ilCtrl->setParameter($this, "bid", $badge_id);
509
510 include_once "./Services/Badge/classes/class.ilBadge.php";
511 $badge = new ilBadge($badge_id);
512 $type = $badge->getTypeInstance();
513 $custom = $type->getConfigGUIInstance();
514 if ($custom &&
515 !($custom instanceof ilBadgeTypeGUI)) {
516 $custom = null;
517 }
518 $form = $this->initBadgeForm("update", $type, $badge->getTypeId());
519 if ($form->checkInput() &&
520 (!$custom || $custom->validateForm($form))) {
521 $badge->setActive($form->getInput("act"));
522 $badge->setTitle($form->getInput("title"));
523 $badge->setDescription($form->getInput("desc"));
524 $badge->setCriteria($form->getInput("crit"));
525 $badge->setValid($form->getInput("valid"));
526
527 if ($custom) {
528 $badge->setConfiguration($custom->getConfigFromForm($form));
529 }
530
531 $badge->update();
532
533 $badge->uploadImage($_FILES["img"]);
534
535 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
536 $ilCtrl->redirect($this, "listBadges");
537 }
538
539 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
540 $form->setValuesByPost();
541 $this->editBadge($form);
542 }
editBadge(ilPropertyFormGUI $a_form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilBadgeManagementGUI::$access
protected

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

Referenced by hasWrite().

◆ $ctrl

◆ $lng

◆ $parent_obj_id

ilBadgeManagementGUI::$parent_obj_id
protected

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

◆ $parent_obj_type

ilBadgeManagementGUI::$parent_obj_type
protected

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

◆ $parent_ref_id

ilBadgeManagementGUI::$parent_ref_id
protected

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

◆ $tabs

ilBadgeManagementGUI::$tabs
protected

◆ $toolbar

ilBadgeManagementGUI::$toolbar
protected

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

Referenced by listBadges(), and listUsers().

◆ $tpl

ilBadgeManagementGUI::$tpl
protected

◆ $user

ilBadgeManagementGUI::$user
protected

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

Referenced by assignBadge().

◆ CLIPBOARD_ID

const ilBadgeManagementGUI::CLIPBOARD_ID = "bdgclpbrd"

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

Referenced by copyBadges().


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