ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBadgeManagementGUI Class Reference

ilBadgeManagementGUI: ilPropertyFormGUI More...

+ Collaboration diagram for ilBadgeManagementGUI:

Public Member Functions

 __construct (private readonly int $parent_ref_id, ?int $a_parent_obj_id=null, ?string $a_parent_obj_type=null)
 
 executeCommand ()
 

Data Fields

const TABLE_ALL_OBJECTS_ACTION = 'ALL_OBJECTS'
 

Protected Member Functions

 setTabs (string $a_active)
 
 hasWrite ()
 
 listBadges ()
 
 addBadge (?ilPropertyFormGUI $a_form=null)
 
 initBadgeForm (string $a_mode, ilBadgeType $a_type, string $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 (bool $a_status)
 
 activateBadges ()
 
 deactivateBadges ()
 
 listUsers ()
 
 awardBadgeUserSelection ()
 
 assignBadge ()
 
 confirmDeassignBadge ()
 
 deassignBadge ()
 
 cloneBadgeTemplate (ilBadge $badge, ?ResourceIdentification $rid)
 
 removeResourceStorageImage (ilBadge $badge)
 

Private Member Functions

 splitBadgeAndUserIdsFromString (array $splittable_user_ids)
 
 selectBadgeForAwardingOrRevoking ()
 

Private Attributes

ilBadgeGUIRequest $request
 
ilBadgeManagementSessionRepository $session_repo
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTabsGUI $tabs
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
ilGlobalTemplateInterface $tpl
 
ilObjUser $user
 
ILIAS UI Factory $ui_factory
 
int $parent_obj_id
 
string $parent_obj_type
 
ilBadgeImage $badge_image_service = null
 
Services $resource_storage
 
FileUpload $upload_service
 
ilBadgePictureDefinition $flavour_definition = null
 
ILIAS HTTP Services $http
 
Factory $refinery
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBadgeManagementGUI::__construct ( private readonly int  $parent_ref_id,
?int  $a_parent_obj_id = null,
?string  $a_parent_obj_type = null 
)

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

References $DIC, ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

61  {
62  global $DIC;
63 
64  $this->lng = $DIC->language();
65  $this->ctrl = $DIC->ctrl();
66  $this->tabs = $DIC->tabs();
67  $this->access = $DIC->access();
68  $this->http = $DIC->http();
69  $this->refinery = $DIC->refinery();
70  $this->toolbar = $DIC->toolbar();
71  $this->ui_factory = $DIC->ui()->factory();
72  $this->resource_storage = $DIC->resourceStorage();
73  $this->upload_service = $DIC->upload();
74  $this->tpl = $DIC->ui()->mainTemplate();
75  $this->user = $DIC->user();
76  $lng = $DIC->language();
77  $this->parent_obj_id = $a_parent_obj_id
78  ?: ilObject::_lookupObjId($parent_ref_id);
79  $this->parent_obj_type = $a_parent_obj_type
80  ?: ilObject::_lookupType($this->parent_obj_id);
81 
82  if (!ilBadgeHandler::getInstance()->isObjectActive($this->parent_obj_id)) {
83  throw new ilException('inactive object');
84  }
85 
86  $lng->loadLanguageModule('badge');
87 
88  $this->request = new ilBadgeGUIRequest(
89  $DIC->http(),
90  $DIC->refinery()
91  );
92 
93  $this->session_repo = new ilBadgeManagementSessionRepository();
94  $this->badge_image_service = new ilBadgeImage(
95  $DIC->resourceStorage(),
96  $DIC->upload(),
97  $DIC->ui()->mainTemplate()
98  );
99  $this->flavour_definition = new ilBadgePictureDefinition();
100  }
loadLanguageModule(string $a_module)
Load language module.
static _lookupObjId(int $ref_id)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ activateBadges()

ilBadgeManagementGUI::activateBadges ( )
protected

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

References toggleBadges().

Referenced by executeCommand().

783  : void
784  {
785  $this->toggleBadges(true);
786  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addBadge()

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

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

References $ctrl, $handler, $tpl, ilBadgeHandler\getInstance(), hasWrite(), initBadgeForm(), and ILIAS\UICore\GlobalTemplate\setContent().

Referenced by saveBadge().

320  : void
321  {
322  $ilCtrl = $this->ctrl;
323  $tpl = $this->tpl;
324 
325  $type_id = $this->request->getType();
326  if (!$type_id ||
327  !$this->hasWrite()) {
328  $ilCtrl->redirect($this, 'listBadges');
329  }
330 
331  $ilCtrl->setParameter($this, 'type', $type_id);
332 
334  $type = $handler->getTypeInstanceByUniqueId($type_id);
335  if (!$type) {
336  $ilCtrl->redirect($this, 'listBadges');
337  }
338 
339  if (!$a_form) {
340  $a_form = $this->initBadgeForm('create', $type, $type_id);
341  }
342 
343  $tpl->setContent($a_form->getHTML());
344  }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
$handler
Definition: oai.php:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
protected

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

References $ctrl, $lng, $user, $user_id, ilBadgeAssignment\exists(), ilBadgeHandler\getInstance(), hasWrite(), splitBadgeAndUserIdsFromString(), and ilLanguage\txt().

Referenced by executeCommand().

884  : void
885  {
886  $ilCtrl = $this->ctrl;
887  $ilUser = $this->user;
888  $lng = $this->lng;
889 
890  $splittable_user_ids = $this->request->getBadgeAssignableUsers();
891  [$user_ids, $badge_id] = $this->splitBadgeAndUserIdsFromString($splittable_user_ids);
892 
893  if (!$user_ids ||
894  !$badge_id ||
895  !$this->hasWrite()) {
896  $ilCtrl->redirect($this, 'listUsers');
897  }
898 
899  $new_badges = [];
900  foreach ($user_ids as $user_id) {
901  if (!ilBadgeAssignment::exists($badge_id, $user_id)) {
902  $ass = new ilBadgeAssignment($badge_id, $user_id);
903  $ass->setAwardedBy($ilUser->getId());
904  $ass->store();
905 
906  $new_badges[$user_id][] = $badge_id;
907  }
908  }
909 
910  ilBadgeHandler::getInstance()->sendNotification($new_badges, $this->parent_ref_id);
911 
912  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
913  $ilCtrl->redirect($this, 'listUsers');
914  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
splitBadgeAndUserIdsFromString(array $splittable_user_ids)
static exists(int $a_badge_id, int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ awardBadgeUserSelection()

ilBadgeManagementGUI::awardBadgeUserSelection ( )
protected

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

References ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), hasWrite(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), null, ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

Referenced by executeCommand().

836  : void
837  {
838  $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
839  $bid = null;
840 
841  if ($badge_ids === []) {
842  if ($this->http->wrapper()->post()->has('bid')) {
843  $bid = $this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int());
844  } elseif ($this->http->wrapper()->query()->has('bid')) {
845  $bid = $this->http->wrapper()->query()->retrieve('bid', $this->refinery->kindlyTo()->int());
846  }
847  } elseif (count($badge_ids) === 1) {
848  $bid = (int) $badge_ids[0];
849  }
850 
851  if (!$bid ||
852  !$this->hasWrite()) {
853  $this->ctrl->redirect($this, 'listUsers');
854  }
855 
856  $manual = array_keys(
857  ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type)
858  );
859 
860  if (!in_array($bid, $manual, true)) {
861  $this->ctrl->redirect($this, 'listUsers');
862  }
863 
864  $back_target = 'listUsers';
865  if ($this->request->getTgt() === 'bdgl') {
866  $this->ctrl->saveParameter($this, 'tgt');
867  $back_target = 'listBadges';
868  }
869 
870  $this->tabs->clearTargets();
871  $this->tabs->setBackTarget(
872  $this->lng->txt('back'),
873  $this->ctrl->getLinkTarget($this, $back_target)
874  );
875 
876  $this->ctrl->setParameter($this, 'bid', $bid);
877 
878  $badge = new ilBadge($bid);
879 
880  $tbl = new ilBadgeUserTableGUI($this->parent_ref_id, $badge);
881  $tbl->renderTable();
882  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearClipboard()

ilBadgeManagementGUI::clearClipboard ( )
protected

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

References $ctrl, and ilCtrl\redirect().

711  : void
712  {
713  $ilCtrl = $this->ctrl;
714 
715  $this->session_repo->clear();
716  $ilCtrl->redirect($this, 'listBadges');
717  }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
+ Here is the call graph for this function:

◆ cloneBadgeTemplate()

ilBadgeManagementGUI::cloneBadgeTemplate ( ilBadge  $badge,
?ResourceIdentification  $rid 
)
protected
Exceptions
Exception

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

References null, ilBadge\setImageRid(), and ilBadge\update().

Referenced by saveBadge(), and updateBadge().

996  : void
997  {
998  if ($rid !== null) {
999  $new_rid = $this->badge_image_service->cloneBadgeImageByRid($rid);
1000  $badge->setImageRid($new_rid);
1001  $badge->update();
1002  }
1003  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setImageRid(?string $image_rid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
protected

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

References $ctrl, $lng, $tabs, $tpl, $user_id, ilBadgeAssignment\getAssignedUsers(), ilUserUtil\getNamePresentation(), hasWrite(), ILIAS\UICore\GlobalTemplate\setContent(), splitBadgeAndUserIdsFromString(), and ilLanguage\txt().

Referenced by executeCommand().

916  : void
917  {
918  $ilCtrl = $this->ctrl;
919  $lng = $this->lng;
920  $tpl = $this->tpl;
921  $ilTabs = $this->tabs;
922 
923  $splittable_user_ids = $this->request->getMultiActionBadgeIdsFromUrl();
924  [$user_ids, $badge_id] = $this->splitBadgeAndUserIdsFromString($splittable_user_ids);
925 
926  if (!$user_ids ||
927  !$badge_id ||
928  !$this->hasWrite()) {
929  $ilCtrl->redirect($this, 'listUsers');
930  }
931 
932  $ilTabs->clearTargets();
933  $ilTabs->setBackTarget(
934  $lng->txt('back'),
935  $ilCtrl->getLinkTarget($this, 'listUsers')
936  );
937 
938  $badge = new ilBadge($badge_id);
939 
940  $ilCtrl->setParameter($this, 'bid', $badge->getId());
941 
942  $confirmation_gui = new ilConfirmationGUI();
943  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
944  $confirmation_gui->setHeaderText(
945  sprintf($lng->txt('badge_assignment_deletion_confirmation'), $badge->getTitle())
946  );
947  $confirmation_gui->setCancel($lng->txt('cancel'), 'listUsers');
948  $confirmation_gui->setConfirm($lng->txt('badge_remove_badge'), 'deassignBadge');
949 
950  $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
951 
952  foreach ($user_ids as $user_id) {
953  if (in_array($user_id, $assigned_users, true)) {
954  $confirmation_gui->addItem(
955  "id[$user_id]",
956  (string) $badge_id,
957  ilUserUtil::getNamePresentation($user_id, false, false, '', true)
958  );
959  }
960  }
961 
962  $tpl->setContent($confirmation_gui->getHTML());
963  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setContent(string $a_html)
Sets content for standard template.
static getAssignedUsers(int $a_badge_id)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path='ilpublicuserprofilegui')
Default behaviour is:
ilGlobalTemplateInterface $tpl
splitBadgeAndUserIdsFromString(array $splittable_user_ids)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
protected

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

References $ctrl, $lng, $tabs, $tpl, ilTabsGUI\clearTargets(), ilBadgeAssignment\getInstancesByBadgeId(), ilBadge\getInstancesByParentId(), ILIAS\UICore\GlobalTemplate\setContent(), and ilLanguage\txt().

Referenced by executeCommand().

615  : void
616  {
617  $ilCtrl = $this->ctrl;
618  $lng = $this->lng;
619  $tpl = $this->tpl;
620  $ilTabs = $this->tabs;
621 
622  $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
623  if ($badge_ids === ['ALL_OBJECTS']) {
624  $badge_ids = [];
625  foreach (ilBadge::getInstancesByParentId($this->parent_obj_id) as $badge) {
626  $badge_ids[] = $badge->getId();
627  }
628  }
629 
630  $ilTabs->clearTargets();
631  $ilTabs->setBackTarget(
632  $lng->txt('back'),
633  $ilCtrl->getLinkTarget($this, 'listBadges')
634  );
635 
636  $confirmation_gui = new ilConfirmationGUI();
637  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
638  $confirmation_gui->setHeaderText($lng->txt('badge_deletion_confirmation'));
639  $confirmation_gui->setCancel($lng->txt('cancel'), 'listBadges');
640  $confirmation_gui->setConfirm($lng->txt('delete'), 'deleteBadges');
641 
642  foreach ($badge_ids as $badge_id) {
643  $badge = new ilBadge((int) $badge_id);
644  $confirmation_gui->addItem(
645  'id[]',
646  (string) $badge_id,
647  $badge->getTitle() .
648  ' (' . count(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ')'
649  );
650  }
651 
652  $tpl->setContent($confirmation_gui->getHTML());
653  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)
setContent(string $a_html)
Sets content for standard template.
static getInstancesByBadgeId(int $a_badge_id)
ilGlobalTemplateInterface $tpl
clearTargets()
clear all targets
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyBadges()

ilBadgeManagementGUI::copyBadges ( )
protected

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

References $ctrl, and getBadgesFromMultiAction().

696  : void
697  {
698  $ilCtrl = $this->ctrl;
699 
700  $badge_ids = $this->getBadgesFromMultiAction();
701 
702  $clip_ids = $this->session_repo->getBadgeIds();
703  $clip_ids = array_unique(
704  array_merge($clip_ids, $badge_ids)
705  );
706  $this->session_repo->setBadgeIds(array_map(intval(...), $clip_ids));
707 
708  $ilCtrl->redirect($this, 'listBadges');
709  }
+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
protected

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

References toggleBadges().

Referenced by executeCommand().

788  : void
789  {
790  $this->toggleBadges(false);
791  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deassignBadge()

ilBadgeManagementGUI::deassignBadge ( )
protected

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

References $ctrl, $lng, $user_id, hasWrite(), null, and ilLanguage\txt().

965  : void
966  {
967  $ilCtrl = $this->ctrl;
968  $lng = $this->lng;
969 
970  $post_values = $this->request->getIds();
971  $user_ids = [];
972  $badge_id = null;
973  foreach ($post_values as $usr_id => $found_badge_id) {
974  $badge_id = $found_badge_id;
975  $user_ids[] = $usr_id;
976  }
977 
978  if (!$user_ids ||
979  !$badge_id ||
980  !$this->hasWrite()) {
981  $ilCtrl->redirect($this, 'listUsers');
982  }
983 
984  foreach ($user_ids as $user_id) {
985  $ass = new ilBadgeAssignment((int) $badge_id, (int) $user_id);
986  $ass->delete();
987  }
988 
989  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
990  $ilCtrl->redirect($this, 'listUsers');
991  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ deleteBadges()

ilBadgeManagementGUI::deleteBadges ( )
protected

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

References $ctrl, $lng, and ilLanguage\txt().

655  : void
656  {
657  $ilCtrl = $this->ctrl;
658  $lng = $this->lng;
659 
660  $badge_ids = $this->request->getIds();
661 
662  if (count($badge_ids) > 0) {
663  foreach ($badge_ids as $badge_id) {
664  $badge = new ilBadge((int) $badge_id);
665  $badge->delete();
666  }
667  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
668  } else {
669  $this->tpl->setOnScreenMessage('failure', $lng->txt('badge_select_one'), true);
670  }
671 
672  $ilCtrl->redirect($this, 'listBadges');
673  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:

◆ editBadge()

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

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

References $ctrl, $lng, $tpl, ilBadgeHandler\getInstance(), hasWrite(), initBadgeForm(), setBadgeFormValues(), ILIAS\UICore\GlobalTemplate\setContent(), and ilLanguage\txt().

Referenced by executeCommand(), and updateBadge().

501  : void
502  {
503  $ilCtrl = $this->ctrl;
504  $tpl = $this->tpl;
505  $lng = $this->lng;
506 
507  $badge_id = $this->request->getBadgeIdFromUrl();
508  if (!$badge_id ||
509  !$this->hasWrite()) {
510  $ilCtrl->redirect($this, 'listBadges');
511  }
512 
513  $ilCtrl->setParameter($this, 'bid', $badge_id);
514 
515  $badge = new ilBadge($badge_id);
516 
517  $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
518  if ($static_cnt) {
519  $this->tpl->setOnScreenMessage('info', sprintf($lng->txt('badge_edit_with_published'), $static_cnt));
520  }
521 
522  if (!$a_form) {
523  $type = $badge->getTypeInstance();
524  $a_form = $this->initBadgeForm('edit', $type, $badge->getTypeId());
525  $this->setBadgeFormValues($a_form, $badge, $type);
526  }
527 
528  $tpl->setContent($a_form->getHTML());
529  }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setContent(string $a_html)
Sets content for standard template.
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeManagementGUI::executeCommand ( )

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

References $ctrl, $DIC, $handler, $id, activateBadges(), assignBadge(), awardBadgeUserSelection(), confirmDeassignBadge(), confirmDeleteBadges(), deactivateBadges(), editBadge(), ilBadgeHandler\getInstance(), ilCtrl\getNextClass(), ilBadge\getTypeId(), initBadgeForm(), and setBadgeFormValues().

146  : void
147  {
148  $ilCtrl = $this->ctrl;
149 
150  $next_class = $ilCtrl->getNextClass($this);
151  $cmd = $ilCtrl->getCmd('listBadges');
152 
153  switch ($next_class) {
154  case 'ilpropertyformgui':
155  // ajax - update
156  if ($this->request->getBadgeId()) {
157  $badge = new ilBadge($this->request->getBadgeId());
158  $type = $badge->getTypeInstance();
159  $form = $this->initBadgeForm('edit', $type, $badge->getTypeId());
160  $this->setBadgeFormValues($form, $badge, $type);
161  } // ajax- create
162  else {
163  $type_id = $this->request->getType();
164  $ilCtrl->setParameter($this, 'type', $type_id);
166  $type = $handler->getTypeInstanceByUniqueId($type_id);
167  $form = $this->initBadgeForm('create', $type, $type_id);
168  }
169  $ilCtrl->forwardCommand($form);
170  break;
171 
172  default:
173  $render_default = true;
174  global $DIC;
175  $action_parameter_token = 'tid_id';
176  $parameter = 'tid_table_action';
177 
178  $query = $DIC->http()->wrapper()->query();
179  if ($query->has($action_parameter_token)) {
180  if ($query->has($action_parameter_token)) {
181  $id = $query->retrieve(
182  $action_parameter_token,
183  $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->string())
184  );
185  if (is_array($id)) {
186  $id = array_pop($id);
187  }
188  $DIC->ctrl()->setParameter($this, "tid", $id);
189  }
190  }
191  $action = '';
192  if ($query->has($parameter)) {
193  $action = $query->retrieve($parameter, $DIC->refinery()->kindlyTo()->string());
194  }
195  if ($action === 'badge_table_activate') {
196  $this->activateBadges();
197  } elseif ($action === 'badge_table_deactivate') {
198  $this->deactivateBadges();
199  } elseif ($action === 'badge_table_edit') {
200  $this->editBadge();
201  $render_default = false;
202  } elseif ($action === 'badge_table_delete') {
203  $this->confirmDeleteBadges();
204  $render_default = false;
205  } elseif ($action === 'award_revoke_badge') {
206  $this->awardBadgeUserSelection();
207  $render_default = false;
208  } elseif ($action === 'revokeBadge') {
209  $this->confirmDeassignBadge();
210  $render_default = false;
211  } elseif ($action === 'assignBadge') {
212  $this->assignBadge();
213  $render_default = false;
214  }
215 
216  if ($render_default) {
217  $this->$cmd();
218  break;
219  }
220  break;
221  }
222  }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
getNextClass($a_gui_class=null)
global $DIC
Definition: shib_login.php:22
editBadge(?ilPropertyFormGUI $a_form=null)
$handler
Definition: oai.php:30
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
protected
Returns
int[]

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

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

Referenced by copyBadges().

683  : array
684  {
685  $ilCtrl = $this->ctrl;
686 
687  $badge_ids = $this->request->getIds();
688  if (!$badge_ids ||
689  !$this->hasWrite()) {
690  $ilCtrl->redirect($this, 'listBadges');
691  }
692 
693  return $badge_ids;
694  }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidBadgesFromClipboard()

ilBadgeManagementGUI::getValidBadgesFromClipboard ( )
protected
Returns
ilBadge[]

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

References $res, and ilBadgeHandler\getInstance().

Referenced by listBadges(), and pasteBadges().

722  : array
723  {
724  $res = [];
725 
726  $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
727 
728  foreach ($this->session_repo->getBadgeIds() as $badge_id) {
729  $badge = new ilBadge($badge_id);
730  if (in_array($badge->getTypeId(), $valid_types, true)) {
731  $res[] = $badge;
732  }
733  }
734 
735  return $res;
736  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasWrite()

ilBadgeManagementGUI::hasWrite ( )
protected

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

References $access, and ilRBACAccessHandler\checkAccess().

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

245  : bool
246  {
247  $ilAccess = $this->access;
248  return $ilAccess->checkAccess('write', '', $this->parent_ref_id);
249  }
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initBadgeForm()

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

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

References $ctrl, $lng, $valid, ilBadgeType\getCaption(), ilBadgeType\getConfigGUIInstance(), ilBadgeImageTemplate\getInstancesByType(), ilTextAreaInputGUI\setMaxNumOfChars(), ilFormPropertyGUI\setRequired(), ilFileInputGUI\setSuffixes(), and ilLanguage\txt().

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

351  $lng = $this->lng;
352  $ilCtrl = $this->ctrl;
353 
354  $form = new ilPropertyFormGUI();
355  $form->setFormAction($ilCtrl->getFormAction($this, 'saveBadge'));
356  $form->setTitle($lng->txt('badge_badge') . ' "' . $a_type->getCaption() . '"');
357 
358  $active = new ilCheckboxInputGUI($lng->txt('active'), 'act');
359  $form->addItem($active);
360 
361  $title = new ilTextInputGUI($lng->txt('title'), 'title');
362  $title->setMaxLength(255);
363  $title->setRequired(true);
364  $form->addItem($title);
365 
366  $desc = new ilTextAreaInputGUI($lng->txt('description'), 'desc');
367  $desc->setMaxNumOfChars(4000);
368  $desc->setRequired(true);
369  $form->addItem($desc);
370 
371  $crit = new ilTextAreaInputGUI($lng->txt('badge_criteria'), 'crit');
372  $crit->setMaxNumOfChars(4000);
373  $crit->setRequired(true);
374  $form->addItem($crit);
375 
376  if ($a_mode === 'create') {
377  // upload
378 
379  $img_mode = new ilRadioGroupInputGUI($lng->txt('image'), 'img_mode');
380  $img_mode->setRequired(true);
381  $img_mode->setValue('tmpl');
382  $form->addItem($img_mode);
383 
384  $img_mode_tmpl = new ilRadioOption($lng->txt('badge_image_from_template'), 'tmpl');
385  $img_mode->addOption($img_mode_tmpl);
386 
387  $img_mode_up = new ilRadioOption($lng->txt('badge_image_from_upload'), 'up');
388  $img_mode->addOption($img_mode_up);
389 
390  $img_upload = new ilImageFileInputGUI($lng->txt('file'), 'img');
391  $img_upload->setRequired(true);
392  $img_upload->setSuffixes(['png', 'svg']);
393  $img_mode_up->addSubItem($img_upload);
394 
395  // templates
396 
397  $valid_templates = ilBadgeImageTemplate::getInstancesByType($a_type_unique_id);
398  if (count($valid_templates)) {
399  $options = [];
400  $options[''] = $lng->txt('please_select');
401  foreach ($valid_templates as $tmpl) {
402  $options[$tmpl->getId()] = $tmpl->getTitle();
403  }
404 
405  $tmpl = new ilSelectInputGUI($lng->txt('badge_image_template_form'), 'tmpl');
406  $tmpl->setRequired(true);
407  $tmpl->setOptions($options);
408  $img_mode_tmpl->addSubItem($tmpl);
409  } else {
410  // no templates, activate upload
411  $img_mode_tmpl->setDisabled(true);
412  $img_mode->setValue('up');
413  }
414  } else {
415  $img_upload = new ilImageFileInputGUI($lng->txt('image'), 'img');
416  $img_upload->setSuffixes(['png', 'svg']);
417  $img_upload->setAllowDeletion(false);
418  $img_upload->setUseCache(false);
419  $form->addItem($img_upload);
420  }
421 
422  $valid = new ilTextInputGUI($lng->txt('badge_valid'), 'valid');
423  $valid->setMaxLength(255);
424  $form->addItem($valid);
425 
426  $custom = $a_type->getConfigGUIInstance();
427  if ($custom instanceof ilBadgeTypeGUI) {
428  $custom->initConfigForm($form, $this->parent_ref_id);
429  }
430 
431  // :TODO: valid date/period
432 
433  if ($a_mode === 'create') {
434  $form->addCommandButton('saveBadge', $lng->txt('save'));
435  } else {
436  $form->addCommandButton('updateBadge', $lng->txt('save'));
437  }
438  $form->addCommandButton('listBadges', $lng->txt('cancel'));
439 
440  return $form;
441  }
This class represents an option in a radio group.
static getInstancesByType(string $a_type_unique_id)
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$valid
getConfigGUIInstance()
Get GUI config instance.
setSuffixes(array $a_suffixes)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRequired(bool $a_required)
This class represents an image file property in a property form.
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listBadges()

ilBadgeManagementGUI::listBadges ( )
protected

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

References $ctrl, $handler, $id, $lng, $toolbar, ilBadge\getExtendedTypeCaption(), ilBadgeHandler\getInstance(), getValidBadgesFromClipboard(), hasWrite(), ilLanguage\loadLanguageModule(), null, setTabs(), and ilLanguage\txt().

251  : void
252  {
253  $ilToolbar = $this->toolbar;
254  $lng = $this->lng;
255  $ilCtrl = $this->ctrl;
256 
257  $this->setTabs('badges');
258 
259  if ($this->hasWrite()) {
261  $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
262  if ($valid_types) {
263  $options = [];
264  foreach ($valid_types as $id => $type) {
265  $ilCtrl->setParameter($this, 'type', $id);
266  $options[$id] = $this->ui_factory->link()->standard(
267  $this->parent_obj_type !== 'bdga' ? ilBadge::getExtendedTypeCaption($type) : $type->getCaption(),
268  $ilCtrl->getLinkTarget($this, 'addBadge')
269  );
270  $ilCtrl->setParameter($this, 'type', null);
271  }
272  asort($options);
273  $options = array_values($options);
274 
275  $ilToolbar->addComponent(
276  $this->ui_factory->dropdown()->standard($options)->withLabel($lng->txt('badge_create'))
277  );
278  } else {
279  $this->tpl->setOnScreenMessage('info', $lng->txt('badge_no_valid_types_for_obj'));
280  }
281 
282  $clip_ids = $this->session_repo->getBadgeIds();
283  if (count($clip_ids) > 0) {
284  if ($valid_types) {
285  $ilToolbar->addSeparator();
286  }
287 
288  $tt = [];
289  foreach ($this->getValidBadgesFromClipboard() as $badge) {
290  $tt[] = $badge->getTitle();
291  }
292  $ttid = 'bdgpst';
293 
294  $lng->loadLanguageModule('content');
295  $ilToolbar->addButton(
296  $lng->txt('cont_paste_from_clipboard') .
297  ' (' . count($tt) . ')',
298  $ilCtrl->getLinkTarget($this, 'pasteBadges'),
299  '',
300  null,
301  '',
302  $ttid
303  );
304  $ilToolbar->addButton(
305  $lng->txt('clear_clipboard'),
306  $ilCtrl->getLinkTarget($this, 'clearClipboard')
307  );
308  }
309  }
310 
311  $table = new ilBadgeTableGUI($this->parent_obj_id, $this->parent_obj_type, $this->hasWrite());
312  $table->renderTable();
313  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
loadLanguageModule(string $a_module)
Load language module.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getExtendedTypeCaption(ilBadgeType $a_type)
$handler
Definition: oai.php:30
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ listUsers()

ilBadgeManagementGUI::listUsers ( )
protected

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

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

798  : void
799  {
800  $lng = $this->lng;
801  $ilCtrl = $this->ctrl;
802  $ilToolbar = $this->toolbar;
803  $tpl = $this->tpl;
804 
805  $this->setTabs('users');
806 
807  if ($this->hasWrite()) {
808  $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges(
809  $this->parent_obj_id,
810  $this->parent_obj_type
811  );
812  if (count($manual)) {
813  $drop = new ilSelectInputGUI($lng->txt('badge_badge'), 'bid');
814  $drop->setOptions($manual);
815  $ilToolbar->addInputItem($drop, true);
816 
817  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, 'selectBadgeForAwardingOrRevoking'));
818  $ilToolbar->addFormButton($lng->txt('badge_award_badge'), 'selectBadgeForAwardingOrRevoking');
819  }
820  }
821 
822  $tbl = new ilBadgeUserTableGUI($this->parent_ref_id);
823  $tbl->renderTable();
824  }
This class represents a selection list property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setOptions(array $a_options)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ pasteBadges()

ilBadgeManagementGUI::pasteBadges ( )
protected

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

References $ctrl, getValidBadgesFromClipboard(), hasWrite(), ILIAS\Repository\lng(), and ilCtrl\redirect().

738  : void
739  {
740  $ilCtrl = $this->ctrl;
741 
742  $clip_ids = $this->session_repo->getBadgeIds();
743  if (!$this->hasWrite() || count($clip_ids) === 0) {
744  $ilCtrl->redirect($this, 'listBadges');
745  }
746 
747  $copy_suffix = $this->lng->txt("copy_of_suffix");
748  foreach ($this->getValidBadgesFromClipboard() as $badge) {
749  $badge->copy($this->parent_obj_id, $copy_suffix);
750  }
751 
752  $ilCtrl->redirect($this, 'listBadges');
753  }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
+ Here is the call graph for this function:

◆ removeResourceStorageImage()

ilBadgeManagementGUI::removeResourceStorageImage ( ilBadge  $badge)
protected

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

References ilBadge\getImageRid().

Referenced by updateBadge().

1005  : void
1006  {
1007  if ($badge->getImageRid() !== '') {
1008  $this->resource_storage->manage()->remove(
1009  new ResourceIdentification($badge->getImageRid()),
1011  );
1012  }
1013  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveBadge()

ilBadgeManagementGUI::saveBadge ( )
protected
Exceptions
ilCtrlException
IllegalStateException

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

References $ctrl, $handler, $lng, addBadge(), cloneBadgeTemplate(), ilBadgeHandler\getInstance(), hasWrite(), initBadgeForm(), and ilLanguage\txt().

447  : void
448  {
449  $ilCtrl = $this->ctrl;
450  $lng = $this->lng;
451 
452  $type_id = $this->request->getType();
453  if (!$type_id ||
454  !$this->hasWrite()) {
455  $ilCtrl->redirect($this, 'listBadges');
456  }
457 
458  $ilCtrl->setParameter($this, 'type', $type_id);
459 
461  $type = $handler->getTypeInstanceByUniqueId($type_id);
462  if (!$type) {
463  $ilCtrl->redirect($this, 'listBadges');
464  }
465 
466  $form = $this->initBadgeForm('create', $type, $type_id);
467  $custom = $type->getConfigGUIInstance();
468 
469  if ($form->checkInput() &&
470  (!$custom || $custom->validateForm($form))) {
471  $badge = new ilBadge();
472  $badge->setParentId($this->parent_obj_id); // :TODO: ref_id?
473  $badge->setTypeId($type_id);
474  $badge->setActive($form->getInput('act'));
475  $badge->setTitle($form->getInput('title'));
476  $badge->setDescription($form->getInput('desc'));
477  $badge->setCriteria($form->getInput('crit'));
478  $badge->setValid($form->getInput('valid'));
479 
480  if ($custom instanceof ilBadgeTypeGUI) {
481  $badge->setConfiguration($custom->getConfigFromForm($form));
482  }
483 
484  $badge->create();
485 
486  if ($form->getInput('img_mode') === 'up') {
487  $this->badge_image_service->processImageUpload($badge);
488  } else {
489  $tmpl = new ilBadgeImageTemplate($form->getInput('tmpl'));
490  $this->cloneBadgeTemplate($badge, new ResourceIdentification($tmpl->getImageRid()));
491  }
492 
493  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
494  $ilCtrl->redirect($this, 'listBadges');
495  }
496 
497  $form->setValuesByPost();
498  $this->addBadge($form);
499  }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
cloneBadgeTemplate(ilBadge $badge, ?ResourceIdentification $rid)
addBadge(?ilPropertyFormGUI $a_form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$handler
Definition: oai.php:30
+ Here is the call graph for this function:

◆ selectBadgeForAwardingOrRevoking()

ilBadgeManagementGUI::selectBadgeForAwardingOrRevoking ( )
private

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

References ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

826  : never
827  {
828  $this->ctrl->setParameter(
829  $this,
830  'bid',
831  $this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int())
832  );
833  $this->ctrl->redirect($this, 'awardBadgeUserSelection');
834  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ setBadgeFormValues()

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

Definition at line 531 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().

535  : void {
536  $a_form->getItemByPostVar('act')->setChecked($a_badge->isActive());
537  $a_form->getItemByPostVar('title')->setValue($a_badge->getTitle());
538  $a_form->getItemByPostVar('desc')->setValue($a_badge->getDescription());
539  $a_form->getItemByPostVar('crit')->setValue($a_badge->getCriteria());
540  $a_form->getItemByPostVar('img')->setValue($a_badge->getImage());
541  $a_form->getItemByPostVar('img')->setImage($a_badge->getImagePath());
542 
543  $image_src = $this->badge_image_service->getImageFromBadge($a_badge);
544  if ($image_src !== '') {
545  $a_form->getItemByPostVar('img')->setImage($image_src);
546  }
547 
548  $a_form->getItemByPostVar('valid')->setValue($a_badge->getValid());
549 
550  $custom = $a_type->getConfigGUIInstance();
551  if ($custom instanceof ilBadgeTypeGUI) {
552  $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
553  }
554  }
getConfiguration()
getItemByPostVar(string $a_post_var)
getConfigGUIInstance()
Get GUI config instance.
getImagePath(bool $a_full_path=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTabs()

ilBadgeManagementGUI::setTabs ( string  $a_active)
protected

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

References $ctrl, $lng, $tabs, and ilLanguage\txt().

Referenced by listBadges(), and listUsers().

224  : void
225  {
226  $ilTabs = $this->tabs;
227  $lng = $this->lng;
228  $ilCtrl = $this->ctrl;
229 
230  $ilTabs->addSubTab(
231  'badges',
232  $lng->txt('obj_bdga'),
233  $ilCtrl->getLinkTarget($this, 'listBadges')
234  );
235 
236  $ilTabs->addSubTab(
237  'users',
238  $lng->txt('users'),
239  $ilCtrl->getLinkTarget($this, 'listUsers')
240  );
241 
242  $ilTabs->activateSubTab($a_active);
243  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ splitBadgeAndUserIdsFromString()

ilBadgeManagementGUI::splitBadgeAndUserIdsFromString ( array  $splittable_user_ids)
private
Parameters
list<string>$splittable_user_ids
Returns
array{0: list<int>, 1: int}

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

References $parent_obj_id, ilObject\_lookupObjId(), ilBadgeHandler\getInstance(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), null, and ILIAS\Repository\refinery().

Referenced by assignBadge(), and confirmDeassignBadge().

106  : array
107  {
108  $user_ids = [];
109  $badge_id = null;
110 
111  if ($splittable_user_ids !== []) {
112  if ($splittable_user_ids === ['ALL_OBJECTS']) {
114  if (!$parent_obj_id && $this->parent_ref_id) {
115  $parent_obj_id = ilObject::_lookupObjId($this->parent_ref_id);
116  }
117 
118  if ($this->parent_ref_id) {
119  $user_ids = ilBadgeHandler::getInstance()->getUserIds($this->parent_ref_id, $parent_obj_id);
120  }
121 
122  $badge_id = $this->http->wrapper()->query()->retrieve('bid', $this->refinery->kindlyTo()->int());
123  return [$user_ids, $badge_id];
124  } else {
125  foreach ($splittable_user_ids as $row) {
126  if (str_contains($row, '_')) {
127  $split = explode('_', $row);
128 
129  if ($badge_id === null && $split[0] !== '') {
130  $badge_id = (int) $split[0];
131  }
132 
133  if ($split[1] !== '') {
134  $user_ids[] = (int) $split[1];
135  }
136  } else {
137  return [$user_ids, 0];
138  }
139  }
140  }
141  }
142 
143  return [$user_ids, $badge_id];
144  }
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toggleBadges()

ilBadgeManagementGUI::toggleBadges ( bool  $a_status)
protected

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

References $ctrl, $lng, ilBadge\getInstancesByParentId(), and ilLanguage\txt().

Referenced by activateBadges(), and deactivateBadges().

755  : void
756  {
757  $ilCtrl = $this->ctrl;
758  $lng = $this->lng;
759 
760  $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
761  if (count($badge_ids) > 0) {
762  foreach ($badge_ids as $badge_id) {
763  if ($badge_id === self::TABLE_ALL_OBJECTS_ACTION) {
764  foreach (ilBadge::getInstancesByParentId($this->parent_obj_id) as $badge) {
765  $badge = new ilBadge($badge->getId());
766  $badge->setActive($a_status);
767  $badge->update();
768  }
769  } else {
770  $badge = new ilBadge((int) $badge_id);
771  $badge->setActive($a_status);
772  $badge->update();
773  }
774  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
775  }
776  } else {
777  $this->tpl->setOnScreenMessage('failure', $lng->txt('badge_select_one'), true);
778  }
779 
780  $ilCtrl->redirect($this, 'listBadges');
781  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateBadge()

ilBadgeManagementGUI::updateBadge ( )
protected
Exceptions
ilCtrlException
IllegalStateException

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

References $ctrl, $lng, cloneBadgeTemplate(), editBadge(), hasWrite(), initBadgeForm(), null, removeResourceStorageImage(), and ilLanguage\txt().

560  : void
561  {
562  $ilCtrl = $this->ctrl;
563  $lng = $this->lng;
564 
565  $badge_id = $this->request->getBadgeId();
566  if (!$badge_id ||
567  !$this->hasWrite()) {
568  $ilCtrl->redirect($this, 'listBadges');
569  }
570 
571  $ilCtrl->setParameter($this, 'bid', $badge_id);
572 
573  $badge = new ilBadge($badge_id);
574  $type = $badge->getTypeInstance();
575  $custom = $type->getConfigGUIInstance();
576  if ($custom &&
577  !($custom instanceof ilBadgeTypeGUI)) {
578  $custom = null;
579  }
580  $form = $this->initBadgeForm('update', $type, $badge->getTypeId());
581  if ($form->checkInput() &&
582  (!$custom || $custom->validateForm($form))) {
583  $badge->setActive($form->getInput('act'));
584  $badge->setTitle($form->getInput('title'));
585  $badge->setDescription($form->getInput('desc'));
586  $badge->setCriteria($form->getInput('crit'));
587  $badge->setValid($form->getInput('valid'));
588 
589  $image = $form->getInput('img');
590  if (isset($image['name']) && $image['name'] !== '') {
591  $this->removeResourceStorageImage($badge);
592  $this->badge_image_service->processImageUpload($badge);
593  }
594 
595  if ($custom) {
596  $badge->setConfiguration($custom->getConfigFromForm($form));
597  }
598  $tmpl_id = $form->getInput('tmpl');
599  if ($tmpl_id !== '') {
600  $this->removeResourceStorageImage($badge);
601  $tmpl = new ilBadgeImageTemplate($tmpl_id);
602  $this->cloneBadgeTemplate($badge, new ResourceIdentification($tmpl->getImageRid()));
603  }
604 
605  $badge->update();
606  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
607  $ilCtrl->redirect($this, 'listBadges');
608  }
609 
610  $this->tpl->setOnScreenMessage('failure', $lng->txt('form_input_not_valid'));
611  $form->setValuesByPost();
612  $this->editBadge($form);
613  }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
cloneBadgeTemplate(ilBadge $badge, ?ResourceIdentification $rid)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
editBadge(?ilPropertyFormGUI $a_form=null)
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilBadgeManagementGUI::$access
private

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

Referenced by hasWrite().

◆ $badge_image_service

ilBadgeImage ilBadgeManagementGUI::$badge_image_service = null
private

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

◆ $ctrl

◆ $flavour_definition

ilBadgePictureDefinition ilBadgeManagementGUI::$flavour_definition = null
private

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

◆ $http

ILIAS HTTP Services ilBadgeManagementGUI::$http
private

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

◆ $lng

◆ $parent_obj_id

int ilBadgeManagementGUI::$parent_obj_id
private

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

Referenced by splitBadgeAndUserIdsFromString().

◆ $parent_obj_type

string ilBadgeManagementGUI::$parent_obj_type
private

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

◆ $refinery

Factory ilBadgeManagementGUI::$refinery
private

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

◆ $request

ilBadgeGUIRequest ilBadgeManagementGUI::$request
private

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

◆ $resource_storage

Services ilBadgeManagementGUI::$resource_storage
private

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

◆ $session_repo

ilBadgeManagementSessionRepository ilBadgeManagementGUI::$session_repo
private

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

◆ $tabs

ilTabsGUI ilBadgeManagementGUI::$tabs
private

◆ $toolbar

ilToolbarGUI ilBadgeManagementGUI::$toolbar
private

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

Referenced by listBadges(), and listUsers().

◆ $tpl

ilGlobalTemplateInterface ilBadgeManagementGUI::$tpl
private

◆ $ui_factory

ILIAS UI Factory ilBadgeManagementGUI::$ui_factory
private

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

◆ $upload_service

FileUpload ilBadgeManagementGUI::$upload_service
private

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

◆ $user

ilObjUser ilBadgeManagementGUI::$user
private

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

Referenced by assignBadge().

◆ TABLE_ALL_OBJECTS_ACTION

const ilBadgeManagementGUI::TABLE_ALL_OBJECTS_ACTION = 'ALL_OBJECTS'

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


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