root/trunk/wifidog-auth/wifidog/classes/MainUI.php @ 630

Revision 630, 12.6 KB (checked in by fproulx, 8 years ago)

2005-05-16 Francois Proulx <francois.proulx@…>

  • Changed login message in MainUI to make it clearer what the login button will do
  • 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 * This program is free software; you can redistribute it and/or    *
4 * modify it under the terms of the GNU General Public License as   *
5 * published by the Free Software Foundation; either version 2 of   *
6 * the License, or (at your option) any later version.              *
7 *                                                                  *
8 * This program is distributed in the hope that it will be useful,  *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
11 * GNU General Public License for more details.                     *
12 *                                                                  *
13 * You should have received a copy of the GNU General Public License*
14 * along with this program; if not, contact:                        *
15 *                                                                  *
16 * Free Software Foundation           Voice:  +1-617-542-5942       *
17 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
18 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
19 *                                                                  *
20 \********************************************************************/
21/**@file MainUI.php
22 * @author Copyright (C) 2005 Technologies Coeus inc.
23 */
24require_once BASEPATH.'include/common.php';
25require_once BASEPATH.'include/common_interface.php';
26/** Style contains functions managing headers, footers, stylesheet, etc.
27 */
28class MainUI
29{
30        private $main_content; /**<Content to be displayed in the main pane */
31        private $tool_content; /**<Content to be displayed in the tool pane */
32        private $smarty;
33        private $title;
34        function __construct()
35        {
36                $this->smarty = new SmartyWifidog();
37                $this->title = Network :: getCurrentNetwork()->getName().' '._("authentication server"); //Default title
38        }
39
40        /** Set the content to be displayed in the main pane */
41        public function setMainContent($html)
42        {
43                $this->main_content = $html;
44        }
45        /** Set the title of the page */
46        public function setTitle($title_string)
47        {
48                $this->title = $title_string;
49        }
50        /** Set the section to be displayed in the tool pane */
51        public function setToolSection($section)
52        {
53                if ($section == 'ADMIN')
54                {
55                        $current_user = User :: getCurrentUser();
56                        $html = '';
57                        $html .= "<ul class='admin_menu_list'>\n";
58           
59            if($current_user && $current_user->isSuperAdmin())
60            {
61                        $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n";
62                        $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n";
63                        $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n";
64                        $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n";
65                        $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n";
66                        $html .= "<li><a href='hotspot.php'>"._("Hotspot creation and configuration")."</a> - Beta</li>\n";
67                        $html .= "<li><a href='owner_sendfiles.php'>"._("Hotspot owner administration")."</a> - Beta</li>\n";
68            }
69
70                        // If the user is super admin OR owner of at least one hotspot show the menu
71                        if($current_user && ($current_user->isSuperAdmin() || $current_user->isOwner()))
72                        {
73                                /* Node admin */
74                                $html .= "<div class='admin_section_container'>\n";
75                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">';
76                                $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n";
77       
78                                $html .= "<div class='admin_section_data'>\n";
79                                $html .= "<input type='hidden' name='action' value='edit'>\n";
80                                $html .= "<input type='hidden' name='object_class' value='Node'><br>\n";
81
82                                if ($current_user->isSuperAdmin())
83                                        $sql_additional_where = '';
84                                else
85                                        $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')";
86                    $html .= "<div id='NodeSelector'>\n";
87                                $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where);
88                    $html .= "</div>\n";
89                                $html .= "</div>\n";
90                                $html .= "<div class='admin_section_tools'>\n";
91       
92                                $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
93                                $html .= "</div>\n";
94                                $html .= '</form>';
95                                $html .= "</div>\n";
96                        }
97
98                        /* Network admin */
99            if($current_user && $current_user->isSuperAdmin())
100            {
101                        $html .= "<div class='admin_section_container'>\n";
102                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">';
103                        $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n";
104   
105                        $html .= "<div class='admin_section_data'>\n";
106                        $html .= "<input type='hidden' name='action' value='edit'>\n";
107                        $html .= "<input type='hidden' name='object_class' value='Network'><br>\n";
108                        $html .= Network :: getSelectNetworkUI('object_id');
109                        $html .= "</div>\n";
110                        $html .= "<div class='admin_section_tools'>\n";
111   
112                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
113                        $html .= "</div>\n";
114                        $html .= '</form>';
115                        $html .= "</div>\n";
116            }
117
118                        $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n";
119                        $html .= "</ul>\n";
120
121                }
122                else
123                {
124                        $html .= "<p class='errormsg'>"._("Unknown section:")." $section</p>\n";
125
126                }
127                $this->tool_content = $html;
128        }
129
130        /** Set the content to be displayed in the tool pane */
131        public function setToolContent($html)
132        {
133                $this->tool_content = $html;
134        }
135
136        /** Get the content to be displayed in the tool pane
137         * @param section, one of:  START, LOGIN,
138         * @return HTML markup */
139        private function getToolContent($section = 'START')
140        {
141        global $session;
142                $html = '';
143                if ($section = 'START')
144                {
145                        $html .= '<div id="tool_section">'."\n";
146                        $html .= '<div class="tool_user_info">'."\n";
147                        $html .= '<span class="tool_user_info">'."\n";
148                        $user = User :: getCurrentUser();
149                        if ($user != null)
150                        {
151                                $html .= '<p>'._("Logged in as:").' '.$user->getUsername().'</p>'."\n";
152                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'user_profile.php"><img class="administration" src="/images/profile.gif" border="0"> '._("My Profile").'</a>'."\n";
153               
154                $gw_id = $session->get(SESS_GW_ID_VAR);
155                $gw_address = $session->get(SESS_GW_ADDRESS_VAR);
156                $gw_port = $session->get(SESS_GW_PORT_VAR);
157
158                if($gw_id && $gw_address && $gw_port)
159                    $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'login/?logout=true&gw_id='.$gw_id.'&gw_address='.$gw_address.'&gw_port='.$gw_port.'"><img class="administration" src="/images/logout.gif" border="0"> '._("Logout").'</a>'."\n";
160                else
161                                   $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'login/?logout=true"><img class="administration" src="/images/logout.gif" border="0"> '._("Logout").'</a>'."\n";
162
163                        }
164                        else
165                        {
166                            $gw_id =  !empty($_REQUEST['gw_id']) ? $_REQUEST['gw_id'] : $session->get(SESS_GW_ID_VAR);
167                $gw_address = !empty($_REQUEST['gw_address']) ? $_REQUEST['gw_address'] : $session->get(SESS_GW_ADDRESS_VAR);
168                $gw_port = !empty($_REQUEST['gw_port']) ? $_REQUEST['gw_port'] : $session->get(SESS_GW_PORT_VAR);
169               
170                // If the user connects physically ( through a gateway don't show the confusing login message )
171                if(empty($gw_id) || empty($gw_address) || empty($gw_port))
172                    $html .= '<p>'._("I'm NOT at a hotspot.").'<br><a href="'.BASE_SSL_PATH.'login/">'._("I would like to login virtually.").'</a></p>'."\n";
173                 else
174                        $html .= '<p>'._("NOT logged in.").'<br><a href="'.BASE_SSL_PATH.'login/?gw_id='.$gw_id.'&gw_address='.$gw_address.'&gw_port='.$gw_port.'">'._("Login to this hotspot.").'</a></p>'."\n";
175                                $html .= '<a class="administration" HREF="'.Network :: getCurrentNetwork()->getHomepageURL().'"><img class="administration" src="/images/lien_ext.gif"> '.Network :: getCurrentNetwork()->getName().'</a>'."\n";
176                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'faq.php"><img class="administration" src="/images/where.gif"> '._("Where am I?").'</a>'."\n";
177                        }
178
179                        $html .= "</span>"."\n"; //End tool_user_info
180                        $html .= "</div>"."\n"; //End tool_user_info
181
182                        $html .= '<div class="navigation">'."\n";
183                        /*
184                        $html .= '<a href="index.php" class="navigation">'._("Start").'</a>'."\n";
185                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
186                        $html .= '<a href="users.php" class="navigation">'._("Users Online").'</a>'."\n";
187                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
188                        $html .= '<a href="news.php" class="navigation">'._("News").'</a>'."\n";
189                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
190                        $html .= '<a href="hotspots.php" class="navigation">'._("Hotspots").'</a>'."\n";
191                        */
192                        $html .= '<span class="navigation">';
193                        $html .= Network :: getCurrentNetwork()->getName()." "._("Building your wireless community");
194                        $html .= '</span>';
195                        $html .= "</div>"."\n"; //End navigation
196
197                        $html .= '<div class="language">'."\n";
198                        $html .= '<form class="language" name="lang_form" method="post" action="'.$_SERVER['REQUEST_URI'].'">'."\n";
199                        $html .= _("Language:")."\n";
200                        $html .= "<select name='lang' onChange='javascript: document.lang_form.submit();'>"."\n";
201                        global $AVAIL_LOCALE_ARRAY; //From config file
202                        foreach ($AVAIL_LOCALE_ARRAY as $lang_ids => $lang_names)
203                        {
204                                if (Locale :: getCurrentLocale()->getId() == $lang_ids)
205                                {
206                                        $selected = "SELECTED";
207                                }
208                                else
209                                {
210                                        $selected = '';
211                                }
212                                $html .= '<option label="'.$lang_names.'" value="'.$lang_ids.'" '.$selected.'>'.$lang_names.'</option>'."\n";
213                        }
214                        $html .= "</select>"."\n";
215                        $html .= "</form>"."\n";
216
217                        $html .= "</div>"."\n"; //End language
218
219                        $html .= "<div class='tool_content'>"."\n";
220                        /******************************/
221                        $html .= $this->tool_content;
222                        /******************************/
223                        $html .= "</div>"."\n"; //End tool_content
224                        $html .= '<div class="avis">'."\n";
225                        $html .= '<span class="avis">'."\n";
226                        $html .= sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName());
227                        $html .= _("Please inform us of any problem or service interruption at:");
228                        $tech_support_email = Network :: getCurrentNetwork()->getTechSupportEmail();
229                        $html .= '<a href="mailto:'.$tech_support_email.'">'.$tech_support_email.'</a>'."\n";
230                        $html .= "</span>"."\n"; //End avis
231                        $html .= "</div>"."\n"; //End avis
232                        $html .= "</div>"."\n"; //End tool_section
233
234                }
235                else
236                        if ($section = 'LOGIN')
237                        {
238
239                        }
240                        else
241                        {
242                                $html .= '<p class="errmsg">MainUI::getToolContent(): Unknown section!</p>'."\n";
243                        }
244                return $html;
245        }
246
247        /** Display the page */
248        public function display()
249        {
250                $html = '';
251                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html");
252
253                /**** Headers ****/
254                $html .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'."\n";
255                $html .= '<html>'."\n";
256                $html .= '<head>'."\n";
257                $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n";
258                $html .= '<meta http-equiv="Pragma" CONTENT="no-cache">'."\n";
259                $html .= '<meta http-equiv="Expires" CONTENT="-1">'."\n";
260                $html .= "<html>\n";
261                $html .= "<head>\n";
262                $html .= "<title>{$this->title}</title>\n";
263                $html .= "<style type='text/css'>\n";
264                if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
265                {
266                        $stylesheet_file = NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
267                }
268                else
269                {
270                        $stylesheet_file = DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
271                }
272                $html .= $this->smarty->fetch($stylesheet_file);
273                $html .= "</style>\n";
274                $html .= "</head>\n";
275
276                $html .= "<body>"."\n";
277                $html .= '<div class="outer_container">'."\n";
278       
279        /**** Tools ******/
280        $html .= $this->getToolContent();
281       
282                /**** Main section ****/
283                $html .= "<div id='main_section'>"."\n";
284                $html .= $this->main_content;
285                $html .= "</div>"."\n"; //End main_section
286       
287                $html .= '</div>'."\n"; //End outer_container
288                $html .= "</body>"."\n";
289                $html .= "</html>"."\n";
290                echo $html;
291
292                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
293        }
294   
295    function displayError($errmsg)
296    {
297        $html = "<p>$errmsg</p>\n";
298        $html .= "<p>"._("Please get in touch with ")."<a href='{TECH_SUPPORT_EMAIL}'>{TECH_SUPPORT_EMAIL}</a></p>";
299        $this->setMainContent($html);
300        $this->display();   
301    }
302   
303} //End class
304?>
Note: See TracBrowser for help on using the browser.