ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSessionStatisticsGUI Class Reference

Class ilSessionStatisticsGUI. More...

+ Collaboration diagram for ilSessionStatisticsGUI:

Public Member Functions

 executeCommand ()
 

Data Fields

const MODE_TODAY = 1
 
const MODE_LAST_DAY = 2
 
const MODE_LAST_WEEK = 3
 
const MODE_LAST_MONTH = 4
 
const MODE_DAY = 5
 
const MODE_WEEK = 6
 
const MODE_MONTH = 7
 
const MODE_YEAR = 8
 
const SCALE_DAY = 1
 
const SCALE_WEEK = 2
 
const SCALE_MONTH = 3
 
const SCALE_YEAR = 4
 
const SCALE_PERIODIC_WEEK = 5
 

Protected Member Functions

 setSubTabs ()
 
 current ($a_export=false)
 
 currentExport ()
 
 importDate ($a_incoming, $a_default=null)
 
 short ($a_export=false)
 
 shortExport ()
 
 long ($a_export=false)
 
 longExport ()
 
 periodic ($a_export=false)
 
 periodicExport ()
 
 renderCurrentBasics ()
 
 buildData ($a_time_from, $a_time_to, $a_title)
 
 render ($a_data, $a_scale, $a_measure=null)
 
 getChart ($a_data, $a_title, $a_scale=self::SCALE_DAY, $a_measure=null)
 Build chart for active sessions. More...
 
 adaptDataToScale ($a_scale, array $a_data)
 
 adminSync ()
 
 exportCSV (array $a_data, $a_scale)
 

Detailed Description

Class ilSessionStatisticsGUI.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilLPListOfObjectsGUI.php 27489 2011-01-19 16:58:09Z jluetzen

Definition at line 15 of file class.ilSessionStatisticsGUI.php.

Member Function Documentation

◆ adaptDataToScale()

ilSessionStatisticsGUI::adaptDataToScale (   $a_scale,
array  $a_data 
)
protected

Definition at line 692 of file class.ilSessionStatisticsGUI.php.

