ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

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

31 {
32 global $lng;
33
34 $this->parent_ref_id = $a_parent_ref_id;
35 $this->parent_obj_id = $a_parent_obj_id
36 ? $a_parent_obj_id
37 : ilObject::_lookupObjId($a_parent_ref_id);
38 $this->parent_obj_type = $a_parent_obj_type
39 ? $a_parent_obj_type
40 : ilObject::_lookupType($this->parent_obj_id);
41
42 if(!ilBadgeHandler::getInstance()->isObjectActive($this->parent_obj_id))
43 {
44 throw new ilException("inactive object");
45 }
46
47 $lng->loadLanguageModule("badge");
48 }
static getInstance()
Constructor.
Base class for ILIAS Exception handling.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
global $lng
Definition: privfeed.php:17

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

+ Here is the call graph for this function:

Member Function Documentation

◆ activateBadges()

ilBadgeManagementGUI::activateBadges ( )
protected

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

659 {
660 $this->toggleBadges(true);
661 }

References toggleBadges().

+ Here is the call graph for this function:

◆ addBadge()

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

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

227 {
228 global $ilCtrl, $tpl;
229
230 $type_id = $_REQUEST["type"];
231 if(!$type_id ||
232 !$this->hasWrite())
233 {
234 $ilCtrl->redirect($this, "listBadges");
235 }
236
237 $ilCtrl->setParameter($this, "type", $type_id);
238
239 $handler = ilBadgeHandler::getInstance();
240 $type = $handler->getTypeInstanceByUniqueId($type_id);
241 if(!$type)
242 {
243 $ilCtrl->redirect($this, "listBadges");
244 }
245
246 if(!$a_form)
247 {
248 $a_form = $this->initBadgeForm("create", $type, $type_id);
249 }
250
251 $tpl->setContent($a_form->getHTML());
252 }
global $tpl
Definition: ilias.php:8
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
global $ilCtrl
Definition: ilias.php:18

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

756 {
757 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
758 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
759 $tbl->resetOffset();
760 $tbl->writeFilterToSession();
762 }
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 203 of file class.ilBadgeManagementGUI.php.

204 {
205 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
206 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
207 $tbl->resetOffset();
208 $tbl->writeFilterToSession();
209 $this->listBadges();
210 }
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 699 of file class.ilBadgeManagementGUI.php.

700 {
701 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
702 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
703 $tbl->resetOffset();
704 $tbl->writeFilterToSession();
705 $this->listUsers();
706 }

References $tbl, and listUsers().

+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

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

774 {
775 global $ilCtrl, $ilUser, $lng;
776
777 $user_ids = $_POST["id"];
778 $badge_id = $_REQUEST["bid"];
779 if(!$user_ids ||
780 !$badge_id ||
781 !$this->hasWrite())
782 {
783 $ilCtrl->redirect($this, "listUsers");
784 }
785
786 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
787 $new_badges = array();
788 foreach($user_ids as $user_id)
789 {
790 if(!ilBadgeAssignment::exists($badge_id, $user_id))
791 {
792 $ass = new ilBadgeAssignment($badge_id, $user_id);
793 $ass->setAwardedBy($ilUser->getId());
794 $ass->store();
795
796 $new_badges[$user_id][] = $badge_id;
797 }
798 }
799
800 ilBadgeHandler::getInstance()->sendNotification($new_badges, $this->parent_ref_id);
801
802 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
803 $ilCtrl->redirect($this, "listUsers");
804 }
$_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, $ilCtrl, $ilUser, $lng, ilBadgeAssignment\exists(), ilBadgeHandler\getInstance(), hasWrite(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

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

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

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

596 {
597 global $ilCtrl;
598
599 unset($_SESSION[self::CLIPBOARD_ID]);
600 $ilCtrl->redirect($this, "listBadges");
601 }
$_SESSION["AccountId"]

References $_SESSION, and $ilCtrl.

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

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

807 {
808 global $ilCtrl, $lng, $tpl, $ilTabs;
809
810 $user_ids = $_POST["id"];
811 $badge_id = $_REQUEST["bid"];
812 if(!$user_ids ||
813 !$badge_id ||
814 !$this->hasWrite())
815 {
816 $ilCtrl->redirect($this, "listUsers");
817 }
818
819 $ilTabs->clearTargets();
820 $ilTabs->setBackTarget($lng->txt("back"),
821 $ilCtrl->getLinkTarget($this, "listUsers"));
822
823 include_once "Services/Badge/classes/class.ilBadge.php";
824 $badge = new ilBadge($badge_id);
825
826 $ilCtrl->setParameter($this, "bid", $badge->getId());
827
828 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
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 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
836 $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
837
838 include_once "Services/User/classes/class.ilUserUtil.php";
839 foreach($user_ids as $user_id)
840 {
841 if(in_array($user_id, $assigned_users))
842 {
843 $confirmation_gui->addItem(
844 "id[]",
845 $user_id,
846 ilUserUtil::getNamePresentation($user_id, false, false, "", true)
847 );
848 }
849 }
850
851 $tpl->setContent($confirmation_gui->getHTML());
852 }
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)
Default behaviour is:

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

+ Here is the call graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

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

518 {
519 global $ilCtrl, $lng, $tpl, $ilTabs;
520
521 $badge_ids = $this->getBadgesFromMultiAction();
522
523 $ilTabs->clearTargets();
524 $ilTabs->setBackTarget($lng->txt("back"),
525 $ilCtrl->getLinkTarget($this, "listBadges"));
526
527 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
528 $confirmation_gui = new ilConfirmationGUI();
529 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
530 $confirmation_gui->setHeaderText($lng->txt("badge_deletion_confirmation"));
531 $confirmation_gui->setCancel($lng->txt("cancel"), "listBadges");
532 $confirmation_gui->setConfirm($lng->txt("delete"), "deleteBadges");
533
534 include_once "Services/Badge/classes/class.ilBadge.php";
535 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
536 foreach($badge_ids as $badge_id)
537 {
538 $badge = new ilBadge($badge_id);
539 $confirmation_gui->addItem("id[]", $badge_id, $badge->getTitle().
540 " (".sizeof(ilBadgeAssignment::getInstancesByBadgeId($badge_id)).")");
541 }
542
543 $tpl->setContent($confirmation_gui->getHTML());
544 }
static getInstancesByBadgeId($a_badge_id)

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

+ Here is the call graph for this function:

◆ copyBadges()

ilBadgeManagementGUI::copyBadges ( )
protected

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

583 {
584 global $ilCtrl;
585
586 $badge_ids = $this->getBadgesFromMultiAction();
587
588 $_SESSION[self::CLIPBOARD_ID] = array_unique(
589 array_merge((array)$_SESSION[self::CLIPBOARD_ID], $badge_ids)
590 );
591
592 $ilCtrl->redirect($this, "listBadges");
593 }

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

+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

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

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

References toggleBadges().

+ Here is the call graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

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

855 {
856 global $ilCtrl, $lng;
857
858 $user_ids = $_POST["id"];
859 $badge_id = $_REQUEST["bid"];
860 if(!$user_ids ||
861 !$badge_id ||
862 !$this->hasWrite())
863 {
864 $ilCtrl->redirect($this, "listUsers");
865 }
866
867 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
868 foreach($user_ids as $user_id)
869 {
870 $ass = new ilBadgeAssignment($badge_id, $user_id);
871 $ass->delete();
872 }
873
874 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
875 $ilCtrl->redirect($this, "listUsers");
876 }

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

+ Here is the call graph for this function:

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

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

547 {
548 global $ilCtrl, $lng;
549
550 $badge_ids = $this->getBadgesFromMultiAction();
551
552 include_once "Services/Badge/classes/class.ilBadge.php";
553 foreach($badge_ids as $badge_id)
554 {
555 $badge = new ilBadge($badge_id);
556 $badge->delete();
557 }
558
559 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
560 $ilCtrl->redirect($this, "listBadges");
561 }

References $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 417 of file class.ilBadgeManagementGUI.php.

418 {
419 global $ilCtrl, $tpl, $lng;
420
421 $badge_id = $_REQUEST["bid"];
422 if(!$badge_id ||
423 !$this->hasWrite())
424 {
425 $ilCtrl->redirect($this, "listBadges");
426 }
427
428 $ilCtrl->setParameter($this, "bid", $badge_id);
429
430 include_once "./Services/Badge/classes/class.ilBadge.php";
431 $badge = new ilBadge($badge_id);
432
433 $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
434 if($static_cnt)
435 {
436 ilUtil::sendInfo(sprintf($lng->txt("badge_edit_with_published"), $static_cnt));
437 }
438
439 if(!$a_form)
440 {
441 $type = $badge->getTypeInstance();
442 $a_form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
443 $this->setBadgeFormValues($a_form, $badge, $type);
444 }
445
446 $tpl->setContent($a_form->getHTML());
447 }
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $ilCtrl, $lng, $tpl, 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 50 of file class.ilBadgeManagementGUI.php.

51 {
52 global $ilCtrl, $ilTabs, $lng;
53
54 $next_class = $ilCtrl->getNextClass($this);
55 $cmd = $ilCtrl->getCmd("listBadges");
56
57 switch($next_class)
58 {
59 case "ilpropertyformgui":
60 // ajax - update
61 if((int)$_REQUEST["bid"])
62 {
63 include_once "./Services/Badge/classes/class.ilBadge.php";
64 $badge = new ilBadge((int)$_REQUEST["bid"]);
65 $type = $badge->getTypeInstance();
66 $form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
67 }
68 // ajax- create
69 else
70 {
71 $type_id = $_REQUEST["type"];
72 $ilCtrl->setParameter($this, "type", $type_id);
73 $handler = ilBadgeHandler::getInstance();
74 $type = $handler->getTypeInstanceByUniqueId($type_id);
75 $form = $this->initBadgeForm("create", $type, $type_id);
76 }
77 $ilCtrl->forwardCommand($form);
78 break;
79
80 /*
81 case "illplistofsettingsgui":
82 $id = $_GET["lpid"];
83 if($id)
84 {
85 $ilCtrl->saveParameter($this, "bid");
86 $ilCtrl->saveParameter($this, "lpid");
87
88 $ilTabs->clearTargets();
89 $ilTabs->setBackTarget(
90 $lng->txt("back"),
91 $ilCtrl->getLinkTarget($this, "editBadge")
92 );
93 include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
94 include_once "Services/Tracking/classes/repository_statistics/class.ilLPListOfSettingsGUI.php";
95 $lpgui = new ilLPListOfSettingsGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $id);
96 $ilCtrl->forwardCommand($lpgui);
97 break;
98 }
99 */
100
101 default:
102 $this->$cmd();
103 break;
104 }
105
106 return true;
107 }
$cmd
Definition: sahs_server.php:35

References $cmd, $ilCtrl, $lng, ilBadgeHandler\getInstance(), and initBadgeForm().

+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected

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

569 {
570 global $ilCtrl;
571
572 $badge_ids = $_REQUEST["id"];
573 if(!$badge_ids ||
574 !$this->hasWrite())
575 {
576 $ilCtrl->redirect($this, "listBadges");
577 }
578
579 return $badge_ids;
580 }

References $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 603 of file class.ilBadgeManagementGUI.php.

604 {
605 $res = array();
606
607 $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
608
609 include_once "Services/Badge/classes/class.ilBadge.php";
610 foreach($_SESSION[self::CLIPBOARD_ID] as $badge_id)
611 {
612 $badge = new ilBadge($badge_id);
613 if(in_array($badge->getTypeId(), $valid_types))
614 {
615 $res[] = $badge;
616 }
617 }
618
619 return $res;
620 }

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

125 {
126 global $ilAccess;
127 return $ilAccess->checkAccess("write", "", $this->parent_ref_id);
128 }

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

255 {
256 global $lng, $ilCtrl;
257
258 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
259 $form = new ilPropertyFormGUI();
260 $form->setFormAction($ilCtrl->getFormAction($this, "saveBadge"));
261 $form->setTitle($lng->txt("badge_badge").' "'.$a_type->getCaption().'"');
262
263 $active = new ilCheckboxInputGUI($lng->txt("active"), "act");
264 $form->addItem($active);
265
266 $title = new ilTextInputGUI($lng->txt("title"), "title");
267 $title->setRequired(true);
268 $form->addItem($title);
269
270 $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
271 $desc->setRequired(true);
272 $form->addItem($desc);
273
274 $crit = new ilTextAreaInputGUI($lng->txt("badge_criteria"), "crit");
275 $crit->setRequired(true);
276 $form->addItem($crit);
277
278 if($a_mode == "create")
279 {
280 // upload
281
282 $img_mode = new ilRadioGroupInputGUI($lng->txt("image"), "img_mode");
283 $img_mode->setRequired(true);
284 $form->addItem($img_mode);
285
286 $img_mode_tmpl = new ilRadioOption($lng->txt("badge_image_from_template"), "tmpl");
287 $img_mode->addOption($img_mode_tmpl);
288
289 $img_mode_up = new ilRadioOption($lng->txt("badge_image_from_upload"), "up");
290 $img_mode->addOption($img_mode_up);
291
292 $img_upload = new ilImageFileInputGUI($lng->txt("file"), "img");
293 $img_upload->setRequired(true);
294 $img_upload->setSuffixes(array("png", "svg"));
295 $img_mode_up->addSubItem($img_upload);
296
297 // templates
298
299 include_once "Services/Badge/classes/class.ilBadgeImageTemplate.php";
300 $valid_templates = ilBadgeImageTemplate::getInstancesByType($a_type_unique_id);
301 if(sizeof($valid_templates))
302 {
303 $options = array();
304 $options[""] = $lng->txt("please_select");
305 foreach($valid_templates as $tmpl)
306 {
307 $options[$tmpl->getId()] = $tmpl->getTitle();
308 }
309
310 $tmpl = new ilSelectInputGUI($lng->txt("badge_image_template_form"), "tmpl");
311 $tmpl->setRequired(true);
312 $tmpl->setOptions($options);
313 $img_mode_tmpl->addSubItem($tmpl);
314 }
315 else
316 {
317 // no templates, activate upload
318 $img_mode_tmpl->setDisabled(true);
319 $img_mode->setValue("up");
320 }
321 }
322 else
323 {
324 $img_upload = new ilImageFileInputGUI($lng->txt("image"), "img");
325 $img_upload->setSuffixes(array("png", "svg"));
326 $img_upload->setALlowDeletion(false);
327 $form->addItem($img_upload);
328 }
329
330 $valid = new ilTextInputGUI($lng->txt("badge_valid"), "valid");
331 $form->addItem($valid);
332
333 $custom = $a_type->getConfigGUIInstance();
334 if($custom &&
335 $custom instanceof ilBadgeTypeGUI)
336 {
337 $custom->initConfigForm($form, $this->parent_ref_id);
338 }
339
340 // :TODO: valid date/period
341
342 if($a_mode == "create")
343 {
344 $form->addCommandButton("saveBadge", $lng->txt("save"));
345 }
346 else
347 {
348 $form->addCommandButton("updateBadge", $lng->txt("save"));
349 }
350 $form->addCommandButton("listBadges", $lng->txt("cancel"));
351
352 return $form;
353 }
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.
if(!is_array($argv)) $options
$a_type
Definition: workflow.php:93

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

131 {
132 global $ilToolbar, $lng, $ilCtrl, $tpl;
133
134 $this->setTabs("badges");
135
136 if($this->hasWrite())
137 {
138 $handler = ilBadgeHandler::getInstance();
139 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
140 if($valid_types)
141 {
142 include_once "Services/Badge/classes/class.ilBadge.php";
143 $options = array();
144 foreach($valid_types as $id => $type)
145 {
146 $options[$id] = ($this->parent_obj_type != "bdga")
148 : $type->getCaption();
149 }
150 asort($options);
151
152 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
153 $drop = new ilSelectInputGUI($lng->txt("type"), "type");
154 $drop->setOptions($options);
155 $ilToolbar->addInputItem($drop, true);
156
157 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addBadge"));
158 $ilToolbar->addFormButton($lng->txt("create"), "addBadge");
159 }
160 else
161 {
162 ilUtil::sendInfo($lng->txt("badge_no_valid_types_for_obj"));
163 }
164
165 if(is_array($_SESSION[self::CLIPBOARD_ID]))
166 {
167 if($valid_types)
168 {
169 $ilToolbar->addSeparator();
170 }
171
172 $tt = array();
173 foreach($this->getValidBadgesFromClipboard() as $badge)
174 {
175 $tt[] = $badge->getTitle();
176 }
177 $ttid = "bdgpst";
178 include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
180 $ttid,
181 implode("<br />", $tt),
182 "",
183 "bottom center",
184 "top center",
185 false
186 );
187
188 $lng->loadLanguageModule("content");
189 $ilToolbar->addButton($lng->txt("cont_paste_from_clipboard").
190 " (".sizeof($tt).")",
191 $ilCtrl->getLinkTarget($this, "pasteBadges"),
192 "", "", "", $ttid);
193 $ilToolbar->addButton($lng->txt("clear_clipboard"),
194 $ilCtrl->getLinkTarget($this, "clearClipboard"));
195 }
196 }
197
198 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
199 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
200 $tpl->setContent($tbl->getHTML());
201 }
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, $ilCtrl, $lng, $options, $tbl, $tpl, 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 673 of file class.ilBadgeManagementGUI.php.

674 {
675 global $lng, $ilCtrl, $ilToolbar, $tpl;
676
677 $this->setTabs("users");
678
679 if($this->hasWrite())
680 {
681 $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type);
682 if(sizeof($manual))
683 {
684 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
685 $drop = new ilSelectInputGUI($lng->txt("badge_badge"), "bid");
686 $drop->setOptions($manual);
687 $ilToolbar->addInputItem($drop, true);
688
689 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "awardBadgeUserSelection"));
690 $ilToolbar->addFormButton($lng->txt("badge_award_badge"), "awardBadgeUserSelection");
691 }
692 }
693
694 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
695 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
696 $tpl->setContent($tbl->getHTML());
697 }

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

623 {
624 global $ilCtrl;
625
626 if(!$this->hasWrite() ||
627 !is_array($_SESSION[self::CLIPBOARD_ID]))
628 {
629 $ilCtrl->redirect($this, "listBadges");
630 }
631
632 foreach($this->getValidBadgesFromClipboard() as $badge)
633 {
634 $badge->copy($this->parent_obj_id);
635 }
636
637 $ilCtrl->redirect($this, "listBadges");
638 }

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

+ Here is the call graph for this function:

◆ resetAwardBadgeUserSelection()

ilBadgeManagementGUI::resetAwardBadgeUserSelection ( )
protected

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

765 {
766 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
767 $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
768 $tbl->resetOffset();
769 $tbl->resetFilter();
771 }

References $tbl, and awardBadgeUserSelection().

+ Here is the call graph for this function:

◆ resetBadgeFilter()

ilBadgeManagementGUI::resetBadgeFilter ( )
protected

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

213 {
214 include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
215 $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
216 $tbl->resetOffset();
217 $tbl->resetFilter();
218 $this->listBadges();
219 }

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

+ Here is the call graph for this function:

◆ resetListUsers()

ilBadgeManagementGUI::resetListUsers ( )
protected

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

709 {
710 include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
711 $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
712 $tbl->resetOffset();
713 $tbl->resetFilter();
714 $this->listUsers();
715 }

References $tbl, and listUsers().

+ Here is the call graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected

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

356 {
357 global $ilCtrl, $lng;
358
359 $type_id = $_REQUEST["type"];
360 if(!$type_id ||
361 !$this->hasWrite())
362 {
363 $ilCtrl->redirect($this, "listBadges");
364 }
365
366 $ilCtrl->setParameter($this, "type", $type_id);
367
368 $handler = ilBadgeHandler::getInstance();
369 $type = $handler->getTypeInstanceByUniqueId($type_id);
370 if(!$type)
371 {
372 $ilCtrl->redirect($this, "listBadges");
373 }
374
375 $form = $this->initBadgeForm("create", $type, $type_id);
376 $custom = $type->getConfigGUIInstance();
377
378 if($form->checkInput() &&
379 (!$custom || $custom->validateForm($form)))
380 {
381 include_once "Services/Badge/classes/class.ilBadge.php";
382 $badge = new ilBadge();
383 $badge->setParentId($this->parent_obj_id); // :TODO: ref_id?
384 $badge->setTypeId($type_id);
385 $badge->setActive($form->getInput("act"));
386 $badge->setTitle($form->getInput("title"));
387 $badge->setDescription($form->getInput("desc"));
388 $badge->setCriteria($form->getInput("crit"));
389 $badge->setValid($form->getInput("valid"));
390
391 if($custom &&
392 $custom instanceof ilBadgeTypeGUI)
393 {
394 $badge->setConfiguration($custom->getConfigFromForm($form));
395 }
396
397 $badge->create();
398
399 if($form->getInput("img_mode") == "up")
400 {
401 $badge->uploadImage($_FILES["img"]);
402 }
403 else
404 {
405 $tmpl = new ilBadgeImageTemplate($form->getInput("tmpl"));
406 $badge->importImage($tmpl->getImage(), $tmpl->getImagePath());
407 }
408
409 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
410 $ilCtrl->redirect($this, "listBadges");
411 }
412
413 $form->setValuesByPost();
414 $this->addBadge($form);
415 }
addBadge(ilPropertyFormGUI $a_form=null)

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

450 {
451 $a_form->getItemByPostVar("act")->setChecked($a_badge->isActive());
452 $a_form->getItemByPostVar("title")->setValue($a_badge->getTitle());
453 $a_form->getItemByPostVar("desc")->setValue($a_badge->getDescription());
454 $a_form->getItemByPostVar("crit")->setValue($a_badge->getCriteria());
455 $a_form->getItemByPostVar("img")->setValue($a_badge->getImage());
456 $a_form->getItemByPostVar("img")->setImage($a_badge->getImagePath());
457 $a_form->getItemByPostVar("valid")->setValue($a_badge->getValid());
458
459 $custom = $a_type->getConfigGUIInstance();
460 if($custom &&
461 $custom instanceof ilBadgeTypeGUI)
462 {
463 $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
464 }
465 }
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 109 of file class.ilBadgeManagementGUI.php.

110 {
111 global $ilTabs, $lng, $ilCtrl;
112
113 $ilTabs->addSubTab("badges",
114 $lng->txt("obj_bdga"),
115 $ilCtrl->getLinkTarget($this, "listBadges"));
116
117 $ilTabs->addSubTab("users",
118 $lng->txt("users"),
119 $ilCtrl->getLinkTarget($this, "listUsers"));
120
121 $ilTabs->activateSubTab($a_active);
122 }

References $ilCtrl, and $lng.

Referenced by listBadges(), and listUsers().

+ Here is the caller graph for this function:

◆ toggleBadges()

ilBadgeManagementGUI::toggleBadges (   $a_status)
protected

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

641 {
642 global $ilCtrl, $lng;
643
644 $badge_ids = $this->getBadgesFromMultiAction();
645
646 include_once "Services/Badge/classes/class.ilBadge.php";
647 foreach($badge_ids as $badge_id)
648 {
649 $badge = new ilBadge($badge_id);
650 $badge->setActive($a_status);
651 $badge->update();
652 }
653
654 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
655 $ilCtrl->redirect($this, "listBadges");
656 }

References $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 467 of file class.ilBadgeManagementGUI.php.

468 {
469 global $ilCtrl, $lng;
470
471 $badge_id = $_REQUEST["bid"];
472 if(!$badge_id ||
473 !$this->hasWrite())
474 {
475 $ilCtrl->redirect($this, "listBadges");
476 }
477
478 $ilCtrl->setParameter($this, "bid", $badge_id);
479
480 include_once "./Services/Badge/classes/class.ilBadge.php";
481 $badge = new ilBadge($badge_id);
482 $type = $badge->getTypeInstance();
483 $custom = $type->getConfigGUIInstance();
484 if($custom &&
485 !($custom instanceof ilBadgeTypeGUI))
486 {
487 $custom = null;
488 }
489 $form = $this->initBadgeForm("update", $type, $badge->getTypeId());
490 if($form->checkInput() &&
491 (!$custom || $custom->validateForm($form)))
492 {
493 $badge->setActive($form->getInput("act"));
494 $badge->setTitle($form->getInput("title"));
495 $badge->setDescription($form->getInput("desc"));
496 $badge->setCriteria($form->getInput("crit"));
497 $badge->setValid($form->getInput("valid"));
498
499 if($custom)
500 {
501 $badge->setConfiguration($custom->getConfigFromForm($form));
502 }
503
504 $badge->update();
505
506 $badge->uploadImage($_FILES["img"]);
507
508 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
509 $ilCtrl->redirect($this, "listBadges");
510 }
511
512 ilUtil::sendFailure($lng->txt("form_input_not_valid"));
513 $form->setValuesByPost();
514 $this->editBadge($form);
515 }
editBadge(ilPropertyFormGUI $a_form=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

Field Documentation

◆ $parent_obj_id

ilBadgeManagementGUI::$parent_obj_id
protected

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

◆ $parent_obj_type

ilBadgeManagementGUI::$parent_obj_type
protected

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

◆ $parent_ref_id

ilBadgeManagementGUI::$parent_ref_id
protected

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

◆ CLIPBOARD_ID

const ilBadgeManagementGUI::CLIPBOARD_ID = "bdgclpbrd"

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

Referenced by copyBadges().


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