root/trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php @ 1249

Revision 1249, 8.1 KB (checked in by benoitg, 6 years ago)

-This is a behemoth "the road to 1.0" commit. I've been working on this for 6 months,
and it's reached the point where others can help. Those are very far reaching changes, please
notify me if anything isn't working right (and im sure I can't have caught everything).

Mostly complete. Missing parts are Content stakeholders, system roles and "su" functionnality.
I need help replacing all the DEPRECATED* methods. Please read the wiki page above for instructions.

  • generic_object_admin.php: More work towards making it generic once again.
  • GenericDataObject?: New class. Eventually, most classes should extend this, instead of directly implementing GenericObject?
  • Menu.php: Finally a uniform Menuing system to replace the mismatch of links that made wifidog impossible to navigate. It's not very sophisticated yet, but it IS permission aware Loosely inspired from Drupal's menuing system. HTML is slightly modified "Son of suckerfish", so will be easy to style (althouh I haven't had time yet). Actual menus are added in the hook_menu methods of each class.
  • VirtualHost.php: Finally properly split off Virtual Hosts, and make Server a singleton.
  • install.php: Do the bare minimum changes so it's still possible to setup a wifidog auth server. However, install.php still needs 1- A good overhaull, 2- A way to install sample databases instead of the minimal one. -Other changes
  • Unbreak signup link for non-javascript enabled devices
  • AbstractDb?: Improve debuging features
  • *:getObject(): Hopefully improve performance of class caching by making sure that we do not manipulate different objects. Otherwise copies would be generated as soon as we change properties, wasting much memory.
    • Add dependency check for XSL module for hotspot_status.php.
    • Some work towards respecting the coding style: http://dev.wifidog.org/wiki/doc/developer/CodingStandard
    • wifidog/admin/index.php: Delete admin page. There is no longuer a concept of a separate admin section. Menu will depend on your access level.
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 NodeLists
39 * @author     Max Horváth <max.horvath@freenet.de>
40 * @copyright  2006 Max Horváth, Horvath Web Consulting
41 * @version    Subversion $Id: Content.php 974 2006-02-25 15:08:12Z max-horvath $
42 * @link       http://www.wifidog.org/
43 */
44
45/**
46 * Load required classes
47 */
48require_once('classes/Dependency.php');
49require_once('classes/Network.php');
50require_once('classes/Node.php');
51require_once('classes/MainUI.php');
52require_once('classes/User.php');
53
54/**
55 * Defines the HTML type of node list
56 *
57 * @package    WiFiDogAuthServer
58 * @subpackage NodeLists
59 * @author     Max Horváth <max.horvath@freenet.de>
60 * @copyright  2006 Max Horváth, Horvath Web Consulting
61 */
62class NodeListHTML {
63
64    /**
65     * Smarty object
66     *
67     * @var object
68
69     */
70    private $_smarty;
71
72    /**
73     * Network to generate the list from
74     *
75     * @var object
76
77     */
78    private $_network;
79
80    /**
81     * Nodes to generate the list from
82     *
83     * @var array
84
85     */
86    private $_nodes;
87
88    /**
89     * Object of current user
90     *
91     * @var object
92
93     */
94    private $_currentUser;
95
96    /**
97     * Object of MainUI class
98     *
99     * @var object
100
101     */
102    private $_mainUI;
103
104    /**
105     * Constructor
106     *
107     * @return void
108     */
109    public function __construct(&$network)
110    {
111       
112        $db = AbstractDb::getObject();
113        $smarty = SmartyWifidog::getObject();
114
115        // Init Smarty
116        $this->_smarty = &$smarty;
117
118        // Init network
119        $this->_network = $network;
120
121        // Init user
122        $this->_currentUser = User::getCurrentUser();
123
124        // Init MainUI class
125        $this->_mainUI = MainUI::getObject();
126
127        // Query the database, sorting by node name
128        $db->execSql("SELECT *, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, EXTRACT(epoch FROM creation_date) as creation_date_epoch, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS is_up FROM nodes WHERE network_id = '" . $db->escapeString($this->_network->getId()) . "' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY lower(name)", $this->_nodes, false);
129    }
130
131    /**
132     * Sets header of output
133     *
134     * @return void
135     */
136    public function setHeader()
137    {
138        header("Cache-control: private, no-cache, must-revalidate");
139        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
140        header("Pragma: no-cache");
141    }
142
143    /**
144     * Retreives the output of this object.
145     *
146     * @param bool $return_object This parameter doesn't have any effect in
147     *                            the class
148     *
149     * @return void
150     *
151     * @author     Benoit Grégoire <bock@step.polymtl.ca>
152     * @author     Francois Proulx <francois.proulx@gmail.com>
153     * @author     Max Horváth <max.horvath@freenet.de>
154     * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc.
155     * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc.
156     * @copyright  2006 Max Horváth, Horvath Web Consulting
157     */
158    public function getOutput($return_object = false)
159    {
160        // Init ALL smarty SWITCH values
161        $this->_smarty->assign('sectionTOOLCONTENT', false);
162        $this->_smarty->assign('sectionMAINCONTENT', false);
163
164        // Init ALL smarty values
165        $this->_smarty->assign('DEPRECATEDisSuperAdmin', false);
166        $this->_smarty->assign('DEPRECATEDisOwner', false);
167        $this->_smarty->assign('GMapsEnabled', false);
168        $this->_smarty->assign('nodes', array());
169        $this->_smarty->assign('num_deployed_nodes', 0);
170        $this->_smarty->assign('PdfSupported', false);
171
172        /*
173         * Tool content
174         */
175
176        /**
177         * Define user security levels for the template
178         *
179         * These values are used in the default template of WiFoDog but could be used
180         * in a customized template to restrict certain links to specific user
181         * access levels.
182         */
183        $this->_smarty->assign('DEPRECATEDisSuperAdmin', $this->_currentUser && $this->_currentUser->DEPRECATEDisSuperAdmin());
184        $this->_smarty->assign('DEPRECATEDisOwner', $this->_currentUser && $this->_currentUser->DEPRECATEDisOwner());
185
186        if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
187            $this->_smarty->assign('GMapsEnabled', true);
188        }
189       
190        $_html=null;
191        /*
192         * Main content
193         */
194
195        // Reset ALL smarty SWITCH values
196        $this->_smarty->assign('sectionTOOLCONTENT', false);
197        $this->_smarty->assign('sectionMAINCONTENT', false);
198
199        // Set section of Smarty template
200        $this->_smarty->assign('sectionMAINCONTENT', true);
201
202        // Node details
203        if ($this->_nodes) {
204            foreach ($this->_nodes as $_nodeData) {
205                $_node = Node::getObject($_nodeData['node_id']);
206                $_nodeData['num_online_users'] = $_node->getNumOnlineUsers();
207                $this->_smarty->append("nodes", $_nodeData);
208            }
209        }
210
211        $this->_smarty->assign("num_deployed_nodes", count($this->_nodes));
212
213        // Compile HTML code
214        $_html_body = $this->_smarty->fetch("templates/sites/hotspot_status.tpl");
215
216        /*
217         * Compile HTML output
218         */
219        $this->_mainUI->setTitle(_("Hotspot list"));
220        $this->_mainUI->appendHtmlHeadContent('<link rel="alternate" type="application/rss+xml" title="' . $this->_network->getName() . ": " . _("Newest Hotspots") . '" href="' . BASE_SSL_PATH . 'hotspot_status.php?format=RSS">');
221        $this->_mainUI->addContent('left_area_middle', $_html);
222        $this->_mainUI->addContent('main_area_middle', $_html_body);
223
224        $this->_mainUI->display();
225    }
226
227}
228
229/*
230 * Local variables:
231 * tab-width: 4
232 * c-basic-offset: 4
233 * c-hanging-comment-ender-p: nil
234 * End:
235 */
236
Note: See TracBrowser for help on using the browser.