ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 651 of file class.ilSessionStatisticsGUI.php.

References $id, array, and date.

Referenced by exportCSV(), and getChart().

652  {
653  // can we use original data?
654  switch ($a_scale) {
655  case self::SCALE_DAY:
656  // 96 values => ok
657  // fallthrough
658 
659  case self::SCALE_WEEK:
660  // 672 values => ok
661  return $a_data;
662  }
663 
664  $tmp = array();
665  foreach ($a_data as $item) {
666  $date_parts = getdate($item["slot_begin"]);
667 
668  // aggregate slots for scale
669  switch ($a_scale) {
670  case self::SCALE_MONTH:
671  // aggregate to hours => 720 values
672  $slot = mktime($date_parts["hours"], 0, 0, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
673  break;
674 
675  case self::SCALE_YEAR:
676  // aggregate to days => 365 values
677  $slot = mktime(0, 0, 1, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
678  break;
679 
680  case self::SCALE_PERIODIC_WEEK:
681  // aggregate to weekdays => 672 values
682  $day = $date_parts["wday"];
683  if (!$day) {
684  $day = 7;
685  }
686  $slot = $day . date("His", $item["slot_begin"]);
687  break;
688  }
689 
690  // process minx/max, prepare avg
691  foreach ($item as $id => $value) {
692  switch (substr($id, -3)) {
693  case "min":
694  if (!$tmp[$slot][$id] || $value < $tmp[$slot][$id]) {
695  $tmp[$slot][$id] = $value;
696  }
697  break;
698 
699  case "max":
700  if (!$tmp[$slot][$id] || $value > $tmp[$slot][$id]) {
701  $tmp[$slot][$id] = $value;
702  }
703  break;
704 
705  case "avg":
706  $tmp[$slot][$id][] = $value;
707  break;
708  }
709  }
710  }
711 
712  foreach ($tmp as $slot => $attr) {
713  $tmp[$slot]["active_avg"] = (int) round(array_sum($attr["active_avg"])/sizeof($attr["active_avg"]));
714  $tmp[$slot]["slot_begin"] = $slot;
715  }
716  ksort($tmp);
717  return array_values($tmp);
718  }
if(!array_key_exists('StateId', $_REQUEST)) $id
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ adminSync()

ilSessionStatisticsGUI::adminSync ( )
protected

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

References $ilCtrl, $lng, ilSession\_destroyExpiredSessions(), ilSessionStatistics\aggretateRaw(), ilUtil\sendSuccess(), and time.

721  {
722  global $ilCtrl, $lng;
723 
724  // see ilSession::_writeData()
725  $now = time();
728 
729  ilUtil::sendSuccess($lng->txt("trac_sync_session_stats_success"), true);
730  $ilCtrl->redirect($this);
731  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _destroyExpiredSessions()
Destroy expired sessions.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static aggretateRaw($a_now)
Aggregate raw session data (older than given time)
+ Here is the call graph for this function:

◆ buildData()

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

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

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

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

457  {
458  global $lng;
459 
460  // basic data - time related
461 
462  $maxed_out_duration = round(ilSessionStatistics::getMaxedOutDuration($a_time_from, $a_time_to)/60);
463  $counters = ilSessionStatistics::getNumberOfSessionsByType($a_time_from, $a_time_to);
464  $opened = (int) $counters["opened"];
465  $closed_limit = (int) $counters["closed_limit"];
466  unset($counters["opened"]);
467  unset($counters["closed_limit"]);
468 
469 
470  // build center column
471 
472  $data = array();
473 
475  $data["title"] = $a_title . " (" .
477  new ilDateTime($a_time_from, IL_CAL_UNIX),
478  new ilDateTime($a_time_to, IL_CAL_UNIX)
479  ) . ")";
480 
481  $data["maxed_out_time"] = array($lng->txt("trac_maxed_out_time"), $maxed_out_duration);
482  $data["maxed_out_counter"] = array($lng->txt("trac_maxed_out_counter"), $closed_limit);
483  $data["opened"] = array($lng->txt("trac_sessions_opened"), $opened);
484  $data["closed"] = array($lng->txt("trac_sessions_closed"), array_sum($counters));
485  foreach ($counters as $type => $counter) {
486  $data["closed_details"][] = array($lng->txt("trac_" . $type), (int) $counter);
487  }
488 
489  $data["active"] = ilSessionStatistics::getActiveSessions($a_time_from, $a_time_to);
490 
491  return $data;
492  }
static getMaxedOutDuration($a_from, $a_to)
Get maxed out duration in given timeframe.
$type
static setUseRelativeDates($a_status)
set use relative dates
static getNumberOfSessionsByType($a_from, $a_to)
Get session counters by type (opened, closed)
const IL_CAL_UNIX
$counter
Date and time handling
Create styles array
The data for the language used.
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
global $lng
Definition: privfeed.php:17
static getActiveSessions($a_from, $a_to)
Get active sessions aggregated data.
+ 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 73 of file class.ilSessionStatisticsGUI.php.

References $data, $ilCtrl, $lng, $title, $tpl, array, buildData(), exportCSV(), render(), renderCurrentBasics(), ilSelectInputGUI\setOptions(), string, and time.

Referenced by currentExport().

74  {
75  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
76 
77  $ilTabs->activateSubTab("current");
78 
79  // current mode
80  if (!$_REQUEST["smd"]) {
81  $_REQUEST["smd"] = self::MODE_TODAY;
82  }
83  $mode = (int) $_REQUEST["smd"];
84 
85  // current measure
86  if (!$_REQUEST["smm"]) {
87  $_REQUEST["smm"] = "avg";
88  }
89  $measure = (string) $_REQUEST["smm"];
90 
91 
92  switch ($mode) {
93  case self::MODE_TODAY:
94  $time_from = strtotime("today");
95  $time_to = strtotime("tomorrow")-1;
96  $scale = self::SCALE_DAY;
97  break;
98 
99  case self::MODE_LAST_DAY:
100  $time_to = time();
101  $time_from = $time_to-60*60*24;
102  $scale = self::SCALE_DAY;
103  break;
104 
105  case self::MODE_LAST_WEEK:
106  $time_to = time();
107  $time_from = $time_to-60*60*24*7;
108  $scale = self::SCALE_WEEK;
109  break;
110 
111  case self::MODE_LAST_MONTH:
112  $time_to = time();
113  $time_from = $time_to-60*60*24*30;
114  $scale = self::SCALE_MONTH;
115  break;
116  }
117 
118  $mode_options = array(
119  self::MODE_TODAY => $lng->txt("trac_session_statistics_mode_today"),
120  self::MODE_LAST_DAY => $lng->txt("trac_session_statistics_mode_last_day"),
121  self::MODE_LAST_WEEK => $lng->txt("trac_session_statistics_mode_last_week"),
122  self::MODE_LAST_MONTH => $lng->txt("trac_session_statistics_mode_last_month"));
123 
124  $title = $lng->txt("trac_current_system_load") . " - " . $mode_options[$mode];
125  $data = $this->buildData($time_from, $time_to, $title);
126 
127  if (!$a_export) {
128  // toolbar
129  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
130  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "current"));
131 
132  $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
133  $mode_selector->setOptions($mode_options);
134  $mode_selector->setValue($mode);
135  $ilToolbar->addInputItem($mode_selector, true);
136 
137  $measure_options = array(
138  "avg" => $lng->txt("trac_session_active_avg"),
139  "min" => $lng->txt("trac_session_active_min"),
140  "max" => $lng->txt("trac_session_active_max"));
141 
142  $measure_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_measure"), "smm");
143  $measure_selector->setOptions($measure_options);
144  $measure_selector->setValue($measure);
145  $ilToolbar->addInputItem($measure_selector, true);
146 
147  $ilToolbar->addFormButton($lng->txt("ok"), "current");
148 
149  if (sizeof($data["active"])) {
150  $ilToolbar->addSeparator();
151  $ilToolbar->addFormButton($lng->txt("export"), "currentExport");
152  }
153 
154  $tpl->setContent($this->render($data, $scale, $measure));
155 
156  $tpl->setLeftContent($this->renderCurrentBasics());
157  } else {
158  $this->exportCSV($data, $scale);
159  }
160  }
Add rich text string
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
buildData($a_time_from, $a_time_to, $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentExport()

ilSessionStatisticsGUI::currentExport ( )
protected

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

References current().

163  {
164  $this->current(true);
165  }
+ Here is the call graph for this function:

◆ executeCommand()

ilSessionStatisticsGUI::executeCommand ( )

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

References $ilCtrl, and setSubTabs().

33  {
34  global $ilCtrl;
35 
36  $this->setSubTabs();
37 
38  switch ($ilCtrl->getNextClass()) {
39  default:
40  $cmd = $ilCtrl->getCmd("current");
41  $this->$cmd();
42  }
43 
44  return true;
45  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ exportCSV()

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

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

References $column, $filename, $ilUser, $lng, $row, ilCalendarUtil\_numericDayToString(), adaptDataToScale(), array, date, exit, ilDatePresentation\formatDate(), header, IL_CAL_UNIX, ilDatePresentation\setUseRelativeDates(), and time.

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

734  {
735  global $lng, $ilClientIniFile, $ilUser;
736 
738  include_once './Services/Link/classes/class.ilLink.php';
739 
740  include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
741  $csv = new ilCSVWriter();
742  $csv->setSeparator(";");
743 
744  $now = time();
745 
746  // meta
747  $meta = array(
748  $lng->txt("trac_name_of_installation") => $ilClientIniFile->readVariable('client', 'name'),
749  $lng->txt("trac_report_date") => ilDatePresentation::formatDate(new ilDateTime($now, IL_CAL_UNIX)),
750  $lng->txt("trac_report_owner") => $ilUser->getFullName(),
751  );
752  foreach ($a_data as $idx => $item) {
753  switch ($idx) {
754  case "title":
755  $meta[$lng->txt("title")] = $item;
756  break;
757 
758  case "active":
759  // nothing to do
760  break;
761 
762  case "closed_details":
763  foreach ($item as $detail) {
764  $meta[$a_data["closed"][0] . " - " . $detail[0]] = $detail[1];
765  }
766  break;
767 
768  default:
769  $meta[$item[0]] = $item[1];
770  break;
771  }
772  }
773  foreach ($meta as $caption => $value) {
774  $csv->addColumn(strip_tags($caption));
775  $csv->addColumn(strip_tags($value));
776  $csv->addRow();
777  }
778  $csv->addRow();
779 
780  // aggregate data
781  $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"], 700);
782  unset($a_data);
783 
784  // header
785  $first = $aggr_data;
786  $first = array_keys(array_shift($first));
787  foreach ($first as $column) {
788  // split weekday and time slot again
789  if ($a_scale == self::SCALE_PERIODIC_WEEK && $column == "slot_begin") {
790  $csv->addColumn("weekday");
791  $csv->addColumn("time");
792  } else {
793  $csv->addColumn(strip_tags($column));
794  }
795  }
796  $csv->addRow();
797 
798  // data
799  foreach ($aggr_data as $row) {
800  foreach ($row as $column => $value) {
801  if (is_array($value)) {
802  $value = implode(', ', $value);
803  }
804  switch ($column) {
805  case "slot_begin":
806  // split weekday and time slot again
807  if ($a_scale == self::SCALE_PERIODIC_WEEK) {
808  $csv->addColumn(ilCalendarUtil::_numericDayToString(substr($value, 0, 1)));
809  $value = substr($value, 1, 2) . ":" . substr($value, 3, 2);
810  break;
811  }
812  // fallthrough
813 
814  // no break
815  case "slot_end":
816  $value = date("d.m.Y H:i", $value);
817  break;
818  }
819  $csv->addColumn(strip_tags($value));
820  }
821  $csv->addRow();
822  }
823 
824  // send
825  $filename .= "session_statistics_" . date("Ymd", $now) . ".csv";
826  header("Content-type: text/comma-separated-values");
827  header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
828  header("Expires: 0");
829  header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
830  header("Pragma: public");
831  echo $csv->getCSVString();
832  exit();
833  }
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)
Format a date public.
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
$column
Definition: 39dropdown.php:62
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Date and time handling
$ilUser
Definition: imgupload.php:18
Add a drawing to the header
Definition: 04printing.php:69
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
adaptDataToScale($a_scale, array $a_data)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 542 of file class.ilSessionStatisticsGUI.php.

References $chart, $legend, $lng, ilCalendarUtil\_numericDayToString(), adaptDataToScale(), array, ilChartGrid\DATA_LINES, date, ilChart\getInstanceByType(), and ilChart\TYPE_GRID.

Referenced by render().

543  {
544  global $lng;
545 
546  include_once "Services/Chart/classes/class.ilChart.php";
548  $chart->setsize(700, 500);
549  $chart->setYAxisToInteger(true);
550 
551  $legend = new ilChartLegend();
552  $chart->setLegend($legend);
553 
554  if (!$a_measure) {
555  $a_measure = array("min", "avg", "max");
556  } elseif (!is_array($a_measure)) {
557  $a_measure = array($a_measure);
558  }
559 
560  $colors_map = array("min" => "#00cc00",
561  "avg" => "#0000cc",
562  "max" => "#cc00cc");
563 
564  $colors = $act_line = array();
565  foreach ($a_measure as $measure) {
566  $act_line[$measure] = $chart->getDataInstance(ilChartGrid::DATA_LINES);
567  $act_line[$measure]->setLineSteps(true);
568  $act_line[$measure]->setLabel($lng->txt("trac_session_active_" . $measure));
569  $colors[] = $colors_map[$measure];
570  }
571 
572  if ($a_scale != self::SCALE_PERIODIC_WEEK) {
573  $max_line = $chart->getDataInstance(ilChartGrid::DATA_LINES);
574  $max_line->setLabel($lng->txt("session_max_count"));
575  $colors[] = "#cc0000";
576  }
577 
578  $chart->setColors($colors);
579 
580  $chart_data = $this->adaptDataToScale($a_scale, $a_data, 700);
581  unset($a_data);
582 
583  $scale = ceil(sizeof($chart_data)/5);
584  $labels = array();
585  foreach ($chart_data as $idx => $item) {
586  $date = $item["slot_begin"];
587 
588  if ($a_scale == self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale))) {
589  switch ($a_scale) {
590  case self::SCALE_DAY:
591  $labels[$date] = date("H:i", $date);
592  break;
593 
594  case self::SCALE_WEEK:
595  $labels[$date] = date("d.m. H", $date) . "h";
596  break;
597 
598  case self::SCALE_MONTH:
599  $labels[$date] = date("d.m.", $date);
600  break;
601 
602  case self::SCALE_YEAR:
603  $labels[$date] = date("Y-m", $date);
604  break;
605 
606  case self::SCALE_PERIODIC_WEEK:
607  $day = substr($date, 0, 1);
608  $hour = substr($date, 1, 2);
609  $min = substr($date, 3, 2);
610 
611  // build ascending scale from day values
612  $day_value = ($day-1)*60*60*24;
613  $date = $day_value+$hour*60*60+$min*60;
614 
615  // 6-hour interval labels
616  if ($hour != $old_hour && $hour && $hour%6 == 0) {
617  $labels[$date] = $hour;
618  $old_hour = $hour;
619  }
620  // day label
621  if ($day != $old_day) {
622  $labels[$date] = ilCalendarUtil::_numericDayToString($day, false);
623  $old_day = $day;
624  }
625  break;
626  }
627  }
628 
629  foreach ($a_measure as $measure) {
630  $value = (int) $item["active_" . $measure];
631  $act_line[$measure]->addPoint($date, $value);
632  }
633 
634  if ($a_scale != self::SCALE_PERIODIC_WEEK) {
635  $max_line->addPoint($date, (int) $item["max_sessions"]);
636  }
637  }
638 
639  foreach ($act_line as $line) {
640  $chart->addData($line);
641  }
642  if ($a_scale != self::SCALE_PERIODIC_WEEK) {
643  $chart->addData($max_line);
644  }
645 
646  $chart->setTicks($labels, null, true);
647 
648  return $chart->getHTML();
649  }
static _numericDayToString($a_day, $a_long=true)
get
Chart legend.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
const TYPE_GRID
global $lng
Definition: privfeed.php:17
adaptDataToScale($a_scale, array $a_data)
static getInstanceByType($a_type, $a_id)
Get type instance.
+ 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 167 of file class.ilSessionStatisticsGUI.php.

