ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 690 of file class.ilSessionStatisticsGUI.php.

References array.

Referenced by exportCSV(), and getChart().

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

◆ adminSync()

ilSessionStatisticsGUI::adminSync ( )
protected

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

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

769  {
770  global $ilCtrl, $lng;
771 
772  // see ilSession::_writeData()
773  $now = time();
776 
777  ilUtil::sendSuccess($lng->txt("trac_sync_session_stats_success"), true);
778  $ilCtrl->redirect($this);
779  }
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 476 of file class.ilSessionStatisticsGUI.php.

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

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

477  {
478  global $lng;
479 
480  // basic data - time related
481 
482  $maxed_out_duration = round(ilSessionStatistics::getMaxedOutDuration($a_time_from, $a_time_to)/60);
483  $counters = ilSessionStatistics::getNumberOfSessionsByType($a_time_from, $a_time_to);
484  $opened = (int)$counters["opened"];
485  $closed_limit = (int)$counters["closed_limit"];
486  unset($counters["opened"]);
487  unset($counters["closed_limit"]);
488 
489 
490  // build center column
491 
492  $data = array();
493 
495  $data["title"] = $a_title." (".
497  new ilDateTime($a_time_to, IL_CAL_UNIX)).")";
498 
499  $data["maxed_out_time"] = array($lng->txt("trac_maxed_out_time"), $maxed_out_duration);
500  $data["maxed_out_counter"] = array($lng->txt("trac_maxed_out_counter"), $closed_limit);
501  $data["opened"] = array($lng->txt("trac_sessions_opened"), $opened);
502  $data["closed"] = array($lng->txt("trac_sessions_closed"), array_sum($counters));
503  foreach($counters as $type => $counter)
504  {
505  $data["closed_details"][] = array($lng->txt("trac_".$type), (int)$counter);
506  }
507 
508  $data["active"] = ilSessionStatistics::getActiveSessions($a_time_from, $a_time_to);
509 
510  return $data;
511  }
static getMaxedOutDuration($a_from, $a_to)
Get maxed out duration in given timeframe.
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
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.
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 62 of file class.ilSessionStatisticsGUI.php.

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

Referenced by currentExport().

63  {
64  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
65 
66  $ilTabs->activateSubTab("current");
67 
68  // current mode
69  if(!$_REQUEST["smd"])
70  {
71  $_REQUEST["smd"] = self::MODE_TODAY;
72  }
73  $mode = (int)$_REQUEST["smd"];
74 
75  // current measure
76  if(!$_REQUEST["smm"])
77  {
78  $_REQUEST["smm"] = "avg";
79  }
80  $measure = (string)$_REQUEST["smm"];
81 
82 
83  switch($mode)
84  {
85  case self::MODE_TODAY:
86  $time_from = strtotime("today");
87  $time_to = strtotime("tomorrow")-1;
88  $scale = self::SCALE_DAY;
89  break;
90 
91  case self::MODE_LAST_DAY:
92  $time_to = time();
93  $time_from = $time_to-60*60*24;
94  $scale = self::SCALE_DAY;
95  break;
96 
97  case self::MODE_LAST_WEEK:
98  $time_to = time();
99  $time_from = $time_to-60*60*24*7;
100  $scale = self::SCALE_WEEK;
101  break;
102 
103  case self::MODE_LAST_MONTH:
104  $time_to = time();
105  $time_from = $time_to-60*60*24*30;
106  $scale = self::SCALE_MONTH;
107  break;
108  }
109 
110  $mode_options = array(
111  self::MODE_TODAY => $lng->txt("trac_session_statistics_mode_today"),
112  self::MODE_LAST_DAY => $lng->txt("trac_session_statistics_mode_last_day"),
113  self::MODE_LAST_WEEK => $lng->txt("trac_session_statistics_mode_last_week"),
114  self::MODE_LAST_MONTH => $lng->txt("trac_session_statistics_mode_last_month"));
115 
116  $title = $lng->txt("trac_current_system_load")." - ".$mode_options[$mode];
117  $data = $this->buildData($time_from, $time_to, $title);
118 
119  if(!$a_export)
120  {
121  // toolbar
122  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
123  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "current"));
124 
125  $mode_selector = new ilSelectInputGUI("&nbsp;".$lng->txt("trac_scale"), "smd");
126  $mode_selector->setOptions($mode_options);
127  $mode_selector->setValue($mode);
128  $ilToolbar->addInputItem($mode_selector, true);
129 
130  $measure_options = array(
131  "avg" => $lng->txt("trac_session_active_avg"),
132  "min" => $lng->txt("trac_session_active_min"),
133  "max" => $lng->txt("trac_session_active_max"));
134 
135  $measure_selector = new ilSelectInputGUI("&nbsp;".$lng->txt("trac_measure"), "smm");
136  $measure_selector->setOptions($measure_options);
137  $measure_selector->setValue($measure);
138  $ilToolbar->addInputItem($measure_selector, true);
139 
140  $ilToolbar->addFormButton($lng->txt("ok"), "current");
141 
142  if(sizeof($data["active"]))
143  {
144  $ilToolbar->addSeparator();
145  $ilToolbar->addFormButton($lng->txt("export"), "currentExport");
146  }
147 
148  $tpl->setContent($this->render($data, $scale, $measure));
149 
150  $tpl->setLeftContent($this->renderCurrentBasics());
151  }
152  else
153  {
154  $this->exportCSV($data, $scale);
155  }
156  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
Add rich text string
The name of the decorator.
global $tpl
Definition: ilias.php:8
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 158 of file class.ilSessionStatisticsGUI.php.

