ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilBadgeProfileGUI Class Reference

Class ilBadgeProfileGUI. More...

+ Collaboration diagram for ilBadgeProfileGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Data Fields

final const BACKPACK_EMAIL = "badge_mozilla_bp"
 

Protected Member Functions

 setTabs ()
 
 getSubTabs (string $a_active)
 
 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

Constructor & Destructor Documentation

◆ __construct()

ilBadgeProfileGUI::__construct ( )

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

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

46  {
47  global $DIC;
48 
49  $this->ctrl = $DIC->ctrl();
50  $this->lng = $DIC->language();
51  $this->tpl = $DIC["tpl"];
52  $this->tabs = $DIC->tabs();
53  $this->user = $DIC->user();
54  $this->access = $DIC->access();
55  $this->factory = $DIC->ui()->factory();
56  $this->renderer = $DIC->ui()->renderer();
57  $this->request = new ilBadgeGUIRequest(
58  $DIC->http(),
59  $DIC->refinery()
60  );
61 
62  $this->noti_repo = new BadgeNotificationPrefRepository();
63 
64  $this->tile_view = new TileView(
65  $DIC,
66  self::class,
67  new Tile($DIC),
68  new PresentationHeader($DIC, self::class)
69  );
70  }
Badge notification repository (using user preferences.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilBadgeProfileGUI::activate ( )
protected

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

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

160  : void
161  {
162  $lng = $this->lng;
163  $ilCtrl = $this->ctrl;
164 
165  foreach ($this->getMultiSelection() as $ass) {
166  // already active?
167  if (!$ass->getPosition()) {
168  $ass->setPosition(999);
169  $ass->store();
170  }
171  }
172 
173  $this->tpl->setOnScreenMessage('success', $lng->txt("position_updated"), true);
174  $ilCtrl->redirect($this, "manageBadges");
175  }
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...
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:

◆ activateInCard()

ilBadgeProfileGUI::activateInCard ( )
protected

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

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

194  : void
195  {
196  $lng = $this->lng;
197  $ilCtrl = $this->ctrl;
198 
199  foreach ($this->getMultiSelection() as $ass) {
200  // already active?
201  if (!$ass->getPosition()) {
202  $ass->setPosition(999);
203  $ass->store();
204  }
205  }
206 
207  $this->tpl->setOnScreenMessage('success', $lng->txt("position_updated"), true);
208  $ilCtrl->redirect($this, "listBadges");
209  }
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...
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:

◆ deactivate()

ilBadgeProfileGUI::deactivate ( )
protected

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

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

177  : void
178  {
179  $lng = $this->lng;
180  $ilCtrl = $this->ctrl;
181 
182  foreach ($this->getMultiSelection() as $ass) {
183  // already inactive?
184  if ($ass->getPosition()) {
185  $ass->setPosition(null);
186  $ass->store();
187  }
188  }
189 
190  $this->tpl->setOnScreenMessage('success', $lng->txt("position_updated"), true);
191  $ilCtrl->redirect($this, "manageBadges");
192  }
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...
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:

◆ deactivateInCard()

ilBadgeProfileGUI::deactivateInCard ( )
protected

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

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

211  : void
212  {
213  $lng = $this->lng;
214  $ilCtrl = $this->ctrl;
215 
216  foreach ($this->getMultiSelection() as $ass) {
217  // already inactive?
218  if ($ass->getPosition()) {
219  $ass->setPosition(null);
220  $ass->store();
221  }
222  }
223 
224  $this->tpl->setOnScreenMessage('success', $lng->txt("position_updated"), true);
225  $ilCtrl->redirect($this, "listBadges");
226  }
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...
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:

◆ editSettings()

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

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

References $ctrl, $tabs, and $tpl.

Referenced by saveSettings().

334  : void
335  {
336  $tpl = $this->tpl;
337  $ilCtrl = $this->ctrl;
338  $ilTabs = $this->tabs;
339 
340  $ilCtrl->redirect($this, "listBadges");
341  }
ilGlobalTemplateInterface $tpl
+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeProfileGUI::executeCommand ( )

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

References $ctrl, $lng, ilLanguage\loadLanguageModule(), and setTabs().

72  : void
73  {
74  $ilCtrl = $this->ctrl;
75  $lng = $this->lng;
76 
77  $lng->loadLanguageModule("badge");
78 
79  switch ($ilCtrl->getNextClass()) {
80  default:
81  $this->setTabs();
82  $cmd = $ilCtrl->getCmd("listBadges");
83  $this->$cmd();
84  break;
85  }
86  }
loadLanguageModule(string $a_module)
Load language module.
+ Here is the call graph for this function:

◆ getBackpackMail()

ilBadgeProfileGUI::getBackpackMail ( )
protected

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

References $user, and ilObjUser\getPref().

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

303  : string
304  {
305  $ilUser = $this->user;
306 
307  $mail = $ilUser->getPref(self::BACKPACK_EMAIL);
308  if (!$mail) {
309  $mail = $ilUser->getEmail();
310  }
311  return $mail;
312  }
getPref(string $a_keyword)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMultiSelection()

ilBadgeProfileGUI::getMultiSelection ( )
protected

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

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

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

136  : array
137  {
138  $lng = $this->lng;
139  $ilCtrl = $this->ctrl;
140  $ilUser = $this->user;
141 
142  $ids = $this->request->getBadgeIds();
143  if (count($ids) > 0) {
144  $res = array();
145  foreach ($ids as $id) {
146  $ass = new ilBadgeAssignment($id, $ilUser->getId());
147  if ($ass->getTimestamp()) {
148  $res[] = $ass;
149  }
150  }
151 
152  return $res;
153  }
154 
155  $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"), true);
156  $ilCtrl->redirect($this, "manageBadges");
157  return [];
158  }
$res
Definition: ltiservices.php:69
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...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubTabs()

ilBadgeProfileGUI::getSubTabs ( string  $a_active)
protected

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

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

95  : void
96  {
97  $ilTabs = $this->tabs;
98  $lng = $this->lng;
99  $ilCtrl = $this->ctrl;
100 
101  $ilTabs->addTab(
102  "list",
103  $lng->txt("badge_profile_view"),
104  $ilCtrl->getLinkTarget($this, "listBadges")
105  );
106  $ilTabs->addTab(
107  "manage",
108  $lng->txt("badge_profile_manage"),
109  $ilCtrl->getLinkTarget($this, "manageBadges")
110  );
111  $ilTabs->activateTab($a_active);
112  }
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:

◆ initSettingsForm()

ilBadgeProfileGUI::initSettingsForm ( )
protected

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

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

Referenced by saveSettings().

315  {
316  $lng = $this->lng;
317  $ilCtrl = $this->ctrl;
318 
319  $form = new ilPropertyFormGUI();
320  $form->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
321  $form->setTitle($lng->txt("settings"));
322 
323  $email = new ilEMailInputGUI($lng->txt("badge_backpack_email"), "email");
324  // $email->setRequired(true);
325  $email->setInfo($lng->txt("badge_backpack_email_info"));
326  $email->setValue($this->getBackpackMail());
327  $form->addItem($email);
328 
329  $form->addCommandButton("saveSettings", $lng->txt("save"));
330 
331  return $form;
332  }
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...
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:

◆ listBackpackGroups()

ilBadgeProfileGUI::listBackpackGroups ( )
protected

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

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

249  : void
250  {
251  $lng = $this->lng;
252  $tpl = $this->tpl;
253  $ilCtrl = $this->ctrl;
254  $ilTabs = $this->tabs;
255 
256  $this->setBackpackSubTabs();
257  $ilTabs->activateSubTab("backpack_badges");
258 
259  $this->tpl->setOnScreenMessage('info', $lng->txt("badge_backpack_gallery_info"));
260 
261  $bp = new ilBadgeBackpack($this->getBackpackMail());
262  $bp_groups = $bp->getGroups();
263 
264  if (!count($bp_groups)) {
265  $this->tpl->setOnScreenMessage('info', $lng->txt("badge_backpack_no_groups"));
266  return;
267  }
268 
269  $tmpl = new ilTemplate("tpl.badge_backpack.html", true, true, "Services/Badge");
270 
271  $tmpl->setVariable("BACKPACK_TITLE", $lng->txt("badge_backpack_list"));
272 
274 
275  foreach ($bp_groups as $group_id => $group) {
276  $bp_badges = $bp->getBadges($group_id);
277  if (count($bp_badges)) {
278  foreach ($bp_badges as $idx => $badge) {
279  $tmpl->setCurrentBlock("badge_bl");
280  $tmpl->setVariable("BADGE_TITLE", $badge["title"]);
281  $tmpl->setVariable("BADGE_DESC", $badge["description"]);
282  $tmpl->setVariable("BADGE_IMAGE", $badge["image_url"]);
283  $tmpl->setVariable("BADGE_CRITERIA", $badge["criteria_url"]);
284  $tmpl->setVariable("BADGE_ISSUER", $badge["issuer_name"]);
285  $tmpl->setVariable("BADGE_ISSUER_URL", $badge["issuer_url"]);
286  $tmpl->setVariable("BADGE_DATE", ilDatePresentation::formatDate($badge["issued_on"]));
287  $tmpl->parseCurrentBlock();
288  }
289  }
290 
291  $tmpl->setCurrentBlock("group_bl");
292  $tmpl->setVariable("GROUP_TITLE", $group["title"]);
293  $tmpl->parseCurrentBlock();
294  }
295 
296  $tpl->setContent($tmpl->get());
297  }
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
static setUseRelativeDates(bool $a_status)
set use relative dates
+ Here is the call graph for this function:

◆ listBadges()

ilBadgeProfileGUI::listBadges ( )
protected

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

References renderDeck().

114  : void
115  {
116  $this->tpl->setContent($this->renderDeck($this->tile_view->show()));
117  $this->noti_repo->updateLastCheckedTimestamp();
118  }
+ Here is the call graph for this function:

◆ manageBadges()

ilBadgeProfileGUI::manageBadges ( )
protected

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

References $DIC, and ILIAS\Repository\lng().

127  : void
128  {
129  global $DIC;
130 
131  $table = new ilBadgePersonalTableGUI($this, "manageBadges");
132  (new PresentationHeader($DIC, self::class))->show($this->lng->txt('table_view'));
133  $this->tpl->setContent($table->getHTML());
134  }
global $DIC
Definition: feed.php:28
TableGUI class for user badge listing.
+ Here is the call graph for this function:

◆ renderDeck()

ilBadgeProfileGUI::renderDeck ( string  $deck)
private

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

Referenced by listBadges().

120  : string
121  {
122  $template = new ilTemplate('tpl.badge_backpack.html', true, true, 'Services/Badge');
123  $template->setVariable('DECK', $deck);
124  return $template->get();
125  }
+ Here is the caller graph for this function:

◆ saveSettings()

ilBadgeProfileGUI::saveSettings ( )
protected

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

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

343  : void
344  {
345  $ilUser = $this->user;
346  $lng = $this->lng;
347  $ilCtrl = $this->ctrl;
348 
349  $form = $this->initSettingsForm();
350  if ($form->checkInput()) {
351  $new_email = $form->getInput("email");
352  $old_email = $this->getBackpackMail();
353 
354  ilObjUser::_writePref($ilUser->getId(), self::BACKPACK_EMAIL, $new_email);
355 
356  // if email was changed: delete badge files
357  if ($new_email != $old_email) {
358  ilBadgeAssignment::clearBadgeCache($ilUser->getId());
359  }
360 
361  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
362  $ilCtrl->redirect($this, "editSettings");
363  }
364 
365  $form->setValuesByPost();
366  $this->editSettings($form);
367  }
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...
editSettings(ilPropertyFormGUI $a_form=null)
static clearBadgeCache(int $a_user_id)
static _writePref(int $a_usr_id, string $a_keyword, string $a_value)
+ Here is the call graph for this function:

◆ setBackpackSubTabs()

ilBadgeProfileGUI::setBackpackSubTabs ( )
protected

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

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

Referenced by listBackpackGroups().

228  : void
229  {
230  $ilTabs = $this->tabs;
231  $lng = $this->lng;
232  $ilCtrl = $this->ctrl;
233 
234  $ilTabs->addSubTab(
235  "backpack_badges",
236  $lng->txt("obj_bdga"),
237  $ilCtrl->getLinkTarget($this, "listBackpackGroups")
238  );
239 
240  $ilTabs->addSubTab(
241  "backpack_settings",
242  $lng->txt("settings"),
243  $ilCtrl->getLinkTarget($this, "editSettings")
244  );
245 
246  $ilTabs->activateTab("backpack_badges");
247  }
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:

◆ setTabs()

ilBadgeProfileGUI::setTabs ( )
protected

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

References $ctrl, $lng, and $tabs.

Referenced by executeCommand().

88  : void
89  {
90  $ilTabs = $this->tabs;
91  $lng = $this->lng;
92  $ilCtrl = $this->ctrl;
93  }
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilBadgeProfileGUI::$access
protected

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

◆ $ctrl

◆ $factory

ILIAS UI Factory ilBadgeProfileGUI::$factory
protected

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

◆ $lng

◆ $noti_repo

BadgeNotificationPrefRepository ilBadgeProfileGUI::$noti_repo
protected

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

◆ $renderer

ILIAS UI Renderer ilBadgeProfileGUI::$renderer
protected

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

◆ $request

ilBadgeGUIRequest ilBadgeProfileGUI::$request
protected

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

◆ $tabs

ilTabsGUI ilBadgeProfileGUI::$tabs
protected

◆ $tile_view

readonly TileView ilBadgeProfileGUI::$tile_view
private

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

◆ $tpl

ilGlobalTemplateInterface ilBadgeProfileGUI::$tpl
protected

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

Referenced by editSettings(), and listBackpackGroups().

◆ $user

ilObjUser ilBadgeProfileGUI::$user
protected

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

Referenced by getBackpackMail(), getMultiSelection(), and saveSettings().

◆ BACKPACK_EMAIL

final const ilBadgeProfileGUI::BACKPACK_EMAIL = "badge_mozilla_bp"

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


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