root/trunk/wifidog-auth/wifidog/portal/index.php @ 779

Revision 779, 10.4 KB (checked in by benoitg, 8 years ago)

2005-09-27 Benoit Gr�goire <bock@…>

  • Partial login page content manager support (Node only for now)
  • 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// $Id$
4/********************************************************************\
5 * This program is free software; you can redistribute it and/or    *
6 * modify it under the terms of the GNU General Public License as   *
7 * published by the Free Software Foundation; either version 2 of   *
8 * the License, or (at your option) any later version.              *
9 *                                                                  *
10 * This program is distributed in the hope that it will be useful,  *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
13 * GNU General Public License for more details.                     *
14 *                                                                  *
15 * You should have received a copy of the GNU General Public License*
16 * along with this program; if not, contact:                        *
17 *                                                                  *
18 * Free Software Foundation           Voice:  +1-617-542-5942       *
19 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
20 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
21 *                                                                  *
22 \********************************************************************/
23/**@file index.php Displays the portal page
24 * @author Copyright (C) 2004 Benoit Gr�goire et Philippe April
25 */
26
27define('BASEPATH', '../');
28require_once BASEPATH.'include/common.php';
29require_once BASEPATH.'include/common_interface.php';
30require_once BASEPATH.'classes/Node.php';
31require_once BASEPATH.'classes/MainUI.php';
32define('TOOLBAR_WIDTH','250');//Must match the stylesheet for the tool section width
33
34$node = null;
35if (!empty ($_REQUEST['gw_id']))
36        $node = Node :: getObject($_REQUEST['gw_id']);
37
38if ($node == null)
39{
40        $smarty->display("templates/message_unknown_hotspot.html");
41        exit;
42}
43$network = $node->getNetwork();
44
45/*  If this node has a custom portal defined, and the network config allows it, redirect to the custom portal */ 
46$custom_portal_url = $node->getCustomPortalRedirectUrl();
47if(!empty($custom_portal_url) && $network->getCustomPortalRedirectAllowed())
48{
49        header("Location: {$custom_portal_url}");
50}
51
52
53$node_id = $node->getId();
54$portal_template = $node_id.".html";
55Node :: setCurrentNode($node);
56
57$ui = new MainUI();
58if (isset ($session))
59{
60    if(!empty($_REQUEST['gw_id']))
61        $session->set(SESS_GW_ID_VAR, $_REQUEST['gw_id']);
62
63}
64
65$tool_html = '';
66
67$tool_html .= "<h1>"._("Online users")."</h1>"."\n";
68$tool_html .= '<p class="indent">'."\n";
69$current_node = Node :: getCurrentNode();
70if ($current_node != null)
71{
72        $current_node_id = $current_node->getId();
73        $online_users = $current_node->getOnlineUsers();
74        $num_online_users = count($online_users);
75        if ($num_online_users > 0)
76        {
77                //$tool_html .= $num_online_users.' '._("other users online at this hotspot...");
78        $tool_html .= "<ul class='users_list'>\n";
79        foreach($online_users as $online_user)
80            $tool_html .= "<li>{$online_user->getUsername()}</li>\n";
81        $tool_html .= "</ul>\n";
82        }
83        else
84        {
85                $tool_html .= _("Nobody is online at this hotspot...");
86        }
87}
88else
89{
90        $network = Network::getCurrentNetwork();
91        $current_node_id = null;
92        $tool_html .= _("You are not currently at a hotspot...");
93}
94$tool_html .= "</p>"."\n";
95
96$tool_html .= '<script type="text/javascript">
97function getElementById(id) {
98    if (document.all) {
99        return document.getElementById(id);
100    }
101    for (i=0;i<document.forms.length;i++) {
102        if (document.forms[i].elements[id]) {return document.forms[i].elements[id]; }
103    }
104}
105
106function getWindowSize(window) {
107var size_array = new Array(2);
108  var myWidth = 0, myHeight = 0;
109  if( typeof( window.innerWidth ) == "number" ) {
110    //Non-IE
111    myWidth = window.innerWidth;
112    myHeight = window.innerHeight;
113  } else if( document.documentElement &&
114      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
115    //IE 6+ in "standards compliant mode"
116    myWidth = document.documentElement.clientWidth;
117    myHeight = document.documentElement.clientHeight;
118  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
119    //IE 4 compatible
120    myWidth = document.body.clientWidth;
121    myHeight = document.body.clientHeight;
122  }
123  size_array[0] = myWidth;
124  size_array[1] = myHeight;
125//  window.alert( "Width = " + myWidth );
126//  window.alert( "Height = " + myHeight );
127return size_array;
128}
129
130
131</script>';
132
133
134$tool_html .= '<p class="indent">'."\n";
135$tool_html .= "<a  id='wifidog_portal_expand' onclick=\"
136var wifidog_portal_expand = getElementById('wifidog_portal_expand');
137var wifidog_portal_collapse = getElementById('wifidog_portal_collapse');
138
139wifidog_portal_expand.style.display = 'none';
140wifidog_portal_collapse.style.display = 'inline';
141var size_array = getWindowSize(window.opener);
142window.resizeTo(size_array[0],size_array[1]);
143\">"._("Expand portal")."</a>"."\n";
144
145$tool_html .= "<a id='wifidog_portal_collapse' onclick=\"
146var wifidog_portal_expand = getElementById('wifidog_portal_expand');
147var wifidog_portal_collapse = getElementById('wifidog_portal_collapse');
148
149wifidog_portal_expand.style.display = 'inline';
150wifidog_portal_collapse.style.display = 'none';
151var size_array = getWindowSize(window.opener);
152window.resizeTo('".TOOLBAR_WIDTH."',size_array[1]);
153
154\">"._("Collapse portal")."</a>"."\n";
155$tool_html .= "</p>"."\n";
156
157
158
159
160        $original_url_requested=$session->get(SESS_ORIGINAL_URL_VAR);
161        if(empty($original_url_requested))
162        {
163                $url="missing_original_url.php";
164        }
165        else
166        {
167                $url=$original_url_requested;
168        }
169$tool_html .= '<p class="indent">'."\n";
170$tool_html .= "<a id='wifidog_use_internet' href='$url' onclick=\"
171var size_array = getWindowSize(window);
172var original_location=window.location.href;
173//this.target='_blank';
174var old_window = window;
175var new_window = window.open('".CURRENT_REQUEST_URL."','wifidog_portal');
176new_window.blur();
177old_window.focus();
178new_window.resizeTo('".TOOLBAR_WIDTH."',size_array[1]);
179
180//old_window.location.href='test';
181//window.moveBy(300, 300);
182/*if(window.open){alert('window.open enabled');}
183else{alert('window.open DISABLED');}*/
184
185\"><img src='/images/start.gif'></a>\n";
186$tool_html .= "</p>"."\n";
187
188$tool_html .= '<script type="text/javascript">
189//Set up if expand/collapse functionnality is to be enabled by checking if we were called from another portal window.
190
191window.is_wifidog_portal=true; //This assignement may be read by another window
192
193var wifidog_portal_expand = document.getElementById("wifidog_portal_expand");
194var wifidog_portal_collapse = document.getElementById("wifidog_portal_collapse");
195var wifidog_use_internet = document.getElementById("wifidog_use_internet");
196if(window.opener && window.opener.is_wifidog_portal==true)
197{
198wifidog_portal_expand.style.display = "inline";
199wifidog_portal_collapse.style.display = "none";
200wifidog_use_internet.style.display = "none";
201}
202else
203{
204wifidog_portal_expand.style.display = "none";
205wifidog_portal_collapse.style.display = "none";
206}
207</script>';
208
209$ui->setToolContent($tool_html);
210
211$hotspot_network_name = $network->getName();
212$hotspot_network_url = $network->getHomepageURL();
213$network_logo_url = COMMON_CONTENT_URL.NETWORK_LOGO_NAME;
214$network_logo_banner_url = COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME;
215
216$hotspot_logo_banner_url = find_local_content_url(HOTSPOT_LOGO_BANNER_NAME);
217
218// Get the current user
219$current_user = User :: getCurrentUser();
220
221$html = '';
222
223// While in validation period, alert user that he should validate his account ASAP
224if($current_user && $current_user->getAccountStatus() == ACCOUNT_STATUS_VALIDATION)
225        $html .= "<div id='warning_message_area'>"._('An email with confirmation instructions was sent to your email address.  Your account has been granted 15 minutes of access to retrieve your email and validate your account.')."</div>";
226       
227$html .= "<div id='portal_container'>\n";
228
229
230/* Network section */
231
232// This table ( width 100% ) force each section to display on top of each other, even though the content will float
233// Until we find a better solution CSS only...
234$html .= "<table><tr><td>";
235$html .= "<div class='portal_network_section'>\n";
236$html .= "<a href='{$hotspot_network_url}'><img class='portal_section_logo' alt='{$hotspot_network_name} logo' src='{$network_logo_banner_url}' border='0'></a>\n";
237// Get all network content and EXCLUDE user subscribed content
238if($current_user)
239    $contents = Network :: getCurrentNetwork()->getAllContent(true, $current_user);
240else
241    $contents = Network :: getCurrentNetwork()->getAllContent();
242if ($contents)
243{
244        foreach ($contents as $content)
245        {
246                if ($content->isDisplayableAt($node))
247                {
248                        $html .= "<div class='portal_content'>\n";
249                        $html .= $content->getUserUI();
250                        $html .= "</div>\n";
251                }
252        }
253}
254$html .= "</div>\n";
255$html .= "</td></tr></table>";
256
257/* Node section */
258// Get all node content and EXCLUDE user subscribed content
259if($current_user)
260    $contents = $node->getAllContent(true, $current_user);
261else
262    $contents = $node->getAllContent();
263if($contents)
264{
265    $html .= "<table><tr><td>";
266    $html .= "<div class='portal_node_section'>\n";
267    $html .= "<span class='portal_section_title'>"._("Content from:")." ";
268    $node_homepage = $node->getHomePageURL();
269    if (!empty ($node_homepage))
270    {
271        $html .= "<a href='$node_homepage'>";
272    }
273    $html .= $node->getName();
274    if (!empty ($node_homepage))
275    {
276        $html .= "</a>\n";
277    }
278    $html .= "</span>";
279    foreach ($contents as $content)
280    {
281        if ($content->isDisplayableAt($node))
282        {
283                $html .= "<div class='portal_content'>\n";
284                $html .= $content->getUserUI();
285                $html .= "</div>\n";
286        }
287    }
288    $html .= "</div>\n";
289    $html .= "</td></tr></table>";
290}
291
292/* User section */
293if($current_user)
294{
295    $contents = User :: getCurrentUser()->getAllContent();
296    if($contents)
297    {
298        $html .= "<table><tr><td>";
299        $html .= "<div class='portal_user_section'>\n";
300        $html .= "<h1>"._("My content")."</h1>\n";
301        foreach ($contents as $content)
302        {
303                $html .= "<div class='portal_content'>\n";
304                $html .= $content->getUserUI();
305                $html .= "</div>\n";
306        }
307        $html .= "</div>\n";
308        $html .= "</td></tr></table>";
309    }
310}
311
312// Hyperlinks to full content display page
313$html .= "<a href='/content/?gw_id={$current_node_id}'>"._("Show all available contents for this hotspot")."</a>"."\n";
314
315$html .= "<div style='clear:both;'></div>";
316$html .= "</div>\n";
317
318$ui->setMainContent($html);
319$ui->display();
320?>
Note: See TracBrowser for help on using the browser.