Changeset 1173

Show
Ignore:
Timestamp:
01/17/07 00:34:12 (5 years ago)
Author:
benoitg
Message:
  • SmartyWifidog?.php: Fix #282 with a slightly dirty workround to the chicken and the egg smarty variables assignment problem.

We now extend the fetch method and do our assignment there instead of in the constructor.


Location:
trunk/wifidog-auth
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1172 r1173  
    55        * It is now possible for an administrator to manually validate or lock-out a user 
    66        * Add new SimpleString content type 
    7          
     7        * SmartyWifidog.php:  Fix #282 with a slightly dirty workround to the chicken and the egg smarty variables assignment problem.   
     8                We now extend the fetch method and do our assignment there instead of in the constructor. 
     9                         
    8102007-01-15 Benoit Grégoire  <bock@step.polymtl.ca> 
    911        * Sync initial schema and translations 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1169 r1173  
    6464{ 
    6565        /** Object cache for the object factory (getObject())*/ 
    66     private static $instanceArray = array(); 
     66        private static $instanceArray = array(); 
    6767        private $mRow; 
    6868        private $mdB; /**< An AbstractDb instance */ 
     
    9393        static function getObject($id) 
    9494        { 
    95                 if(!isset(self::$instanceArray[$id])) 
    96         { 
     95            if(!isset(self::$instanceArray[$id])) 
     96            { 
    9797                self::$instanceArray[$id] = new self($id); 
    98         } 
    99         return self::$instanceArray[$id]; 
     98            } 
     99            return self::$instanceArray[$id]; 
    100100        } 
    101101 
     
    106106        static function getObjectByGatewayId($gwId) 
    107107        { 
    108                 $object = null; 
    109                 $object = new self($gwId, 'GATEWAY_ID'); 
    110                 return $object; 
     108            $object = null; 
     109            $object = new self($gwId, 'GATEWAY_ID'); 
     110            return $object; 
    111111        } 
    112112        /** Get the current node for which the portal is displayed or to which a user is physically connected. 
     
    116116        static function getCurrentNode($real_node_only = false) 
    117117        { 
    118                 $object = null; 
    119                 if (self :: $current_node_id != null && $real_node_only == false) 
    120                 { 
    121                         $object = self::getObject(self :: $current_node_id); 
    122                 } 
    123                 else 
    124                 { 
    125                         $object = self :: getCurrentRealNode(); 
    126                 } 
    127                 return $object; 
     118            $object = null; 
     119            if (self :: $current_node_id != null && $real_node_only == false) 
     120            { 
     121                $object = self::getObject(self :: $current_node_id); 
     122            } 
     123            else 
     124            { 
     125                $object = self :: getCurrentRealNode(); 
     126            } 
     127            return $object; 
    128128        } 
    129129 
     
    133133        static function setCurrentNode(Node $node) 
    134134        { 
    135                 self :: $current_node_id = $node->GetId(); 
    136                 return true; 
     135            self :: $current_node_id = $node->GetId(); 
     136            return true; 
    137137        } 
    138138 
     
    142142        public static function getCurrentRealNode() 
    143143        { 
    144                 static $currentRealNode; 
    145                 static $currentRealNodeComputed; 
    146                 if(!isset($currentRealNodeComputed)) 
    147         { 
     144            static $currentRealNode; 
     145            static $currentRealNodeComputed; 
     146            if(!isset($currentRealNodeComputed)) 
     147            { 
    148148                $currentRealNodeComputed=true; 
    149         $db = AbstractDb::getObject(); 
    150                 $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; 
    151                 $node_rows = null; 
    152                 $db->execSql($sql, $node_rows, false); 
    153                 $num_match = count($node_rows); 
    154                 if ($num_match == 0) 
    155                 { 
    156  
    157                         // User is not physically connected to a node 
    158                         $currentRealNode = null; 
    159                 } 
    160                 else 
    161                         if ($num_match = 1) 
    162                         { 
    163                                 // Only a single node matches, the user is presumed to be there 
    164                                 $currentRealNode = self::getObject($node_rows[0]['node_id']); 
    165                         } 
    166                         else 
    167                         { 
    168                                 /* We have more than one node matching the IP (the nodes are behind the same NAT). 
    169                                 * We will try to discriminate by finding which node the user last authenticated against. 
    170                                 * If the IP matches, we can be pretty certain the user is there. 
    171                                 */ 
    172                                 $currentRealNode = null; 
    173                                 $current_user = User :: getCurrentUser(); 
    174                                 if ($current_user != null) 
    175                                 { 
    176                                         $current_user_id = $current_user->getId(); 
    177                                         $_SERVER['REMOTE_ADDR']; 
    178                                         $sql = "SELECT node_id, last_heartbeat_ip from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' ORDER BY last_updated DESC "; 
    179                                         $db->execSql($sql, $node_rows, false); 
    180                                         $node_row = $node_rows[0]; 
    181                                         if ($node_row != null && $node_row['last_heartbeat_ip'] == $_SERVER['REMOTE_ADDR']) 
    182                                         { 
    183                                                 $currentRealNode = self::getObject($node_row['node_id']); 
    184                                         } 
    185                                 } 
    186                         } 
    187         } 
    188  
    189                 return $currentRealNode; 
     149                $db = AbstractDb::getObject(); 
     150                $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; 
     151                $node_rows = null; 
     152                $db->execSql($sql, $node_rows, false); 
     153                $num_match = count($node_rows); 
     154                if ($num_match == 0) 
     155                { 
     156 
     157                    // User is not physically connected to a node 
     158                    $currentRealNode = null; 
     159                } 
     160                else 
     161                if ($num_match = 1) 
     162                { 
     163                    // Only a single node matches, the user is presumed to be there 
     164                    $currentRealNode = self::getObject($node_rows[0]['node_id']); 
     165                } 
     166                else 
     167                { 
     168                    /* We have more than one node matching the IP (the nodes are behind the same NAT). 
     169                    * We will try to discriminate by finding which node the user last authenticated against. 
     170                    * If the IP matches, we can be pretty certain the user is there. 
     171                    */ 
     172                    $currentRealNode = null; 
     173                    $current_user = User :: getCurrentUser(); 
     174                    if ($current_user != null) 
     175                    { 
     176                        $current_user_id = $current_user->getId(); 
     177                        $_SERVER['REMOTE_ADDR']; 
     178                        $sql = "SELECT node_id, last_heartbeat_ip from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' ORDER BY last_updated DESC "; 
     179                        $db->execSql($sql, $node_rows, false); 
     180                        $node_row = $node_rows[0]; 
     181                        if ($node_row != null && $node_row['last_heartbeat_ip'] == $_SERVER['REMOTE_ADDR']) 
     182                        { 
     183                            $currentRealNode = self::getObject($node_row['node_id']); 
     184                        } 
     185                    } 
     186                } 
     187            } 
     188 
     189            return $currentRealNode; 
    190190        } 
    191191 
    192192        public function delete(& $errmsg) 
    193193        { 
    194                 $retval = false; 
    195                 $user = User :: getCurrentUser(); 
    196                 if ($user->isSuperAdmin()) { 
    197                         $db = AbstractDb::getObject(); 
    198                         $id = $db->escapeString($this->getId()); 
    199                         if (!$db->execSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false)) 
    200                         { 
    201                                 $errmsg = _('Could not delete node!'); 
    202                         } 
    203                         else 
    204                         { 
    205                                 $retval = true; 
    206                         } 
    207                 } 
    208                 else 
    209                 { 
    210                         $errmsg = _('Access denied!'); 
    211                 } 
    212  
    213                 return $retval; 
     194            $retval = false; 
     195            $user = User :: getCurrentUser(); 
     196            if ($user->isSuperAdmin()) { 
     197                $db = AbstractDb::getObject(); 
     198                $id = $db->escapeString($this->getId()); 
     199                if (!$db->execSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false)) 
     200                { 
     201                    $errmsg = _('Could not delete node!'); 
     202                } 
     203                else 
     204                { 
     205                    $retval = true; 
     206                } 
     207            } 
     208            else 
     209            { 
     210                $errmsg = _('Access denied!'); 
     211            } 
     212 
     213            return $retval; 
    214214        } 
    215215 
     
    230230        public static function createNewObject($gw_id = null, $network = null) 
    231231        { 
    232                 $db = AbstractDb::getObject(); 
    233         if (empty ($gw_id)) { 
    234             $gw_id = $db->escapeString(_('PUT_GATEWAY_ID_HERE')); 
    235         } 
    236         else 
    237         { 
    238                     $gw_id = $db->escapeString($gw_id); 
    239         } 
    240                         $node_id = get_guid(); 
    241  
    242  
    243                 if (empty ($network)) { 
    244                         $network = Network::getCurrentNetwork(); 
    245                 } 
    246  
    247                 $network_id = $db->escapeString($network->getId()); 
    248  
    249                 $node_deployment_status = $db->escapeString("IN_PLANNING"); 
    250                 $node_name = _("New node"); 
    251 $duplicate = null; 
    252 try{ 
    253   $duplicate = Node::getObjectByGatewayId($gw_id); 
    254 } 
    255 catch (Exception $e) 
    256 { 
    257 } 
    258             if ($duplicate) { 
    259                 throw new Exception(sprintf(_('Sorry, a node for the gateway %s already exists.'),$gw_id)); 
    260             } 
    261  
    262             $sql = "INSERT INTO nodes (node_id, gw_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$gw_id', '$network_id', CURRENT_TIMESTAMP,'$node_deployment_status', '$node_name')"; 
    263  
    264             if (!$db->execSqlUpdate($sql, false)) { 
    265                 throw new Exception(_('Unable to insert new node into database!')); 
    266             } 
    267  
    268             $object = self::getObject($node_id); 
    269  
    270             return $object; 
     232            $db = AbstractDb::getObject(); 
     233            if (empty ($gw_id)) { 
     234                $gw_id = $db->escapeString(_('PUT_GATEWAY_ID_HERE')); 
     235            } 
     236            else 
     237            { 
     238                $gw_id = $db->escapeString($gw_id); 
     239            } 
     240            $node_id = get_guid(); 
     241 
     242 
     243            if (empty ($network)) { 
     244                $network = Network::getCurrentNetwork(); 
     245            } 
     246 
     247            $network_id = $db->escapeString($network->getId()); 
     248 
     249            $node_deployment_status = $db->escapeString("IN_PLANNING"); 
     250            $node_name = _("New node"); 
     251            $duplicate = null; 
     252            try{ 
     253                $duplicate = Node::getObjectByGatewayId($gw_id); 
     254            } 
     255            catch (Exception $e) 
     256            { 
     257            } 
     258            if ($duplicate) { 
     259                throw new Exception(sprintf(_('Sorry, a node for the gateway %s already exists.'),$gw_id)); 
     260            } 
     261 
     262            $sql = "INSERT INTO nodes (node_id, gw_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$gw_id', '$network_id', CURRENT_TIMESTAMP,'$node_deployment_status', '$node_name')"; 
     263 
     264            if (!$db->execSqlUpdate($sql, false)) { 
     265                throw new Exception(_('Unable to insert new node into database!')); 
     266            } 
     267 
     268            $object = self::getObject($node_id); 
     269 
     270            return $object; 
    271271        } 
    272272 
     
    282282        public static function getSelectNodeUI($user_prefix, $sql_additional_join = null, $sql_additional_where = null,$selectedNodes = null, $type_interface = "select") 
    283283        { 
    284                 $db = AbstractDb::getObject(); 
    285                 $html = ''; 
    286                 $name = "{$user_prefix}"; 
     284            $db = AbstractDb::getObject(); 
     285            $html = ''; 
     286            $name = "{$user_prefix}"; 
    287287 
    288288        $_deploymentStatuses = array( 
     
    295295            ); 
    296296 
    297                 $sql = "SELECT node_id, name, gw_id, node_deployment_status, is_splash_only_node from nodes $sql_additional_join WHERE 1=1 $sql_additional_where ORDER BY lower(node_id)"; 
    298                 $node_rows = null; 
    299                 $db->execSql($sql, $node_rows, false); 
    300  
    301                 if ($node_rows != null) { 
    302                         Utils :: natsort2d($node_rows, "name"); 
    303                         if ($type_interface != "table") { 
    304                                 $i = 0; 
    305                                 foreach ($node_rows as $node_row) 
    306                                 { 
    307                                         $tab[$i][0] = $node_row['node_id']; 
    308                                         //$tab[$i][1] = sprintf(_("%s (gw: %s)"),$node_row['name'],$node_row['gw_id']); 
    309                                         $tab[$i][1] = $node_row['name']; 
    310                                         $i ++; 
    311                                 } 
    312                                 if($type_interface == "select_multiple"){ 
    313                                         $select_options="MULTIPLE SIZE=6"; 
    314                                 } 
    315                                 else 
    316                                 { 
    317                                         $select_options=null; 
    318                                 } 
    319                                 //pretty_print_r($selectedNodes); 
    320                                 if(is_array($selectedNodes)){ 
    321                                         $selectedPrimaryKey=array(); 
    322                                         foreach($selectedNodes as $node){ 
    323                                                 $selectedPrimaryKey[]=$node->getId(); 
    324                                                 } 
    325                                                  
    326                                 } 
    327                                 else if($selectedNodes instanceof Node){ 
    328                                         $selectedPrimaryKey=$selectedNodes->getId(); 
    329                                 } 
    330                                 else{ 
    331                                         $selectedPrimaryKey=null; 
    332                                 } 
    333                                 $html .= FormSelectGenerator :: generateFromArray($tab, $selectedPrimaryKey, $name, null, false, null, $select_options); 
    334                         } else { 
    335                                 $html .= "<fieldset>\n    <legend>Node List</legend>\n"; 
    336                                 $html .= "    <span class='node_admin'>"._("Filter:")."<input type=\"text\" tabindex=\"1\" maxlength=\"40\" size=\"40\" id=\"nodes_list_filter\" name=\"nodes_list_filter\" /></span>\n    <br/>\n"; 
    337                                 $html .= "    <!--[if IE]><style type='text/css'>#node_list_div table.scrollable>tbody { height: 15px; }</style><![endif]-->\n"; 
    338                                 $html .= "    <script src='" . BASE_URL_PATH . "js/filtertable.js' type='text/javascript' language='javascript' charset='utf-8'></script>\n"; 
    339                                 $html .= "    <script src='" . BASE_URL_PATH . "js/sorttable.js' type='text/javascript' language='javascript' charset='utf-8'></script>\n"; 
    340                                 $html .= "    <div id='node_list_div' class='node_admin tableContainer'>\n"; 
    341                                 $html .= "        <table id='nodes_list' class='node_admin filterable scrollable sortable'>\n\n"; 
    342                                 $html .= "            <thead class='fixedHeader'>\n"; 
    343                                 $html .= "<tr class='nofilter'>\n"; 
    344                                 $html .= "<th>"._("Node Name")."</th>\n"; 
    345                                 $html .= "<th>"._("Gateway ID")."</th>\n"; 
    346                                 $html .= "<th>"._("Deployment Status")."</th>\n"; 
    347                                 $html .= "</tr>\n"; 
    348                                 $html .= "</thead>\n"; 
    349                                 $html .= "<tbody>"; 
    350  
    351                                 $i = 0; 
    352                                 foreach ($node_rows as $node_row) 
    353                                 { 
    354                                         $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$node_row['node_id']}&object_class=Node&action=edit"; 
    355                                         $_deployStatusNode = $node_row['node_deployment_status']; 
    356                                         $html .= "<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n"; 
    357                                         $html .= "<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n"; 
    358                                         $html .= "<td>{$node_row['gw_id']}</td>\n"; 
    359                                         $html .= "<td>{$_deploymentStatuses[$_deployStatusNode]}</td>\n"; 
    360                                         $html .= "</tr>\n"; 
    361                                 } 
    362                                 $html .= "            </tbody>\n        </table>\n"; 
    363                                 $html .= "    </div>\n"; 
    364                                 $html .= "</fieldset>\n"; 
    365  
    366                         } 
    367                 } else { 
    368                         $html .= "<div class='warningmsg'>"._("Sorry, no nodes available in the database")."</div>\n"; 
    369                 } 
    370                 return $html; 
     297            $sql = "SELECT node_id, name, gw_id, node_deployment_status, is_splash_only_node from nodes $sql_additional_join WHERE 1=1 $sql_additional_where ORDER BY lower(node_id)"; 
     298            $node_rows = null; 
     299            $db->execSql($sql, $node_rows, false); 
     300 
     301            if ($node_rows != null) { 
     302                Utils :: natsort2d($node_rows, "name"); 
     303                if ($type_interface != "table") { 
     304                    $i = 0; 
     305                    foreach ($node_rows as $node_row) 
     306                    { 
     307                        $tab[$i][0] = $node_row['node_id']; 
     308                        //$tab[$i][1] = sprintf(_("%s (gw: %s)"),$node_row['name'],$node_row['gw_id']); 
     309                        $tab[$i][1] = $node_row['name']; 
     310                        $i ++; 
     311                    } 
     312                    if($type_interface == "select_multiple"){ 
     313                        $select_options="MULTIPLE SIZE=6"; 
     314                    } 
     315                    else 
     316                    { 
     317                        $select_options=null; 
     318                    } 
     319                    //pretty_print_r($selectedNodes); 
     320                    if(is_array($selectedNodes)){ 
     321                        $selectedPrimaryKey=array(); 
     322                        foreach($selectedNodes as $node){ 
     323                            $selectedPrimaryKey[]=$node->getId(); 
     324                        } 
     325 
     326                    } 
     327                    else if($selectedNodes instanceof Node){ 
     328                        $selectedPrimaryKey=$selectedNodes->getId(); 
     329                    } 
     330                    else{ 
     331                        $selectedPrimaryKey=null; 
     332                    } 
     333                    $html .= FormSelectGenerator :: generateFromArray($tab, $selectedPrimaryKey, $name, null, false, null, $select_options); 
     334                } else { 
     335                    $html .= "<fieldset>\n    <legend>Node List</legend>\n"; 
     336                    $html .= "    <span class='node_admin'>"._("Filter:")."<input type=\"text\" tabindex=\"1\" maxlength=\"40\" size=\"40\" id=\"nodes_list_filter\" name=\"nodes_list_filter\" /></span>\n    <br/>\n"; 
     337                    $html .= "    <!--[if IE]><style type='text/css'>#node_list_div table.scrollable>tbody { height: 15px; }</style><![endif]-->\n"; 
     338                    $html .= "    <script src='" . BASE_URL_PATH . "js/filtertable.js' type='text/javascript' language='javascript' charset='utf-8'></script>\n"; 
     339                    $html .= "    <script src='" . BASE_URL_PATH . "js/sorttable.js' type='text/javascript' language='javascript' charset='utf-8'></script>\n"; 
     340                    $html .= "    <div id='node_list_div' class='node_admin tableContainer'>\n"; 
     341                    $html .= "        <table id='nodes_list' class='node_admin filterable scrollable sortable'>\n\n"; 
     342                    $html .= "            <thead class='fixedHeader'>\n"; 
     343                    $html .= "<tr class='nofilter'>\n"; 
     344                    $html .= "<th>"._("Node Name")."</th>\n"; 
     345                    $html .= "<th>"._("Gateway ID")."</th>\n"; 
     346                    $html .= "<th>"._("Deployment Status")."</th>\n"; 
     347                    $html .= "</tr>\n"; 
     348                    $html .= "</thead>\n"; 
     349                    $html .= "<tbody>"; 
     350 
     351                    $i = 0; 
     352                    foreach ($node_rows as $node_row) 
     353                    { 
     354                        $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$node_row['node_id']}&object_class=Node&action=edit"; 
     355                        $_deployStatusNode = $node_row['node_deployment_status']; 
     356                        $html .= "<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n"; 
     357                        $html .= "<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n"; 
     358                        $html .= "<td>{$node_row['gw_id']}</td>\n"; 
     359                        $html .= "<td>{$_deploymentStatuses[$_deployStatusNode]}</td>\n"; 
     360                        $html .= "</tr>\n"; 
     361                    } 
     362                    $html .= "            </tbody>\n        </table>\n"; 
     363                    $html .= "    </div>\n"; 
     364                    $html .= "</fieldset>\n"; 
     365 
     366                } 
     367            } else { 
     368                $html .= "<div class='warningmsg'>"._("Sorry, no nodes available in the database")."</div>\n"; 
     369            } 
     370            return $html; 
    371371        } 
    372372 
     
    378378        static function processSelectNodeUI($user_prefix) 
    379379        { 
    380                 $object = null; 
    381                 $name = "{$user_prefix}"; 
    382                 return self::getObject($_REQUEST[$name]); 
     380            $object = null; 
     381            $name = "{$user_prefix}"; 
     382            return self::getObject($_REQUEST[$name]); 
    383383        } 
    384384 
     
    390390        public static function getCreateNewObjectUI($network = null) 
    391391        { 
    392                 $html = ''; 
    393                 $html .= _("Add a new node for the gateway ID")." \n"; 
    394                 $name = "new_node_gw_id"; 
    395                 $html .= "<input type='text' size='10' name='{$name}'>\n"; 
    396                 if ($network) 
    397                 { 
    398                         $name = "new_node_network_id"; 
    399                         $html .= "<input type='hidden' name='{$name}' value='{$network->getId()}'>\n"; 
    400                 } 
    401                 else 
    402                 { 
    403                         $html .= " "._("in ")." \n"; 
    404                         $html .= Network :: getSelectNetworkUI('new_node'); 
    405                 } 
    406                 return $html; 
     392            $html = ''; 
     393            $html .= _("Add a new node for the gateway ID")." \n"; 
     394            $name = "new_node_gw_id"; 
     395            $html .= "<input type='text' size='10' name='{$name}'>\n"; 
     396            if ($network) 
     397            { 
     398                $name = "new_node_network_id"; 
     399                $html .= "<input type='hidden' name='{$name}' value='{$network->getId()}'>\n"; 
     400            } 
     401            else 
     402            { 
     403                $html .= " "._("in ")." \n"; 
     404                $html .= Network :: getSelectNetworkUI('new_node'); 
     405            } 
     406            return $html; 
    407407 
    408408        } 
     
    417417        { 
    418418            // Init values 
    419                 $retval = null; 
    420                 $name = "new_node_gw_id"; 
    421  
    422                 if (!empty ($_REQUEST[$name])) { 
    423                         $gw_id = $_REQUEST[$name]; 
    424         } 
    425         else 
    426         { 
    427             $gw_id = null; 
    428         } 
    429                         $name = "new_node_network_id"; 
    430  
    431                         if (!empty ($_REQUEST[$name])) { 
    432                                 $network = Network::getObject($_REQUEST[$name]); 
    433                         } else { 
    434                                 $network = Network::processSelectNetworkUI('new_node'); 
    435                         } 
    436  
    437                         if ($network) { 
    438                             try { 
    439                                 if (!$network->hasAdminAccess(User :: getCurrentUser())) { 
    440                                         throw new Exception(_("Access denied")); 
    441                                 } 
    442                 } catch (Exception $e) { 
    443                     $ui = MainUI::getObject(); 
    444                     $ui->setToolSection('ADMIN'); 
    445                     $ui->displayError($e->getMessage(), false); 
    446                     exit; 
    447                 } 
    448  
    449                                 $retval = self::createNewObject($gw_id, $network); 
    450                         } 
    451  
    452                 return $retval; 
     419            $retval = null; 
     420            $name = "new_node_gw_id"; 
     421 
     422            if (!empty ($_REQUEST[$name])) { 
     423                $gw_id = $_REQUEST[$name]; 
     424            } 
     425            else 
     426            { 
     427                $gw_id = null; 
     428            } 
     429            $name = "new_node_network_id"; 
     430 
     431            if (!empty ($_REQUEST[$name])) { 
     432                $network = Network::getObject($_REQUEST[$name]); 
     433            } else { 
     434                $network = Network::processSelectNetworkUI('new_node'); 
     435            } 
     436 
     437            if ($network) { 
     438                try { 
     439                    if (!$network->hasAdminAccess(User :: getCurrentUser())) { 
     440                        throw new Exception(_("Access denied")); 
     441                    } 
     442                } catch (Exception $e) { 
     443                    $ui = MainUI::getObject(); 
     444                    $ui->setToolSection('ADMIN'); 
     445                    $ui->displayError($e->getMessage(), false); 
     446                    exit; 
     447                } 
     448 
     449                $retval = self::createNewObject($gw_id, $network); 
     450            } 
     451 
     452            return $retval; 
    453453        } 
    454454 
     
    461461     * @return string HTML markup 
    462462     */ 
    463         public function getSelectDeploymentStatus($user_prefix) 
    464         { 
    465              
    466                 $db = AbstractDb::getObject(); 
    467  
    468                 // Init values 
    469                 $html = ""; 
    470                 $status_list = null; 
    471                 $tab = array(); 
    472  
    473                 $name = "{$user_prefix}"; 
    474                 $db->execSql("SELECT node_deployment_status FROM node_deployment_status", $status_list, false); 
    475  
    476                 if ($status_list == null) { 
    477                         throw new Exception(_("No deployment statuses could be found in the database")); 
    478                 } 
    479  
    480                 foreach ($status_list as $status) { 
    481                     $_statusvalue = $status['node_deployment_status']; 
    482                         $tab[] = array($_statusvalue, $this->_deploymentStatuses["$_statusvalue"]); 
    483                 } 
    484  
    485                 $html .= FormSelectGenerator::generateFromArray($tab, $this->getDeploymentStatus(), $name, null, false); 
    486  
    487                 return $html; 
    488         } 
     463    public function getSelectDeploymentStatus($user_prefix) 
     464    { 
     465          
     466        $db = AbstractDb::getObject(); 
     467 
     468        // Init values 
     469        $html = ""; 
     470        $status_list = null; 
     471        $tab = array(); 
     472 
     473        $name = "{$user_prefix}"; 
     474        $db->execSql("SELECT node_deployment_status FROM node_deployment_status", $status_list, false); 
     475 
     476        if ($status_list == null) { 
     477            throw new Exception(_("No deployment statuses could be found in the database")); 
     478        } 
     479 
     480        foreach ($status_list as $status) { 
     481            $_statusvalue = $status['node_deployment_status']; 
     482            $tab[] = array($_statusvalue, $this->_deploymentStatuses["$_statusvalue"]); 
     483        } 
     484 
     485        $html .= FormSelectGenerator::generateFromArray($tab, $this->getDeploymentStatus(), $name, null, false); 
     486 
     487        return $html; 
     488    } 
    489489 
    490490        /** 
     
    500500        public function processSelectDeploymentStatus($user_prefix) 
    501501        { 
    502                 $object = null; 
    503                 $name = "{$user_prefix}"; 
    504                 return $_REQUEST[$name]; 
     502            $object = null; 
     503            $name = "{$user_prefix}"; 
     504            return $_REQUEST[$name]; 
    505505        } 
    506506 
     
    509509        private function __construct($id, $idType='NODE_ID') 
    510510        { 
    511                 $db = AbstractDb::getObject(); 
    512                 $this->mDb = & $db; 
    513  
    514                 $id_str = $db->escapeString($id); 
    515                 switch ($idType) { 
    516                     case 'NODE_ID': $sqlWhere = "node_id='$id_str'"; 
    517                     break; 
    518                     case 'GATEWAY_ID': $sqlWhere = "gw_id='$id_str'"; 
    519                     break; 
    520                     default: 
    521                     throw new exception('Unknown idType parameter'); 
    522                 } 
    523                 $sqlWhere =  
    524                 $sql = "SELECT * FROM nodes WHERE $sqlWhere"; 
    525                 $row = null; 
    526                 $db->execSqlUniqueRes($sql, $row, false); 
    527                 if ($row == null) 
    528                 { 
    529                         throw new Exception(sprintf(_("The node with %s: %s could not be found in the database!"), $idType, $id_str)); 
    530                 } 
     511            $db = AbstractDb::getObject(); 
     512            $this->mDb = & $db; 
     513 
     514            $id_str = $db->escapeString($id); 
     515            switch ($idType) { 
     516                case 'NODE_ID': $sqlWhere = "node_id='$id_str'"; 
     517                break; 
     518                case 'GATEWAY_ID': $sqlWhere = "gw_id='$id_str'"; 
     519                break; 
     520                default: 
     521                    throw new exception('Unknown idType parameter'); 
     522            } 
     523            $sqlWhere = 
     524            $sql = "SELECT * FROM nodes WHERE $sqlWhere"; 
     525            $row = null; 
     526            $db->execSqlUniqueRes($sql, $row, false); 
     527            if ($row == null) 
     528            { 
     529                throw new Exception(sprintf(_("The node with %s: %s could not be found in the database!"), $idType, $id_str)); 
     530            } 
    531531 
    532532        $this->_deploymentStatuses = array( 
     
    539539            ); 
    540540 
    541                 $this->mRow = $row; 
    542                 $this->id = $row['node_id']; 
     541            $this->mRow = $row; 
     542            $this->id = $row['node_id']; 
    543543        } 
    544544 
    545545        function getId() 
    546546        { 
    547                 return $this->id; 
     547            return $this->id; 
    548548        } 
    549549 
     
    551551        function getGatewayId() 
    552552        { 
    553                 return $this->mRow['gw_id']; 
     553            return $this->mRow['gw_id']; 
    554554        } 
    555555        /** Change the gateway ID of the gateway asociated with this node. 
     
    561561        function setGatewayId($id) 
    562562        { 
    563                 $id = $this->mDb->escapeString($id); 
    564                 $retval = $this->mDb->execSqlUpdate("UPDATE nodes SET gw_id = '{$id}' WHERE node_id = '{$this->getId()}'"); 
    565                 if ($retval) 
    566                 { 
    567                         $this->refresh(); 
    568                 } 
    569                 return $retval; 
     563            $id = $this->mDb->escapeString($id); 
     564            $retval = $this->mDb->execSqlUpdate("UPDATE nodes SET gw_id = '{$id}' WHERE node_id = '{$this->getId()}'"); 
     565            if ($retval) 
     566            { 
     567                $this->refresh(); 
     568            } 
     569            return $retval; 
    570570        } 
    571571 
     
    575575        public function getNetwork() 
    576576        { 
    577                 return Network :: getObject($this->mRow['network_id']); 
     577            return Network :: getObject($this->mRow['network_id']); 
    578578        } 
    579579 
     
    582582        function getGisLocation() 
    583583        { 
    584                 // Altitude is not supported yet 
    585                 return new GisPoint($this->mRow['latitude'], $this->mRow['longitude'], 0); 
     584            // Altitude is not supported yet 
     585            return new GisPoint($this->mRow['latitude'], $this->mRow['longitude'], 0); 
    586586        } 
    587587 
    588588        function setGisLocation($pt) 
    589589        { 
    590                 if (!empty ($pt)) 
    591                 { 
    592                         $lat = $this->mDb->escapeString($pt->getLatitude()); 
    593                         $long = $this->mDb->escapeString($pt->getLongitude()); 
    594  
    595                         if (!empty ($lat) && !empty ($long)) 
    596                                 $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'"); 
    597                         else 
    598                                 $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = NULL, longitude = NULL WHERE node_id = '{$this->getId()}'"); 
    599                         $this->refresh(); 
    600                 } 
     590            if (!empty ($pt)) 
     591            { 
     592                $lat = $this->mDb->escapeString($pt->getLatitude()); 
     593                $long = $this->mDb->escapeString($pt->getLongitude()); 
     594 
     595                if (!empty ($lat) && !empty ($long)) 
     596                $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'"); 
     597                else 
     598                $this->mDb->execSqlUpdate("UPDATE nodes SET latitude = NULL, longitude = NULL WHERE node_id = '{$this->getId()}'"); 
     599                $this->refresh(); 
     600            } 
    601601        } 
    602602 
     
    605605        function getName() 
    606606        { 
    607                 return $this->mRow['name']; 
     607            return $this->mRow['name']; 
    608608        } 
    609609 
    610610        function setName($name) 
    611611        { 
    612                 $name = $this->mDb->escapeString($name); 
    613                 $this->mDb->execSqlUpdate("UPDATE nodes SET name = '{$name}' WHERE node_id = '{$this->getId()}'"); 
    614                 $this->refresh(); 
     612            $name = $this->mDb->escapeString($name); 
     613            $this->mDb->execSqlUpdate("UPDATE nodes SET name = '{$name}' WHERE node_id = '{$this->getId()}'"); 
     614            $this->refresh(); 
    615615        } 
    616616 
    617617        function getCreationDate() 
    618618        { 
    619                 return $this->mRow['creation_date']; 
     619            return $this->mRow['creation_date']; 
    620620        } 
    621621 
    622622        function setCreationDate($creation_date) 
    623623        { 
    624                 $creation_date = $this->mDb->escapeString($creation_date); 
    625                 $this->mDb->execSqlUpdate("UPDATE nodes SET creation_date = '{$creation_date}' WHERE node_id = '{$this->getId()}'"); 
    626                 $this->refresh(); 
     624            $creation_date = $this->mDb->escapeString($creation_date); 
     625            $this->mDb->execSqlUpdate("UPDATE nodes SET creation_date = '{$creation_date}' WHERE node_id = '{$this->getId()}'"); 
     626            $this->refresh(); 
    627627        } 
    628628 
    629629        function getHomePageURL() 
    630630        { 
    631                 return $this->mRow['home_page_url']; 
     631            return $this->mRow['home_page_url']; 
    632632        } 
    633633 
    634634        function setHomePageUrl($url) 
    635635        { 
    636                 $url = $this->mDb->escapeString($url); 
    637                 $this->mDb->execSqlUpdate("UPDATE nodes SET home_page_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 
    638                 $this->refresh(); 
     636            $url = $this->mDb->escapeString($url); 
     637            $this->mDb->execSqlUpdate("UPDATE nodes SET home_page_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 
     638            $this->refresh(); 
    639639        } 
    640640 
    641641        function getDescription() 
    642642        { 
    643                 return $this->mRow['description']; 
     643            return $this->mRow['description']; 
    644644        } 
    645645 
    646646        function setDescription($description) 
    647647        { 
    648                 $description = $this->mDb->escapeString($description); 
    649                 $this->mDb->execSqlUpdate("UPDATE nodes SET description = '{$description}' WHERE node_id = '{$this->getId()}'"); 
    650                 $this->refresh(); 
     648            $description = $this->mDb->escapeString($description); 
     649            $this->mDb->execSqlUpdate("UPDATE nodes SET description = '{$description}' WHERE node_id = '{$this->getId()}'"); 
     650            $this->refresh(); 
    651651        } 
    652652 
    653653        function getMapURL() 
    654654        { 
    655                 return $this->mRow['map_url']; 
     655            return $this->mRow['map_url']; 
    656656        } 
    657657 
    658658        function setMapURL($url) 
    659659        { 
    660                 $url = $this->mDb->escapeString($url); 
    661                 $this->mDb->execSqlUpdate("UPDATE nodes SET map_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 
    662                 $this->refresh(); 
     660            $url = $this->mDb->escapeString($url); 
     661            $this->mDb->execSqlUpdate("UPDATE nodes SET map_url = '{$url}' WHERE node_id = '{$this->getId()}'"); 
     662            $this->refresh(); 
    663663        } 
    664664 
    665665        public function getCivicNumber() 
    666666        { 
    667                 return $this->mRow['civic_number']; 
     667            return $this->mRow['civic_number']; 
    668668        } 
    669669 
    670670        public function setCivicNumber($civic_number) 
    671671        { 
    672                 $civic_number = $this->mDb->escapeString($civic_number); 
    673                 $this->mDb->execSqlUpdate("UPDATE nodes SET civic_number = '{$civic_number}' WHERE node_id = '{$this->getId()}'"); 
    674                 $this->refresh(); 
     672            $civic_number = $this->mDb->escapeString($civic_number); 
     673            $this->mDb->execSqlUpdate("UPDATE nodes SET civic_number = '{$civic_number}' WHERE node_id = '{$this->getId()}'"); 
     674            $this->refresh(); 
    675675        } 
    676676 
    677677        public function getStreetName() 
    678678        { 
    679                 return $this->mRow['street_name']; 
     679            return $this->mRow['street_name']; 
    680680        } 
    681681 
    682682        public function setStreetName($street_name) 
    683683        { 
    684                 $street_name = $this->mDb->escapeString($street_name); 
    685                 $this->mDb->execSqlUpdate("UPDATE nodes SET street_name = '{$street_name}' WHERE node_id = '{$this->getId()}'"); 
    686                 $this->refresh(); 
     684            $street_name = $this->mDb->escapeString($street_name); 
     685            $this->mDb->execSqlUpdate("UPDATE nodes SET street_name = '{$street_name}' WHERE node_id = '{$this->getId()}'"); 
     686            $this->refresh(); 
    687687        } 
    688688 
    689689        public function getCity() 
    690690        { 
    691                 return $this->mRow['city']; 
     691            return $this->mRow['city']; 
    692692        } 
    693693 
    694694        public function setCity($city) 
    695695        { 
    696                 $city = $this->mDb->escapeString($city); 
    697                 $this->mDb->execSqlUpdate("UPDATE nodes SET city = '{$city}' WHERE node_id = '{$this->getId()}'"); 
    698                 $this->refresh(); 
     696            $city = $this->mDb->escapeString($city); 
     697            $this->mDb->execSqlUpdate("UPDATE nodes SET city = '{$city}' WHERE node_id = '{$this->getId()}'"); 
     698            $this->refresh(); 
    699699        } 
    700700 
    701701        public function getProvince() 
    702702        { 
    703                 return $this->mRow['province']; 
     703            return $this->mRow['province']; 
    704704        } 
    705705 
    706706        public function setProvince($province) 
    707707        { 
    708                 $province = $this->mDb->escapeString($province); 
    709                 $this->mDb->execSqlUpdate("UPDATE nodes SET province = '{$province}' WHERE node_id = '{$this->getId()}'"); 
    710                 $this->refresh(); 
     708            $province = $this->mDb->escapeString($province); 
     709            $this->mDb->execSqlUpdate("UPDATE nodes SET province = '{$province}' WHERE node_id = '{$this->getId()}'"); 
     710            $this->refresh(); 
    711711        } 
    712712 
    713713        public function getCountry() 
    714714        { 
    715                 return $this->mRow['country']; 
     715            return $this->mRow['country']; 
    716716        } 
    717717 
    718718        protected function setCountry($country) 
    719719        { 
    720                 $country = $this->mDb->escapeString($country); 
    721                 $this->mDb->execSqlUpdate("UPDATE nodes SET country = '{$country}' WHERE node_id = '{$this->getId()}'"); 
    722                 $this->refresh(); 
     720            $country = $this->mDb->escapeString($country); 
     721            $this->mDb->execSqlUpdate("UPDATE nodes SET country = '{$country}' WHERE node_id = '{$this->getId()}'"); 
     722            $this->refresh(); 
    723723        } 
    724724 
    725725        public function getPostalCode() 
    726726        { 
    727                 return $this->mRow['postal_code']; 
     727            return $this->mRow['postal_code']; 
    728728        } 
    729729 
    730730        public function setPostalCode($postal_code) 
    731731        { 
    732                 $postal_code = $this->mDb->escapeString($postal_code); 
    733                 $this->mDb->execSqlUpdate("UPDATE nodes SET postal_code = '{$postal_code}' WHERE node_id = '{$this->getId()}'"); 
    734                 $this->refresh(); 
     732            $postal_code = $this->mDb->escapeString($postal_code); 
     733            $this->mDb->execSqlUpdate("UPDATE nodes SET postal_code = '{$postal_code}' WHERE node_id = '{$this->getId()}'"); 
     734            $this->refresh(); 
    735735        } 
    736736 
    737737        function getTelephone() 
    738738        { 
    739                 return $this->mRow['public_phone_number']; 
     739            return $this->mRow['public_phone_number']; 
    740740        } 
    741741 
    742742        function setTelephone($phone) 
    743743        { 
    744                 $phone = $this->mDb->escapeString($phone); 
    745                 $this->mDb->execSqlUpdate("UPDATE nodes SET public_phone_number = '{$phone}' WHERE node_id = '{$this->getId()}'"); 
    746                 $this->refresh(); 
     744            $phone = $this->mDb->escapeString($phone); 
     745            $this->mDb->execSqlUpdate("UPDATE nodes SET public_phone_number = '{$phone}' WHERE node_id = '{$this->getId()}'"); 
     746            $this->refresh(); 
    747747        } 
    748748 
    749749        function getTransitInfo() 
    750750        { 
    751                 return $this->mRow['mass_transit_info']; 
     751            return $this->mRow['mass_transit_info']; 
    752752        } 
    753753 
    754754        function setTransitInfo($transit_info) 
    755755        { 
    756                 $transit_info = $this->mDb->escapeString($transit_info); 
    757                 $this->mDb->execSqlUpdate("UPDATE nodes SET mass_transit_info = '{$transit_info}' WHERE node_id = '{$this->getId()}'"); 
    758                 $this->refresh(); 
     756            $transit_info = $this->mDb->escapeString($transit_info); 
     757            $this->mDb->execSqlUpdate("UPDATE nodes SET mass_transit_info = '{$transit_info}' WHERE node_id = '{$this->getId()}'"); 
     758            $this->refresh(); 
    759759        } 
    760760 
    761761        function getEmail() 
    762762        { 
    763                 return $this->mRow['public_email']; 
     763            return $this->mRow['public_email']; 
    764764        } 
    765765 
    766766        function setEmail($email) 
    767767        { 
    768                 $email = $this->mDb->escapeString($email); 
    769                 $this->mDb->execSqlUpdate("UPDATE nodes SET public_email = '{$email}' WHERE node_id = '{$this->getId()}'"); 
    770                 $this->refresh(); 
     768            $email = $this->mDb->escapeString($email); 
     769            $this->mDb->execSqlUpdate("UPDATE nodes SET public_email = '{$email}' WHERE node_id = '{$this->getId()}'"); 
     770            $this->refresh(); 
    771771        } 
    772772 
    773773        function getDeploymentStatus() 
    774774        { 
    775                 return $this->mRow['node_deployment_status']; 
     775            return $this->mRow['node_deployment_status']; 
    776776        } 
    777777 
    778778        function setDeploymentStatus($status) 
    779779        { 
    780                 $status = $this->mDb->escapeString($status); 
    781                 $this->mDb->execSqlUpdate("UPDATE nodes SET node_deployment_status = '{$status}' WHERE node_id = '{$this->getId()}'"); 
    782                 $this->refresh(); 
     780            $status = $this->mDb->escapeString($status); 
     781            $this->mDb->execSqlUpdate("UPDATE nodes SET node_deployment_status = '{$status}' WHERE node_id = '{$this->getId()}'"); 
     782            $this->refresh(); 
    783783        } 
    784784 
    785785        function getLastPaged() 
    786786        { 
    787                 return $this->mRow['last_paged']; 
     787            return $this->mRow['last_paged']; 
    788788        } 
    789789 
    790790        function setLastPaged($last_paged) 
    791791        { 
    792                 $this->mDb->execSqlUpdate("UPDATE nodes SET last_paged = {$last_paged}::abstime WHERE node_id = '{$this->getId()}'"); 
    793                 $this->refresh(); 
     792            $this->mDb->execSqlUpdate("UPDATE nodes SET last_paged = {$last_paged}::abstime WHERE node_id = '{$this->getId()}'"); 
     793            $this->refresh(); 
    794794        } 
    795795 
    796796        function getLastHeartbeatIP() 
    797797        { 
    798                 return $this->mRow['last_heartbeat_ip']; 
     798            return $this->mRow['last_heartbeat_ip']; 
    799799        } 
    800800 
    801801        function getLastHeartbeatUserAgent() 
    802802        { 
    803                 return $this->mRow['last_heartbeat_user_agent']; 
     803            return $this->mRow['last_heartbeat_user_agent']; 
    804804        } 
    805805 
    806806        function getLastHeartbeatTimestamp() 
    807807        { 
    808                 return $this->mRow['last_heartbeat_timestamp']; 
     808            return $this->mRow['last_heartbeat_timestamp']; 
    809809        } 
    810810 
    811811        function setLastHeartbeatTimestamp($timestamp) 
    812812        { 
    813                 $this->mDb->execSqlUpdate("UPDATE nodes SET last_heartbeat_timestamp = '{$timestamp}' WHERE node_id = '{$this->getId()}'"); 
    814                 $this->refresh(); 
     813            $this->mDb->execSqlUpdate("UPDATE nodes SET last_heartbeat_timestamp = '{$timestamp}' WHERE node_id = '{$this->getId()}'"); 
     814            $this->refresh(); 
    815815        } 
    816816 
     
    819819        public function isSplashOnly() 
    820820        { 
    821                 return $this->getNetwork()->getSplashOnlyNodesAllowed() && $this->isConfiguredSplashOnly(); 
     821            return $this->getNetwork()->getSplashOnlyNodesAllowed() && $this->isConfiguredSplashOnly(); 
    822822        } 
    823823 
     
    829829        public function isConfiguredSplashOnly() 
    830830        { 
    831                 return (($this->mRow['is_splash_only_node'] == 't') ? true : false); 
     831            return (($this->mRow['is_splash_only_node'] == 't') ? true : false); 
    832832        } 
    833833 
     
    837837        function setIsConfiguredSplashOnly($value) 
    838838        { 
    839                 $retval = true; 
    840                 if ($value != $this->isConfiguredSplashOnly()) 
    841                 { 
    842                         $db = AbstractDb::getObject(); 
    843                         $value ? $value = 'TRUE' : $value = 'FALSE'; 
    844                         $retval = $db->execSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); 
    845                         $this->refresh(); 
    846                 } 
    847                 return $retval; 
     839            $retval = true; 
     840            if ($value != $this->isConfiguredSplashOnly()) 
     841            { 
     842                $db = AbstractDb::getObject(); 
     843                $value ? $value = 'TRUE' : $value = 'FALSE'; 
     844                $retval = $db->execSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); 
     845                $this->refresh(); 
     846            } 
     847            return $retval; 
    848848        } 
    849849 
     
    853853        function getCustomPortalRedirectUrl() 
    854854        { 
    855                 return $this->mRow['custom_portal_redirect_url']; 
     855            return $this->mRow['custom_portal_redirect_url']; 
    856856        } 
    857857 
     
    861861        function setCustomPortalRedirectUrl($value) 
    862862        { 
    863                 $retval = true; 
    864                 if ($value != $this->getCustomPortalRedirectUrl()) 
    865                 { 
    866                         $db = AbstractDb::getObject(); 
    867                         $value = $db->escapeString($value); 
    868                         $retval = $db->execSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false); 
    869                         $this->refresh(); 
    870                 } 
    871                 return $retval; 
     863            $retval = true; 
     864            if ($value != $this->getCustomPortalRedirectUrl()) 
     865            { 
     866                $db = AbstractDb::getObject(); 
     867                $value = $db->escapeString($value); 
     868                $retval = $db->execSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false); 
     869                $this->refresh(); 
     870            } 
     871            return $retval; 
    872872        } 
    873873 
     
    886886            require_once('classes/InterfaceElements.php'); 
    887887            // Init values 
    888                 $html = ''; 
    889                 if (!User::getCurrentUser()) { 
    890                         throw new Exception(_('Access denied!')); 
    891                 } 
    892  
    893                 // Get information about the network 
    894                 $network = $this->getNetwork(); 
    895  
    896                 // Check if user is a admin 
    897                 $_userIsAdmin = User::getCurrentUser()->isSuperAdmin(); 
    898  
    899                 $node_id = $this->getId(); 
    900  
    901                 /* 
     888            $html = ''; 
     889            if (!User::getCurrentUser()) { 
     890                throw new Exception(_('Access denied!')); 
     891            } 
     892 
     893            // Get information about the network 
     894            $network = $this->getNetwork(); 
     895 
     896            // Check if user is a admin 
     897            $_userIsAdmin = User::getCurrentUser()->isSuperAdmin(); 
     898 
     899            $node_id = $this->getId(); 
     900 
     901            /* 
    902902                 * Check for a warning message 
    903903                 */ 
  • trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php

    r1159 r1173  
    168168    $this->assign('base_non_ssl_path', BASE_NON_SSL_PATH); 
    169169    $this->assign('common_images_url', COMMON_IMAGES_URL); 
    170  
    171      /* Other useful stuff */ 
    172      Network::assignSmartyValues($this); 
    173      Node::assignSmartyValues($this); 
    174      User::assignSmartyValues($this); 
    175170   } 
    176171 
     
    179174     $this->template_dir= $template_dir; 
    180175   } 
    181  
     176     /** 
     177     * executes & returns or displays the template results 
     178     * This is extended by wifidog to make sure that the variables influenced by state (such as the current node) are as up to date as humanly possible. 
     179     * @param string $resource_name 
     180     * @param string $cache_id 
     181     * @param string $compile_id 
     182     * @param boolean $display 
     183     */ 
     184    public function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) 
     185    { 
     186     /* Other useful variables */ 
     187     Network::assignSmartyValues($this); 
     188     Node::assignSmartyValues($this); 
     189     User::assignSmartyValues($this); 
     190     return parent::fetch($resource_name, $cache_id, $compile_id, $display); 
     191    } 
    182192} 
    183193