693 {
694 // can we use original data?
695 switch ($a_scale) {
696 case self::SCALE_DAY:
697 // 96 values => ok
698 // fallthrough
699
700 case self::SCALE_WEEK:
701 // 672 values => ok
702 return $a_data;
703 }
704
705 $tmp = array();
706 foreach ($a_data as $item) {
707 $date_parts = getdate($item["slot_begin"]);
708
709 // aggregate slots for scale
710 switch ($a_scale) {
712 // aggregate to hours => 720 values
713 $slot = mktime($date_parts["hours"], 0, 0, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
714 break;
715
716 case self::SCALE_YEAR:
717 // aggregate to days => 365 values
718 $slot = mktime(0, 0, 1, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
719 break;
720
722 // aggregate to weekdays => 672 values
723 $day = $date_parts["wday"];
724 if (!$day) {
725 $day = 7;
726 }
727 $slot = $day . date("His", $item["slot_begin"]);
728 break;
729 }
730
731 // process minx/max, prepare avg
732 foreach ($item as $id => $value) {
733 switch (substr($id, -3)) {
734 case "min":
735 if (!$tmp[$slot][$id] || $value < $tmp[$slot][$id]) {
736 $tmp[$slot][$id] = $value;
737 }
738 break;
739
740 case "max":
741 if (!$tmp[$slot][$id] || $value > $tmp[$slot][$id]) {
742 $tmp[$slot][$id] = $value;
743 }
744 break;
745
746 case "avg":
747 $tmp[$slot][$id][] = $value;
748 break;
749 }
750 }
751 }
752
753 foreach ($tmp as $slot => $attr) {
754 $tmp[$slot]["active_avg"] = (int) round(array_sum($attr["active_avg"]) / sizeof($attr["active_avg"]));
755 $tmp[$slot]["slot_begin"] = $slot;
756 }
757 ksort($tmp);
758 return array_values($tmp);
759 }

References SCALE_DAY, SCALE_MONTH, SCALE_PERIODIC_WEEK, SCALE_WEEK, and SCALE_YEAR.

Referenced by exportCSV(), and getChart().

+ Here is the caller graph for this function:

◆ adminSync()

ilSessionStatisticsGUI::adminSync ( )
protected

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

762 {
763 global $DIC;
764
765 $ilCtrl = $DIC['ilCtrl'];
766 $lng = $DIC['lng'];
767
768 // see ilSession::_writeData()
769 $now = time();
772
773 ilUtil::sendSuccess($lng->txt("trac_sync_session_stats_success"), true);
774 $ilCtrl->redirect($this);
775 }
static aggretateRaw($a_now)
Aggregate raw session data (older than given time)
static _destroyExpiredSessions()
Destroy expired sessions.
global $ilCtrl
Definition: ilias.php:18
$lng
$DIC
Definition: xapitoken.php:46

References $DIC, $ilCtrl, $lng, ilSession\_destroyExpiredSessions(), and ilSessionStatistics\aggretateRaw().

+ Here is the call graph for this function:

◆ buildData()

ilSessionStatisticsGUI::buildData (   $a_time_from,
  $a_time_to,
  $a_title 
)
protected

Definition at line 491 of file class.ilSessionStatisticsGUI.php.

492 {
493 global $DIC;
494
495 $lng = $DIC['lng'];
496
497 // basic data - time related
498
499 $maxed_out_duration = round(ilSessionStatistics::getMaxedOutDuration($a_time_from, $a_time_to) / 60);
500 $counters = ilSessionStatistics::getNumberOfSessionsByType($a_time_from, $a_time_to);
501 $opened = (int) $counters["opened"];
502 $closed_limit = (int) $counters["closed_limit"];
503 unset($counters["opened"]);
504 unset($counters["closed_limit"]);
505
506
507 // build center column
508
509 $data = array();
510
512 $data["title"] = $a_title . " (" .
514 new ilDateTime($a_time_from, IL_CAL_UNIX),
515 new ilDateTime($a_time_to, IL_CAL_UNIX)
516 ) . ")";
517
518 $data["maxed_out_time"] = array($lng->txt("trac_maxed_out_time"), $maxed_out_duration);
519 $data["maxed_out_counter"] = array($lng->txt("trac_maxed_out_counter"), $closed_limit);
520 $data["opened"] = array($lng->txt("trac_sessions_opened"), $opened);
521 $data["closed"] = array($lng->txt("trac_sessions_closed"), array_sum($counters));
522 foreach ($counters as $type => $counter) {
523 $data["closed_details"][] = array($lng->txt("trac_" . $type), (int) $counter);
524 }
525
526 $data["active"] = ilSessionStatistics::getActiveSessions($a_time_from, $a_time_to);
527
528 return $data;
529 }
const IL_CAL_UNIX
static setUseRelativeDates($a_status)
set use relative dates
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
@classDescription Date and time handling
static getActiveSessions($a_from, $a_to)
Get active sessions aggregated data.
static getMaxedOutDuration($a_from, $a_to)
Get maxed out duration in given timeframe.
static getNumberOfSessionsByType($a_from, $a_to)
Get session counters by type (opened, closed)
$type
$data
Definition: storeScorm.php:23

References $data, $DIC, $lng, $type, ilDatePresentation\formatPeriod(), ilSessionStatistics\getActiveSessions(), ilSessionStatistics\getMaxedOutDuration(), ilSessionStatistics\getNumberOfSessionsByType(), IL_CAL_UNIX, and ilDatePresentation\setUseRelativeDates().

Referenced by current(), long(), periodic(), and short().

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

◆ current()

ilSessionStatisticsGUI::current (   $a_export = false)
protected

Definition at line 79 of file class.ilSessionStatisticsGUI.php.

80 {
81 global $DIC;
82
83 $tpl = $DIC['tpl'];
84 $ilToolbar = $DIC['ilToolbar'];
85 $ilCtrl = $DIC['ilCtrl'];
86 $ilTabs = $DIC['ilTabs'];
87 $lng = $DIC['lng'];
88
89 $ilTabs->activateSubTab("current");
90
91 // current mode
92 if (!$_REQUEST["smd"]) {
93 $_REQUEST["smd"] = self::MODE_TODAY;
94 }
95 $mode = (int) $_REQUEST["smd"];
96
97 // current measure
98 if (!$_REQUEST["smm"]) {
99 $_REQUEST["smm"] = "avg";
100 }
101 $measure = (string) $_REQUEST["smm"];
102
103
104 switch ($mode) {
105 case self::MODE_TODAY:
106 $time_from = strtotime("today");
107 $time_to = strtotime("tomorrow") - 1;
108 $scale = self::SCALE_DAY;
109 break;
110
112 $time_to = time();
113 $time_from = $time_to - 60 * 60 * 24;
114 $scale = self::SCALE_DAY;
115 break;
116
118 $time_to = time();
119 $time_from = $time_to - 60 * 60 * 24 * 7;
120 $scale = self::SCALE_WEEK;
121 break;
122
124 $time_to = time();
125 $time_from = $time_to - 60 * 60 * 24 * 30;
126 $scale = self::SCALE_MONTH;
127 break;
128 }
129
130 $mode_options = array(
131 self::MODE_TODAY => $lng->txt("trac_session_statistics_mode_today"),
132 self::MODE_LAST_DAY => $lng->txt("trac_session_statistics_mode_last_day"),
133 self::MODE_LAST_WEEK => $lng->txt("trac_session_statistics_mode_last_week"),
134 self::MODE_LAST_MONTH => $lng->txt("trac_session_statistics_mode_last_month"));
135
136 $title = $lng->txt("trac_current_system_load") . " - " . $mode_options[$mode];
137 $data = $this->buildData($time_from, $time_to, $title);
138
139 if (!$a_export) {
140 // toolbar
141 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
142 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "current"));
143
144 $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
145 $mode_selector->setOptions($mode_options);
146 $mode_selector->setValue($mode);
147 $ilToolbar->addInputItem($mode_selector, true);
148
149 $measure_options = array(
150 "avg" => $lng->txt("trac_session_active_avg"),
151 "min" => $lng->txt("trac_session_active_min"),
152 "max" => $lng->txt("trac_session_active_max"));
153
154 $measure_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_measure"), "smm");
155 $measure_selector->setOptions($measure_options);
156 $measure_selector->setValue($measure);
157 $ilToolbar->addInputItem($measure_selector, true);
158
159 $ilToolbar->addFormButton($lng->txt("ok"), "current");
160
161 if (sizeof($data["active"])) {
162 $ilToolbar->addSeparator();
163 $ilToolbar->addFormButton($lng->txt("export"), "currentExport");
164 }
165
166 $tpl->setContent($this->render($data, $scale, $measure));
167
168 $tpl->setLeftContent($this->renderCurrentBasics());
169 } else {
170 $this->exportCSV($data, $scale);
171 }
172 }
This class represents a selection list property in a property form.
buildData($a_time_from, $a_time_to, $a_title)
render($a_data, $a_scale, $a_measure=null)
exportCSV(array $a_data, $a_scale)
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $data, $DIC, $ilCtrl, $lng, $tpl, buildData(), exportCSV(), MODE_LAST_DAY, MODE_LAST_MONTH, MODE_LAST_WEEK, MODE_TODAY, render(), renderCurrentBasics(), SCALE_DAY, SCALE_MONTH, and SCALE_WEEK.