References current().

159  {
160  $this->current(true);
161  }
+ Here is the call graph for this function:

◆ executeCommand()

ilSessionStatisticsGUI::executeCommand ( )

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

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

33  {
34  global $ilCtrl;
35 
36  $this->setSubTabs();
37 
38  switch($ilCtrl->getNextClass())
39  {
40  default:
41  $cmd = $ilCtrl->getCmd("current");
42  $this->$cmd();
43  }
44 
45  return true;
46  }
$cmd
Definition: sahs_server.php:35
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 781 of file class.ilSessionStatisticsGUI.php.

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

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

782  {
783  global $lng, $ilClientIniFile, $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") =>
799  $lng->txt("trac_report_owner") => $ilUser->getFullName(),
800  );
801  foreach($a_data as $idx => $item)
802  {
803  switch($idx)
804  {
805  case "title":
806  $meta[$lng->txt("title")] = $item;
807  break;
808 
809  case "active":
810  // nothing to do
811  break;
812 
813  case "closed_details":
814  foreach($item as $detail)
815  {
816  $meta[$a_data["closed"][0]." - ".$detail[0]] = $detail[1];
817  }
818  break;
819 
820  default:
821  $meta[$item[0]] = $item[1];
822  break;
823  }
824  }
825  foreach($meta as $caption => $value)
826  {
827  $csv->addColumn(strip_tags($caption));
828  $csv->addColumn(strip_tags($value));
829  $csv->addRow();
830  }
831  $csv->addRow();
832 
833  // aggregate data
834  $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"], 700);
835  unset($a_data);
836 
837  // header
838  $first = $aggr_data;
839  $first = array_keys(array_shift($first));
840  foreach ($first as $column)
841  {
842  // split weekday and time slot again
843  if($a_scale == self::SCALE_PERIODIC_WEEK && $column == "slot_begin")
844  {
845  $csv->addColumn("weekday");
846  $csv->addColumn("time");
847  }
848  else
849  {
850  $csv->addColumn(strip_tags($column));
851  }
852  }
853  $csv->addRow();
854 
855  // data
856  foreach($aggr_data as $row)
857  {
858  foreach ($row as $column => $value)
859  {
860  if(is_array($value))
861  {
862  $value = implode(', ', $value);
863  }
864  switch($column)
865  {
866  case "slot_begin":
867  // split weekday and time slot again
868  if($a_scale == self::SCALE_PERIODIC_WEEK)
869  {
870  $csv->addColumn(ilCalendarUtil::_numericDayToString(substr($value, 0, 1)));
871  $value = substr($value, 1, 2).":".substr($value, 3, 2);
872  break;
873  }
874  // fallthrough
875 
876  case "slot_end":
877  $value = date("d.m.Y H:i", $value);
878  break;
879  }
880  $csv->addColumn(strip_tags($value));
881  }
882  $csv->addRow();
883  }
884 
885  // send
886  $filename .= "session_statistics_".date("Ymd", $now).".csv";
887  header("Content-type: text/comma-separated-values");
888  header("Content-Disposition: attachment; filename=\"".$filename."\"");
889  header("Expires: 0");
890  header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
891  header("Pragma: public");
892  echo $csv->getCSVString();
893  exit();
894  }
const IL_CAL_DATETIME
Helper class to generate CSV files.
static _numericDayToString($a_day, $a_long=true)
get
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
$column
Definition: 39dropdown.php:62
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static formatDate(ilDateTime $date)
Format a date public.
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 567 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().

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

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

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

164  {
165  if(!$a_default)
166  {
167  $a_default = time();
168  }
169 
170  include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
171  $parsed = ilCalendarUtil::parseIncomingDate($a_incoming);
172  return $parsed
173  ? $parsed->get(IL_CAL_UNIX)
174  : $a_default;
175  }
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 267 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().

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

References long().

342  {
343  $this->long(true);
344  }
+ Here is the call graph for this function:

◆ periodic()

ilSessionStatisticsGUI::periodic (   $a_export = false)
protected

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

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

Referenced by periodicExport().

347  {
348  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
349 
350  $ilTabs->activateSubTab("periodic");
351 
352  // current start
353  $time_to = $this->importDate($_REQUEST["sst"]);
354 
355  // current end
356  $time_from = $this->importDate($_REQUEST["sto"], strtotime("-7 days"));
357 
358  // mixed up dates?
359  if($time_to < $time_from)
360  {
361  $tmp = $time_to;
362  $time_to = $time_from;
363  $time_from = $tmp;
364  }
365 
366  $title = $lng->txt("trac_periodic_system_load");
367  $data = $this->buildData($time_from, $time_to, $title);
368 
369  if(!$a_export)
370  {
371  // toolbar
372  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
373  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "periodic"));
374 
375  $end_selector = new ilDateTimeInputGUI($lng->txt("trac_begin_at"), "sto");
376  $end_selector->setDate(new ilDate($time_from, IL_CAL_UNIX));
377  $ilToolbar->addInputItem($end_selector, true);
378 
379  $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
380  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
381  $ilToolbar->addInputItem($start_selector, true);
382 
383  $ilToolbar->addFormButton($lng->txt("ok"), "periodic");
384 
385  if(sizeof($data["active"]))
386  {
387  $ilToolbar->addSeparator();
388  $ilToolbar->addFormButton($lng->txt("export"), "periodicExport");
389  }
390 
391  $tpl->setContent($this->render($data, self::SCALE_PERIODIC_WEEK));
392  }
393  else
394  {
395  $this->exportCSV($data, self::SCALE_PERIODIC_WEEK);
396  }
397  }
exportCSV(array $a_data, $a_scale)
const IL_CAL_UNIX
setDate(ilDateTime $a_date=NULL)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
importDate($a_incoming, $a_default=null)
This class represents a date/time property in a property form.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
Class for single dates.
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 399 of file class.ilSessionStatisticsGUI.php.

References periodic().

400  {
401  $this->periodic(true);
402  }
+ Here is the call graph for this function:

◆ render()

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

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

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

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

514  {
515  global $lng;
516 
517  $center = new ilTemplate("tpl.session_statistics_center.html", true, true, "Services/Authentication");
518 
519  foreach($a_data as $idx => $item)
520  {
521  switch($idx)
522  {
523  case "active":
524  case "title":
525  // nothing to do
526  break;
527 
528  case "closed_details":
529  $center->setCurrentBlock("closed_details");
530  foreach($item as $detail)
531  {
532  $center->setVariable("CAPTION_CLOSED_DETAILS", $detail[0]);
533  $center->setVariable("VALUE_CLOSED_DETAILS", $detail[1]);
534  $center->parseCurrentBlock();
535  }
536  break;
537 
538  default:
539  $tpl_var = strtoupper($idx);
540  $center->setVariable("CAPTION_".$tpl_var, $item[0]);
541  $center->setVariable("VALUE_".$tpl_var, $item[1]);
542  break;
543  }
544  }
545 
546  if($a_data["active"])
547  {
548  $center->setVariable("CHART", $this->getChart($a_data["active"], $a_data["title"], $a_scale, $a_measure));
549  }
550  else
551  {
552  ilUtil::sendInfo($lng->txt("trac_session_statistics_no_data"));
553  }
554 
555  return $center->get();
556  }
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 404 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().

405  {
406  global $ilSetting, $lng, $ilCtrl, $ilAccess;
407 
408  // basic data - not time related
409 
410  include_once "Services/Authentication/classes/class.ilSessionControl.php";
412 
413  $control_active = ($ilSetting->get('session_handling_type', 0) == 1);
414  if($control_active)
415  {
416  $control_max_sessions = (int)$ilSetting->get('session_max_count', ilSessionControl::DEFAULT_MAX_COUNT);
417  $control_min_idle = (int)$ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE);
418  $control_max_idle = (int)$ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE);
419  $control_max_idle_first = (int)$ilSetting->get('session_max_idle_after_first_request', ilSessionControl::DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST);
420  }
421 
424 
425 
426  // build left column
427 
428  $left = new ilTemplate("tpl.session_statistics_left.html", true, true, "Services/Authentication");
429 
430  $left->setVariable("CAPTION_CURRENT", $lng->txt("users_online"));
431  $left->setVariable("VALUE_CURRENT", $active);
432 
433  $left->setVariable("CAPTION_LAST_AGGR", $lng->txt("trac_last_aggregation"));
434  $left->setVariable("VALUE_LAST_AGGR", ilDatePresentation::formatDate($last_aggr));
435 
436  $left->setVariable("CAPTION_LAST_MAX", $lng->txt("trac_last_maxed_out_sessions"));
437  $left->setVariable("VALUE_LAST_MAX", ilDatePresentation::formatDate($last_maxed_out));
438 
439  $left->setVariable("CAPTION_SESSION_CONTROL", $lng->txt("sess_load_dependent_session_handling"));
440  if(!$control_active)
441  {
442  $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("no"));
443  }
444  else
445  {
446  $left->setVariable("VALUE_SESSION_CONTROL", $lng->txt("yes"));
447 
448  $left->setCurrentBlock("control_details");
449 
450  $left->setVariable("CAPTION_SESSION_CONTROL_LIMIT", $lng->txt("session_max_count"));
451  $left->setVariable("VALUE_SESSION_CONTROL_LIMIT", $control_max_sessions);
452 
453  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MIN", $lng->txt("session_min_idle"));
454  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MIN", $control_min_idle);
455 
456  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_MAX", $lng->txt("session_max_idle"));
457  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_MAX", $control_max_idle);
458 
459  $left->setVariable("CAPTION_SESSION_CONTROL_IDLE_FIRST", $lng->txt("session_max_idle_after_first_request"));
460  $left->setVariable("VALUE_SESSION_CONTROL_IDLE_FIRST", $control_max_idle_first);
461 
462  $left->parseCurrentBlock();
463  }
464 
465  // sync button
466  if($ilAccess->checkAccess("write", "", (int)$_REQUEST["ref_id"]))
467  {
468  $left->setVariable("URL_SYNC", $ilCtrl->getFormAction($this, "adminSync"));
469  $left->setVariable("CMD_SYNC", "adminSync");
470  $left->setVariable("TXT_SYNC", $lng->txt("trac_sync_session_stats"));
471  }
472 
473  return $left->get();
474  }
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet ...
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
static formatDate(ilDateTime $date)
Format a date public.
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 48 of file class.ilSessionStatisticsGUI.php.

References $ilCtrl, and $lng.

Referenced by executeCommand().

49  {
50  global $ilTabs, $ilCtrl, $lng;
51 
52  $ilTabs->addSubTab("current", $lng->txt("trac_current_system_load"),
53  $ilCtrl->getLinkTarget($this, "current"));
54  $ilTabs->addSubTab("short", $lng->txt("trac_short_system_load"),
55  $ilCtrl->getLinkTarget($this, "short"));
56  $ilTabs->addSubTab("long", $lng->txt("trac_long_system_load"),
57  $ilCtrl->getLinkTarget($this, "long"));
58  $ilTabs->addSubTab("periodic", $lng->txt("trac_periodic_system_load"),
59  $ilCtrl->getLinkTarget($this, "periodic"));
60  }
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 177 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().

178  {
179  global $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng;
180 
181  $ilTabs->activateSubTab("short");
182 
183  // current start
184  $time_to = $this->importDate($_REQUEST["sst"]);
185 
186  // current mode
187  if(!$_REQUEST["smd"])
188  {
189  $_REQUEST["smd"] = self::MODE_DAY;
190  }
191  $mode = (int)$_REQUEST["smd"];
192 
193  // current measure
194  if(!$_REQUEST["smm"])
195  {
196  $_REQUEST["smm"] = "avg";
197  }
198  $measure = (string)$_REQUEST["smm"];
199 
200  switch($mode)
201  {
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  {
223  // toolbar
224  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
225  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "short"));
226 
227  $start_selector = new ilDateTimeInputGUI($lng->txt("trac_end_at"), "sst");
228  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
229  $ilToolbar->addInputItem($start_selector, true);
230 
231  $mode_selector = new ilSelectInputGUI("&nbsp;".$lng->txt("trac_scale"), "smd");
232  $mode_selector->setOptions($mode_options);
233  $mode_selector->setValue($mode);
234  $ilToolbar->addInputItem($mode_selector, true);
235 
236  $measure_options = array(
237  "avg" => $lng->txt("trac_session_active_avg"),
238  "min" => $lng->txt("trac_session_active_min"),
239  "max" => $lng->txt("trac_session_active_max"));
240 
241  $measure_selector = new ilSelectInputGUI("&nbsp;".$lng->txt("trac_measure"), "smm");
242  $measure_selector->setOptions($measure_options);
243  $measure_selector->setValue($measure);
244  $ilToolbar->addInputItem($measure_selector, true);
245 
246  $ilToolbar->addFormButton($lng->txt("ok"), "short");
247 
248  if(sizeof($data["active"]))
249  {
250  $ilToolbar->addSeparator();
251  $ilToolbar->addFormButton($lng->txt("export"), "shortExport");
252  }
253 
254  $tpl->setContent($this->render($data, $scale, $measure));
255  }
256  else
257  {
258  $this->exportCSV($data, $scale);
259  }
260  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
Add rich text string
The name of the decorator.
const IL_CAL_UNIX
setDate(ilDateTime $a_date=NULL)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
importDate($a_incoming, $a_default=null)
This class represents a date/time property in a property form.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
render($a_data, $a_scale, $a_measure=null)
Class for single dates.
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 262 of file class.ilSessionStatisticsGUI.php.

References short().

263  {
264  $this->short(true);
265  }
+ 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: