root/trunk/wifidog-auth/wifidog/classes/Statistics.php @ 1013

Revision 1013, 27.0 KB (checked in by benoitg, 7 years ago)

* dump_initial_data_postgres.sh: Add the
content_available_display_pages table to the dump, can someone
re-generate the initial data from a working install
* Remove the ?> tags from all the classes.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5// +-------------------------------------------------------------------+
6// | WiFiDog Authentication Server                                     |
7// | =============================                                     |
8// |                                                                   |
9// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10// | portal suite.                                                     |
11// +-------------------------------------------------------------------+
12// | PHP version 5 required.                                           |
13// +-------------------------------------------------------------------+
14// | Homepage:     http://www.wifidog.org/                             |
15// | Source Forge: http://sourceforge.net/projects/wifidog/            |
16// +-------------------------------------------------------------------+
17// | This program is free software; you can redistribute it and/or     |
18// | modify it under the terms of the GNU General Public License as    |
19// | published by the Free Software Foundation; either version 2 of    |
20// | the License, or (at your option) any later version.               |
21// |                                                                   |
22// | This program is distributed in the hope that it will be useful,   |
23// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25// | GNU General Public License for more details.                      |
26// |                                                                   |
27// | You should have received a copy of the GNU General Public License |
28// | along with this program; if not, contact:                         |
29// |                                                                   |
30// | Free Software Foundation           Voice:  +1-617-542-5942        |
31// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33// |                                                                   |
34// +-------------------------------------------------------------------+
35
36/**
37 * @package    WiFiDogAuthServer
38 * @subpackage Statistics
39 * @author     Benoit Gregoire <bock@step.polymtl.ca>
40 * @copyright  2004-2006 Benoit Gregoire, Technologies Coeus inc.
41 * @version    Subversion $Id$
42 * @link       http://www.wifidog.org/
43 */
44
45/**
46 * Load required files
47 */
48require_once('include/common.php');
49
50/**
51 * Gives various statistics about the status of the network or of a specific node
52 *
53 * @package    WiFiDogAuthServer
54 * @subpackage Statistics
55 * @author     Benoit Gregoire <bock@step.polymtl.ca>
56 * @copyright  2004-2006 Benoit Gregoire, Technologies Coeus inc.
57 */
58class Statistics
59{
60    /** An array of the of the selected networks.
61     * The key is the network_id, the value is the Network object. */
62    private $report_selected_networks = array ();
63    private $report_date_min; /**< Minimum timestamp */
64    /** Maximum timestamp */
65    private $report_date_max;
66    /** How to distinguish unique users.  Either 'user_mac' (MAC adresses) or 'user_id' */
67    private $report_distinguish_users_by = 'user_id';
68
69    /* Options on how to distinguish users ,see constructor */
70    private $user_distinguish_by_options = array ();
71
72    /** An array of the node_ids to which the statistics should be restricted.
73         * The key is the network_id, the value is the Network object.*/
74    private $report_selected_nodes = array ();
75    /** An array of the selected reports to be generated.
76     *  The key is the classname, the value is the report object */
77    private $report_selected_reports = array ();
78
79    /** An array of the selected users to which the reports should be restricted.
80     *  The  key is the user_id or user_mac, the value is the User object,
81     *  or null if the key is a MAC address */
82    private $report_selected_users = array ();
83    function __construct()
84    {
85        $network = Network :: GetCurrentNetwork();
86        $this->report_selected_networks[$network->getId()] = $network;
87        $this->user_distinguish_by_options = array ('user_id' => _("Usernames"), 'user_mac' => _("MAC adresses"));
88
89    }
90
91    /**
92     * Get the list of available report types
93     *
94     * @return array An array of class names
95     */
96    public function getAvailableReports()
97    {
98        $dir = WIFIDOG_ABS_FILE_PATH . 'classes/StatisticReport';
99        if ($handle = opendir($dir))
100        {
101            $tab = Array ();
102            /* This is the correct way to loop over the directory. */
103            while (false !== ($file = readdir($handle)))
104            {
105                if ($file != '.' && $file != '..')
106                {
107                    $matches = null;
108                    if (preg_match("/^(.*)\.php$/", $file, $matches) > 0)
109                    {
110                        //pretty_print_r($matches);
111                        $filename = $dir.'/'.$matches[0];
112                        require_once ($filename);
113                        $classname = $matches[1];
114                        if (call_user_func(array ($classname, 'isAvailable'), $this))
115                        {
116                            $name = call_user_func(array ($classname, 'getReportName'), $this);
117
118                            $tab[$classname] = $name;
119                        }
120                    }
121                }
122            }
123            closedir($handle);
124        }
125        else
126        {
127            throw new Exception(_('Unable to open directory ').$dir);
128        }
129        $tab = str_ireplace('.php', '', $tab);
130        asort($tab);
131        return $tab;
132    }
133
134    /**
135     * UI for selecting the date ragnge for the report
136     *
137     * @return string HTML markup
138     */
139    private function getDateRangeUI()
140    {
141        $html = '';
142        $html .=<<<EOF
143<script language="javascript">
144    function change_value(value, from, to) {
145        if (value != "") {
146            var values_array = value.split(",");
147            from.value = values_array[0];
148            if (values_array[1]) {
149                to.value = values_array[1];
150            }
151        }
152    }
153</script>
154EOF;
155        $from_presets = array (_("No restriction...") => "", _("yesterday") => strftime("%Y-%m-%d 00:00", strtotime("-1 day")), _("today") => strftime("%Y-%m-%d 00:00", time()), _("2 days ago") => strftime("%Y-%m-%d 00:00", strtotime("-2 days")), _("3 days ago") => strftime("%Y-%m-%d 00:00", strtotime("-3 days")), _("1 week ago") => strftime("%Y-%m-%d 00:00", strtotime("-1 week")), _("2 weeks ago") => strftime("%Y-%m-%d 00:00", strtotime("-2 weeks")), _("3 weeks ago") => strftime("%Y-%m-%d 00:00", strtotime("-3 weeks")), _("1 month ago") => strftime("%Y-%m-%d 00:00", strtotime("-1 month")), _("2 months ago") => strftime("%Y-%m-%d 00:00", strtotime("-2 months")), _("6 months ago") => strftime("%Y-%m-%d 00:00", strtotime("-6 months")), _("1 year ago") => strftime("%Y-%m-%d 00:00", strtotime("-1 year")), _("-") => "", _("Select from and to...") => "", _("yesterday (whole day)") => strftime("%Y-%m-%d 00:00", strtotime("-1 day")).",".strftime("%Y-%m-%d 11:59", strtotime("-1 day")), _("today (whole day)") => strftime("%Y-%m-%d 00:00", time()).",".strftime("%Y-%m-%d %H:%M", time()), _("this month") => strftime("%Y-%m-01 00:00", time()).",".strftime("%Y-%m-%d %H:%M", time()), _("last month") => strftime("%Y-%m-01 00:00", strtotime("-1 month")).",".strftime("%Y-%m-01 00:00", time()), _("this year") => strftime("%Y-01-01 00:00", time()).",".strftime("%Y-%m-%d %H:%M", time()), _("forever") => "1970-01-01 00:00,".strftime("%Y-%m-%d %H:%M", time()));
156
157        $to_presets = array (_("No restriction...") => "", _("yesterday") => strftime("%Y-%m-%d 11:59", strtotime("-1 day")), _("today") => strftime("%Y-%m-%d 11:59", time()), _("2 days ago") => strftime("%Y-%m-%d 11:59", strtotime("-2 days")), _("3 days ago") => strftime("%Y-%m-%d 11:59", strtotime("-3 days")), _("1 week ago") => strftime("%Y-%m-%d 11:59", strtotime("-1 week")), _("2 weeks ago") => strftime("%Y-%m-%d 11:59", strtotime("-2 weeks")), _("3 weeks ago") => strftime("%Y-%m-%d 11:59", strtotime("-3 weeks")), _("1 month ago") => strftime("%Y-%m-%d 11:59", strtotime("-1 month")), _("2 months ago") => strftime("%Y-%m-%d 11:59", strtotime("-2 months")), _("6 months ago") => strftime("%Y-%m-%d 11:59", strtotime("-6 months")), _("1 year ago") => strftime("%Y-%m-%d 11:59", strtotime("-1 year")), _("-") => "", _("Select from and to...") => "", _("yesterday (whole day)") => strftime("%Y-%m-%d 11:59", strtotime("-1 day")).",".strftime("%Y-%m-%d 00:00", strtotime("-1 day")), _("today (whole day)") => strftime("%Y-%m-%d %H:%M", time()).",".strftime("%Y-%m-%d 00:00", time()), _("this month") => strftime("%Y-%m-%d %H:%M", time()).",".strftime("%Y-%m-01 00:00", time()), _("last month") => strftime("%Y-%m-01 00:00", time()).",".strftime("%Y-%m-01 00:00", strtotime("-1 month")), _("this year") => strftime("%Y-%m-%d %H:%M", time()).",".strftime("%Y-01-01 00:00", time()), _("forever") => strftime("%Y-%m-%d %H:%M", time()).",1970-01-01 00:00");
158
159        $html .= "<table>";
160        $html .= "<tr>";
161        $html .= "    <th>"._("From").":</th>";
162        $html .= "    <td><input type='text' name='date_from' value='{$this->report_date_min}'></td>";
163        $html .= "    <td>";
164        $html .= "    <select onChange=\"javascript:change_value(this.value,this.form.date_from,this.form.date_to);\">";
165
166        foreach ($from_presets as $label => $value)
167        {
168            //echo "<p>$value, $this->report_date_min </p>";
169            $value == $this->report_date_min ? $selected = 'SELECTED' : $selected = '';
170            $html .= "<option value=\"{$value}\" $selected>{$label}";
171        }
172
173        $html .= "    </select>\n";
174        $html .= "    </td>\n";
175        $html .= "</tr>\n";
176        $html .= "<tr>\n";
177        $html .= "    <th>"._("To").":</th>\n";
178        $html .= "    <td><input type=\"text\" name=\"date_to\" value=\"{$this->report_date_max}\"></td>\n";
179        $html .= "    <td>\n";
180        $html .= "    <select onChange=\"javascript:change_value(this.value,this.form.date_to,this.form.date_from);\">\n";
181
182        foreach ($to_presets as $label => $value)
183        {
184            $value == $this->report_date_max ? $selected = 'SELECTED' : $selected = '';
185            $html .= "<option value=\"{$value}\" $selected>{$label}";
186        }
187
188        $html .= "    </select>\n";
189        $html .= "    </td>\n";
190        $html .= "</tr>\n";
191        $html .= "</table>\n";
192        return $html;
193
194    }
195    /**
196     * Process the date range selection UI
197     *
198     * @return void
199     */
200    private function processDateRangeUI()
201    {
202        if (isset($_REQUEST['date_from'])) {
203            $this->report_date_min = $_REQUEST['date_from'];
204        }
205
206        if (isset($_REQUEST['date_to'])) {
207            $this->report_date_max = $_REQUEST['date_to'];
208        }
209    }
210
211    /**
212     * Get the actual SQL fragment to restrict a report to a specific date
213     *
214     * @param string $column The column in the database that must be higher or equal to
215     * the min date and lower or equal to the max date
216     * @return string SQL AND clauses
217     */
218    public function getSqlDateConstraint($column = 'timestamp_in')
219    {
220        global $db;
221        $column = $db->escapeString($column);
222        $sql = '';
223        if ($date_min = $db->escapeString($this->report_date_min))
224        {
225            $sql .= " AND $column >= '$date_min' ";
226        }
227        if ($date_max = $db->escapeString($this->report_date_max))
228        {
229            $sql .= " AND $column <= '$date_max' ";
230        }
231        return $sql;
232    }
233
234    /**
235     * Get the actual SQL fragment to restrict a report to the specific
236     * node(s) selected
237     *
238     * @param string $column The column in the database that must match the node_id
239     * @return string SQL AND clauses
240     */
241    public function getSqlNodeConstraint($column)
242    {
243        global $db;
244        $column = $db->escapeString($column);
245        $sql = '';
246        if (count($this->report_selected_nodes) > 0)
247        {
248            $sql .= " AND (";
249            $first = true;
250            foreach ($this->report_selected_nodes as $node_id => $node)
251            {
252                $node_id = $db->escapeString($node_id);
253                $first ? $sql .= "" : $sql .= " OR ";
254                $sql .= "$column = '$node_id'";
255                $first = false;
256            }
257            $sql .= ") \n";
258        }
259        return $sql;
260    }
261    /**
262     * Get the actual SQL fragment to restrict a report to a specific network(s)
263     * selected
264     * @param string $column The column in the database that must match the network_id
265     * @return string SQL AND clauses
266     */
267    public function getSqlNetworkConstraint($column)
268    {
269        global $db;
270        $column = $db->escapeString($column);
271        $sql = '';
272        if (count($this->report_selected_networks) > 0)
273        {
274            $sql .= " AND (";
275            $first = true;
276            foreach ($this->report_selected_networks as $network_id => $network)
277            {
278                $network_id = $db->escapeString($network_id);
279                $first ? $sql .= "" : $sql .= " OR ";
280                $sql .= "$column = '$network_id'";
281                $first = false;
282            }
283            $sql .= ") \n";
284        }
285        return $sql;
286    }
287    /**
288     * Get the actual SQL fragment to restrict a report to the specific
289     * user(s) selected
290     *
291     * @return string SQL AND clauses
292     */
293    public function getSqlUserConstraint()
294    {
295        global $db;
296        $column = $db->escapeString($this->report_distinguish_users_by);
297        $sql = '';
298        if (count($this->report_selected_users) > 0)
299        {
300            $sql .= " AND (";
301            $first = true;
302            foreach ($this->report_selected_users as $id => $user)
303            {
304                $id = $db->escapeString($id);
305                $first ? $sql .= "" : $sql .= " OR ";
306                $sql .= "$column = '$id'";
307                $first = false;
308            }
309            $sql .= ") \n";
310        }
311        return $sql;
312    }
313
314    /**
315     * Get the actual SQL fragment to get the candidates rows from the connections table,
316     * once obeying all the report configuration constraints.  Only connections
317     * with actuall data transferred is considered.  Connections is always
318     * joined to the nodes table, but not to network or users.
319     *
320     * @param string $select_columns The selected columns, will be inserted between
321     * between SELECT and FROM
322     * @param string $join_users true or false, Should we join with the users table?
323     * @return string SQL select statemnt.  You can append additional AND and GROUP BY
324     * clauses
325     */
326    public function getSqlCandidateConnectionsQuery($select_columns = '*', $join_users = false)
327    {
328        $sql = '';
329        $date_constraint = $this->getSqlDateConstraint('timestamp_in');
330        $node_constraint = $this->getSqlNodeConstraint('connections.node_id');
331        $network_constraint = $this->getSqlNetworkConstraint('nodes.network_id');
332        $user_constraint = $this->getSqlUserConstraint();
333        $join_users_sql = '';
334        if ($join_users)
335        {
336            $join_users_sql = "JOIN users ON (connections.user_id = users.user_id)";
337        }
338        $sql .= "SELECT $select_columns \n";
339
340        $sql .= "FROM connections  \n";
341        $sql .= "JOIN nodes ON (connections.node_id = nodes.node_id) \n";
342        $sql .= "$join_users_sql \n";
343        $sql .= "WHERE (incoming!=0 OR outgoing!=0) \n";
344        $sql .= " {$date_constraint} {$node_constraint} {$network_constraint} {$user_constraint}";
345        return $sql;
346    }
347
348    /**
349     * Get the actual SQL fragment to get all the conn_id of the all users first successfull connections from the connections table.  Only connections
350     * with actuall data transferred is considered. It will ignore all report
351     * configuration except getDistinguishUsersBy() and selected users, because
352     * doing otherwise would not give the real first connection.
353     *
354     * @return string SQL query
355     */
356    public function getSqlRealFirstConnectionsQuery($select_columns = '*', $join_users = false)
357    {
358        $sql = '';
359        $distinguish_users_by = $this->getDistinguishUsersBy();
360        $user_constraint = $this->getSqlUserConstraint();
361
362        $sql .= "SELECT DISTINCT ON(connections.$distinguish_users_by) connections.conn_id  \n";
363        $sql .= "FROM connections  \n";
364        $sql .= "WHERE (incoming!=0 OR outgoing!=0) \n";
365        $sql .= " {$user_constraint}";
366        $sql .= "  ORDER BY connections.$distinguish_users_by, timestamp_in DESC";
367
368        return $sql;
369    }
370
371    /**
372     * Get an interface to pick to which nodes the statistics apply.
373     *
374     * @return string HTML markup
375     */
376    private function getSelectedNodesUI()
377    {
378        global $db;
379        $html = '';
380        $name = "statistics_selected_nodes[]";
381        $user = User :: getCurrentUser();
382        if ($user->isSuperAdmin())
383        {
384            $sql_join = '';
385        }
386        else
387        {
388            $user_id = $db->escapeString($user->getId());
389            $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') ";
390        }
391        $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY node_id";
392        $node_rows = null;
393        $db->execSql($sql, $node_rows, false);
394        $html .= "<select multiple size = 6 name='$name'>\n";
395
396        /*count($this->report_selected_nodes)==0?$selected=' SELECTED ':$selected='';
397                    $html.= "<option value='' $selected>"._("Statistics for all nodes")."</option>\n";
398        */
399        if ($node_rows != null)
400        {
401            foreach ($node_rows as $node_row)
402            {
403                $html .= "<option ";
404                if (array_key_exists($node_row['node_id'], $this->report_selected_nodes))
405                {
406                    $html .= " SELECTED ";
407                }
408
409                $nom = $node_row['node_id'].": ".$node_row['name'];
410                $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8');
411                $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8');
412                $html .= "value='$primary_key'>$nom</option>\n";
413            }
414        }
415        $html .= "</select>\n";
416        return $html;
417    }
418
419    /**
420     * Get the select node interface.
421     */
422    private function processSelectedNodesUI()
423    {
424        $name = "statistics_selected_nodes";
425        //pretty_print_r($_REQUEST[$name]);
426        $this->report_selected_nodes = array ();
427        if (!empty ($_REQUEST[$name]))
428        {
429            foreach ($_REQUEST[$name] as $value)
430            {
431                if (!empty ($value))
432                    $this->report_selected_nodes[$value] = Node :: getObject($value);
433            }
434        }
435    }
436
437    /**
438     * Get the selected nodes for the reports.
439     * @return array An array of Node objects, with the node_id as the key, or
440     * an empty array
441     */
442    public function getSelectedNodes()
443    {
444        return $this->report_selected_nodes;
445    }
446
447    /**
448     * UI for selecting how the database determines if a user is unique
449     *
450     * @return string HTML markup
451     */
452    private function getDistinguishUsersByUI()
453    {
454        $html = '';
455
456        /*      $html .= " < input type = \ "radio\" name=\"group_connections\" value=\"\"";
457        $html .= empty ($_REQUEST['group_connections']) ? 'CHECKED' : '';
458        $html .= ">"._("No")."<br>";
459        */
460        $html .= "    <select name=\"distinguish_users_by\">";
461
462        foreach ($this->user_distinguish_by_options as $value => $label)
463        {
464            //echo "<p>$value, $this->report_date_min </p>";
465            $value == $this->report_distinguish_users_by ? $selected = 'SELECTED' : $selected = '';
466            $html .= "<option value=\"{$value}\" $selected>{$label}";
467        }
468
469        $html .= "    </select>\n";
470
471        return $html;
472    }
473
474    /**
475     * Process the date range selection UI
476     */
477    private function processDistinguishUsersByUI()
478    {
479        if (!isset ($this->user_distinguish_by_options[$_REQUEST['distinguish_users_by']]))
480            throw new exception(_("Invalid parameter"));
481        $this->report_distinguish_users_by = $_REQUEST['distinguish_users_by'];
482    }
483
484    /**
485     * Get how are users to be ddistinguished
486     *
487     * @return string Either 'user_id' our 'user_mac'
488     */
489    public function getDistinguishUsersBy()
490    {
491        return $this->report_distinguish_users_by;
492    }
493
494    /**
495     * UI for selecting to which users to restrict the reports
496     *
497     * @return string HTML markup
498     *
499     * @todo Allow to select more than one user
500     */
501    private function getSelectedUsersUI()
502    {
503        $html = '';
504        $value = '';
505        foreach ($this->report_selected_users as $id => $user)
506        {
507            if ($this->report_distinguish_users_by == 'user_id')
508            {
509                $value .= $user->getUsername();
510            }
511            else
512            {
513                $value .= $id;
514            }
515        }
516        $html .= "    <input type='text' name=\"stats_selected_users\" value='$value'>";
517
518        $type_caption = $this->user_distinguish_by_options[$this->report_distinguish_users_by];
519        $html .= " $type_caption\n";
520
521        return $html;
522    }
523
524    /**
525     * Process the users selection UI
526     *
527     * @todo Allow to select more than one user
528     */
529    private function processSelectedUsersUI()
530    {
531        $this->report_selected_users = array ();
532        $user_obj = null;
533        if ($this->report_distinguish_users_by == 'user_id')
534        {
535            global $db;
536            $username = $db->escapeString($_REQUEST['stats_selected_users']);
537            $row = null;
538            $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username='$username'", $row);
539            if ($row)
540            {
541                $user_id = $row['user_id'];
542                $user_obj = User :: getObject($user_id);
543                $this->report_selected_users[$user_id] = $user_obj;
544            }
545        }
546        else
547        {
548            //We have a MAC address
549            if (!empty ($_REQUEST['stats_selected_users']))
550                $this->report_selected_users[$_REQUEST['stats_selected_users']] = null;
551        }
552
553    }
554
555    /**
556     * Get the selected users for the reports.
557     *
558     * @return array An empty array or an array of user_id or MAC addresses as the
559     * key and a User object as the value, unless it's a MAC in which case the
560     * value is null
561     */
562    public function getSelectedUsers()
563    {
564        return $this->report_selected_users;
565    }
566
567    /**
568     * Get the selected nodes for the reports.
569     *
570     * @return array An array of Network objects, with the network_id as the
571     * key, or an empty array
572     */
573    public function getSelectedNetworks()
574    {
575        return $this->report_selected_networks;
576    }
577
578    /**
579     * UI for selecting how the database determines if a user is unique
580     *
581     * @return string HTML markup
582     */
583    private function getSelectedReportsUI()
584    {
585        $html = '';
586        $html .= "<ul>\n";
587        foreach (self :: getAvailableReports() as $key => $name)
588        {
589            array_key_exists($key, $this->report_selected_reports) ? $checked = ' CHECKED ' : $checked = '';
590            $html .= "<li><input type='checkbox' name='$key' $checked /> $name</li>\n";
591        }
592        $html .= "</ul>\n";
593
594        return $html;
595    }
596
597    /**
598     * Process the date range selection UI
599     */
600    private function processSelectedReportsUI()
601    {
602        $this->report_selected_reports = array ();
603        foreach (self :: getAvailableReports() as $key => $name)
604        {
605            if (array_key_exists($key, $_REQUEST))
606            {
607                $this->report_selected_reports[$key] = call_user_func(array ($key, 'getObject'), $key, $this);
608            }
609        }
610        //pretty_print_r($this->report_selected_reports);
611    }
612
613    public function getAdminUI()
614    {
615        $html = '';
616        $html .= "<h3>"._("Report configuration")."</h3>\n";
617        $html .= "<div class='admin_container'>\n";
618
619        // Network
620        $html .= "<div class='admin_section_container'>\n";
621        //$html .= "<div class='admin_section_title'>".." : </div>\n";
622        $html .= "<div class='admin_section_data'>\n";
623        $html .= Network :: getSelectNetworkUI('Statistics', reset($this->report_selected_networks));
624        $html .= "</div>\n";
625        $html .= "</div>\n";
626
627        // Date range
628        $html .= "<div class='admin_section_container'>\n";
629        $html .= "<div class='admin_section_title'>"._("Restrict the time range for which statistics will be computed")." : </div>\n";
630        $html .= "<div class='admin_section_data'>\n";
631        $html .= $this->getDateRangeUI();
632        $html .= "</div>\n";
633        $html .= "</div>\n";
634
635        // Selected nodes
636        $html .= "<div class='admin_section_container'>\n";
637        $html .= "<div class='admin_section_title'>"._("Restrict stats to the following nodes")." : </div>\n";
638        $html .= "<div class='admin_section_data'>\n";
639        $html .= $this->getSelectedNodesUI();
640        $html .= "</div>\n";
641        $html .= "</div>\n";
642
643        // Unique user criteria
644        $html .= "<div class='admin_section_container'>\n";
645        $html .= "<div class='admin_section_title'>"._("Distinguish users by")." : </div>\n";
646        $html .= "<div class='admin_section_data'>\n";
647        $html .= $this->getDistinguishUsersByUI();
648        $html .= "</div>\n";
649        $html .= "</div>\n";
650
651        // Selected users
652        $html .= "<div class='admin_section_container'>\n";
653        $html .= "<div class='admin_section_title'>"._("Restrict stats to the selected users")." : </div>\n";
654        $html .= "<div class='admin_section_data'>\n";
655        $html .= $this->getSelectedUsersUI();
656        $html .= "</div>\n";
657        $html .= "</div>\n";
658
659        // Reports
660        $html .= "<div class='admin_section_container'>\n";
661        $html .= "<div class='admin_section_title'>"._("Selected reports")." : </div>\n";
662        $html .= "<div class='admin_section_data'>\n";
663        $html .= $this->getSelectedReportsUI();
664        $html .= "</div>\n";
665        $html .= "</div>\n";
666        $html .= "</div>\n";
667        return $html;
668    }
669
670    public function processAdminUI()
671    {
672        $network = Network :: processSelectNetworkUI('Statistics');
673        $this->report_selected_networks = array ();
674        $this->report_selected_networks[$network->getId()] = $network;
675        $this->processDateRangeUI();
676        $this->processSelectedNodesUI();
677        $this->processDistinguishUsersByUI();
678        $this->processSelectedUsersUI();
679        $this->processSelectedReportsUI();
680    }
681
682    /**
683     * Get the output of all the selected reports
684     *
685     * @return string HTML markup
686     */
687    public function getReportUI()
688    {
689        $html = '';
690        foreach ($this->report_selected_reports as $classname => $report)
691        {
692            $html .= $report->getReportUI();
693            //$html.='<hr />';
694        }
695
696        return $html;
697    }
698
699}
700
701/*
702 * Local variables:
703 * tab-width: 4
704 * c-basic-offset: 4
705 * c-hanging-comment-ender-p: nil
706 * End:
707 */
708
709
Note: See TracBrowser for help on using the browser.