Referenced by currentExport().

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

◆ currentExport()

ilSessionStatisticsGUI::currentExport ( )
protected

Definition at line 174 of file class.ilSessionStatisticsGUI.php.

175 {
176 $this->current(true);
177 }

References current().

+ Here is the call graph for this function:

◆ executeCommand()

ilSessionStatisticsGUI::executeCommand ( )

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

33 {
34 global $DIC;
35
36 $ilCtrl = $DIC['ilCtrl'];
37
38 $this->setSubTabs();
39
40 switch ($ilCtrl->getNextClass()) {
41 default:
42 $cmd = $ilCtrl->getCmd("current");
43 $this->$cmd();
44 }
45
46 return true;
47 }

References $DIC, $ilCtrl, and setSubTabs().

+ Here is the call graph for this function:

◆ exportCSV()

ilSessionStatisticsGUI::exportCSV ( array  $a_data,
  $a_scale 
)
protected

Definition at line 777 of file class.ilSessionStatisticsGUI.php.

778 {
779 global $DIC;
780
781 $lng = $DIC['lng'];
782 $ilClientIniFile = $DIC['ilClientIniFile'];
783 $ilUser = $DIC['ilUser'];
784
786 include_once './Services/Link/classes/class.ilLink.php';
787
788 include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
789 $csv = new ilCSVWriter();
790 $csv->setSeparator(";");
791
792 $now = time();
793
794 // meta
795 $meta = array(
796 $lng->txt("trac_name_of_installation") => $ilClientIniFile->readVariable('client', 'name'),
797 $lng->txt("trac_report_date") => ilDatePresentation::formatDate(new ilDateTime($now, IL_CAL_UNIX)),
798 $lng->txt("trac_report_owner") => $ilUser->getFullName(),
799 );
800 foreach ($a_data as $idx => $item) {
801 switch ($idx) {
802 case "title":
803 $meta[$lng->txt("title")] = $item;
804 break;
805
806 case "active":
807 // nothing to do
808 break;
809
810 case "closed_details":
811 foreach ($item as $detail) {
812 $meta[$a_data["closed"][0] . " - " . $detail[0]] = $detail[1];
813 }
814 break;
815
816 default:
817 $meta[$item[0]] = $item[1];
818 break;
819 }
820 }
821 foreach ($meta as $caption => $value) {
822 $csv->addColumn(strip_tags($caption));
823 $csv->addColumn(strip_tags($value));
824 $csv->addRow();
825 }
826 $csv->addRow();
827
828 // aggregate data
829 $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"], 700);
830 unset($a_data);
831
832 // header
833 $first = $aggr_data;
834 $first = array_keys(array_shift($first));
835 foreach ($first as $column) {
836 // split weekday and time slot again
837 if ($a_scale == self::SCALE_PERIODIC_WEEK && $column == "slot_begin") {
838 $csv->addColumn("weekday");
839 $csv->addColumn("time");
840 } else {
841 $csv->addColumn(strip_tags($column));
842 }
843 }
844 $csv->addRow();
845
846 // data
847 foreach ($aggr_data as $row) {
848 foreach ($row as $column => $value) {
849 if (is_array($value)) {
850 $value = implode(', ', $value);
851 }
852 switch ($column) {
853 case "slot_begin":
854 // split weekday and time slot again
855 if ($a_scale == self::SCALE_PERIODIC_WEEK) {
856 $csv->addColumn(ilCalendarUtil::_numericDayToString(substr($value, 0, 1)));
857 $value = substr($value, 1, 2) . ":" . substr($value, 3, 2);
858 break;
859 }
860 // fallthrough
861
862 // no break
863 case "slot_end":
864 $value = date("d.m.Y H:i", $value);
865 break;
866 }
867 $csv->addColumn(strip_tags($value));
868 }
869 $csv->addRow();
870 }
871
872 // send
873 $filename .= "session_statistics_" . date("Ymd", $now) . ".csv";
874 header("Content-type: text/comma-separated-values");
875 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
876 header("Expires: 0");
877 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
878 header("Pragma: public");
879 echo $csv->getCSVString();
880 exit();
881 }
$filename
Definition: buildRTE.php:89
Helper class to generate CSV files.
static _numericDayToString($a_day, $a_long=true)
get
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
adaptDataToScale($a_scale, array $a_data)
exit
Definition: login.php:29
$ilUser
Definition: imgupload.php:18