References IL_CAL_UNIX, ilCalendarUtil\parseIncomingDate(), and time.

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

168  {
169  if (!$a_default) {
170  $a_default = time();
171  }
172 
173  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
174  $parsed = ilCalendarUtil::parseIncomingDate($a_incoming);
175  return $parsed
176  ? $parsed->get(IL_CAL_UNIX)
177  : $a_default;
178  }
const IL_CAL_UNIX
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static parseIncomingDate($a_value, $a_add_time=null)
Try to parse incoming value to date object.
+ 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 263 of file class.ilSessionStatisticsGUI.php.

References $data, $ilCtrl, $lng, $title, $tpl, array, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), render(), ilDateTimeInputGUI\setDate(), and ilSelectInputGUI\setOptions().

Referenced by longExport().

264  {
265  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
266 
267  $ilTabs->activateSubTab("long");
268 
269  // current start
270  $time_to = $this->importDate($_REQUEST["sst"]);
271 
272  // current mode
273  if (!$_REQUEST["smd"]) {
274  $_REQUEST["smd"] = self::MODE_WEEK;
275  }
276  $mode = (int) $_REQUEST["smd"];
277 
278  switch ($mode) {
279  case self::MODE_WEEK:
280  $time_from = $time_to-60*60*24*7;
281  $scale = self::SCALE_WEEK;
282  break;
283 
284  case self::MODE_MONTH:
285  $time_from = $time_to-60*60*24*30;
286  $scale = self::SCALE_MONTH;
287  break;
288 
289  case self::MODE_YEAR:
290  $time_from = $time_to-60*60*24*365;
291  $scale = self::SCALE_YEAR;
292  break;
293  }
294 
295  $mode_options = array(
296  self::MODE_WEEK => $lng->txt("trac_session_statistics_mode_week"),
297  self::MODE_MONTH => $lng->txt("trac_session_statistics_mode_month"),
298  self::MODE_YEAR => $lng->txt("trac_session_statistics_mode_year")
299  );
300 
301  $title = $lng->txt("trac_long_system_load") . " - " . $mode_options[$mode];
302  $data = $this->buildData($time_from, $time_to, $title);
303 
304  if (!$a_export) {
305  // toolbar
306  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
307  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "long"));
308 
309  $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
310  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
311  $ilToolbar->addInputItem($start_selector, true);
312 
313  $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
314  $mode_selector->setOptions($mode_options);
315  $mode_selector->setValue($mode);
316  $ilToolbar->addInputItem($mode_selector, true);
317 
318  $ilToolbar->addFormButton($lng->txt("ok"), "long");
319 
320  if (sizeof($data["active"])) {
321  $ilToolbar->addSeparator();
322  $ilToolbar->addFormButton($lng->txt("export"), "longExport");
323  }
324 
325  $tpl->setContent($this->render($data, $scale));
326  } else {
327  $this->exportCSV($data, $scale);
328  }
329  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
$tpl
Definition: ilias.php:10
const IL_CAL_UNIX
importDate($a_incoming, $a_default=null)
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
Class for single dates.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
buildData($a_time_from, $a_time_to, $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ longExport()

ilSessionStatisticsGUI::longExport ( )
protected

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

References long().

332  {
333  $this->long(true);
334  }
+ Here is the call graph for this function:

◆ periodic()

ilSessionStatisticsGUI::periodic (   $a_export = false)
protected

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

References $data, $ilCtrl, $lng, $title, $tpl, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), render(), and ilDateTimeInputGUI\setDate().

Referenced by periodicExport().

337  {
338  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
339 
340  $ilTabs->activateSubTab("periodic");
341 
342  // current start
343  $time_to = $this->importDate($_REQUEST["sst"]);
344 
345  // current end
346  $time_from = $this->importDate($_REQUEST["sto"], strtotime("-7 days"));
347 
348  // mixed up dates?
349  if ($time_to < $time_from) {
350  $tmp = $time_to;
351  $time_to = $time_from;
352  $time_from = $tmp;
353  }
354 
355  $title = $lng->txt("trac_periodic_system_load");
356  $data = $this->buildData($time_from, $time_to, $title);
357 
358  if (!$a_export) {
359  // toolbar
360  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
361  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "periodic"));
362 
363  $end_selector = new ilDateTimeInputGUI($lng->txt("trac_begin_at"), "sto");
364  $end_selector->setDate(new ilDate($time_from, IL_CAL_UNIX));
365  $ilToolbar->addInputItem($end_selector, true);
366 
367  $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
368  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
369  $ilToolbar->addInputItem($start_selector, true);
370 
371  $ilToolbar->addFormButton($lng->txt("ok"), "periodic");
372 
373  if (sizeof($data["active"])) {
374  $ilToolbar->addSeparator();
375  $ilToolbar->addFormButton($lng->txt("export"), "periodicExport");
376  }
377 
378  $tpl->setContent($this->render($data, self::SCALE_PERIODIC_WEEK));
379  } else {
380  $this->exportCSV($data, self::SCALE_PERIODIC_WEEK);
381  }
382  }
exportCSV(array $a_data, $a_scale)
$tpl
Definition: ilias.php:10
const IL_CAL_UNIX
importDate($a_incoming, $a_default=null)
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
Class for single dates.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
global $lng
Definition: privfeed.php:17
buildData($a_time_from, $a_time_to, $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ periodicExport()

ilSessionStatisticsGUI::periodicExport ( )
protected

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

References periodic().

385  {
386  $this->periodic(true);
387  }
+ Here is the call graph for this function:

◆ render()

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

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

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

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

495  {
496  global $lng;
497 
498  $center = new ilTemplate("tpl.session_statistics_center.html", true, true, "Services/Authentication");
499 
500  foreach ($a_data as $idx => $item) {
501  switch ($idx) {
502  case "active":
503  case "title":
504  // nothing to do
505  break;
506 
507  case "closed_details":
508  $center->setCurrentBlock("closed_details");
509  foreach ($item as $detail) {
510  $center->setVariable("CAPTION_CLOSED_DETAILS", $detail[0]);
511  $center->setVariable("VALUE_CLOSED_DETAILS", $detail[1]);
512  $center->parseCurrentBlock();
513  }
514  break;
515 
516  default:
517  $tpl_var = strtoupper($idx);
518  $center->setVariable("CAPTION_" . $tpl_var, $item[0]);
519  $center->setVariable("VALUE_" . $tpl_var, $item[1]);
520  break;
521  }
522  }
523 
524  if ($a_data["active"]) {
525  $center->setVariable("CHART", $this->getChart($a_data["active"], $a_data["title"], $a_scale, $a_measure));
526  } else {
527  ilUtil::sendInfo($lng->txt("trac_session_statistics_no_data"));
528  }
529 
530  return $center->get();
531  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
getChart($a_data, $a_title, $a_scale=self::SCALE_DAY, $a_measure=null)
Build chart for active sessions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderCurrentBasics()

ilSessionStatisticsGUI::renderCurrentBasics ( )
protected

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

References $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().

390  {
391  global $ilSetting, $lng, $ilCtrl, $ilAccess;
392 
393  // basic data - not time related
394 
395  include_once "Services/Authentication/classes/class.ilSessionControl.php";
397 
398  $control_active = ($ilSetting->get('session_handling_type', 0) == 1);
399  if ($control_active) {
400  $control_max_sessions = (int) $ilSetting->get('session_max_count', ilSessionControl::DEFAULT_MAX_COUNT);
401  $control_min_idle = (int) $ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE);
402  $control_max_idle = (int) $ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE);
403  $control_max_idle_first = (int) $ilSetting->get('session_max_idle_after_first_request', ilSessionControl::DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST);
404  }
405 
408 
409 
410  // build left column
411 
412  $left = new ilTemplate("tpl.session_statistics_left.html", true, true, "Services/Authentication");
413 
414  $left->setVariable("CAPTION_CURRENT", $lng->txt("users_online"));
415  $left->setVariable("VALUE_CURRENT", $active);
416 
417  $left->setVariable("CAPTION_LAST_AGGR", $lng->txt("trac_last_aggregation"));
418  $left->setVariable("VALUE_LAST_AGGR", ilDatePresentation::formatDate($last_aggr));
419 
420  $left->setVariable("CAPTION_LAST_MAX", $lng->txt("trac_last_maxed_out_sessions"));
421  $left->setVariable("VALUE_LAST_MAX", ilDatePresentation::formatDate($last_maxed_out));
422 
423  $left->setVariable("CAPTION_SESSION_CONTROL", $lng->txt("sess_load_dependent_session_handling"));
424  if (!$control_active) {
425  $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("no"));
426  } else {
427  $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("yes"));
428 
429  $left->setCurrentBlock("control_details");
430 
431  $left->setVariable("CAPTION_SESSION_CONTROL_LIMIT", $lng->txt("session_max_count"));
432  $left->setVariable("VALUE_SESSION_CONTROL_LIMIT", $control_max_sessions);
433 
434  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MIN", $lng->txt("session_min_idle"));
435  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MIN", $control_min_idle);
436 
437  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MAX", $lng->txt("session_max_idle"));
438  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MAX", $control_max_idle);
439 
440  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_FIRST", $lng->txt("session_max_idle_after_first_request"));
441  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_FIRST", $control_max_idle_first);
442 
443  $left->parseCurrentBlock();
444  }
445 
446  // sync button
447  if ($ilAccess->checkAccess("write", "", (int) $_REQUEST["ref_id"])) {
448  $left->setVariable("URL_SYNC", $ilCtrl->getFormAction($this, "adminSync"));
449  $left->setVariable("CMD_SYNC", "adminSync");
450  $left->setVariable("TXT_SYNC", $lng->txt("trac_sync_session_stats"));
451  }
452 
453  return $left->get();
454  }
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
const IL_CAL_UNIX
global $ilCtrl
Definition: ilias.php:18
static getLastAggregation()
Get timestamp of last aggregation.
special template class to simplify handling of ITX/PEAR
Date and time handling
static getExistingSessionCount(array $a_types)
returns number of valid sessions relating to given session types
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
static getLastMaxedOut()
Get latest slot during which sessions were maxed out.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubTabs()

