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

Revision 593, 11.2 KB (checked in by fproulx, 8 years ago)

2005-04-28 Fran�ois Proulx <francois.proulx@…>

  • Added check in MainUI toolbar so that it won't show "NOT logged in ?" message when connect to a real hotspot ( not virtual )
    • This message confused many users ( they clicked and got the virtual login instead ! )
  • Hide adminstration features ( statistics, hotspot creation, network wide content etc...) from all but Super admins
  • Fixed getAllLocativeArtisticContent in Node.php added is_persistent check
  • Added $associate_existing_content parameter to processNewContentUI to allows reuse for existing content ( in ContentGroup? )
  • Fixed bug in FlickrPhotoStream? delete ( missing return from parent )
  • Added security check in all content classes ( ProcessAdminUI )
  • 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>\n";
58           
59            if($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                        /* Node admin */
71                        $html .= "<div class='admin_section_container'>\n";
72                        $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">';
73                        $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n";
74
75                        $html .= "<div class='admin_section_data'>\n";
76                        $html .= "<input type='hidden' name='action' value='edit'>\n";
77                        $html .= "<input type='hidden' name='object_class' value='Node'><br>\n";
78
79                        if ($current_user->isSuperAdmin())
80                        {
81                                $sql_additional_where = '';
82                        }
83                        else
84                        {
85                                $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')";
86                        }
87            $html .= "<div id='NodeSelector'>\n";
88                        $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where);
89            $html .= "</div>\n";
90                        $html .= "</div>\n";
91                        $html .= "<div class='admin_section_tools'>\n";
92
93                        $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n";
94                        $html .= "</div>\n";
95                        $html .= '</form>';
96                        $html .= "</div>\n";
97
98                        /* Network admin */
99            if($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                $html = '';
142                if ($section = 'START')
143                {
144                        $html .= '<div id="tool_section">'."\n";
145                        $html .= '<div class="tool_user_info">'."\n";
146                        $html .= '<span class="tool_user_info">'."\n";
147                        $user = User :: getCurrentUser();
148                        if ($user != null)
149                        {
150                                $html .= '<p>'._("Logged in as:").' '.$user->getUsername().'</p>'."\n";
151                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'?content=myprofile"><img class="administration" src="/images/profile.gif" border="0"> My profile</a>'."\n";
152                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'login/?logout=true"><img class="administration" src="/images/logout.gif" border="0"> Logout</a>'."\n";
153
154                        }
155                        else
156                        {
157                // If the user connects physically ( through a gateway don't show the confusing login message )
158                if(empty($_REQUEST['gw_id']) || empty($_REQUEST['gw_address']) || empty($_REQUEST['gw_port'])) 
159                    $html .= '<p>'._("NOT logged in.").' <a href="'.BASE_SSL_PATH.'login/">'. ("Login?").'</a></p>'."\n";
160                                $html .= '<a class="administration" HREF="'.Network :: getCurrentNetwork()->getHomepageURL().'"><img class="administration" src="/images/lien_ext.gif"> '.Network :: getCurrentNetwork()->getName().'</a>'."\n";
161                                $html .= '<a class="administration" HREF="'.BASE_SSL_PATH.'faq.php"><img class="administration" src="/images/where.gif"> '._("Where am I?").'</a>'."\n";
162                        }
163
164                        $html .= "</span>"."\n"; //End tool_user_info
165                        $html .= "</div>"."\n"; //End tool_user_info
166
167                        $html .= '<div class="navigation">'."\n";
168                        /*
169                        $html .= '<a href="index.php" class="navigation">'._("Start").'</a>'."\n";
170                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
171                        $html .= '<a href="users.php" class="navigation">'._("Users Online").'</a>'."\n";
172                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
173                        $html .= '<a href="news.php" class="navigation">'._("News").'</a>'."\n";
174                        $html .= '<img class="separator" src="'.BASE_NON_SSL_PATH.'/images/separator.gif">'."\n";
175                        $html .= '<a href="hotspots.php" class="navigation">'._("Hotspots").'</a>'."\n";
176                        */
177                        $html .= '<span class="navigation">';
178                        $html .= Network :: getCurrentNetwork()->getName().". Building your wireless community";
179                        $html .= '</span>';
180                        $html .= "</div>"."\n"; //End navigation
181
182                        $html .= '<div class="language">'."\n";
183                        $html .= '<form class="language" name="lang_form" method="post" action="'.$_SERVER['REQUEST_URI'].'">'."\n";
184                        $html .= _("Language:")."\n";
185                        $html .= "<select name='lang' onChange='javascript: document.lang_form.submit();'>"."\n";
186                        global $AVAIL_LOCALE_ARRAY; //From config file
187                        foreach ($AVAIL_LOCALE_ARRAY as $lang_ids => $lang_names)
188                        {
189                                if (Locale :: getCurrentLocale()->getId() == $lang_ids)
190                                {
191                                        $selected = "SELECTED";
192                                }
193                                else
194                                {
195                                        $selected = '';
196                                }
197                                $html .= '<option label="'.$lang_names.'" value="'.$lang_ids.'" '.$selected.'>'.$lang_names.'</option>'."\n";
198                        }
199                        $html .= "</select>"."\n";
200                        $html .= "</form>"."\n";
201
202                        $html .= "</div>"."\n"; //End language
203
204                        $html .= "<div class='tool_content'>"."\n";
205                        /******************************/
206                        $html .= $this->tool_content;
207                        /******************************/
208                        $html .= "</div>"."\n"; //End tool_content
209                        $html .= '<div class="avis">'."\n";
210                        $html .= '<span class="avis">'."\n";
211                        $html .= sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName());
212                        $html .= _("Please inform us of any problem or service interruption at:");
213                        $tech_support_email = Network :: getCurrentNetwork()->getTechSupportEmail();
214                        $html .= '<a href="mailto:'.$tech_support_email.'">'.$tech_support_email.'</a>'."\n";
215                        $html .= "</span>"."\n"; //End avis
216                        $html .= "</div>"."\n"; //End avis
217                        $html .= "</div>"."\n"; //End tool_section
218
219                }
220                else
221                        if ($section = 'LOGIN')
222                        {
223
224                        }
225                        else
226                        {
227                                $html .= '<p class="errmsg">MainUI::getToolContent(): Unknown section!</p>'."\n";
228                        }
229                return $html;
230        }
231
232        /** Display the page */
233        public function display()
234        {
235                $html = '';
236                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html");
237
238                /**** Headers ****/
239                $html .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'."\n";
240                $html .= '<html>'."\n";
241                $html .= '<head>'."\n";
242                $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'."\n";
243                $html .= '<meta http-equiv="Pragma" CONTENT="no-cache">'."\n";
244                $html .= '<meta http-equiv="Expires" CONTENT="-1">'."\n";
245                $html .= "<html>\n";
246                $html .= "<head>\n";
247                $html .= "<title>{$this->title}</title>\n";
248                $html .= "<style type='text/css'>\n";
249                if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.STYLESHEET_NAME))
250                {
251                        $stylesheet_file = NODE_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
252                }
253                else
254                {
255                        $stylesheet_file = DEFAULT_CONTENT_SMARTY_PATH.STYLESHEET_NAME;
256                }
257                $html .= $this->smarty->fetch($stylesheet_file);
258                $html .= "</style>\n";
259                $html .= "</head>\n";
260
261                $html .= "<body>"."\n";
262                $html .= '<div class="outer_container">'."\n";
263       
264        /**** Tools ******/
265        $html .= $this->getToolContent();
266       
267                /**** Main section ****/
268                $html .= "<div id='main_section'>"."\n";
269                $html .= $this->main_content;
270                $html .= "</div>"."\n"; //End main_section
271       
272                $html .= '</div>'."\n"; //End outer_container
273                $html .= "</body>"."\n";
274                $html .= "</html>"."\n";
275                echo $html;
276
277                //$this->smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
278        }
279   
280    function displayError($errmsg)
281    {
282        $html = "<p>$errmsg</p>\n";
283        $html .= "<p>"._("Please get in touch with ")."<a href='{TECH_SUPPORT_EMAIL}'>{TECH_SUPPORT_EMAIL}</a></p>";
284        $this->setMainContent($html);
285        $this->display();   
286    }
287   
288} //End class
289?>
Note: See TracBrowser for help on using the browser.