ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

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  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance()
Constructor.
+ Here is the call graph for this function:

Member Function Documentation

◆ activateBadges()

ilBadgeManagementGUI::activateBadges ( )
protected

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

References toggleBadges().

686  {
687  $this->toggleBadges(true);
688  }
+ Here is the call graph for this function:

◆ addBadge()

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

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

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

Referenced by saveBadge().

278  {
280  $tpl = $this->tpl;
281 
282  $type_id = $_REQUEST["type"];
283  if (!$type_id ||
284  !$this->hasWrite()) {
285  $ilCtrl->redirect($this, "listBadges");
286  }
287 
288  $ilCtrl->setParameter($this, "type", $type_id);
289 
291  $type = $handler->getTypeInstanceByUniqueId($type_id);
292  if (!$type) {
293  $ilCtrl->redirect($this, "listBadges");
294  }
295 
296  if (!$a_form) {
297  $a_form = $this->initBadgeForm("create", $type, $type_id);
298  }
299 
300  $tpl->setContent($a_form->getHTML());
301  }
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
$type
global $ilCtrl
Definition: ilias.php:18
$handler
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyAwardBadgeUserSelection()

ilBadgeManagementGUI::applyAwardBadgeUserSelection ( )
protected

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

References $tbl, and awardBadgeUserSelection().

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

◆ applyBadgeFilter()

ilBadgeManagementGUI::applyBadgeFilter ( )
protected

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

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

255  {
256  include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
257  $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
258  $tbl->resetOffset();
259  $tbl->writeFilterToSession();
260  $this->listBadges();
261  }
$tbl
Definition: example_048.php:81
TableGUI class for badge listing.
+ Here is the call graph for this function:

◆ applyListUsers()

ilBadgeManagementGUI::applyListUsers ( )
protected

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

References $tbl, and listUsers().

728  {
729  include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
730  $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
731  $tbl->resetOffset();
732  $tbl->writeFilterToSession();
733  $this->listUsers();
734  }
$tbl
Definition: example_048.php:81
TableGUI class for badge user listing.
+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

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

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

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

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

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

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

Referenced by applyAwardBadgeUserSelection(), and resetAwardBadgeUserSelection().

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

◆ clearClipboard()

ilBadgeManagementGUI::clearClipboard ( )
protected

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

References $_SESSION, $ctrl, and $ilCtrl.

627  {
629 
630  unset($_SESSION[self::CLIPBOARD_ID]);
631  $ilCtrl->redirect($this, "listBadges");
632  }
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

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

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

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

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

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

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

546  {
548  $lng = $this->lng;
549  $tpl = $this->tpl;
550  $ilTabs = $this->tabs;
551 
552  $badge_ids = $this->getBadgesFromMultiAction();
553 
554  $ilTabs->clearTargets();
555  $ilTabs->setBackTarget(
556  $lng->txt("back"),
557  $ilCtrl->getLinkTarget($this, "listBadges")
558  );
559 
560  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
561  $confirmation_gui = new ilConfirmationGUI();
562  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
563  $confirmation_gui->setHeaderText($lng->txt("badge_deletion_confirmation"));
564  $confirmation_gui->setCancel($lng->txt("cancel"), "listBadges");
565  $confirmation_gui->setConfirm($lng->txt("delete"), "deleteBadges");
566 
567  include_once "Services/Badge/classes/class.ilBadge.php";
568  include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
569  foreach ($badge_ids as $badge_id) {
570  $badge = new ilBadge($badge_id);
571  $confirmation_gui->addItem("id[]", $badge_id, $badge->getTitle() .
572  " (" . sizeof(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ")");
573  }
574 
575  $tpl->setContent($confirmation_gui->getHTML());
576  }
global $ilCtrl
Definition: ilias.php:18
static getInstancesByBadgeId($a_badge_id)
Confirmation screen class.
+ Here is the call graph for this function:

◆ copyBadges()

ilBadgeManagementGUI::copyBadges ( )
protected

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

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

614  {
616 
617  $badge_ids = $this->getBadgesFromMultiAction();
618 
619  $_SESSION[self::CLIPBOARD_ID] = array_unique(
620  array_merge((array) $_SESSION[self::CLIPBOARD_ID], $badge_ids)
621  );
622 
623  $ilCtrl->redirect($this, "listBadges");
624  }
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

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

References toggleBadges().

691  {
692  $this->toggleBadges(false);
693  }
+ Here is the call graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

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

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

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

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

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

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

579  {
581  $lng = $this->lng;
582 
583  $badge_ids = $this->getBadgesFromMultiAction();
584 
585  include_once "Services/Badge/classes/class.ilBadge.php";
586  foreach ($badge_ids as $badge_id) {
587  $badge = new ilBadge($badge_id);
588  $badge->delete();
589  }
590 
591  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
592  $ilCtrl->redirect($this, "listBadges");
593  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ editBadge()

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

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

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

Referenced by updateBadge().

451  {
453  $tpl = $this->tpl;
454  $lng = $this->lng;
455 
456  $badge_id = $_REQUEST["bid"];
457  if (!$badge_id ||
458  !$this->hasWrite()) {
459  $ilCtrl->redirect($this, "listBadges");
460  }
461 
462  $ilCtrl->setParameter($this, "bid", $badge_id);
463 
464  include_once "./Services/Badge/classes/class.ilBadge.php";
465  $badge = new ilBadge($badge_id);
466 
467  $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
468  if ($static_cnt) {
469  ilUtil::sendInfo(sprintf($lng->txt("badge_edit_with_published"), $static_cnt));
470  }
471 
472  if (!$a_form) {
473  $type = $badge->getTypeInstance();
474  $a_form = $this->initBadgeForm("edit", $type, $badge->getTypeId());
475  $this->setBadgeFormValues($a_form, $badge, $type);
476  }
477 
478  $tpl->setContent($a_form->getHTML());
479  }
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
$type
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstance()
Constructor.
+ 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.

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

94  {
96  $ilTabs = $this->tabs;
97  $lng = $this->lng;
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  $this->setBadgeFormValues($form, $badge, $type);
111  }
112  // ajax- create
113  else {
114  $type_id = $_REQUEST["type"];
115  $ilCtrl->setParameter($this, "type", $type_id);
117  $type = $handler->getTypeInstanceByUniqueId($type_id);
118  $form = $this->initBadgeForm("create", $type, $type_id);
119  }
120  $ilCtrl->forwardCommand($form);
121  break;
122 
123  /*
124  case "illplistofsettingsgui":
125  $id = $_GET["lpid"];
126  if($id)
127  {
128  $ilCtrl->saveParameter($this, "bid");
129  $ilCtrl->saveParameter($this, "lpid");
130 
131  $ilTabs->clearTargets();
132  $ilTabs->setBackTarget(
133  $lng->txt("back"),
134  $ilCtrl->getLinkTarget($this, "editBadge")
135  );
136  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
137  include_once "Services/Tracking/classes/repository_statistics/class.ilLPListOfSettingsGUI.php";
138  $lpgui = new ilLPListOfSettingsGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $id);
139  $ilCtrl->forwardCommand($lpgui);
140  break;
141  }
142  */
143 
144  default:
145  $this->$cmd();
146  break;
147  }
148 
149  return true;
150  }
initBadgeForm($a_mode, ilBadgeType $a_type, $a_type_unique_id)
$type
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
$handler
static getInstance()
Constructor.
+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected

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

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

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

