ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBadgeProfileGUI Class Reference
+ Collaboration diagram for ilBadgeProfileGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

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.

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

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  }
factory()
renderer()
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilBadgeProfileGUI::activate ( )
protected

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

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

Referenced by executeCommand().

133  : void
134  {
135  $lng = $this->lng;
136  $ilCtrl = $this->ctrl;
137 
138  foreach ($this->getMultiSelection() as $ass) {
139  // already active?
140  if (!$ass->getPosition()) {
141  $ass->setPosition(999);
142  $ass->store();
143  }
144  }
145 
146  $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
147  $ilCtrl->redirect($this, 'manageBadges');
148  }
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:
+ Here is the caller graph for this function:

◆ activateInCard()

ilBadgeProfileGUI::activateInCard ( )
protected

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

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

167  : void
168  {
169  $lng = $this->lng;
170  $ilCtrl = $this->ctrl;
171 
172  foreach ($this->getMultiSelection() as $ass) {
173  // already active?
174  if (!$ass->getPosition()) {
175  $ass->setPosition(999);
176  $ass->store();
177  }
178  }
179 
180  $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
181  $ilCtrl->redirect($this, 'listBadges');
182  }
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 150 of file class.ilBadgeProfileGUI.php.

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

Referenced by executeCommand().

150  : void
151  {
152  $lng = $this->lng;
153  $ilCtrl = $this->ctrl;
154 
155  foreach ($this->getMultiSelection() as $ass) {
156  // already inactive?
157  if ($ass->getPosition()) {
158  $ass->setPosition(null);
159  $ass->store();
160  }
161  }
162 
163  $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
164  $ilCtrl->redirect($this, 'manageBadges');
165  }
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
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:

◆ deactivateInCard()

ilBadgeProfileGUI::deactivateInCard ( )
protected

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

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

184  : void
185  {
186  $lng = $this->lng;
187  $ilCtrl = $this->ctrl;
188 
189  foreach ($this->getMultiSelection() as $ass) {
190  // already inactive?
191  if ($ass->getPosition()) {
192  $ass->setPosition(null);
193  $ass->store();
194  }
195  }
196 
197  $this->tpl->setOnScreenMessage('success', $lng->txt('position_updated'), true);
198  $ilCtrl->redirect($this, 'listBadges');
199  }
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
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 307 of file class.ilBadgeProfileGUI.php.

References $ctrl, $tabs, and $tpl.

Referenced by saveSettings().

307  : void
308  {
309  $tpl = $this->tpl;
310  $ilCtrl = $this->ctrl;
311  $ilTabs = $this->tabs;
312 
313  $ilCtrl->redirect($this, 'listBadges');
314  }
ilGlobalTemplateInterface $tpl
+ Here is the caller graph for this function:

◆ executeCommand()

ilBadgeProfileGUI::executeCommand ( )

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

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

67  : void
68  {
69  $ilCtrl = $this->ctrl;
70  $lng = $this->lng;
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 ($query->has($parameter)) {
83  $action = $query->retrieve($parameter, $DIC->refinery()->kindlyTo()->string());
84  }
85  if ($action === 'obj_badge_activate') {
86  $this->activate();
87  } elseif ($action === 'obj_badge_deactivate') {
88  $this->deactivate();
89  }
90  $this->$cmd();
91  break;
92  }
93  }
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ getBackpackMail()

ilBadgeProfileGUI::getBackpackMail ( )
protected

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

References $user, and ilObjUser\getPref().

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

276  : string
277  {
278  $ilUser = $this->user;
279 
280  $mail = $ilUser->getPref(self::BACKPACK_EMAIL);
281  if (!$mail) {
282  $mail = $ilUser->getEmail();
283  }
284  return $mail;
285  }
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 114 of file class.ilBadgeProfileGUI.php.

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

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

114  : array
115  {
116  $ids = $this->request->getBadgeIds();
117  if (count($ids) > 0) {
118  $res = [];
119  foreach ($ids as $id) {
120  $ass = new ilBadgeAssignment($id, $this->user->getId());
121  if ($ass->getTimestamp()) {
122  $res[] = $ass;
123  }
124  }
125 
126  return $res;
127  }
128 
129  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'), true);
130  $this->ctrl->redirect($this, 'manageBadges');
131  }
$res
Definition: ltiservices.php:66
$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:

◆ initSettingsForm()

ilBadgeProfileGUI::initSettingsForm ( )
protected

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

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

Referenced by saveSettings().

288  {
289  $lng = $this->lng;
290  $ilCtrl = $this->ctrl;
291 
292  $form = new ilPropertyFormGUI();
293  $form->setFormAction($ilCtrl->getFormAction($this, 'saveSettings'));
294  $form->setTitle($lng->txt('settings'));
295 
296  $email = new ilEMailInputGUI($lng->txt('badge_backpack_email'), 'email');
297  // $email->setRequired(true);
298  $email->setInfo($lng->txt('badge_backpack_email_info'));
299  $email->setValue($this->getBackpackMail());
300  $form->addItem($email);
301 
302  $form->addCommandButton('saveSettings', $lng->txt('save'));
303 
304  return $form;
305  }
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 class represents a email property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listBackpackGroups()