ilSessionStatisticsGUI::setSubTabs ( )
protected

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

References $ilCtrl, and $lng.

Referenced by executeCommand().

48  {
49  global $ilTabs, $ilCtrl, $lng;
50 
51  $ilTabs->addSubTab(
52  "current",
53  $lng->txt("trac_current_system_load"),
54  $ilCtrl->getLinkTarget($this, "current")
55  );
56  $ilTabs->addSubTab(
57  "short",
58  $lng->txt("trac_short_system_load"),
59  $ilCtrl->getLinkTarget($this, "short")
60  );
61  $ilTabs->addSubTab(
62  "long",
63  $lng->txt("trac_long_system_load"),
64  $ilCtrl->getLinkTarget($this, "long")
65  );
66  $ilTabs->addSubTab(
67  "periodic",
68  $lng->txt("trac_periodic_system_load"),
69  $ilCtrl->getLinkTarget($this, "periodic")
70  );
71  }
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ short()

ilSessionStatisticsGUI::short (   $a_export = false)
protected

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

References $data, $ilCtrl, $lng, $title, $tpl, array, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), render(), ilDateTimeInputGUI\setDate(), ilSelectInputGUI\setOptions(), and string.

Referenced by shortExport().

181  {
182  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
183 
184  $ilTabs->activateSubTab("short");
185 
186  // current start
187  $time_to = $this->importDate($_REQUEST["sst"]);
188 
189  // current mode
190  if (!$_REQUEST["smd"]) {
191  $_REQUEST["smd"] = self::MODE_DAY;
192  }
193  $mode = (int) $_REQUEST["smd"];
194 
195  // current measure
196  if (!$_REQUEST["smm"]) {
197  $_REQUEST["smm"] = "avg";
198  }
199  $measure = (string) $_REQUEST["smm"];
200 
201  switch ($mode) {
202  case self::MODE_DAY:
203  $time_from = $time_to-60*60*24;
204  $scale = self::SCALE_DAY;
205  break;
206 
207  case self::MODE_WEEK:
208  $time_from = $time_to-60*60*24*7;
209  $scale = self::SCALE_WEEK;
210  break;
211  }
212 
213  $mode_options = array(
214  self::MODE_DAY => $lng->txt("trac_session_statistics_mode_day"),
215  self::MODE_WEEK => $lng->txt("trac_session_statistics_mode_week")
216  );
217 
218  $title = $lng->txt("trac_short_system_load") . " - " . $mode_options[$mode];
219  $data = $this->buildData($time_from, $time_to, $title);
220 
221  if (!$a_export) {
222  // toolbar
223  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
224  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "short"));
225 
226  $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
227  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
228  $ilToolbar->addInputItem($start_selector, true);
229 
230  $mode_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_scale"), "smd");
231  $mode_selector->setOptions($mode_options);
232  $mode_selector->setValue($mode);
233  $ilToolbar->addInputItem($mode_selector, true);
234 
235  $measure_options = array(
236  "avg" => $lng->txt("trac_session_active_avg"),
237  "min" => $lng->txt("trac_session_active_min"),
238  "max" => $lng->txt("trac_session_active_max"));
239 
240  $measure_selector = new ilSelectInputGUI("&nbsp;" . $lng->txt("trac_measure"), "smm");
241  $measure_selector->setOptions($measure_options);
242  $measure_selector->setValue($measure);
243  $ilToolbar->addInputItem($measure_selector, true);
244 
245  $ilToolbar->addFormButton($lng->txt("ok"), "short");
246 
247  if (sizeof($data["active"])) {
248  $ilToolbar->addSeparator();
249  $ilToolbar->addFormButton($lng->txt("export"), "shortExport");
250  }
251 
252  $tpl->setContent($this->render($data, $scale, $measure));
253  } else {
254  $this->exportCSV($data, $scale);
255  }
256  }
Add rich text string
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
$tpl
Definition: ilias.php:10
const IL_CAL_UNIX
importDate($a_incoming, $a_default=null)
This class represents a date/time property in a property form.
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
Class for single dates.
setDate(ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
buildData($a_time_from, $a_time_to, $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shortExport()

ilSessionStatisticsGUI::shortExport ( )
protected

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

References short().

259  {
260  $this->short(true);
261  }
+ 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.

◆ MODE_LAST_DAY

const ilSessionStatisticsGUI::MODE_LAST_DAY = 2

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

◆ MODE_LAST_MONTH

const ilSessionStatisticsGUI::MODE_LAST_MONTH = 4

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

◆ MODE_LAST_WEEK

const ilSessionStatisticsGUI::MODE_LAST_WEEK = 3

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

◆ MODE_MONTH

const ilSessionStatisticsGUI::MODE_MONTH = 7

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

◆ MODE_TODAY

const ilSessionStatisticsGUI::MODE_TODAY = 1

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

◆ MODE_WEEK

const ilSessionStatisticsGUI::MODE_WEEK = 6

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

◆ MODE_YEAR

const ilSessionStatisticsGUI::MODE_YEAR = 8

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

◆ SCALE_DAY

const ilSessionStatisticsGUI::SCALE_DAY = 1

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

◆ SCALE_MONTH

const ilSessionStatisticsGUI::SCALE_MONTH = 3

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

◆ SCALE_PERIODIC_WEEK

const ilSessionStatisticsGUI::SCALE_PERIODIC_WEEK = 5

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

◆ SCALE_WEEK

const ilSessionStatisticsGUI::SCALE_WEEK = 2

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

◆ SCALE_YEAR

const ilSessionStatisticsGUI::SCALE_YEAR = 4

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


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