References $DIC, $filename, $ilUser, $lng, ilCalendarUtil\_numericDayToString(), adaptDataToScale(), exit, ilDatePresentation\formatDate(), IL_CAL_UNIX, and ilDatePresentation\setUseRelativeDates().

Referenced by current(), long(), periodic(), and short().

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

◆ getChart()

ilSessionStatisticsGUI::getChart (   $a_data,
  $a_title,
  $a_scale = self::SCALE_DAY,
  $a_measure = null 
)
protected

Build chart for active sessions.

Parameters
array$a_data
string$a_title
int$a_scale
array$a_measure
Returns
string

Definition at line 581 of file class.ilSessionStatisticsGUI.php.

582 {
583 global $DIC;
584
585 $lng = $DIC['lng'];
586
587 include_once "Services/Chart/classes/class.ilChart.php";
589 $chart->setsize(700, 500);
590 $chart->setYAxisToInteger(true);
591
592 $legend = new ilChartLegend();
593 $chart->setLegend($legend);
594
595 if (!$a_measure) {
596 $a_measure = array("min", "avg", "max");
597 } elseif (!is_array($a_measure)) {
598 $a_measure = array($a_measure);
599 }
600
601 $colors_map = array("min" => "#00cc00",
602 "avg" => "#0000cc",
603 "max" => "#cc00cc");
604
605 $colors = $act_line = array();
606 foreach ($a_measure as $measure) {
607 $act_line[$measure] = $chart->getDataInstance(ilChartGrid::DATA_LINES);
608 $act_line[$measure]->setLineSteps(true);
609 $act_line[$measure]->setLabel($lng->txt("trac_session_active_" . $measure));
610 $colors[] = $colors_map[$measure];
611 }
612
613 if ($a_scale != self::SCALE_PERIODIC_WEEK) {
614 $max_line = $chart->getDataInstance(ilChartGrid::DATA_LINES);
615 $max_line->setLabel($lng->txt("session_max_count"));
616 $colors[] = "#cc0000";
617 }
618
619 $chart->setColors($colors);
620
621 $chart_data = $this->adaptDataToScale($a_scale, $a_data, 700);
622 unset($a_data);
623
624 $scale = ceil(sizeof($chart_data) / 5);
625 $labels = array();
626 foreach ($chart_data as $idx => $item) {
627 $date = $item["slot_begin"];
628
629 if ($a_scale == self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale))) {
630 switch ($a_scale) {
631 case self::SCALE_DAY:
632 $labels[$date] = date("H:i", $date);
633 break;
634
635 case self::SCALE_WEEK:
636 $labels[$date] = date("d.m. H", $date) . "h";
637 break;
638
640 $labels[$date] = date("d.m.", $date);
641 break;
642
643 case self::SCALE_YEAR:
644 $labels[$date] = date("Y-m", $date);
645 break;
646
648 $day = substr($date, 0, 1);
649 $hour = substr($date, 1, 2);
650 $min = substr($date, 3, 2);
651
652 // build ascending scale from day values
653 $day_value = ($day - 1) * 60 * 60 * 24;
654 $date = $day_value + $hour * 60 * 60 + $min * 60;
655
656 // 6-hour interval labels
657 if ($hour != $old_hour && $hour && $hour % 6 == 0) {
658 $labels[$date] = $hour;
659 $old_hour = $hour;
660 }
661 // day label
662 if ($day != $old_day) {
663 $labels[$date] = ilCalendarUtil::_numericDayToString($day, false);
664 $old_day = $day;
665 }
666 break;
667 }
668 }
669
670 foreach ($a_measure as $measure) {
671 $value = (int) $item["active_" . $measure];
672 $act_line[$measure]->addPoint($date, $value);
673 }
674
675 if ($a_scale != self::SCALE_PERIODIC_WEEK) {
676 $max_line->addPoint($date, (int) $item["max_sessions"]);
677 }
678 }
679
680 foreach ($act_line as $line) {
681 $chart->addData($line);
682 }
683 if ($a_scale != self::SCALE_PERIODIC_WEEK) {
684 $chart->addData($max_line);
685 }
686
687 $chart->setTicks($labels, null, true);
688
689 return $chart->getHTML();
690 }
static getInstanceByType($a_type, $a_id)
Get type instance.
const TYPE_GRID

References $DIC, $lng, ilCalendarUtil\_numericDayToString(), adaptDataToScale(), ilChartGrid\DATA_LINES, ilChart\getInstanceByType(), SCALE_DAY, SCALE_MONTH, SCALE_PERIODIC_WEEK, SCALE_WEEK, SCALE_YEAR, and ilChart\TYPE_GRID.

Referenced by render().

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

◆ importDate()

ilSessionStatisticsGUI::importDate (   $a_incoming,
  $a_default = null 
)
protected

Definition at line 179 of file class.ilSessionStatisticsGUI.php.

180 {
181 if (!$a_default) {
182 $a_default = time();
183 }
184
185 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
186 $parsed = ilCalendarUtil::parseIncomingDate($a_incoming);
187 return $parsed
188 ? $parsed->get(IL_CAL_UNIX)
189 : $a_default;
190 }
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.

References IL_CAL_UNIX, and ilCalendarUtil\parseIncomingDate().

Referenced by long(), periodic(), and short().

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

◆ long()

ilSessionStatisticsGUI::long (   $a_export = false)
protected

Definition at line 281 of file class.ilSessionStatisticsGUI.php.

282 {
283 global $DIC;
284
285 $tpl = $DIC['tpl'];
286 $ilToolbar = $DIC['ilToolbar'];
287 $ilCtrl = $DIC['ilCtrl'];
288 $ilTabs = $DIC['ilTabs'];
289 $lng = $DIC['lng'];
290
291 $ilTabs->activateSubTab("long");
292
293 // current start
294 $time_to = $this->importDate($_REQUEST["sst"]);
295
296 // current mode
297 if (!$_REQUEST["smd"]) {
298 $_REQUEST["smd"] = self::MODE_WEEK;
299 }
300 $mode = (int) $_REQUEST["smd"];
301
302 switch ($mode) {
303 case self::MODE_WEEK:
304 $time_from = $time_to - 60 * 60 * 24 * 7;
305 $scale = self::SCALE_WEEK;
306 break;
307
308 case self::MODE_MONTH:
309 $time_from = $time_to - 60 * 60 * 24 * 30;
310 $scale = self::SCALE_MONTH;
311 break;
312
313 case self::MODE_YEAR:
314 $time_from = $time_to - 60 * 60 * 24 * 365;
315 $scale = self::SCALE_YEAR;
316 break;
317 }
318
319 $mode_options = array(
320 self::MODE_WEEK => $lng->txt("trac_session_statistics_mode_week"),
321 self::MODE_MONTH => $lng->txt("trac_session_statistics_mode_month"),
322 self::MODE_YEAR => $lng->txt("trac_session_statistics_mode_year")
323 );
324
325 $title = $lng->txt("trac_long_system_load") . " - " . $mode_options[$mode];
326 $data = $this->buildData($time_from, $time_to, $title);
327
328 if (!$a_export) {
329 // toolbar
330 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
331 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "long"));
332
333 $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
334 $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
335 $ilToolbar->addInputItem($start_selector, true);
336
337 $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
338 $mode_selector->setOptions($mode_options);
339 $mode_selector->setValue($mode);
340 $ilToolbar->addInputItem($mode_selector, true);
341
342 $ilToolbar->addFormButton($lng->txt("ok"), "long");
343
344 if (sizeof($data["active"])) {
345 $ilToolbar->addSeparator();
346 $ilToolbar->addFormButton($lng->txt("export"), "longExport");
347 }
348
349 $tpl->setContent($this->render($data, $scale));
350 } else {
351 $this->exportCSV($data, $scale);
352 }
353 }
This class represents a date/time property in a property form.
Class for single dates.
importDate($a_incoming, $a_default=null)

References $data, $DIC, $ilCtrl, $lng, $tpl, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), MODE_MONTH, MODE_WEEK, MODE_YEAR, render(), SCALE_MONTH, SCALE_WEEK, and SCALE_YEAR.

Referenced by longExport().

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

◆ longExport()

ilSessionStatisticsGUI::longExport ( )
protected

Definition at line 355 of file class.ilSessionStatisticsGUI.php.

356 {
357 $this->long(true);
358 }

References long().

+ Here is the call graph for this function:

◆ periodic()

ilSessionStatisticsGUI::periodic (   $a_export = false)
protected

Definition at line 360 of file class.ilSessionStatisticsGUI.php.

361 {
362 global $DIC;
363
364 $tpl = $DIC['tpl'];
365 $ilToolbar = $DIC['ilToolbar'];
366 $ilCtrl = $DIC['ilCtrl'];
367 $ilTabs = $DIC['ilTabs'];
368 $lng = $DIC['lng'];
369
370 $ilTabs->activateSubTab("periodic");
371
372 // current start
373 $time_to = $this->importDate($_REQUEST["sst"]);
374
375 // current end
376 $time_from = $this->importDate($_REQUEST["sto"], strtotime("-7 days"));
377
378 // mixed up dates?
379 if ($time_to < $time_from) {
380 $tmp = $time_to;
381 $time_to = $time_from;
382 $time_from = $tmp;
383 }
384
385 $title = $lng->txt("trac_periodic_system_load");
386 $data = $this->buildData($time_from, $time_to, $title);
387
388 if (!$a_export) {
389 // toolbar
390 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
391 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "periodic"));
392
393 $end_selector = new ilDateTimeInputGUI($lng->txt("trac_begin_at"), "sto");
394 $end_selector->setDate(new ilDate($time_from, IL_CAL_UNIX));
395 $ilToolbar->addInputItem($end_selector, true);
396
397 $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
398 $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
399 $ilToolbar->addInputItem($start_selector, true);
400
401 $ilToolbar->addFormButton($lng->txt("ok"), "periodic");
402
403 if (sizeof($data["active"])) {
404 $ilToolbar->addSeparator();
405 $ilToolbar->addFormButton($lng->txt("export"), "periodicExport");
406 }
407
408 $tpl->setContent($this->render($data, self::SCALE_PERIODIC_WEEK));
409 } else {
410 $this->exportCSV($data, self::SCALE_PERIODIC_WEEK);
411 }
412 }

References $data, $DIC, $ilCtrl, $lng, $tpl, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), and render().

Referenced by periodicExport().

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

◆ periodicExport()

ilSessionStatisticsGUI::periodicExport ( )
protected

Definition at line 414 of file class.ilSessionStatisticsGUI.php.

415 {
416 $this->periodic(true);
417 }

References periodic().

+ Here is the call graph for this function:

◆ render()

ilSessionStatisticsGUI::render (   $a_data,
  $a_scale,
  $a_measure = null 
)
protected

Definition at line 531 of file class.ilSessionStatisticsGUI.php.

532 {
533 global $DIC;
534
535 $lng = $DIC['lng'];
536
537 $center = new ilTemplate("tpl.session_statistics_center.html", true, true, "Services/Authentication");
538
539 foreach ($a_data as $idx => $item) {
540 switch ($idx) {
541 case "active":
542 case "title":
543 // nothing to do
544 break;
545
546 case "closed_details":
547 $center->setCurrentBlock("closed_details");
548 foreach ($item as $detail) {
549 $center->setVariable("CAPTION_CLOSED_DETAILS", $detail[0]);
550 $center->setVariable("VALUE_CLOSED_DETAILS", $detail[1]);
551 $center->parseCurrentBlock();
552 }
553 break;
554
555 default:
556 $tpl_var = strtoupper($idx);
557 $center->setVariable("CAPTION_" . $tpl_var, $item[0]);
558 $center->setVariable("VALUE_" . $tpl_var, $item[1]);
559 break;
560 }
561 }
562
563 if ($a_data["active"]) {
564 $center->setVariable("CHART", $this->getChart($a_data["active"], $a_data["title"], $a_scale, $a_measure));
565 } else {
566 ilUtil::sendInfo($lng->txt("trac_session_statistics_no_data"));
567 }
568
569 return $center->get();
570 }
getChart($a_data, $a_title, $a_scale=self::SCALE_DAY, $a_measure=null)
Build chart for active sessions.
special template class to simplify handling of ITX/PEAR
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $DIC, $lng, getChart(), and ilUtil\sendInfo().

Referenced by current(), long(), periodic(), and short().

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

◆ renderCurrentBasics()

ilSessionStatisticsGUI::renderCurrentBasics ( )
protected

Definition at line 419 of file class.ilSessionStatisticsGUI.php.

420 {
421 global $DIC;
422
423 $ilSetting = $DIC['ilSetting'];
424 $lng = $DIC['lng'];
425 $ilCtrl = $DIC['ilCtrl'];
426 $ilAccess = $DIC['ilAccess'];
427
428 // basic data - not time related
429
430 include_once "Services/Authentication/classes/class.ilSessionControl.php";
432
433 $control_active = ($ilSetting->get('session_handling_type', 0) == 1);
434 if ($control_active) {
435 $control_max_sessions = (int) $ilSetting->get('session_max_count', ilSessionControl::DEFAULT_MAX_COUNT);
436 $control_min_idle = (int) $ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE);
437 $control_max_idle = (int) $ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE);
438 $control_max_idle_first = (int) $ilSetting->get('session_max_idle_after_first_request', ilSessionControl::DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST);
439 }
440
443
444
445 // build left column
446
447 $left = new ilTemplate("tpl.session_statistics_left.html", true, true, "Services/Authentication");
448
449 $left->setVariable("CAPTION_CURRENT", $lng->txt("users_online"));
450 $left->setVariable("VALUE_CURRENT", $active);
451
452 $left->setVariable("CAPTION_LAST_AGGR", $lng->txt("trac_last_aggregation"));
453 $left->setVariable("VALUE_LAST_AGGR", ilDatePresentation::formatDate($last_aggr));
454
455 $left->setVariable("CAPTION_LAST_MAX", $lng->txt("trac_last_maxed_out_sessions"));
456 $left->setVariable("VALUE_LAST_MAX", ilDatePresentation::formatDate($last_maxed_out));
457
458 $left->setVariable("CAPTION_SESSION_CONTROL", $lng->txt("sess_load_dependent_session_handling"));
459 if (!$control_active) {
460 $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("no"));
461 } else {
462 $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("yes"));
463
464 $left->setCurrentBlock("control_details");
465
466 $left->setVariable("CAPTION_SESSION_CONTROL_LIMIT", $lng->txt("session_max_count"));
467 $left->setVariable("VALUE_SESSION_CONTROL_LIMIT", $control_max_sessions);
468
469 $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MIN", $lng->txt("session_min_idle"));
470 $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MIN", $control_min_idle);
471
472 $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MAX", $lng->txt("session_max_idle"));
473 $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MAX", $control_max_idle);
474
475 $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_FIRST", $lng->txt("session_max_idle_after_first_request"));
476 $left->setVariable("VALUE_SESSION_CONTROL_IDLE_FIRST", $control_max_idle_first);
477
478 $left->parseCurrentBlock();
479 }
480
481 // sync button
482 if ($ilAccess->checkAccess("write", "", (int) $_REQUEST["ref_id"])) {
483 $left->setVariable("URL_SYNC", $ilCtrl->getFormAction($this, "adminSync"));
484 $left->setVariable("CMD_SYNC", "adminSync");
485 $left->setVariable("TXT_SYNC", $lng->txt("trac_sync_session_stats"));
486 }
487
488 return $left->get();
489 }
static getExistingSessionCount(array $a_types)
returns number of valid sessions relating to given session types
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet
static getLastAggregation()
Get timestamp of last aggregation.
static getLastMaxedOut()
Get latest slot during which sessions were maxed out.
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilCtrl, $ilSetting, $lng, ilSessionControl\$session_types_controlled, ilSessionControl\DEFAULT_MAX_COUNT, ilSessionControl\DEFAULT_MAX_IDLE, ilSessionControl\DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST, ilSessionControl\DEFAULT_MIN_IDLE, ilDatePresentation\formatDate(), ilSessionControl\getExistingSessionCount(), ilSessionStatistics\getLastAggregation(), ilSessionStatistics\getLastMaxedOut(), and IL_CAL_UNIX.

Referenced by current().

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

◆ setSubTabs()

ilSessionStatisticsGUI::setSubTabs ( )
protected

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

50 {
51 global $DIC;
52
53 $ilTabs = $DIC['ilTabs'];
54 $ilCtrl = $DIC['ilCtrl'];
55 $lng = $DIC['lng'];
56
57 $ilTabs->addSubTab(
58 "current",
59 $lng->txt("trac_current_system_load"),
60 $ilCtrl->getLinkTarget($this, "current")
61 );
62 $ilTabs->addSubTab(
63 "short",
64 $lng->txt("trac_short_system_load"),
65 $ilCtrl->getLinkTarget($this, "short")
66 );
67 $ilTabs->addSubTab(
68 "long",
69 $lng->txt("trac_long_system_load"),
70 $ilCtrl->getLinkTarget($this, "long")
71 );
72 $ilTabs->addSubTab(
73 "periodic",
74 $lng->txt("trac_periodic_system_load"),
75 $ilCtrl->getLinkTarget($this, "periodic")
76 );
77 }

References $DIC, $ilCtrl, and $lng.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ short()

ilSessionStatisticsGUI::short (   $a_export = false)
protected

Definition at line 192 of file class.ilSessionStatisticsGUI.php.

193 {
194 global $DIC;
195
196 $tpl = $DIC['tpl'];
197 $ilToolbar = $DIC['ilToolbar'];
198 $ilCtrl = $DIC['ilCtrl'];
199 $ilTabs = $DIC['ilTabs'];
200 $lng = $DIC['lng'];
201
202 $ilTabs->activateSubTab("short");
203
204 // current start
205 $time_to = $this->importDate($_REQUEST["sst"]);
206
207 // current mode
208 if (!$_REQUEST["smd"]) {
209 $_REQUEST["smd"] = self::MODE_DAY;
210 }
211 $mode = (int) $_REQUEST["smd"];
212
213 // current measure
214 if (!$_REQUEST["smm"]) {
215 $_REQUEST["smm"] = "avg";
216 }
217 $measure = (string) $_REQUEST["smm"];
218
219 switch ($mode) {
220 case self::MODE_DAY:
221 $time_from = $time_to - 60 * 60 * 24;
222 $scale = self::SCALE_DAY;
223 break;
224
225 case self::MODE_WEEK:
226 $time_from = $time_to - 60 * 60 * 24 * 7;
227 $scale = self::SCALE_WEEK;
228 break;
229 }
230
231 $mode_options = array(
232 self::MODE_DAY => $lng->txt("trac_session_statistics_mode_day"),
233 self::MODE_WEEK => $lng->txt("trac_session_statistics_mode_week")
234 );
235
236 $title = $lng->txt("trac_short_system_load") . " - " . $mode_options[$mode];
237 $data = $this->buildData($time_from, $time_to, $title);
238
239 if (!$a_export) {
240 // toolbar
241 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
242 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "short"));
243
244 $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
245 $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
246 $ilToolbar->addInputItem($start_selector, true);
247
248 $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
249 $mode_selector->setOptions($mode_options);
250 $mode_selector->setValue($mode);
251 $ilToolbar->addInputItem($mode_selector, true);
252
253 $measure_options = array(
254 "avg" => $lng->txt("trac_session_active_avg"),
255 "min" => $lng->txt("trac_session_active_min"),
256 "max" => $lng->txt("trac_session_active_max"));
257
258 $measure_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_measure"), "smm");
259 $measure_selector->setOptions($measure_options);
260 $measure_selector->setValue($measure);
261 $ilToolbar->addInputItem($measure_selector, true);
262
263 $ilToolbar->addFormButton($lng->txt("ok"), "short");
264
265 if (sizeof($data["active"])) {
266 $ilToolbar->addSeparator();
267 $ilToolbar->addFormButton($lng->txt("export"), "shortExport");
268 }
269
270 $tpl->setContent($this->render($data, $scale, $measure));
271 } else {
272 $this->exportCSV($data, $scale);
273 }
274 }

References $data, $DIC, $ilCtrl, $lng, $tpl, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), MODE_DAY, MODE_WEEK, render(), SCALE_DAY, and SCALE_WEEK.

Referenced by shortExport().

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

◆ shortExport()

ilSessionStatisticsGUI::shortExport ( )
protected

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

277 {
278 $this->short(true);
279 }

References short().

+ Here is the call graph for this function:

Field Documentation

◆ MODE_DAY

const ilSessionStatisticsGUI::MODE_DAY = 5

Definition at line 21 of file class.ilSessionStatisticsGUI.php.

Referenced by short().

◆ MODE_LAST_DAY

const ilSessionStatisticsGUI::MODE_LAST_DAY = 2

Definition at line 18 of file class.ilSessionStatisticsGUI.php.

Referenced by current().

◆ MODE_LAST_MONTH

const ilSessionStatisticsGUI::MODE_LAST_MONTH = 4

Definition at line 20 of file class.ilSessionStatisticsGUI.php.

Referenced by current().

◆ MODE_LAST_WEEK

const ilSessionStatisticsGUI::MODE_LAST_WEEK = 3

Definition at line 19 of file class.ilSessionStatisticsGUI.php.

Referenced by current().

◆ MODE_MONTH

const ilSessionStatisticsGUI::MODE_MONTH = 7

Definition at line 23 of file class.ilSessionStatisticsGUI.php.

Referenced by long().

◆ MODE_TODAY

const ilSessionStatisticsGUI::MODE_TODAY = 1

Definition at line 17 of file class.ilSessionStatisticsGUI.php.

Referenced by current().

◆ MODE_WEEK

const ilSessionStatisticsGUI::MODE_WEEK = 6

Definition at line 22 of file class.ilSessionStatisticsGUI.php.

Referenced by long(), and short().

◆ MODE_YEAR

const ilSessionStatisticsGUI::MODE_YEAR = 8

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

Referenced by long().

◆ SCALE_DAY

const ilSessionStatisticsGUI::SCALE_DAY = 1

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

Referenced by adaptDataToScale(), current(), getChart(), and short().

◆ SCALE_MONTH

const ilSessionStatisticsGUI::SCALE_MONTH = 3

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

Referenced by adaptDataToScale(), current(), getChart(), and long().

◆ SCALE_PERIODIC_WEEK

const ilSessionStatisticsGUI::SCALE_PERIODIC_WEEK = 5

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

Referenced by adaptDataToScale(), and getChart().

◆ SCALE_WEEK

const ilSessionStatisticsGUI::SCALE_WEEK = 2

Definition at line 27 of file class.ilSessionStatisticsGUI.php.

Referenced by adaptDataToScale(), current(), getChart(), long(), and short().

◆ SCALE_YEAR

const ilSessionStatisticsGUI::SCALE_YEAR = 4

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

Referenced by adaptDataToScale(), getChart(), and long().


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