ilBadgeProfileGUI::listBackpackGroups ( )
protected

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

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

222  : void
223  {
224  $lng = $this->lng;
225  $tpl = $this->tpl;
226  $ilCtrl = $this->ctrl;
227  $ilTabs = $this->tabs;
228 
229  $this->setBackpackSubTabs();
230  $ilTabs->activateSubTab('backpack_badges');
231 
232  $this->tpl->setOnScreenMessage('info', $lng->txt('badge_backpack_gallery_info'));
233 
234  $bp = new ilBadgeBackpack($this->getBackpackMail());
235  $bp_groups = $bp->getGroups();
236 
237  if (!count($bp_groups)) {
238  $this->tpl->setOnScreenMessage('info', $lng->txt('badge_backpack_no_groups'));
239  return;
240  }
241 
242  $tmpl = new ilTemplate('tpl.badge_backpack.html', true, true, 'components/ILIAS/Badge/');
243 
244  $tmpl->setVariable('BACKPACK_TITLE', $lng->txt('badge_backpack_list'));
245 
247 
248  foreach ($bp_groups as $group_id => $group) {
249  $bp_badges = $bp->getBadges($group_id);
250  if (count($bp_badges)) {
251  foreach ($bp_badges as $idx => $badge) {
252  $tmpl->setCurrentBlock('badge_bl');
253  $tmpl->setVariable('BADGE_TITLE', $badge['title']);
254  $tmpl->setVariable('BADGE_DESC', $badge['description']);
255  $tmpl->setVariable('BADGE_IMAGE', $badge['image_url']);
256  $tmpl->setVariable('BADGE_CRITERIA', $badge['criteria_url']);
257  $tmpl->setVariable('BADGE_ISSUER', $badge['issuer_name']);
258  $tmpl->setVariable('BADGE_ISSUER_URL', $badge['issuer_url']);
259  $tmpl->setVariable('BADGE_DATE', ilDatePresentation::formatDate($badge['issued_on']));
260  $tmpl->parseCurrentBlock();
261  }
262  }
263 
264  $tmpl->setCurrentBlock('group_bl');
265  $tmpl->setVariable('GROUP_TITLE', $group['title']);
266  $tmpl->parseCurrentBlock();
267  }
268 
269  $tpl->setContent($tmpl->get());
270  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
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...
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:

◆ listBadges()

ilBadgeProfileGUI::listBadges ( )
protected

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

References renderDeck().

95  : void
96  {
97  $this->tpl->setContent($this->renderDeck($this->tile_view->show()));
98  $this->noti_repo->updateLastCheckedTimestamp();
99  }
+ Here is the call graph for this function:

◆ manageBadges()

ilBadgeProfileGUI::manageBadges ( )
protected

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

108  : void
109  {
111  $tpl->renderTable();
112  }
ilGlobalTemplateInterface $tpl

◆ renderDeck()

ilBadgeProfileGUI::renderDeck ( string  $deck)
private

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

Referenced by listBadges().

101  : string
102  {
103  $template = new ilTemplate('tpl.badge_backpack.html', true, true, 'components/ILIAS/Badge/');
104  $template->setVariable('DECK', $deck);
105  return $template->get();
106  }
+ Here is the caller graph for this function:

◆ saveSettings()

ilBadgeProfileGUI::saveSettings ( )
protected

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

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

316  : void
317  {
318  $ilUser = $this->user;
319  $lng = $this->lng;
320  $ilCtrl = $this->ctrl;
321 
322  $form = $this->initSettingsForm();
323  if ($form->checkInput()) {
324  $new_email = $form->getInput('email');
325  $old_email = $this->getBackpackMail();
326 
327  ilObjUser::_writePref($ilUser->getId(), self::BACKPACK_EMAIL, $new_email);
328 
329  // if email was changed: delete badge files
330  if ($new_email != $old_email) {
331  ilBadgeAssignment::clearBadgeCache($ilUser->getId());
332  }
333 
334  $this->tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
335  $ilCtrl->redirect($this, 'editSettings');
336  }
337 
338  $form->setValuesByPost();
339  $this->editSettings($form);
340  }
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 201 of file class.ilBadgeProfileGUI.php.

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

Referenced by listBackpackGroups().

201  : void
202  {
203  $ilTabs = $this->tabs;
204  $lng = $this->lng;
205  $ilCtrl = $this->ctrl;
206 
207  $ilTabs->addSubTab(
208  'backpack_badges',
209  $lng->txt('obj_bdga'),
210  $ilCtrl->getLinkTarget($this, 'listBackpackGroups')
211  );
212 
213  $ilTabs->addSubTab(
214  'backpack_settings',
215  $lng->txt('settings'),
216  $ilCtrl->getLinkTarget($this, 'editSettings')
217  );
218 
219  $ilTabs->activateTab('backpack_badges');
220  }
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:

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(), and listBackpackGroups().

◆ $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: