ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilBadgeManagementGUI Class Reference

@ilCtrl_Calls ilBadgeManagementGUI: ilPropertyFormGUI More...

+ Inheritance diagram for ilBadgeManagementGUI:
+ 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 ()
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Data Fields

const string TABLE_ALL_OBJECTS_ACTION = 'ALL_OBJECTS'
 

Private Member Functions

 splitBadgeAndUserIdsFromString (array $splittable_user_ids)
 
 getTableAction ()
 
 handleTableActionsCmd ()
 
 setTabs (string $a_active)
 
 hasWrite ()
 
 listBadgesCmd ()
 
 addBadgeCmd (?ilPropertyFormGUI $a_form=null)
 
 initBadgeForm (string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
 
 saveBadgeCmd ()
 
 editBadgeCmd (?ilPropertyFormGUI $a_form=null)
 
 setBadgeFormValues (ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)
 
 updateBadgeCmd ()
 
 confirmDeleteBadges ()
 
 deleteBadgesCmd ()
 
 getBadgesFromMultiAction ()
 
 copyBadgesCmd ()
 
 clearClipboardCmd ()
 
 getValidBadgesFromClipboard ()
 
 pasteBadgesCmd ()
 
 toggleBadges (bool $a_status)
 
 activateBadges ()
 
 deactivateBadges ()
 
 listUsersCmd ()
 
 selectBadgeForAwardingOrRevokingCmd ()
 
 awardBadgeUserSelectionCmd ()
 
 assignBadge ()
 
 confirmDeassignBadge ()
 
 deassignBadgeCmd ()
 
 cloneBadgeTemplate (ilBadge $badge, ?ResourceIdentification $rid)
 
 removeResourceStorageImage (ilBadge $badge)
 

Private Attributes

const string LIST_USERS_ACTION = 'listUsers'
 
const string LIST_BADGES_ACTION = 'listBadges'
 
const string DELETE_BADGES_ACTION = 'deleteBadges'
 
const string DEASSIGN_BADGE_ACTION = 'deassignBadge'
 
const string SAVE_BADGE_ACTION = 'saveBadge'
 
const string UPDATE_BADGE_ACTION = 'updateBadge'
 
const string ADD_BADGE_ACTION = 'addBadge'
 
const string PASTE_BADGES_ACTION = 'pasteBadges'
 
const string CLEAR_CLIPBOARD_ACTION = 'clearClipboard'
 
const string SELECT_BADGE_FOR_AWARD_REVOKE_ACTION = 'selectBadgeForAwardingOrRevoking'
 
const string AWARD_BADGE_USER_SELECTION_ACTION = 'awardBadgeUserSelection'
 
const string DEFAULT_ACTION = self::LIST_BADGES_ACTION
 
const string TABLE_ACTIONS = 'handleTableActions'
 
ilBadgeGUIRequest $request
 
ilBadgeManagementSessionRepository $session_repo
 
ilLanguage $lng
 
ilCtrlInterface $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
 
ILIAS HTTP Services $http
 
Factory $refinery
 

Detailed Description

@ilCtrl_Calls ilBadgeManagementGUI: ilPropertyFormGUI

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

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

69 {
70 global $DIC;
71
72 $this->lng = $DIC->language();
73 $this->ctrl = $DIC->ctrl();
74 $this->tabs = $DIC->tabs();
75 $this->access = $DIC->access();
76 $this->http = $DIC->http();
77 $this->refinery = $DIC->refinery();
78 $this->toolbar = $DIC->toolbar();
79 $this->ui_factory = $DIC->ui()->factory();
80 $this->resource_storage = $DIC->resourceStorage();
81 $this->tpl = $DIC->ui()->mainTemplate();
82 $this->user = $DIC->user();
83 $lng = $DIC->language();
84 $this->parent_obj_id = $a_parent_obj_id
85 ?: ilObject::_lookupObjId($parent_ref_id);
86 $this->parent_obj_type = $a_parent_obj_type
87 ?: ilObject::_lookupType($this->parent_obj_id);
88
89 if (!ilBadgeHandler::getInstance()->isObjectActive($this->parent_obj_id)) {
90 throw new ilException('inactive object');
91 }
92
93 $lng->loadLanguageModule('badge');
94
95 $this->request = new ilBadgeGUIRequest(
96 $DIC->http(),
97 $DIC->refinery()
98 );
99
100 $this->session_repo = new ilBadgeManagementSessionRepository();
101 $this->badge_image_service = new ilBadgeImage(
102 $DIC->resourceStorage(),
103 $DIC->upload(),
104 $DIC->ui()->mainTemplate()
105 );
106 }
Base class for ILIAS Exception handling.
loadLanguageModule(string $a_module)
Load language module.
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, $lng, 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().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateBadges()

ilBadgeManagementGUI::activateBadges ( )
private

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

756 : void
757 {
758 $this->toggleBadges(true);
759 }

Referenced by handleTableActionsCmd().

+ Here is the caller graph for this function:

◆ addBadgeCmd()

ilBadgeManagementGUI::addBadgeCmd ( ?ilPropertyFormGUI  $a_form = null)
private

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

318 : void
319 {
320 $type_id = $this->request->getType();
321 if (!$type_id ||
322 !$this->hasWrite()) {
323 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
324 }
325
326 $this->ctrl->setParameter($this, 'type', $type_id);
327
329 $type = $handler->getTypeInstanceByUniqueId($type_id);
330 if (!$type) {
331 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
332 }
333
334 if (!$a_form) {
335 $a_form = $this->initBadgeForm('create', $type, $type_id);
336 }
337
338 $this->tpl->setContent($a_form->getHTML());
339 }
initBadgeForm(string $a_mode, ilBadgeType $a_type, string $a_type_unique_id)
$handler
Definition: oai.php:31

References $handler, ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), hasWrite(), and initBadgeForm().

+ Here is the call graph for this function:

◆ assignBadge()

ilBadgeManagementGUI::assignBadge ( )
private

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

856 : void
857 {
858 $splittable_user_ids = $this->request->getBadgeAssignableUsers();
859 [$user_ids, $badge_id] = $this->splitBadgeAndUserIdsFromString($splittable_user_ids);
860
861 if (!$user_ids ||
862 !$badge_id ||
863 !$this->hasWrite()) {
864 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
865 }
866
867 $new_badges = [];
868 foreach ($user_ids as $user_id) {
869 if (!ilBadgeAssignment::exists($badge_id, $user_id)) {
870 $ass = new ilBadgeAssignment($badge_id, $user_id);
871 $ass->setAwardedBy($this->user->getId());
872 $ass->store();
873
874 $new_badges[$user_id][] = $badge_id;
875 }
876 }
877
878 ilBadgeHandler::getInstance()->sendNotification($new_badges, $this->parent_ref_id);
879
880 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('settings_saved'), true);
881 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
882 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static exists(int $a_badge_id, int $a_user_id)
splitBadgeAndUserIdsFromString(array $splittable_user_ids)

References $user_id, ILIAS\Repository\ctrl(), ilBadgeAssignment\exists(), ilBadgeHandler\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ awardBadgeUserSelectionCmd()

ilBadgeManagementGUI::awardBadgeUserSelectionCmd ( )
private

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

808 : void
809 {
810 $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
811 $bid = null;
812
813 if ($badge_ids === []) {
814 if ($this->http->wrapper()->post()->has('bid')) {
815 $bid = $this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int());
816 } elseif ($this->http->wrapper()->query()->has('bid')) {
817 $bid = $this->http->wrapper()->query()->retrieve('bid', $this->refinery->kindlyTo()->int());
818 }
819 } elseif (count($badge_ids) === 1) {
820 $bid = (int) $badge_ids[0];
821 }
822
823 if (!$bid ||
824 !$this->hasWrite()) {
825 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
826 }
827
828 $manual = array_keys(
829 ilBadgeHandler::getInstance()->getAvailableManualBadges($this->parent_obj_id, $this->parent_obj_type)
830 );
831
832 if (!in_array($bid, $manual, true)) {
833 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
834 }
835
836 $back_target = self::LIST_USERS_ACTION;
837 if ($this->request->getTgt() === 'bdgl') {
838 $this->ctrl->saveParameter($this, 'tgt');
839 $back_target = self::LIST_BADGES_ACTION;
840 }
841
842 $this->tabs->clearTargets();
843 $this->tabs->setBackTarget(
844 $this->lng->txt('back'),
845 $this->ctrl->getLinkTarget($this, $back_target)
846 );
847
848 $this->ctrl->setParameter($this, 'bid', $bid);
849
850 $badge = new ilBadge($bid);
851
852 $tbl = new ilBadgeUserTableGUI($this->parent_ref_id, $badge);
853 $tbl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
854 }

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

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearClipboardCmd()

ilBadgeManagementGUI::clearClipboardCmd ( )
private

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

687 : void
688 {
689 $this->session_repo->clear();
690 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
691 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ cloneBadgeTemplate()

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

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

956 : void
957 {
958 if ($rid !== null) {
959 $new_rid = $this->badge_image_service->cloneBadgeImageByRid($rid);
960 $badge->setImageRid($new_rid);
961 $badge->update();
962 }
963 }
setImageRid(?string $image_rid)

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

+ Here is the call graph for this function:

◆ confirmDeassignBadge()

ilBadgeManagementGUI::confirmDeassignBadge ( )
private

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

884 : void
885 {
886 $splittable_user_ids = $this->request->getMultiActionBadgeIdsFromUrl();
887 [$user_ids, $badge_id] = $this->splitBadgeAndUserIdsFromString($splittable_user_ids);
888
889 if (!$user_ids ||
890 !$badge_id ||
891 !$this->hasWrite()) {
892 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
893 }
894
895 $this->tabs->clearTargets();
896 $this->tabs->setBackTarget(
897 $this->lng->txt('back'),
898 $this->ctrl->getLinkTarget($this, self::LIST_USERS_ACTION)
899 );
900
901 $badge = new ilBadge($badge_id);
902
903 $this->ctrl->setParameter($this, 'bid', $badge->getId());
904
905 $confirmation_gui = new ilConfirmationGUI();
906 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this, self::DEASSIGN_BADGE_ACTION));
907 $confirmation_gui->setHeaderText(
908 sprintf($this->lng->txt('badge_assignment_deletion_confirmation'), $badge->getTitle())
909 );
910 $confirmation_gui->setCancel($this->lng->txt('cancel'), self::LIST_USERS_ACTION);
911 $confirmation_gui->setConfirm($this->lng->txt('badge_remove_badge'), self::DEASSIGN_BADGE_ACTION);
912
913 $assigned_users = ilBadgeAssignment::getAssignedUsers($badge->getId());
914
915 foreach ($user_ids as $user_id) {
916 if (in_array($user_id, $assigned_users, true)) {
917 $confirmation_gui->addItem(
918 "id[$user_id]",
919 (string) $badge_id,
920 ilUserUtil::getNamePresentation($user_id, false, false, '', true)
921 );
922 }
923 }
924
925 $this->tpl->setContent($confirmation_gui->getHTML());
926 }
static getAssignedUsers(int $a_badge_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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=null)
Default behaviour is:

References $user_id, ILIAS\Repository\ctrl(), ilBadgeAssignment\getAssignedUsers(), ilUserUtil\getNamePresentation(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteBadges()

ilBadgeManagementGUI::confirmDeleteBadges ( )
private

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

604 : void
605 {
606 $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
607 if ($badge_ids === [self::TABLE_ALL_OBJECTS_ACTION]) {
608 $badge_ids = [];
609 foreach (ilBadge::getInstancesByParentId($this->parent_obj_id) as $badge) {
610 $badge_ids[] = $badge->getId();
611 }
612 }
613
614 $this->tabs->clearTargets();
615 $this->tabs->setBackTarget(
616 $this->lng->txt('back'),
617 $this->ctrl->getLinkTarget($this, self::LIST_BADGES_ACTION)
618 );
619
620 $confirmation_gui = new ilConfirmationGUI();
621 $confirmation_gui->setFormAction($this->ctrl->getFormAction($this));
622 $confirmation_gui->setHeaderText($this->lng->txt('badge_deletion_confirmation'));
623 $confirmation_gui->setCancel($this->lng->txt('cancel'), self::LIST_BADGES_ACTION);
624 $confirmation_gui->setConfirm($this->lng->txt('delete'), self::DELETE_BADGES_ACTION);
625
626 foreach ($badge_ids as $badge_id) {
627 $badge = new ilBadge((int) $badge_id);
628 $confirmation_gui->addItem(
629 'id[]',
630 (string) $badge_id,
631 $badge->getTitle() .
632 ' (' . count(ilBadgeAssignment::getInstancesByBadgeId($badge_id)) . ')'
633 );
634 }
635
636 $this->tpl->setContent($confirmation_gui->getHTML());
637 }
static getInstancesByBadgeId(int $a_badge_id)
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)

References ILIAS\Repository\ctrl(), ilBadgeAssignment\getInstancesByBadgeId(), ilBadge\getInstancesByParentId(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyBadgesCmd()

ilBadgeManagementGUI::copyBadgesCmd ( )
private

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

674 : void
675 {
676 $badge_ids = $this->getBadgesFromMultiAction();
677
678 $clip_ids = $this->session_repo->getBadgeIds();
679 $clip_ids = array_unique(
680 array_merge($clip_ids, $badge_ids)
681 );
682 $this->session_repo->setBadgeIds(array_map(intval(...), $clip_ids));
683
684 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
685 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ deactivateBadges()

ilBadgeManagementGUI::deactivateBadges ( )
private

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

761 : void
762 {
763 $this->toggleBadges(false);
764 }

Referenced by handleTableActionsCmd().

+ Here is the caller graph for this function:

◆ deassignBadgeCmd()

ilBadgeManagementGUI::deassignBadgeCmd ( )
private

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

928 : void
929 {
930 $post_values = $this->request->getIds();
931 $user_ids = [];
932 $badge_id = null;
933 foreach ($post_values as $usr_id => $found_badge_id) {
934 $badge_id = $found_badge_id;
935 $user_ids[] = $usr_id;
936 }
937
938 if (!$user_ids ||
939 !$badge_id ||
940 !$this->hasWrite()) {
941 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
942 }
943
944 foreach ($user_ids as $user_id) {
945 $ass = new ilBadgeAssignment((int) $badge_id, (int) $user_id);
946 $ass->delete();
947 }
948
949 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('settings_saved'), true);
950 $this->ctrl->redirect($this, self::LIST_USERS_ACTION);
951 }

References $user_id, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteBadgesCmd()

ilBadgeManagementGUI::deleteBadgesCmd ( )
private

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

639 : void
640 {
641 $badge_ids = $this->request->getIds();
642
643 if (count($badge_ids) > 0) {
644 foreach ($badge_ids as $badge_id) {
645 $badge = new ilBadge((int) $badge_id);
646 $badge->delete();
647 }
648 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('settings_saved'), true);
649 } else {
650 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('badge_select_one'), true);
651 }
652
653 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
654 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ editBadgeCmd()

ilBadgeManagementGUI::editBadgeCmd ( ?ilPropertyFormGUI  $a_form = null)
private

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

490 : void
491 {
492 $badge_id = $this->request->getBadgeIdFromUrl();
493 if (!$badge_id) {
494 $badge_id = $this->request->getBadgeId();
495 }
496
497 if (!$badge_id ||
498 !$this->hasWrite()) {
499 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
500 }
501
502 $this->ctrl->setParameter($this, 'bid', $badge_id);
503
504 $badge = new ilBadge($badge_id);
505
506 $static_cnt = ilBadgeHandler::getInstance()->countStaticBadgeInstances($badge);
507 if ($static_cnt) {
508 $this->tpl->setOnScreenMessage(
509 $this->tpl::MESSAGE_TYPE_INFO,
510 sprintf($this->lng->txt('badge_edit_with_published'), $static_cnt)
511 );
512 }
513
514 if (!$a_form) {
515 $type = $badge->getTypeInstance();
516 $a_form = $this->initBadgeForm('edit', $type, $badge->getTypeId());
517 $this->setBadgeFormValues($a_form, $badge, $type);
518 }
519
520 $this->tpl->setContent($a_form->getHTML());
521 }
setBadgeFormValues(ilPropertyFormGUI $a_form, ilBadge $a_badge, ilBadgeType $a_type)

References ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), and ILIAS\Repository\lng().

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeManagementGUI::executeCommand ( )

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

153 : void
154 {
155 $next_class = $this->ctrl->getNextClass($this);
156 $cmd = $this->ctrl->getCmd(self::DEFAULT_ACTION);
157 if ($cmd === null || $cmd === '' || !method_exists($this, $cmd . 'Cmd')) {
159 }
160 $cmd .= 'Cmd';
161
162 switch ($next_class) {
163 case 'ilpropertyformgui':
164 // ajax - update
165 if ($this->request->getBadgeId()) {
166 $badge = new ilBadge($this->request->getBadgeId());
167 $type = $badge->getTypeInstance();
168 $form = $this->initBadgeForm('edit', $type, $badge->getTypeId());
169 $this->setBadgeFormValues($form, $badge, $type);
170 } // ajax- create
171 else {
172 $type_id = $this->request->getType();
173 $this->ctrl->setParameter($this, 'type', $type_id);
175 $type = $handler->getTypeInstanceByUniqueId($type_id);
176 $form = $this->initBadgeForm('create', $type, $type_id);
177 }
178 $this->ctrl->forwardCommand($form);
179 break;
180
181 default:
182 $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
183 if (count($badge_ids) === 1) {
184 $badge_id = array_pop($badge_ids);
185 $this->ctrl->setParameter($this, 'tid', $badge_id);
186 }
187
188 $this->$cmd();
189 break;
190 }
191 }

References $handler, ILIAS\Repository\ctrl(), DEFAULT_ACTION, ilBadgeHandler\getInstance(), initBadgeForm(), and setBadgeFormValues().

+ Here is the call graph for this function:

◆ getBadgesFromMultiAction()

ilBadgeManagementGUI::getBadgesFromMultiAction ( )
private
Returns
int[]

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

663 : array
664 {
665 $badge_ids = $this->request->getIds();
666 if (!$badge_ids ||
667 !$this->hasWrite()) {
668 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
669 }
670
671 return $badge_ids;
672 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getSafePostCommands()

ilBadgeManagementGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

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

193 : array
194 {
195 return [];
196 }

◆ getTableAction()

ilBadgeManagementGUI::getTableAction ( )
private

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

198 : ?string
199 {
200 return $this->http->wrapper()->query()->retrieve(
201 'tid_table_action',
202 $this->refinery->byTrying([
203 $this->refinery->kindlyTo()->string(),
204 $this->refinery->always(null)
205 ])
206 );
207 }

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

Referenced by handleTableActionsCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUnsafeGetCommands()

ilBadgeManagementGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

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

223 : array
224 {
225 return [self::TABLE_ACTIONS];
226 }

References TABLE_ACTIONS.

◆ getValidBadgesFromClipboard()

ilBadgeManagementGUI::getValidBadgesFromClipboard ( )
private
Returns
ilBadge[]

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

696 : array
697 {
698 $res = [];
699
700 $valid_types = array_keys(ilBadgeHandler::getInstance()->getAvailableTypesForObjType($this->parent_obj_type));
701
702 foreach ($this->session_repo->getBadgeIds() as $badge_id) {
703 $badge = new ilBadge($badge_id);
704 if (in_array($badge->getTypeId(), $valid_types, true)) {
705 $res[] = $badge;
706 }
707 }
708
709 return $res;
710 }
$res
Definition: ltiservices.php:69

References $res, and ilBadgeHandler\getInstance().

Referenced by listBadgesCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleTableActionsCmd()

ilBadgeManagementGUI::handleTableActionsCmd ( )
private

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

209 : void
210 {
211 match ($this->getTableAction()) {
212 'badge_table_activate' => $this->activateBadges(),
213 'badge_table_deactivate' => $this->deactivateBadges(),
214 'badge_table_edit' => $this->editBadgeCmd(),
215 'badge_table_delete' => $this->confirmDeleteBadges(),
216 'award_revoke_badge' => $this->awardBadgeUserSelectionCmd(),
217 'revokeBadge' => $this->confirmDeassignBadge(),
218 'assignBadge' => $this->assignBadge(),
219 default => $this->ctrl->redirect($this, self::DEFAULT_ACTION),
220 };
221 }
editBadgeCmd(?ilPropertyFormGUI $a_form=null)

References activateBadges(), assignBadge(), awardBadgeUserSelectionCmd(), confirmDeassignBadge(), confirmDeleteBadges(), ILIAS\Repository\ctrl(), deactivateBadges(), editBadgeCmd(), and getTableAction().

+ Here is the call graph for this function:

◆ hasWrite()

ilBadgeManagementGUI::hasWrite ( )
private

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

245 : bool
246 {
247 return $this->access->checkAccess('write', '', $this->parent_ref_id);
248 }

References ILIAS\Repository\access().

Referenced by addBadgeCmd(), and listBadgesCmd().

+ 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 
)
private

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

346 $form = new ilPropertyFormGUI();
347 $form->setFormAction($this->ctrl->getFormAction($this, self::SAVE_BADGE_ACTION));
348 $form->setTitle($this->lng->txt('badge_badge') . ' "' . $a_type->getCaption() . '"');
349
350 $active = new ilCheckboxInputGUI($this->lng->txt('active'), 'act');
351 $form->addItem($active);
352
353 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
354 $title->setMaxLength(255);
355 $title->setRequired(true);
356 $form->addItem($title);
357
358 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
359 $desc->setMaxNumOfChars(4000);
360 $desc->setRequired(true);
361 $form->addItem($desc);
362
363 $crit = new ilTextAreaInputGUI($this->lng->txt('badge_criteria'), 'crit');
364 $crit->setMaxNumOfChars(4000);
365 $crit->setRequired(true);
366 $form->addItem($crit);
367
368 if ($a_mode === 'create') {
369 // upload
370
371 $img_mode = new ilRadioGroupInputGUI($this->lng->txt('image'), 'img_mode');
372 $img_mode->setRequired(true);
373 $img_mode->setValue('tmpl');
374 $form->addItem($img_mode);
375
376 $img_mode_tmpl = new ilRadioOption($this->lng->txt('badge_image_from_template'), 'tmpl');
377 $img_mode->addOption($img_mode_tmpl);
378
379 $img_mode_up = new ilRadioOption($this->lng->txt('badge_image_from_upload'), 'up');
380 $img_mode->addOption($img_mode_up);
381
382 $img_upload = new ilImageFileInputGUI($this->lng->txt('file'), 'img');
383 $img_upload->setRequired(true);
384 $img_upload->setSuffixes(['png', 'svg']);
385 $img_mode_up->addSubItem($img_upload);
386
387 // templates
388
389 $valid_templates = ilBadgeImageTemplate::getInstancesByType($a_type_unique_id);
390 if (count($valid_templates)) {
391 $options = [];
392 $options[''] = $this->lng->txt('please_select');
393 foreach ($valid_templates as $tmpl) {
394 $options[$tmpl->getId()] = $tmpl->getTitle();
395 }
396
397 $tmpl = new ilSelectInputGUI($this->lng->txt('badge_image_template_form'), 'tmpl');
398 $tmpl->setRequired(true);
399 $tmpl->setOptions($options);
400 $img_mode_tmpl->addSubItem($tmpl);
401 } else {
402 // no templates, activate upload
403 $img_mode_tmpl->setDisabled(true);
404 $img_mode->setValue('up');
405 }
406 } else {
407 $img_upload = new ilImageFileInputGUI($this->lng->txt('image'), 'img');
408 $img_upload->setSuffixes(['png', 'svg']);
409 $img_upload->setAllowDeletion(false);
410 $img_upload->setUseCache(false);
411 $form->addItem($img_upload);
412 }
413
414 $valid = new ilTextInputGUI($this->lng->txt('badge_valid'), 'valid');
415 $valid->setMaxLength(255);
416 $form->addItem($valid);
417
418 $custom = $a_type->getConfigGUIInstance();
419 if ($custom instanceof ilBadgeTypeGUI) {
420 $custom->initConfigForm($form, $this->parent_ref_id);
421 }
422
423 // :TODO: valid date/period
424
425 if ($a_mode === 'create') {
426 $form->addCommandButton(self::SAVE_BADGE_ACTION, $this->lng->txt('save'));
427 } else {
428 $form->addCommandButton(self::UPDATE_BADGE_ACTION, $this->lng->txt('save'));
429 }
430 $form->addCommandButton(self::LIST_BADGES_ACTION, $this->lng->txt('cancel'));
431
432 return $form;
433 }
static getInstancesByType(string $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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getConfigGUIInstance()
Get GUI config instance.

Referenced by addBadgeCmd(), and executeCommand().

+ Here is the caller graph for this function:

◆ listBadgesCmd()

ilBadgeManagementGUI::listBadgesCmd ( )
private

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

250 : void
251 {
252 $this->setTabs('badges');
253
254 if ($this->hasWrite()) {
256 $valid_types = $handler->getAvailableTypesForObjType($this->parent_obj_type);
257 if ($valid_types) {
258 $options = [];
259 foreach ($valid_types as $id => $type) {
260 $this->ctrl->setParameter($this, 'type', $id);
261 $options[$id] = $this->ui_factory->link()->standard(
262 $this->parent_obj_type !== 'bdga' ? ilBadge::getExtendedTypeCaption($type) : $type->getCaption(
263 ),
264 $this->ctrl->getLinkTarget($this, self::ADD_BADGE_ACTION)
265 );
266 $this->ctrl->setParameter($this, 'type', null);
267 }
268 asort($options);
269 $options = array_values($options);
270
271 $this->toolbar->addComponent(
272 $this->ui_factory->dropdown()->standard($options)->withLabel($this->lng->txt('badge_create'))
273 );
274 } else {
275 $this->tpl->setOnScreenMessage(
276 $this->tpl::MESSAGE_TYPE_INFO,
277 $this->lng->txt('badge_no_valid_types_for_obj')
278 );
279 }
280
281 $clip_ids = $this->session_repo->getBadgeIds();
282 if (count($clip_ids) > 0) {
283 if ($valid_types) {
284 $this->toolbar->addSeparator();
285 }
286
287 $tt = [];
288 foreach ($this->getValidBadgesFromClipboard() as $badge) {
289 $tt[] = $badge->getTitle();
290 }
291 $ttid = 'bdgpst';
292
293 $this->lng->loadLanguageModule('content');
294 $this->toolbar->addButton(
295 $this->lng->txt('cont_paste_from_clipboard') .
296 ' (' . count($tt) . ')',
297 $this->ctrl->getLinkTarget($this, self::PASTE_BADGES_ACTION),
298 '',
299 null,
300 '',
301 $ttid
302 );
303 $this->toolbar->addButton(
304 $this->lng->txt('clear_clipboard'),
305 $this->ctrl->getLinkTarget($this, self::CLEAR_CLIPBOARD_ACTION)
306 );
307 }
308 }
309
310 $table = new ilBadgeTableGUI($this->parent_obj_id, $this->parent_obj_type, $this->hasWrite());
311 $table->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
312 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getExtendedTypeCaption(ilBadgeType $a_type)

References $handler, $id, ILIAS\UI\Implementation\Component\Input\Field\$options, ILIAS\Repository\ctrl(), ilBadge\getExtendedTypeCaption(), ilBadgeHandler\getInstance(), getValidBadgesFromClipboard(), hasWrite(), ILIAS\Repository\lng(), setTabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ listUsersCmd()

ilBadgeManagementGUI::listUsersCmd ( )
private

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

770 : void
771 {
772 $this->setTabs('users');
773
774 if ($this->hasWrite()) {
775 $manual = ilBadgeHandler::getInstance()->getAvailableManualBadges(
776 $this->parent_obj_id,
777 $this->parent_obj_type
778 );
779 if (count($manual)) {
780 $drop = new ilSelectInputGUI($this->lng->txt('badge_badge'), 'bid');
781 $drop->setOptions($manual);
782 $this->toolbar->addInputItem($drop, true);
783
784 $this->toolbar->setFormAction(
785 $this->ctrl->getFormAction($this, self::SELECT_BADGE_FOR_AWARD_REVOKE_ACTION)
786 );
787 $this->toolbar->addFormButton(
788 $this->lng->txt('badge_award_badge'),
789 self::SELECT_BADGE_FOR_AWARD_REVOKE_ACTION
790 );
791 }
792 }
793
794 $tbl = new ilBadgeUserTableGUI($this->parent_ref_id);
795 $tbl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, self::TABLE_ACTIONS));
796 }

References ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ pasteBadgesCmd()

ilBadgeManagementGUI::pasteBadgesCmd ( )
private

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

712 : void
713 {
714 $clip_ids = $this->session_repo->getBadgeIds();
715 if (!$this->hasWrite() || count($clip_ids) === 0) {
716 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
717 }
718
719 $copy_suffix = $this->lng->txt('copy_of_suffix');
720 foreach ($this->getValidBadgesFromClipboard() as $badge) {
721 $badge->copy($this->parent_obj_id, $copy_suffix);
722 }
723
724 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
725 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ removeResourceStorageImage()

ilBadgeManagementGUI::removeResourceStorageImage ( ilBadge  $badge)
private

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

965 : void
966 {
967 if ($badge->getImageRid() !== '') {
968 $this->resource_storage->manage()->remove(
969 new ResourceIdentification($badge->getImageRid()),
971 );
972 }
973 }

References ilBadge\getImageRid().

+ Here is the call graph for this function:

◆ saveBadgeCmd()

ilBadgeManagementGUI::saveBadgeCmd ( )
private
Exceptions
ilCtrlException
IllegalStateException

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

439 : void
440 {
441 $type_id = $this->request->getType();
442 if (!$type_id ||
443 !$this->hasWrite()) {
444 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
445 }
446
447 $this->ctrl->setParameter($this, 'type', $type_id);
448
450 $type = $handler->getTypeInstanceByUniqueId($type_id);
451 if (!$type) {
452 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
453 }
454
455 $form = $this->initBadgeForm('create', $type, $type_id);
456 $custom = $type->getConfigGUIInstance();
457
458 if ($form->checkInput() &&
459 (!$custom || $custom->validateForm($form))) {
460 $badge = new ilBadge();
461 $badge->setParentId($this->parent_obj_id); // :TODO: ref_id?
462 $badge->setTypeId($type_id);
463 $badge->setActive($form->getInput('act'));
464 $badge->setTitle($form->getInput('title'));
465 $badge->setDescription($form->getInput('desc'));
466 $badge->setCriteria($form->getInput('crit'));
467 $badge->setValid($form->getInput('valid'));
468
469 if ($custom instanceof ilBadgeTypeGUI) {
470 $badge->setConfiguration($custom->getConfigFromForm($form));
471 }
472
473 $badge->create();
474
475 if ($form->getInput('img_mode') === 'up') {
476 $this->badge_image_service->processImageUpload($badge);
477 } else {
478 $tmpl = new ilBadgeImageTemplate($form->getInput('tmpl'));
479 $this->cloneBadgeTemplate($badge, new ResourceIdentification($tmpl->getImageRid()));
480 }
481
482 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('settings_saved'), true);
483 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
484 }
485
486 $form->setValuesByPost();
487 $this->addBadgeCmd($form);
488 }
addBadgeCmd(?ilPropertyFormGUI $a_form=null)
cloneBadgeTemplate(ilBadge $badge, ?ResourceIdentification $rid)

References $handler, ILIAS\Repository\ctrl(), ilBadgeHandler\getInstance(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ selectBadgeForAwardingOrRevokingCmd()

ilBadgeManagementGUI::selectBadgeForAwardingOrRevokingCmd ( )
private

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

798 : never
799 {
800 $this->ctrl->setParameter(
801 $this,
802 'bid',
803 $this->http->wrapper()->post()->retrieve('bid', $this->refinery->kindlyTo()->int())
804 );
805 $this->ctrl->redirect($this, self::AWARD_BADGE_USER_SELECTION_ACTION);
806 }

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

+ Here is the call graph for this function:

◆ setBadgeFormValues()

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

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

527 : void {
528 $a_form->getItemByPostVar('act')->setChecked($a_badge->isActive());
529 $a_form->getItemByPostVar('title')->setValue($a_badge->getTitle());
530 $a_form->getItemByPostVar('desc')->setValue($a_badge->getDescription());
531 $a_form->getItemByPostVar('crit')->setValue($a_badge->getCriteria());
532 $a_form->getItemByPostVar('img')->setValue($a_badge->getImage());
533 $a_form->getItemByPostVar('img')->setImage($a_badge->getImagePath());
534
535 $image_src = $this->badge_image_service->getImageFromBadge($a_badge);
536 if ($image_src !== '') {
537 $a_form->getItemByPostVar('img')->setImage($image_src);
538 }
539
540 $a_form->getItemByPostVar('valid')->setValue($a_badge->getValid());
541
542 $custom = $a_type->getConfigGUIInstance();
543 if ($custom instanceof ilBadgeTypeGUI) {
544 $custom->importConfigToForm($a_form, $a_badge->getConfiguration());
545 }
546 }
getImagePath(bool $a_full_path=true)
getConfiguration()
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getItemByPostVar().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTabs()

ilBadgeManagementGUI::setTabs ( string  $a_active)
private

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

228 : void
229 {
230 $this->tabs->addSubTab(
231 'badges',
232 $this->lng->txt('obj_bdga'),
233 $this->ctrl->getLinkTarget($this, self::LIST_BADGES_ACTION)
234 );
235
236 $this->tabs->addSubTab(
237 'users',
238 $this->lng->txt('users'),
239 $this->ctrl->getLinkTarget($this, self::LIST_USERS_ACTION)
240 );
241
242 $this->tabs->activateSubTab($a_active);
243 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by listBadgesCmd().

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

112 : array
113 {
114 $user_ids = [];
115 $badge_id = null;
116
117 if ($splittable_user_ids !== []) {
118 if ($splittable_user_ids === [self::TABLE_ALL_OBJECTS_ACTION]) {
120 if (!$parent_obj_id && $this->parent_ref_id) {
121 $parent_obj_id = ilObject::_lookupObjId($this->parent_ref_id);
122 }
123
124 if ($this->parent_ref_id) {
125 $user_ids = ilBadgeHandler::getInstance()->getUserIds($this->parent_ref_id, $parent_obj_id);
126 }
127
128 $badge_id = $this->http->wrapper()->query()->retrieve('bid', $this->refinery->kindlyTo()->int());
129
130 return [$user_ids, $badge_id];
131 } else {
132 foreach ($splittable_user_ids as $row) {
133 if (str_contains($row, '_')) {
134 $split = explode('_', $row);
135
136 if ($badge_id === null && $split[0] !== '') {
137 $badge_id = (int) $split[0];
138 }
139
140 if ($split[1] !== '') {
141 $user_ids[] = (int) $split[1];
142 }
143 } else {
144 return [$user_ids, 0];
145 }
146 }
147 }
148 }
149
150 return [$user_ids, $badge_id];
151 }

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

+ Here is the call graph for this function:

◆ toggleBadges()

ilBadgeManagementGUI::toggleBadges ( bool  $a_status)
private

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

727 : void
728 {
729 $badge_ids = $this->request->getMultiActionBadgeIdsFromUrl();
730 if (count($badge_ids) > 0) {
731 foreach ($badge_ids as $badge_id) {
732 if ($badge_id === self::TABLE_ALL_OBJECTS_ACTION) {
733 foreach (ilBadge::getInstancesByParentId($this->parent_obj_id) as $badge) {
734 $badge = new ilBadge($badge->getId());
735 $badge->setActive($a_status);
736 $badge->update();
737 }
738 } else {
739 $badge = new ilBadge((int) $badge_id);
740 $badge->setActive($a_status);
741 $badge->update();
742 }
743 $this->tpl->setOnScreenMessage(
744 $this->tpl::MESSAGE_TYPE_SUCCESS,
745 $this->lng->txt('settings_saved'),
746 true
747 );
748 }
749 } else {
750 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('badge_select_one'), true);
751 }
752
753 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
754 }

References ILIAS\Repository\ctrl(), ilBadge\getInstancesByParentId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ updateBadgeCmd()

ilBadgeManagementGUI::updateBadgeCmd ( )
private
Exceptions
ilCtrlException
IllegalStateException

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

552 : void
553 {
554 $badge_id = $this->request->getBadgeId();
555 if (!$badge_id ||
556 !$this->hasWrite()) {
557 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
558 }
559
560 $this->ctrl->setParameter($this, 'bid', $badge_id);
561
562 $badge = new ilBadge($badge_id);
563 $type = $badge->getTypeInstance();
564 $custom = $type->getConfigGUIInstance();
565 if ($custom &&
566 !($custom instanceof ilBadgeTypeGUI)) {
567 $custom = null;
568 }
569 $form = $this->initBadgeForm('update', $type, $badge->getTypeId());
570 if ($form->checkInput() &&
571 (!$custom || $custom->validateForm($form))) {
572 $badge->setActive($form->getInput('act'));
573 $badge->setTitle($form->getInput('title'));
574 $badge->setDescription($form->getInput('desc'));
575 $badge->setCriteria($form->getInput('crit'));
576 $badge->setValid($form->getInput('valid'));
577
578 $image = $form->getInput('img');
579 if (isset($image['name']) && $image['name'] !== '') {
580 $this->removeResourceStorageImage($badge);
581 $this->badge_image_service->processImageUpload($badge);
582 }
583
584 if ($custom) {
585 $badge->setConfiguration($custom->getConfigFromForm($form));
586 }
587 $tmpl_id = $form->getInput('tmpl');
588 if ($tmpl_id !== '') {
589 $this->removeResourceStorageImage($badge);
590 $tmpl = new ilBadgeImageTemplate($tmpl_id);
591 $this->cloneBadgeTemplate($badge, new ResourceIdentification($tmpl->getImageRid()));
592 }
593
594 $badge->update();
595 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('settings_saved'), true);
596 $this->ctrl->redirect($this, self::LIST_BADGES_ACTION);
597 }
598
599 $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('form_input_not_valid'));
600 $form->setValuesByPost();
601 $this->editBadgeCmd($form);
602 }
removeResourceStorageImage(ilBadge $badge)

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilBadgeManagementGUI::$access
private

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

◆ $badge_image_service

ilBadgeImage ilBadgeManagementGUI::$badge_image_service = null
private

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

◆ $ctrl

ilCtrlInterface ilBadgeManagementGUI::$ctrl
private

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

◆ $http

ILIAS HTTP Services ilBadgeManagementGUI::$http
private

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

◆ $lng

ilLanguage ilBadgeManagementGUI::$lng
private

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

Referenced by __construct().

◆ $parent_obj_id

int ilBadgeManagementGUI::$parent_obj_id
private

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

Referenced by splitBadgeAndUserIdsFromString().

◆ $parent_obj_type

string ilBadgeManagementGUI::$parent_obj_type
private

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

◆ $refinery

Factory ilBadgeManagementGUI::$refinery
private

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

◆ $request

ilBadgeGUIRequest ilBadgeManagementGUI::$request
private

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

◆ $resource_storage

Services ilBadgeManagementGUI::$resource_storage
private

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

◆ $session_repo

ilBadgeManagementSessionRepository ilBadgeManagementGUI::$session_repo
private

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

◆ $tabs

ilTabsGUI ilBadgeManagementGUI::$tabs
private

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

◆ $toolbar

ilToolbarGUI ilBadgeManagementGUI::$toolbar
private

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

◆ $tpl

ilGlobalTemplateInterface ilBadgeManagementGUI::$tpl
private

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

◆ $ui_factory

ILIAS UI Factory ilBadgeManagementGUI::$ui_factory
private

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

◆ $user

ilObjUser ilBadgeManagementGUI::$user
private

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

◆ ADD_BADGE_ACTION

const string ilBadgeManagementGUI::ADD_BADGE_ACTION = 'addBadge'
private

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

◆ AWARD_BADGE_USER_SELECTION_ACTION

const string ilBadgeManagementGUI::AWARD_BADGE_USER_SELECTION_ACTION = 'awardBadgeUserSelection'
private

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

◆ CLEAR_CLIPBOARD_ACTION

const string ilBadgeManagementGUI::CLEAR_CLIPBOARD_ACTION = 'clearClipboard'
private

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

◆ DEASSIGN_BADGE_ACTION

const string ilBadgeManagementGUI::DEASSIGN_BADGE_ACTION = 'deassignBadge'
private

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

◆ DEFAULT_ACTION

const string ilBadgeManagementGUI::DEFAULT_ACTION = self::LIST_BADGES_ACTION
private

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

Referenced by executeCommand().

◆ DELETE_BADGES_ACTION

const string ilBadgeManagementGUI::DELETE_BADGES_ACTION = 'deleteBadges'
private

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

◆ LIST_BADGES_ACTION

const string ilBadgeManagementGUI::LIST_BADGES_ACTION = 'listBadges'
private

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

◆ LIST_USERS_ACTION

const string ilBadgeManagementGUI::LIST_USERS_ACTION = 'listUsers'
private

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

◆ PASTE_BADGES_ACTION

const string ilBadgeManagementGUI::PASTE_BADGES_ACTION = 'pasteBadges'
private

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

◆ SAVE_BADGE_ACTION

const string ilBadgeManagementGUI::SAVE_BADGE_ACTION = 'saveBadge'
private

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

◆ SELECT_BADGE_FOR_AWARD_REVOKE_ACTION

const string ilBadgeManagementGUI::SELECT_BADGE_FOR_AWARD_REVOKE_ACTION = 'selectBadgeForAwardingOrRevoking'
private

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

◆ TABLE_ACTIONS

const string ilBadgeManagementGUI::TABLE_ACTIONS = 'handleTableActions'
private

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

Referenced by getUnsafeGetCommands().

◆ TABLE_ALL_OBJECTS_ACTION

const string ilBadgeManagementGUI::TABLE_ALL_OBJECTS_ACTION = 'ALL_OBJECTS'

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

◆ UPDATE_BADGE_ACTION

const string ilBadgeManagementGUI::UPDATE_BADGE_ACTION = 'updateBadge'
private

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


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