601  {
603 
604  $badge_ids = $_REQUEST["id"];
605  if (!$badge_ids ||
606  !$this->hasWrite()) {
607  $ilCtrl->redirect($this, "listBadges");
608  }
609 
610  return $badge_ids;
611  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidBadgesFromClipboard()

ilBadgeManagementGUI::getValidBadgesFromClipboard ( )
protected

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

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

Referenced by listBadges(), and pasteBadges().

635  {
636  $res = array();
637 
638  $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
639 
640  include_once "Services/Badge/classes/class.ilBadge.php";
641  foreach ($_SESSION[self::CLIPBOARD_ID] as $badge_id) {
642  $badge = new ilBadge($badge_id);
643  if (in_array($badge->getTypeId(), $valid_types)) {
644  $res[] = $badge;
645  }
646  }
647 
648  return $res;
649  }
$_SESSION["AccountId"]
foreach($_POST as $key=> $value) $res
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasWrite()

ilBadgeManagementGUI::hasWrite ( )
protected

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

References $access.

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

174  {
175  $ilAccess = $this->access;
176  return $ilAccess->checkAccess("write", "", $this->parent_ref_id);
177  }
+ Here is the caller graph for this function:

◆ initBadgeForm()

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

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

References $ctrl, $form, $ilCtrl, $lng, PHPMailer\PHPMailer\$options, $title, $valid, ilBadgeType\getCaption(), ilBadgeType\getConfigGUIInstance(), ilBadgeImageTemplate\getInstancesByType(), ilFormPropertyGUI\setRequired(), and ilFileInputGUI\setSuffixes().

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

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

◆ listBadges()

ilBadgeManagementGUI::listBadges ( )
protected

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

References $_SESSION, $ctrl, $handler, $id, $ilCtrl, $lng, PHPMailer\PHPMailer\$options, $tbl, $toolbar, $tpl, $type, ilTooltipGUI\addTooltip(), ilBadge\getExtendedTypeCaption(), ilBadgeHandler\getInstance(), getValidBadgesFromClipboard(), hasWrite(), ilUtil\sendInfo(), ilSelectInputGUI\setOptions(), and setTabs().

Referenced by applyBadgeFilter(), and resetBadgeFilter().

180  {
181  $ilToolbar = $this->toolbar;
182  $lng = $this->lng;
184  $tpl = $this->tpl;
185 
186  $this->setTabs("badges");
187 
188  if ($this->hasWrite()) {
190  $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
191  if ($valid_types) {
192  include_once "Services/Badge/classes/class.ilBadge.php";
193  $options = array();
194  foreach ($valid_types as $id => $type) {
195  $options[$id] = ($this->parent_obj_type != "bdga")
197  : $type->getCaption();
198  }
199  asort($options);
200 
201  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
202  $drop = new ilSelectInputGUI($lng->txt("type"), "type");
203  $drop->setOptions($options);
204  $ilToolbar->addInputItem($drop, true);
205 
206  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "addBadge"));
207  $ilToolbar->addFormButton($lng->txt("create"), "addBadge");
208  } else {
209  ilUtil::sendInfo($lng->txt("badge_no_valid_types_for_obj"));
210  }
211 
212  if (is_array($_SESSION[self::CLIPBOARD_ID])) {
213  if ($valid_types) {
214  $ilToolbar->addSeparator();
215  }
216 
217  $tt = array();
218  foreach ($this->getValidBadgesFromClipboard() as $badge) {
219  $tt[] = $badge->getTitle();
220  }
221  $ttid = "bdgpst";
222  include_once "Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
224  $ttid,
225  implode("<br />", $tt),
226  "",
227  "bottom center",
228  "top center",
229  false
230  );
231 
232  $lng->loadLanguageModule("content");
233  $ilToolbar->addButton(
234  $lng->txt("cont_paste_from_clipboard") .
235  " (" . sizeof($tt) . ")",
236  $ilCtrl->getLinkTarget($this, "pasteBadges"),
237  "",
238  "",
239  "",
240  $ttid
241  );
242  $ilToolbar->addButton(
243  $lng->txt("clear_clipboard"),
244  $ilCtrl->getLinkTarget($this, "clearClipboard")
245  );
246  }
247  }
248 
249  include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
250  $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
251  $tpl->setContent($tbl->getHTML());
252  }
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.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
$type
$tbl
Definition: example_048.php:81
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getExtendedTypeCaption(ilBadgeType $a_type)
setOptions($a_options)
Set Options.
TableGUI class for badge listing.
$handler
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listUsers()

ilBadgeManagementGUI::listUsers ( )
protected

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

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

Referenced by applyListUsers(), and resetListUsers().

701  {
702  $lng = $this->lng;
704  $ilToolbar = $this->toolbar;
705  $tpl = $this->tpl;
706 
707  $this->setTabs("users");
708 
709  if ($this->hasWrite()) {
710  $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type);
711  if (sizeof($manual)) {
712  include_once "Services/Form/classes/class.ilSelectInputGUI.php";
713  $drop = new ilSelectInputGUI($lng->txt("badge_badge"), "bid");
714  $drop->setOptions($manual);
715  $ilToolbar->addInputItem($drop, true);
716 
717  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "awardBadgeUserSelection"));
718  $ilToolbar->addFormButton($lng->txt("badge_award_badge"), "awardBadgeUserSelection");
719  }
720  }
721 
722  include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
723  $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
724  $tpl->setContent($tbl->getHTML());
725  }
This class represents a selection list property in a property form.
$tbl
Definition: example_048.php:81
global $ilCtrl
Definition: ilias.php:18
setOptions($a_options)
Set Options.
TableGUI class for badge user listing.
static getInstance()
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pasteBadges()

ilBadgeManagementGUI::pasteBadges ( )
protected

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

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

652  {
654 
655  if (!$this->hasWrite() ||
656  !is_array($_SESSION[self::CLIPBOARD_ID])) {
657  $ilCtrl->redirect($this, "listBadges");
658  }
659 
660  foreach ($this->getValidBadgesFromClipboard() as $badge) {
661  $badge->copy($this->parent_obj_id);
662  }
663 
664  $ilCtrl->redirect($this, "listBadges");
665  }
$_SESSION["AccountId"]
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ resetAwardBadgeUserSelection()

ilBadgeManagementGUI::resetAwardBadgeUserSelection ( )
protected

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

References $tbl, and awardBadgeUserSelection().

795  {
796  include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
797  $tbl = new ilBadgeUserTableGUI($this, "awardBadgeUserSelection", $this->parent_ref_id);
798  $tbl->resetOffset();
799  $tbl->resetFilter();
800  $this->awardBadgeUserSelection();
801  }
$tbl
Definition: example_048.php:81
TableGUI class for badge user listing.
+ Here is the call graph for this function:

◆ resetBadgeFilter()

ilBadgeManagementGUI::resetBadgeFilter ( )
protected

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

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

264  {
265  include_once "Services/Badge/classes/class.ilBadgeTableGUI.php";
266  $tbl = new ilBadgeTableGUI($this, "listBadges", $this->parent_obj_id, $this->hasWrite());
267  $tbl->resetOffset();
268  $tbl->resetFilter();
269  $this->listBadges();
270  }
$tbl
Definition: example_048.php:81
TableGUI class for badge listing.
+ Here is the call graph for this function:

◆ resetListUsers()

ilBadgeManagementGUI::resetListUsers ( )
protected

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

References $tbl, and listUsers().

737  {
738  include_once "Services/Badge/classes/class.ilBadgeUserTableGUI.php";
739  $tbl = new ilBadgeUserTableGUI($this, "listUsers", $this->parent_ref_id);
740  $tbl->resetOffset();
741  $tbl->resetFilter();
742  $this->listUsers();
743  }
$tbl
Definition: example_048.php:81
TableGUI class for badge user listing.
+ Here is the call graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected

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

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

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

◆ setBadgeFormValues()

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

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

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

Referenced by editBadge(), and executeCommand().

482  {
483  $a_form->getItemByPostVar("act")->setChecked($a_badge->isActive());
484  $a_form->getItemByPostVar("title")->setValue($a_badge->getTitle());
485  $a_form->getItemByPostVar("desc")->setValue($a_badge->getDescription());
486  $a_form->getItemByPostVar("crit")->setValue($a_badge->getCriteria());
487  $a_form->getItemByPostVar("img")->setValue($a_badge->getImage());
488  $a_form->getItemByPostVar("img")->setImage($a_badge->getImagePath());
489  $a_form->getItemByPostVar("valid")->setValue($a_badge->getValid());
490 
491  $custom = $a_type->getConfigGUIInstance();
492  if ($custom &&
493  $custom instanceof ilBadgeTypeGUI) {
494  $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
495  }
496  }
getImagePath($a_full_path=true)
getItemByPostVar($a_post_var)
Get Item by POST variable.
getConfiguration()
getConfigGUIInstance()
Get GUI config instance.
Badge type gui interface.
+ 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 152 of file class.ilBadgeManagementGUI.php.

References $ctrl, $ilCtrl, $lng, and $tabs.

Referenced by listBadges(), and listUsers().

153  {
154  $ilTabs = $this->tabs;
155  $lng = $this->lng;
157 
158  $ilTabs->addSubTab(
159  "badges",
160  $lng->txt("obj_bdga"),
161  $ilCtrl->getLinkTarget($this, "listBadges")
162  );
163 
164  $ilTabs->addSubTab(
165  "users",
166  $lng->txt("users"),
167  $ilCtrl->getLinkTarget($this, "listUsers")
168  );
169 
170  $ilTabs->activateSubTab($a_active);
171  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ toggleBadges()

ilBadgeManagementGUI::toggleBadges (   $a_status)
protected

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

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

Referenced by activateBadges(), and deactivateBadges().

668  {
670  $lng = $this->lng;
671 
672  $badge_ids = $this->getBadgesFromMultiAction();
673 
674  include_once "Services/Badge/classes/class.ilBadge.php";
675  foreach ($badge_ids as $badge_id) {
676  $badge = new ilBadge($badge_id);
677  $badge->setActive($a_status);
678  $badge->update();
679  }
680 
681  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
682  $ilCtrl->redirect($this, "listBadges");
683  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateBadge()

ilBadgeManagementGUI::updateBadge ( )
protected

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

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

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


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