ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBadgeProfileGUI Class Reference
+ Inheritance diagram for ilBadgeProfileGUI:
+ Collaboration diagram for ilBadgeProfileGUI:

Public Member Functions

 __construct ()
 
 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

final const BACKPACK_EMAIL = 'badge_mozilla_bp'
 

Protected Member Functions

 listBadges ()
 
 manageBadges ()
 
 getMultiSelection ()
 
 activate ()
 
 deactivate ()
 
 activateInCard ()
 
 deactivateInCard ()
 
 setBackpackSubTabs ()
 
 listBackpackGroups ()
 
 getBackpackMail ()
 
 initSettingsForm ()
 
 editSettings (?ilPropertyFormGUI $a_form=null)
 
 saveSettings ()
 

Protected Attributes

ilBadgeGUIRequest $request
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilTabsGUI $tabs
 
ilObjUser $user
 
ilAccessHandler $access
 
ILIAS UI Factory $factory
 
ILIAS UI Renderer $renderer
 
BadgeNotificationPrefRepository $noti_repo
 

Private Member Functions

 renderDeck (string $deck)
 

Private Attributes

readonly TileView $tile_view
 

Detailed Description

Definition at line 24 of file class.ilBadgeProfileGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadgeProfileGUI::__construct ( )

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

41 {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $this->tpl = $DIC['tpl'];
47 $this->tabs = $DIC->tabs();
48 $this->user = $DIC->user();
49 $this->access = $DIC->access();
50 $this->factory = $DIC->ui()->factory();
51 $this->renderer = $DIC->ui()->renderer();
52 $this->request = new ilBadgeGUIRequest(
53 $DIC->http(),
54 $DIC->refinery()
55 );
56
57 $this->noti_repo = new BadgeNotificationPrefRepository();
58
59 $this->tile_view = new TileView(
60 $DIC,
61 self::class,
62 new Tile($DIC),
63 new PresentationHeader($DIC, self::class)
64 );
65 }
renderer()
factory()
Badge notification repository (using user preferences.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), factory(), ILIAS\Repository\lng(), renderer(), ILIAS\Repository\tabs(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilBadgeProfileGUI::activate ( )
protected

Definition at line 144 of file class.ilBadgeProfileGUI.php.

144 : void
145 {
147 $ilCtrl = $this->ctrl;
148
149 foreach ($this->getMultiSelection() as $ass) {
150 // already active?
151 if (!$ass->getPosition()) {
152 $ass->setPosition(999);
153 $ass->store();
154 }
155 }
156
157 $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
158 $ilCtrl->redirect($this, 'manageBadges');
159 }
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
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...

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

Referenced by executeCommand().

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

◆ activateInCard()

ilBadgeProfileGUI::activateInCard ( )
protected

Definition at line 178 of file class.ilBadgeProfileGUI.php.

178 : void
179 {
181 $ilCtrl = $this->ctrl;
182
183 foreach ($this->getMultiSelection() as $ass) {
184 // already active?
185 if (!$ass->getPosition()) {
186 $ass->setPosition(999);
187 $ass->store();
188 }
189 }
190
191 $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
192 $ilCtrl->redirect($this, 'listBadges');
193 }

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

+ Here is the call graph for this function:

◆ deactivate()

ilBadgeProfileGUI::deactivate ( )
protected

Definition at line 161 of file class.ilBadgeProfileGUI.php.

161 : void
162 {
164 $ilCtrl = $this->ctrl;
165
166 foreach ($this->getMultiSelection() as $ass) {
167 // already inactive?
168 if ($ass->getPosition()) {
169 $ass->setPosition(null);
170 $ass->store();
171 }
172 }
173
174 $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
175 $ilCtrl->redirect($this, 'manageBadges');
176 }

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

Referenced by executeCommand().

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

◆ deactivateInCard()

ilBadgeProfileGUI::deactivateInCard ( )
protected

Definition at line 195 of file class.ilBadgeProfileGUI.php.

195 : void
196 {
198 $ilCtrl = $this->ctrl;
199
200 foreach ($this->getMultiSelection() as $ass) {
201 // already inactive?
202 if ($ass->getPosition()) {
203 $ass->setPosition(null);
204 $ass->store();
205 }
206 }
207
208 $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
209 $ilCtrl->redirect($this, 'listBadges');
210 }

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

+ Here is the call graph for this function:

◆ editSettings()

ilBadgeProfileGUI::editSettings ( ?ilPropertyFormGUI  $a_form = null)
protected

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

318 : void
319 {
321 $ilCtrl = $this->ctrl;
322 $ilTabs = $this->tabs;
323
324 $ilCtrl->redirect($this, 'listBadges');
325 }
ilGlobalTemplateInterface $tpl

References $ctrl, $tabs, and $tpl.

Referenced by saveSettings().

+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeProfileGUI::executeCommand ( )

Definition at line 67 of file class.ilBadgeProfileGUI.php.

67 : void
68 {
69 $ilCtrl = $this->ctrl;
71
72 $lng->loadLanguageModule('badge');
73
74 switch ($ilCtrl->getNextClass()) {
75 default:
76 $cmd = $ilCtrl->getCmd('listBadges');
77
78 global $DIC;
79 $query = $DIC->http()->wrapper()->query();
80 $action = '';
81 $parameter = 'badge_table_action';
82 if ($cmd === 'action' && $this->query->has($parameter)) {
83 $action = $this->query->retrieve($parameter, $DIC->refinery()->kindlyTo()->string());
84 $cmd = 'listBadges';
85 }
86 if ($action === 'obj_badge_activate') {
87 $this->activate();
88 } elseif ($action === 'obj_badge_deactivate') {
89 $this->deactivate();
90 }
91 $this->$cmd();
92 break;
93 }
94 }
loadLanguageModule(string $a_module)
Load language module.

References $ctrl, $DIC, $lng, activate(), deactivate(), and ilLanguage\loadLanguageModule().

+ Here is the call graph for this function:

◆ getBackpackMail()

ilBadgeProfileGUI::getBackpackMail ( )
protected

Definition at line 287 of file class.ilBadgeProfileGUI.php.

287 : string
288 {
289 $ilUser = $this->user;
290
291 $mail = $ilUser->getPref(self::BACKPACK_EMAIL);
292 if (!$mail) {
293 $mail = $ilUser->getEmail();
294 }
295 return $mail;
296 }
getPref(string $a_keyword)

References $user, and ilObjUser\getPref().

Referenced by initSettingsForm(), listBackpackGroups(), and saveSettings().

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

◆ getMultiSelection()

ilBadgeProfileGUI::getMultiSelection ( )
protected

Definition at line 125 of file class.ilBadgeProfileGUI.php.

125 : array
126 {
127 $ids = $this->request->getBadgeIds();
128 if (count($ids) > 0) {
129 $res = [];
130 foreach ($ids as $id) {
131 $ass = new ilBadgeAssignment($id, $this->user->getId());
132 if ($ass->getTimestamp()) {
133 $res[] = $ass;
134 }
135 }
136
137 return $res;
138 }
139
140 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
141 $this->ctrl->redirect($this, 'manageBadges');
142 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69

References $id, $res, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by activate(), activateInCard(), deactivate(), and deactivateInCard().

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

◆ getSafePostCommands()

ilBadgeProfileGUI::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 96 of file class.ilBadgeProfileGUI.php.

96 : array
97 {
98 return [];
99 }

◆ getUnsafeGetCommands()

ilBadgeProfileGUI::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 101 of file class.ilBadgeProfileGUI.php.

101 : array
102 {
103 return ['action'];
104 }

◆ initSettingsForm()

ilBadgeProfileGUI::initSettingsForm ( )
protected

Definition at line 298 of file class.ilBadgeProfileGUI.php.

299 {
301 $ilCtrl = $this->ctrl;
302
303 $form = new ilPropertyFormGUI();
304 $form->setFormAction($ilCtrl->getFormAction($this, 'saveSettings'));
305 $form->setTitle($lng->txt('settings'));
306
307 $email = new ilEMailInputGUI($lng->txt('badge_backpack_email'), 'email');
308 // $email->setRequired(true);
309 $email->setInfo($lng->txt('badge_backpack_email_info'));
310 $email->setValue($this->getBackpackMail());
311 $form->addItem($email);
312
313 $form->addCommandButton('saveSettings', $lng->txt('save'));
314
315 return $form;
316 }
This class represents a email property in a property form.
This class represents a property form user interface.

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

Referenced by saveSettings().

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

◆ listBackpackGroups()

ilBadgeProfileGUI::listBackpackGroups ( )
protected

Definition at line 233 of file class.ilBadgeProfileGUI.php.

233 : void
234 {
237 $ilCtrl = $this->ctrl;
238 $ilTabs = $this->tabs;
239
240 $this->setBackpackSubTabs();
241 $ilTabs->activateSubTab('backpack_badges');
242
243 $this->tpl->setOnScreenMessage('info', $lng->txt('badge_backpack_gallery_info'));
244
245 $bp = new ilBadgeBackpack($this->getBackpackMail());
246 $bp_groups = $bp->getGroups();
247
248 if (!count($bp_groups)) {
249 $this->tpl->setOnScreenMessage('info', $lng->txt('badge_backpack_no_groups'));
250 return;
251 }
252
253 $tmpl = new ilTemplate('tpl.badge_backpack.html', true, true, 'components/ILIAS/Badge/');
254
255 $tmpl->setVariable('BACKPACK_TITLE', $lng->txt('badge_backpack_list'));
256
258
259 foreach ($bp_groups as $group_id => $group) {
260 $bp_badges = $bp->getBadges($group_id);
261 if (count($bp_badges)) {
262 foreach ($bp_badges as $idx => $badge) {
263 $tmpl->setCurrentBlock('badge_bl');
264 $tmpl->setVariable('BADGE_TITLE', $badge['title']);
265 $tmpl->setVariable('BADGE_DESC', $badge['description']);
266 $tmpl->setVariable('BADGE_IMAGE', $badge['image_url']);
267 $tmpl->setVariable('BADGE_CRITERIA', $badge['criteria_url']);
268 $tmpl->setVariable('BADGE_ISSUER', $badge['issuer_name']);
269 $tmpl->setVariable('BADGE_ISSUER_URL', $badge['issuer_url']);
270 $tmpl->setVariable('BADGE_DATE', ilDatePresentation::formatDate($badge['issued_on']));
271 $tmpl->parseCurrentBlock();
272 }
273 }
274
275 $tmpl->setCurrentBlock('group_bl');
276 $tmpl->setVariable('GROUP_TITLE', $group['title']);
277 $tmpl->parseCurrentBlock();
278 }
279
280 $tpl->setContent($tmpl->get());
281 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
special template class to simplify handling of ITX/PEAR
setContent(string $a_html)
Sets content for standard template.

References $ctrl, $lng, $tabs, $tpl, ilDatePresentation\formatDate(), getBackpackMail(), setBackpackSubTabs(), ILIAS\UICore\GlobalTemplate\setContent(), ilDatePresentation\setUseRelativeDates(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ listBadges()

ilBadgeProfileGUI::listBadges ( )
protected

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

106 : void
107 {
108 $this->tpl->setContent($this->renderDeck($this->tile_view->show()));
109 $this->noti_repo->updateLastCheckedTimestamp();
110 }

References renderDeck().

+ Here is the call graph for this function:

◆ manageBadges()

ilBadgeProfileGUI::manageBadges ( )
protected

Definition at line 119 of file class.ilBadgeProfileGUI.php.

119 : void
120 {
122 $tpl->renderTable(ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'action'));
123 }

References $tpl, and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ renderDeck()

ilBadgeProfileGUI::renderDeck ( string  $deck)
private

Definition at line 112 of file class.ilBadgeProfileGUI.php.

112 : string
113 {
114 $template = new ilTemplate('tpl.badge_backpack.html', true, true, 'components/ILIAS/Badge/');
115 $template->setVariable('DECK', $deck);
116 return $template->get();
117 }

Referenced by listBadges().

+ Here is the caller graph for this function:

◆ saveSettings()

ilBadgeProfileGUI::saveSettings ( )
protected

Definition at line 327 of file class.ilBadgeProfileGUI.php.

327 : void
328 {
329 $ilUser = $this->user;
331 $ilCtrl = $this->ctrl;
332
333 $form = $this->initSettingsForm();
334 if ($form->checkInput()) {
335 $new_email = $form->getInput('email');
336 $old_email = $this->getBackpackMail();
337
338 $ilUser->writePref(self::BACKPACK_EMAIL, $new_email);
339
340 // if email was changed: delete badge files
341 if ($new_email != $old_email) {
342 ilBadgeAssignment::clearBadgeCache($ilUser->getId());
343 }
344
345 $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
346 $ilCtrl->redirect($this, 'editSettings');
347 }
348
349 $form->setValuesByPost();
350 $this->editSettings($form);
351 }
static clearBadgeCache(int $a_user_id)
editSettings(?ilPropertyFormGUI $a_form=null)

References $ctrl, $lng, $user, ilBadgeAssignment\clearBadgeCache(), editSettings(), getBackpackMail(), initSettingsForm(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ setBackpackSubTabs()

ilBadgeProfileGUI::setBackpackSubTabs ( )
protected

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

212 : void
213 {
214 $ilTabs = $this->tabs;
216 $ilCtrl = $this->ctrl;
217
218 $ilTabs->addSubTab(
219 'backpack_badges',
220 $lng->txt('obj_bdga'),
221 $ilCtrl->getLinkTarget($this, 'listBackpackGroups')
222 );
223
224 $ilTabs->addSubTab(
225 'backpack_settings',
226 $lng->txt('settings'),
227 $ilCtrl->getLinkTarget($this, 'editSettings')
228 );
229
230 $ilTabs->activateTab('backpack_badges');
231 }

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

Referenced by listBackpackGroups().

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

Field Documentation

◆ $access

ilAccessHandler ilBadgeProfileGUI::$access
protected

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

◆ $ctrl

◆ $factory

ILIAS UI Factory ilBadgeProfileGUI::$factory
protected

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

◆ $lng

◆ $noti_repo

BadgeNotificationPrefRepository ilBadgeProfileGUI::$noti_repo
protected

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

◆ $renderer

ILIAS UI Renderer ilBadgeProfileGUI::$renderer
protected

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

◆ $request

ilBadgeGUIRequest ilBadgeProfileGUI::$request
protected

Definition at line 28 of file class.ilBadgeProfileGUI.php.

◆ $tabs

ilTabsGUI ilBadgeProfileGUI::$tabs
protected

◆ $tile_view

readonly TileView ilBadgeProfileGUI::$tile_view
private

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

◆ $tpl

ilGlobalTemplateInterface ilBadgeProfileGUI::$tpl
protected

Definition at line 31 of file class.ilBadgeProfileGUI.php.

Referenced by editSettings(), listBackpackGroups(), and manageBadges().

◆ $user

ilObjUser ilBadgeProfileGUI::$user
protected

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

Referenced by getBackpackMail(), and saveSettings().

◆ BACKPACK_EMAIL

final const ilBadgeProfileGUI::BACKPACK_EMAIL = 'badge_mozilla_bp'

Definition at line 26 of file class.ilBadgeProfileGUI.php.


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