ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSessionOverviewGUI Class Reference
+ Collaboration diagram for ilSessionOverviewGUI:

Public Member Functions

 __construct (int $a_crs_ref_id, ilParticipants $a_members)
 
 executeCommand ()
 
 listSessions ()
 list sessions of all user More...
 
 exportCSV ()
 

Protected Attributes

ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilErrorHandling $error
 
ilTree $tree
 
ilAccessHandler $access
 
int $course_ref_id = 0
 
int $course_id = 0
 
ilParticipants $members_obj
 
ilCSVWriter $csv
 

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 29 of file class.ilSessionOverviewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSessionOverviewGUI::__construct ( int  $a_crs_ref_id,
ilParticipants  $a_members 
)

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

References $DIC, ilObject\_lookupObjId(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

44  {
45  global $DIC;
46 
47  $this->tpl = $DIC->ui()->mainTemplate();
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50  $this->toolbar = $DIC->toolbar();
51  $this->error = $DIC['ilErr'];
52  $this->tree = $DIC->repositoryTree();
53  $this->access = $DIC->access();
54 
55  $this->lng->loadLanguageModule('event');
56  $this->lng->loadLanguageModule('crs');
57 
58  $this->course_ref_id = $a_crs_ref_id;
59  $this->course_id = ilObject::_lookupObjId($this->course_ref_id);
60  $this->members_obj = $a_members;
61  }
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilSessionOverviewGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

63  : void
64  {
65  $next_class = $this->ctrl->getNextClass($this);
66  $cmd = $this->ctrl->getCmd();
67 
68  switch ($next_class) {
69  default:
70  if (!$cmd) {
71  $cmd = "listSessions";
72  }
73  $this->$cmd();
74  break;
75  }
76  }
+ Here is the call graph for this function:

◆ exportCSV()

ilSessionOverviewGUI::exportCSV ( )

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

References Vendor\Package\$a, $access, Vendor\Package\$b, $name, $tree, ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilUtil\deliverData(), ilOrgUnitPositionAndRBACAccessHandler\filterUserIdsByRbacOrPositionOfCurrentUser(), ilObjectFactory\getInstanceByRefId(), ilTree\getNodeData(), IL_CAL_FKT_DATE, IL_CAL_UNIX, ILIAS\Repository\int(), and ILIAS\Repository\lng().

108  : void
109  {
110  $tree = $this->tree;
111  $ilAccess = $this->access;
112 
114  'manage_members',
115  'manage_members',
116  $this->course_ref_id,
117  $this->members_obj->getParticipants()
118  );
119 
120  $sortedMembers = [];
121  foreach($part as $user_id) {
122  $name = ilObjUser::_lookupName($user_id);
123  $sortedMembers[] = [
124  'userid' => (int) $user_id,
125  'firstname' => (string) $name["firstname"],
126  'lastname' => (string) $name['lastname']
127  ];
128  }
129  usort($sortedMembers, function ($a, $b) {
130  return $a['lastname'] <=> $b['lastname'];
131  });
132 
133  $events = [];
134  foreach ($tree->getSubtree($tree->getNodeData($this->course_ref_id), false, ['sess']) as $event_id) {
135  $tmp_event = ilObjectFactory::getInstanceByRefId($event_id, false);
136  if (!is_object($tmp_event) || !$ilAccess->checkAccess('manage_members', '', $event_id)) {
137  continue;
138  }
139  $events[] = $tmp_event;
140  }
141 
142  $this->csv = new ilCSVWriter();
143  $this->csv->addColumn($this->lng->txt("lastname"));
144  $this->csv->addColumn($this->lng->txt("firstname"));
145  $this->csv->addColumn($this->lng->txt("login"));
146 
147  foreach ($events as $event_obj) {
148  // TODO: do not export relative dates
149  $this->csv->addColumn($event_obj->getTitle() . ' (' . $event_obj->getFirstAppointment()->appointmentToString() . ')');
150  }
151 
152  $this->csv->addRow();
153 
154  foreach ($sortedMembers as $member) {
155  $this->csv->addColumn($member['lastname']);
156  $this->csv->addColumn($member['firstname']);
157  $this->csv->addColumn(ilObjUser::_lookupLogin($member['userid']));
158 
159  foreach ($events as $event_obj) {
160  $event_part = new ilEventParticipants($event_obj->getId());
161 
162  $this->csv->addColumn($event_part->hasParticipated($member['userid']) ?
163  $this->lng->txt('event_participated') :
164  $this->lng->txt('event_not_participated'));
165  }
166 
167  $this->csv->addRow();
168  }
169  $date = new ilDate(time(), IL_CAL_UNIX);
170 
172  $this->csv->getCSVString(),
173  $date->get(IL_CAL_FKT_DATE, 'Y-m-d') . "_course_events.csv",
174  "text/csv"
175  );
176  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
static _lookupName(int $a_user_id)
lookup user name
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
const IL_CAL_UNIX
if($format !==null) $name
Definition: metadata.php:247
filterUserIdsByRbacOrPositionOfCurrentUser(string $rbac_perm, string $pos_perm, int $ref_id, array $user_ids)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
const IL_CAL_FKT_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:

◆ listSessions()

ilSessionOverviewGUI::listSessions ( )

list sessions of all user

Definition at line 81 of file class.ilSessionOverviewGUI.php.

References $access, $error, $ilErr, $toolbar, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

82  {
83  $ilToolbar = $this->toolbar;
85  $ilAccess = $this->access;
86 
87  if (!$ilAccess->checkRbacOrPositionPermissionAccess('manage_members', 'manage_members', $this->course_ref_id)) {
88  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
89  }
90 
91  $ilToolbar->addButton(
92  $this->lng->txt('event_csv_export'),
93  $this->ctrl->getLinkTarget($this, 'exportCSV')
94  );
95 
96  $part = $this->members_obj->getParticipants();
97  $part = $ilAccess->filterUserIdsByRbacOrPositionOfCurrentUser(
98  'manage_members',
99  'manage_members',
100  $this->course_ref_id,
101  $part
102  );
103 
104  $tbl = new ilSessionOverviewTableGUI($this, 'listSessions', $this->course_ref_id, $part);
105  $this->tpl->setContent($tbl->getHTML());
106  }
Table presentation for session overview.
$ilErr
Definition: raiseError.php:17
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilSessionOverviewGUI::$access
protected

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

Referenced by exportCSV(), and listSessions().

◆ $course_id

int ilSessionOverviewGUI::$course_id = 0
protected

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

◆ $course_ref_id

int ilSessionOverviewGUI::$course_ref_id = 0
protected

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

◆ $csv

ilCSVWriter ilSessionOverviewGUI::$csv
protected

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

◆ $ctrl

ilCtrl ilSessionOverviewGUI::$ctrl
protected

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

◆ $error

ilErrorHandling ilSessionOverviewGUI::$error
protected

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

Referenced by listSessions().

◆ $lng

ilLanguage ilSessionOverviewGUI::$lng
protected

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

◆ $members_obj

ilParticipants ilSessionOverviewGUI::$members_obj
protected

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

◆ $toolbar

ilToolbarGUI ilSessionOverviewGUI::$toolbar
protected

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

Referenced by listSessions().

◆ $tpl

ilGlobalTemplateInterface ilSessionOverviewGUI::$tpl
protected

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

◆ $tree

ilTree ilSessionOverviewGUI::$tree
protected

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

Referenced by exportCSV().


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